summaryrefslogtreecommitdiffstats
path: root/template/en/default/search/field.html.tmpl
blob: fe0eb2144ebb73079289f1aa1adcb787e04bf026 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
[%# The contents of this file are subject to the Mozilla Public
  # License Version 1.1 (the "License"); you may not use this file
  # except in compliance with the License. You may obtain a copy of
  # the License at http://www.mozilla.org/MPL/
  #
  # Software distributed under the License is distributed on an "AS
  # IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
  # implied. See the License for the specific language governing
  # rights and limitations under the License.
  #
  # The Original Code is the Bugzilla Bug Tracking System.
  #
  # The Initial Developer of the Original Code is Guy Pyrzak
  # Portions created by the Initial Developer are Copyright (C) 2010 the
  # Initial Developer. All Rights Reserved.
  #
  # Contributor(s): Guy Pyrzak <guy.pyrzak@gmail.com>
  #                 Reed Loden <reed@reedloden.com>
  #
  #%]
[%# INTERFACE:
  #   field: a Bugzilla::Field object
  #   value: the value or values that should be used to prepopulate the field
  #   accesskey: the access key used to access the field more quickly
  #   onchange: js to run when the change event fires on the field
  #   type_selected: used by the free text to indicate which type of text
  #                  search was selected for a particular field
  #%]

[% SWITCH field.type %]
  [% CASE [ constants.FIELD_TYPE_FREETEXT,
            constants.FIELD_TYPE_TEXTAREA,
            constants.FIELD_TYPE_UNKNOWN ] %]
    [% INCLUDE "bug/field-label.html.tmpl"
      field = field
      tag_name = "span"
      editable = 1
    %]
    [% INCLUDE "search/type-select.html.tmpl"
       name = field.name _ "_type",
       types = types,
       selected = type_selected
    %]
    <input name="[% field.name FILTER html %]"
           id="[% field.name FILTER html %]" size="40"
           [% IF autofocus %] autofocus[% END %]
           [% IF onchange %] onchange="[% onchange FILTER html %]"[% END %]
           value="[% value FILTER html %]">
  [% CASE constants.FIELD_TYPE_KEYWORDS %]
    [% INCLUDE "bug/field-label.html.tmpl"
      field = field
      tag_name = "span"
      editable = 1
    %]
    [% INCLUDE "search/type-select.html.tmpl"
       name = field.name _ "_type",
       types = types,
       selected = type_selected
    %]
    <input name="[% field.name FILTER html %]"
           id="[% field.name FILTER html %]" size="40"
           class="bz_autocomplete_values"
           [% IF onchange %] onchange="[% onchange FILTER html %]"[% END %]
           value="[% value FILTER html %]"
           data-values="[% field.name FILTER html %]">
    <script [% script_nonce FILTER none %]>
      if (typeof BUGZILLA.autocomplete_values === 'undefined')
        BUGZILLA.autocomplete_values = [];
      BUGZILLA.autocomplete_values['[% field.name FILTER js %]'] = [
        [%- FOREACH keyword = all_keywords %]
          [%-# %]"[% keyword.name FILTER js %]"
          [%- "," IF NOT loop.last %][% END %]];
    </script>
  [% CASE [constants.FIELD_TYPE_DATETIME, constants.FIELD_TYPE_DATE] %]
    [% INCLUDE "bug/field-label.html.tmpl"
      field = field
      tag_name = "span"
      editable = 1
    %]
    from <input name="[% field.name FILTER html %]from"
                id="[% field.name FILTER html %]"
                size="10" maxlength="10"
                value="[% value.0 FILTER html %]"
                onchange="updateCalendarFromField(this);[% onchange FILTER html %]">
         <button type="button" class="calendar_button"
                        id="button_calendar_[% field.name FILTER html %]"
                        onclick="showCalendar('[% field.name FILTER js %]')">
           <span>Calendar</span>
         </button>
         <span id="con_calendar_[% field.name FILTER html %]"></span>
    to <input name="[% field.name FILTER html %]to"
              id="[% field.name FILTER html %]to" size="10" maxlength="10"
              value="[% value.1 FILTER html %]"
              onchange="updateCalendarFromField(this);[% onchange FILTER html %]">
       <button type="button" class="calendar_button"
                      id="button_calendar_[% field.name FILTER html %]to"
                      onclick="showCalendar('[% field.name FILTER js %]to')">
         <span>Calendar</span>
       </button>
    <small>(YYYY-MM-DD or relative dates)</small>

    <span id="con_calendar_[% field.name FILTER html %]to"></span>
    <script [% script_nonce FILTER none %]>
      createCalendar('[% field.name FILTER js %]');
      createCalendar('[% field.name FILTER js %]to');
    </script>
  [% CASE [ constants.FIELD_TYPE_SINGLE_SELECT,
            constants.FIELD_TYPE_MULTI_SELECT ] %]
    <div id="container_[% field.name FILTER html %]" class="search_field_grid">
      [% INCLUDE "bug/field-label.html.tmpl"
        field = field
        editable = 1
        tag_name = "span"
      %]
      <select name="[% field.name FILTER html%]"
              id="[% field.name FILTER html %]"
        [% IF onchange %] onchange="[% onchange FILTER html %]"[% END %]
        multiple="multiple" size="9">
        [% legal_values = ${field.name} %]
        [% IF field.name == "component" %]
          [% legal_values = ${"component_"} %]
        [% END %]
        [% FOREACH current_value = legal_values %]
          [% IF current_value.id %]
            [%# current_value is a hash instead of a value which
                only applies for Resolution really, everywhere else current_value
                is just the value %]
            [% v = current_value.name OR '---' -%]
            <option value="[% v FILTER html %]"
              [% ' selected="selected"' IF value.contains( v ) %]>
              [% display_value(field.name, current_value.name) FILTER html %]
            </option>
          [% ELSE %]
            <option value="[% current_value OR '---' FILTER html %]"
              [% ' selected="selected"' IF value.contains( current_value ) %]>
              [% display_value(field.name, current_value) FILTER html %]
            </option>
          [% END %]
        [% END %]
      </select>
    </div>
  [% END %]