diff options
author | mkanat%bugzilla.org <> | 2008-10-25 06:11:30 +0200 |
---|---|---|
committer | mkanat%bugzilla.org <> | 2008-10-25 06:11:30 +0200 |
commit | 3cea91884b28b52df4e38f2ba88c00b65071a81f (patch) | |
tree | c0f451235176b2b542a38b0c935dcddf0453a1ee /template/en/default/admin/custom_fields/cf-js.js.tmpl | |
parent | e0da20baba17b7f068946c8647fb6d67e77c39b7 (diff) | |
download | bugzilla-3cea91884b28b52df4e38f2ba88c00b65071a81f.tar.gz bugzilla-3cea91884b28b52df4e38f2ba88c00b65071a81f.tar.xz |
Bug 291433: Ability to have custom fields whose visibility depends on the values of other fields
Patch By Max Kanat-Alexander <mkanat@bugzilla.org> r=bbaetz, a=mkanat
Diffstat (limited to 'template/en/default/admin/custom_fields/cf-js.js.tmpl')
-rw-r--r-- | template/en/default/admin/custom_fields/cf-js.js.tmpl | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/template/en/default/admin/custom_fields/cf-js.js.tmpl b/template/en/default/admin/custom_fields/cf-js.js.tmpl new file mode 100644 index 000000000..863f14dca --- /dev/null +++ b/template/en/default/admin/custom_fields/cf-js.js.tmpl @@ -0,0 +1,47 @@ +[%# 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 NASA. + # Portions created by NASA are Copyright (C) 2008 + # San Jose State University Foundation. All Rights Reserved. + # + # Contributor(s): Max Kanat-Alexander <mkanat@bugzilla.org> + #%] + +// Disable a checkbox based on the state of another one. +function toggleCheckbox(this_checkbox, other_checkbox_id) { + var other_checkbox = document.getElementById(other_checkbox_id); + other_checkbox.disabled = !this_checkbox.checked; +} + +var select_values = new Array(); +[% FOREACH sel_field = Bugzilla.active_custom_fields %] + [% NEXT IF !sel_field.is_select %] + select_values[[% sel_field.id FILTER js %]] = [ + [% FOREACH legal_value = sel_field.legal_values %] + [[% legal_value.id FILTER js %], '[% legal_value.name FILTER html %]'], + [% END %] + ]; +[% END %] + +function onChangeVisibilityField() { + var vis_field = document.getElementById('visibility_field_id'); + var vis_value = document.getElementById('visibility_value_id'); + + if (vis_field.value) { + var values = select_values[vis_field.value]; + bz_populateSelectFromArray(vis_value, values); + } + else { + bz_clearOptions(vis_value); + } +} |