summaryrefslogtreecommitdiffstats
path: root/template/en/default/search/field.html.tmpl
diff options
context:
space:
mode:
authorMax Kanat-Alexander <mkanat@bugzilla.org>2011-08-09 23:19:43 +0200
committerMax Kanat-Alexander <mkanat@bugzilla.org>2011-08-09 23:19:43 +0200
commit80c6d150b42ae5d9ba7464c5e20023cc90388259 (patch)
tree77df9794d444fbc861f53aa0240128a53f9d6467 /template/en/default/search/field.html.tmpl
parent93175c689f0349d879b3dfca5bd0236c19b73855 (diff)
downloadbugzilla-80c6d150b42ae5d9ba7464c5e20023cc90388259.tar.gz
bugzilla-80c6d150b42ae5d9ba7464c5e20023cc90388259.tar.xz
Bug 636416: Use the standard value-controller javascript to control the
drop-down fields on the Advanced Search page. r=glob, a=mkanat
Diffstat (limited to 'template/en/default/search/field.html.tmpl')
-rw-r--r--template/en/default/search/field.html.tmpl79
1 files changed, 64 insertions, 15 deletions
diff --git a/template/en/default/search/field.html.tmpl b/template/en/default/search/field.html.tmpl
index defc94cc3..c237ac16c 100644
--- a/template/en/default/search/field.html.tmpl
+++ b/template/en/default/search/field.html.tmpl
@@ -121,22 +121,71 @@
[% 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 %]
+ [% SET v = current_value.name OR '---' -%]
+ [% SET display = display_value(field.name, current_value.name) %]
+ <option [% IF v != display %]value="[% v FILTER html %]"[% END ~%]
+ id="v[% current_value.id FILTER html %]_[% field.name FILTER html %]"
+ [% ' selected="selected"' IF value.contains( v ) %]>
+ [%~ display FILTER html ~%]
+ </option>
[% END %]
</select>
</div>
+
+ [% IF value_controllers.${field.name}.defined %]
+ <script type="text/javascript"><!--
+ [%+ FILTER collapse %]
+ [% FOREACH accessor = value_controllers.${field.name}.keys %]
+ [% PROCESS controller_js %]
+ [% END %]
+ [%~ END ~%]
+ // --></script>
+ [% END %]
+ [% IF duplicates.${field.name}.keys.size %]
+ [% SET field_dups = duplicates.${field.name} %]
+ [% SET dup_counts = duplicate_count.${field.name} %]
+ <script type="text/javascript">
+ [%+ FILTER collapse %]
+ bz_option_duplicates['[% field.name FILTER js %]'] = {
+ [% FOREACH dup = field_dups.keys %]
+ [% dup FILTER js %]:[% field_dups.$dup.id FILTER js %]
+ [%~ ',' UNLESS loop.last %]
+ [% END ~%]
+ };
+ bz_option_duplicate_count['[% field.name FILTER js %]'] = {
+ [% FOREACH dup_target = dup_counts.keys %]
+ [% dup_target FILTER js %]:[% dup_counts.$dup_target %]
+ [%~ ',' UNLESS loop.last %]
+ [% END %]
+ };
+ [% END %]
+ </script>
+ [% END %]
+
+ [% END %]
+[%# END OF SWITCH %]
+
+[% BLOCK controller_js %]
+ [%# If there are selected values already, we need to fire the
+ # "change" event once the page has loaded, so we can set all
+ # the values in all the other <select>s properly.
+ #%]
+ YAHOO.util.Event.onDOMReady(function() {
+ var field = document.getElementById('[% field.name FILTER js %]');
+ if (field.selectedIndex != -1) bz_fireEvent(field, 'change');
+ });
+
+ [% SET sub_field = value_controllers.${field.name}.$accessor %]
+ [% FOREACH legal_value = legal_values %]
+ [% SET controlled_ids = [] %]
+ [% FOREACH sub_value = legal_value.$accessor %]
+ [% controlled_ids.push(sub_value.id) %]
+ [% END %]
+ [% NEXT IF !controlled_ids.size %]
+ showValueWhen('[% sub_field.name FILTER js %]',
+ [[% controlled_ids.join(',') FILTER js %]],
+ '[% field.name FILTER js %]',
+ [% legal_value.id FILTER js %],
+ true);
[% END %]
+[% END %]