summaryrefslogtreecommitdiffstats
path: root/template
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
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')
-rw-r--r--template/en/default/search/field.html.tmpl79
-rw-r--r--template/en/default/search/form.html.tmpl104
-rw-r--r--template/en/default/search/search-advanced.html.tmpl12
-rw-r--r--template/en/default/search/search-create-series.html.tmpl2
-rw-r--r--template/en/default/search/search-report-graph.html.tmpl2
-rw-r--r--template/en/default/search/search-report-table.html.tmpl2
6 files changed, 82 insertions, 119 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 %]
diff --git a/template/en/default/search/form.html.tmpl b/template/en/default/search/form.html.tmpl
index 41e116518..fb9454ff6 100644
--- a/template/en/default/search/form.html.tmpl
+++ b/template/en/default/search/form.html.tmpl
@@ -25,85 +25,6 @@
<script type="text/javascript">
-var first_load = true; [%# is this the first time we load the page? %]
-var last_sel = new Array(); [%# caches last selection %]
-
-[% IF Param('useclassification') %]
-var useclassification = true;
-var prods = new Array();
-[% ELSE %]
-var useclassification = false;
-[% END %]
-var cpts = new Array();
-var vers = new Array();
-[% IF Param('usetargetmilestone') %]
-var tms = new Array();
-[% END %]
-
-[%# Create an array of products, indexed by the classification #%]
-
-[% nclass = 0 %]
-[% FOREACH c = classification %]
- prods[[% nclass FILTER js %]] = [
- [% sep = '' %]
- [%- FOREACH item = user.get_selectable_products(c.id) -%]
- [%- IF item.components.size -%]
- [%- sep FILTER js %]'[% item.name FILTER js %]'
- [%- sep = ',' -%]
- [%- END -%]
- [%- END -%] ];
- [% nclass = nclass+1 %]
-[% END %]
-
-[%# Create three arrays of components, versions and target milestones, indexed
- # numerically according to the product they refer to. #%]
-
-[% n = 0 %]
-[% FOREACH p = product %]
- [% NEXT IF NOT p.components.size %]
- [% IF Param('useclassification') %]
- prods['[% p.name FILTER js %]'] = [% n %]
- [% END %]
- cpts[[% n %]] = [
- [%- FOREACH item = p.components %]'[% item.name FILTER js %]'[% ", " UNLESS loop.last %] [%- END -%] ];
- vers[[% n %]] = [
- [%- FOREACH item = p.versions -%]'[% item.name FILTER js %]'[% ", " UNLESS loop.last %] [%- END -%] ];
- [% IF Param('usetargetmilestone') %]
- tms[[% n %]] = [
- [%- FOREACH item = p.milestones %]'[% item.name FILTER js %]'[% ", " UNLESS loop.last %] [%- END -%] ];
- [% END %]
- [% n = n+1 %]
-[% END %]
-
-/*
- * doOnSelectProduct determines which selection should get updated
- *
- * - selectmode = 0 - init
- * selectmode = 1 - classification selected
- * selectmode = 2 - product selected
- *
- * globals:
- * queryform - string holding the name of the selection form
- */
-function doOnSelectProduct(selectmode) {
- var f = document.forms[queryform];
- var milestone = (typeof(f.target_milestone) == "undefined" ?
- null : f.target_milestone);
- if (selectmode == 0) {
- // If there is no classification selected, give us a chance to fill
- // the select fields with values from the possibly selected product.
- if (useclassification && f.classification.selectedIndex > -1) {
- selectClassification(f.classification, f.product, f.component, f.version, milestone);
- } else {
- selectProduct(f.product, f.component, f.version, milestone, null);
- }
- } else if (selectmode == 1) {
- selectClassification(f.classification, f.product, f.component, f.version, milestone);
- } else {
- selectProduct(f.product, f.component, f.version, milestone, null);
- }
-}
-
// Hide the Advanced Fields by default, unless the user has a cookie
// that specifies otherwise.
// &#9656; and &#9662; are both utf8 escaped characters for right
@@ -143,7 +64,7 @@ TUI_hide_default('information_query');
accesskey = "s"
%]
<script type="text/javascript"> <!--
- document.forms[queryform].short_desc.focus();
+ document.getElementById('short_desc').focus();
// -->
</script>
@@ -154,23 +75,26 @@ TUI_hide_default('information_query');
</div>
[%# *** Classification Product Component *** %]
-
+
+[% value_controllers = {
+ 'classification' => { 'products' => bug_fields.product },
+ 'product' => { 'components' => bug_fields.component,
+ 'versions' => bug_fields.version,
+ 'milestones' => bug_fields.target_milestone },
+} %]
+
[% Hook.process('before_selects_top') %]
[% IF Param('useclassification') %]
- [% fake_classfication = { name => bug_fields.classification.name,
- type => constants.FIELD_TYPE_SINGLE_SELECT } %]
- [% INCLUDE "search/field.html.tmpl"
- field => fake_classfication
- accesskey => "c"
- onchange => "doOnSelectProduct(1);"
- value => default.classification
- %]
+ [% INCLUDE "search/field.html.tmpl"
+ field => bug_fields.classification
+ accesskey => "c"
+ value => default.classification
+ %]
[% END %]
[% INCLUDE "search/field.html.tmpl"
field => bug_fields.product
accesskey => "p"
- onchange => "doOnSelectProduct(2);"
value => default.product
%]
[% INCLUDE "search/field.html.tmpl"
diff --git a/template/en/default/search/search-advanced.html.tmpl b/template/en/default/search/search-advanced.html.tmpl
index ef7fa769a..4f6f37bf2 100644
--- a/template/en/default/search/search-advanced.html.tmpl
+++ b/template/en/default/search/search-advanced.html.tmpl
@@ -30,21 +30,12 @@
[% cgi = Bugzilla.cgi %]
-[% js_data = BLOCK %]
-var queryform = "queryform"
-[% END %]
-
[% PROCESS global/header.html.tmpl
title = "Search for $terms.bugs"
- onload = "doOnSelectProduct(0);"
- javascript = js_data
yui = [ 'autocomplete', 'calendar' ]
- javascript_urls = [ "js/productform.js", "js/util.js", "js/TUI.js", "js/field.js"]
+ javascript_urls = [ "js/util.js", "js/TUI.js", "js/field.js"]
style_urls = [ "skins/standard/search_form.css" ]
doc_section = "query.html"
- style = "dl.bug_changes dt {
- margin-top: 15px;
- }"
%]
[% WRAPPER search/tabs.html.tmpl %]
@@ -63,7 +54,6 @@ var queryform = "queryform"
</form>
-
[% END %]
[% PROCESS global/footer.html.tmpl %]
diff --git a/template/en/default/search/search-create-series.html.tmpl b/template/en/default/search/search-create-series.html.tmpl
index 3ca68ac49..6863eba10 100644
--- a/template/en/default/search/search-create-series.html.tmpl
+++ b/template/en/default/search/search-create-series.html.tmpl
@@ -35,7 +35,7 @@
onload = "doOnSelectProduct(0);"
yui = [ 'autocomplete', 'calendar' ]
javascript = js_data
- javascript_urls = [ "js/util.js", "js/productform.js", "js/TUI.js", "js/field.js" ]
+ javascript_urls = [ "js/util.js", "js/TUI.js", "js/field.js" ]
style_urls = [ "skins/standard/search_form.css" ]
doc_section = "reporting.html#charts-new-series"
%]
diff --git a/template/en/default/search/search-report-graph.html.tmpl b/template/en/default/search/search-report-graph.html.tmpl
index 3c894cf73..362c910fa 100644
--- a/template/en/default/search/search-report-graph.html.tmpl
+++ b/template/en/default/search/search-report-graph.html.tmpl
@@ -34,7 +34,7 @@ var queryform = "reportform"
onload = "doOnSelectProduct(0); chartTypeChanged()"
yui = [ 'autocomplete', 'calendar' ]
javascript = js_data
- javascript_urls = [ "js/util.js", "js/productform.js", "js/TUI.js", "js/field.js" ]
+ javascript_urls = [ "js/util.js", "js/TUI.js", "js/field.js" ]
style_urls = [ "skins/standard/search_form.css" ]
doc_section = "reporting.html#reports"
%]
diff --git a/template/en/default/search/search-report-table.html.tmpl b/template/en/default/search/search-report-table.html.tmpl
index 7e087e7fe..c59743965 100644
--- a/template/en/default/search/search-report-table.html.tmpl
+++ b/template/en/default/search/search-report-table.html.tmpl
@@ -34,7 +34,7 @@ var queryform = "reportform"
onload = "doOnSelectProduct(0)"
yui = [ 'autocomplete', 'calendar' ]
javascript = js_data
- javascript_urls = [ "js/util.js", "js/productform.js", "js/TUI.js", "js/field.js" ]
+ javascript_urls = [ "js/util.js", "js/TUI.js", "js/field.js" ]
style_urls = [ "skins/standard/search_form.css" ]
doc_section = "reporting.html#reports"
%]