boolean-charts.html.tmpl 6.87 KB
Newer Older
1 2 3
[%# This Source Code Form is subject to the terms of the Mozilla Public
  # License, v. 2.0. If a copy of the MPL was not distributed with this
  # file, You can obtain one at http://mozilla.org/MPL/2.0/.
4
  #
5 6
  # This Source Code Form is "Incompatible With Secondary Licenses", as
  # defined by the Mozilla Public License, v. 2.0.
7
  #%]
8

9
[% types = [
10 11 12 13 14 15 16 17 18 19 20 21 22
  "noop",
  "equals",
  "notequals",
  "anyexact",
  "substring",
  "casesubstring",
  "notsubstring",
  "anywordssubstr",
  "allwordssubstr",
  "nowordssubstr",
  "regexp",
  "notregexp",
  "lessthan",
23
  "lessthaneq",
24
  "greaterthan",
25
  "greaterthaneq",
26 27 28 29 30 31 32 33 34
  "anywords",
  "allwords",
  "nowords",
  "changedbefore",
  "changedafter",
  "changedfrom",
  "changedto",
  "changedby",
  "matches",
35
  "notmatches",
36 37
  "isempty",
  "isnotempty",
38
] %]
39

40 41
<div class="bz_section_title" id="custom_search_filter">
  <div id="custom_search_query_controller" class="arrow">&#9660;</div>
42
  <a id="chart" href="javascript:TUI_toggle_class('custom_search_query')" >
43
    Custom Search</a> <span class="section_help">Didn't find what 
44
      you're looking for above? This area allows for ANDs, ORs, 
45
      and other more complex searches.</span>
46 47 48 49
</div>
<div id="custom_search_filter_section" 
     class="bz_search_section custom_search_query">
  [% SET indent_level = 0 %]
50
  [% SET cond_num = 0 %]
51 52 53 54 55 56 57 58 59 60 61
  [% FOREACH condition = default.custom_search %]
    [% SET cond_num = loop.count - 1 %]
    [% PROCESS one_condition with_buttons = 0 %]
  [% END %]
  [% PROCESS one_condition
    with_buttons = 1
    condition = { f => 'noop' }
    cond_num = cond_num + 1 %]
  <script type="text/javascript">
    TUI_alternates['custom_search_query'] = '&#9658;';
    TUI_hide_default('custom_search_query');
62 63
    TUI_alternates['custom_search_advanced'] = "Show Advanced Features";
    TUI_hide_default('custom_search_advanced');
64
  </script>
65 66 67
  <script type="text/javascript" src="[% 'js/custom-search.js' FILTER mtime %]"></script>
  <script type="text/javascript">
    redirect_html4_browsers();
68 69 70 71
    [%# These are alternative labels for the AND and OR options in and_all_select %]
    var cs_and_label = 'Match ALL of the following:';
    var cs_or_label  = 'Match ANY of the following:';
    cs_reconfigure('custom_search_last_row');
72
  </script>
73
  <script type="text/javascript" src="[% 'js/history.js/native.history.js' FILTER mtime %]"></script>
74
</div>
75 76


77 78 79 80 81 82
[% BLOCK one_condition %]
  [%# Skip any conditions that don't have a field defined. %]
  [% RETURN IF !condition.f %]
  
  [% IF !top_level_any_shown %]
    [% INCLUDE any_all_select
83 84
      name = "j_top" selected = default.j_top.0
      with_advanced_link = 1 %]
85 86
    [% top_level_any_shown = 1 %]
  [% END %]
87

88 89 90 91 92 93 94
  [% IF condition.f == "CP" %]
    [% indent_level = indent_level - 1 %]
  [% END %]

  <div class="custom_search_condition"
       [% ' style="margin-left: ' _ (indent_level * 2) _ 'em"' IF indent_level %]
       [% ' id="custom_search_last_row"' IF with_buttons %]>
95
    
96 97
    [% IF previous_condition.f == "OP" %]
      [% INCLUDE any_all_select
98
        name = "j" _ (cond_num - 1) 
99 100 101 102
        selected = previous_condition.j %]
    [% END %]

    [% IF with_buttons %]
103
      <button id="op_button" type="button" class="custom_search_advanced"
104 105 106 107 108
              title="Start a new group of criteria, including this row"
              onclick="custom_search_open_paren()">(</button>
    [% END %]

    [% UNLESS condition.f == "CP" %]
109 110 111 112
      [%# This only gets hidden via custom_search_advanced if it isn't set. %]
      <span id="custom_search_not_container_[% cond_num FILTER html %]"
            class="custom_search_not_container
                   [%- ' custom_search_advanced' UNLESS condition.n %]"
113 114 115 116
            title="Search for the opposite of the criteria here">
        <input type="checkbox" id="n[% cond_num FILTER html %]"
               class="custom_search_form_field"
               name="n[% cond_num FILTER html %]" value="1"
117
               onclick="custom_search_not_changed([% cond_num FILTER js %])"
118 119 120 121 122 123 124 125 126 127 128
               [% ' checked="checked"' IF condition.n %]>
        <label for="n[% cond_num FILTER html %]">Not</label>
      </span>
    [% END %]

    [% IF condition.f == "OP" %]
      <input type="hidden" name="f[% cond_num FILTER html %]"
             id="f[% cond_num FILTER html %]" value="OP">
      (
      [% indent_level = indent_level + 1 %]
    [% ELSIF condition.f == "CP" %]
129 130
      <input type="hidden" name="f[% cond_num FILTER html %]"
             id="f[% cond_num FILTER html %]" value="CP">
131
      )
132
    [% ELSE %]
133 134
      <select name="f[% cond_num FILTER html %]" title="Field"
              id="f[% cond_num FILTER html %]"
135
              onchange="fix_query_string(this)"
136
              class="custom_search_form_field">
137 138 139 140 141 142 143 144 145
        [%# Turn the array in to a hash with the name as the key %]
        [%
          field_hash = {};
          FOREACH field IN fields;
            field_hash.${field.name} = field;
          END;
        %]
        [% FOREACH field_name = field_hash.keys.sort_by_field_name(field_descs) %]
          [% field = field_hash.$field_name %]
146 147 148 149 150 151 152 153 154 155 156 157 158
          <option value="[% field.name FILTER html %]"
                  [%~ ' selected="selected"' IF field.name == condition.f %]>
            [% field_descs.${field.name} || field.description FILTER html %]
          </option>
        [% END %]
      </select>
    
      [% INCLUDE "search/type-select.html.tmpl"
         name = "o${cond_num}", class = "custom_search_form_field"
         types = types, selected = condition.o %]
    
      <input name="v[% cond_num FILTER html %]" title="Value"
             class="custom_search_form_field"
159
             onchange="fix_query_string(this)"
160
             value="[% condition.v FILTER html %]">
161 162
    [% END %]
    
163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179
    [% IF with_buttons %]
      <button class="custom_search_add_button" type="button"
              id="add_button" title="Add a new row"
              onclick="custom_search_new_row()">+</button>
      <span id="cp_container" [% ' class="bz_default_hidden"' IF !indent_level %]>
        <button id="cp_button" type="button"
                title="End this group of criteria"
                onclick="custom_search_close_paren()">)</button>
      </span>
    [% END %]
  </div>
  
  [% previous_condition = condition %]
[% END %]

[% BLOCK any_all_select %]
  <div class="any_all_select">
180 181
    <select name="[% name FILTER html %]" id="[% name FILTER html %]"
            onchange="fix_query_string(this)">
182
      <option value="AND">Match ALL of the following separately:</option>
183
      <option value="OR" [% ' selected="selected"' IF selected == "OR" %]>
184 185 186
        Match ANY of the following separately:</option>
      <option value="AND_G" [% ' selected' IF selected == "AND_G" %]>
        Match ALL of the following against the same field:</option>
187
    </select>
188 189 190 191 192 193
    [% IF with_advanced_link %]
      <a id="custom_search_advanced_controller"
         href="javascript:TUI_toggle_class('custom_search_advanced')">
        Hide Advanced Features
      </a>
    [% END %]
194
  </div>
195
[% END %]