From bcab6fcb10aa88683490bef03c607173f9c0b063 Mon Sep 17 00:00:00 2001 From: Kent Rogers Date: Mon, 5 Jul 2010 14:49:52 -0700 Subject: Bug 514618: Allow restricting the visibility and values of fields by classification. r=mkanat, r=timello, a=mkanat --- template/en/default/bug/edit.html.tmpl | 23 ++++++++++++++++++++++- template/en/default/bug/field-events.js.tmpl | 3 +++ 2 files changed, 25 insertions(+), 1 deletion(-) (limited to 'template') diff --git a/template/en/default/bug/edit.html.tmpl b/template/en/default/bug/edit.html.tmpl index 5520e7699..0a558ecc1 100644 --- a/template/en/default/bug/edit.html.tmpl +++ b/template/en/default/bug/edit.html.tmpl @@ -128,6 +128,15 @@ [% END %] + /* Index all classifications so we can keep track of the classification + * for the selected product, which could control field visibility. + */ + var all_classifications = new Array([% bug.choices.product.size %]); + [%- FOREACH product = bug.choices.product %] + all_classifications['[% product.name FILTER js %]'] = ' + [%- product.classification.name FILTER js %]'; + [%- END %] + //--> @@ -319,7 +328,6 @@ [%#############%] [%# PRODUCT #%] [%#############%] - [% INCLUDE bug/field.html.tmpl bug = bug, field = bug_fields.product, @@ -327,6 +335,19 @@ desc_url = 'describecomponents.cgi', value = bug.product editable = bug.check_can_change_field('product', 0, 1) %] + + [%# Classification is here so that it can be used in value controllers + # and visibility controllers. It comes after product because + # it uses some javascript that depends on the existence of the + # product field. + #%] + + [% INCLUDE bug/field.html.tmpl + bug = bug field = bug_fields.classification + override_legal_values = bug.choices.classification + value = bug.classification + editable = bug.check_can_change_field('product', 0, 1) %] + [%###############%] [%# Component #%] [%###############%] diff --git a/template/en/default/bug/field-events.js.tmpl b/template/en/default/bug/field-events.js.tmpl index 763687e06..f9e0ea93d 100644 --- a/template/en/default/bug/field-events.js.tmpl +++ b/template/en/default/bug/field-events.js.tmpl @@ -39,3 +39,6 @@ [% legal_value.id FILTER js %]); [% END %] [% END %] +[% IF field.name == 'classification' %] + YAHOO.util.Event.on('product', 'change', setClassification); +[% END %] -- cgit v1.2.3-24-g4f1b