summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--extensions/TrackingFlags/Extension.pm40
-rw-r--r--extensions/TrackingFlags/template/en/default/hook/bug/create/create-form.html.tmpl89
2 files changed, 74 insertions, 55 deletions
diff --git a/extensions/TrackingFlags/Extension.pm b/extensions/TrackingFlags/Extension.pm
index cc2c55334..0c70c54f6 100644
--- a/extensions/TrackingFlags/Extension.pm
+++ b/extensions/TrackingFlags/Extension.pm
@@ -77,9 +77,11 @@ sub template_before_process {
is_active => 1,
});
- $vars->{tracking_flags} = $flags;
- $vars->{tracking_flags_json} = _flags_to_json($flags);
- $vars->{tracking_flag_types} = FLAG_TYPES;
+ $vars->{tracking_flags} = $flags;
+ $vars->{tracking_flags_json} = _flags_to_json($flags);
+ $vars->{tracking_flag_types} = FLAG_TYPES;
+ $vars->{tracking_flag_components} = _flags_to_components($flags, $vars->{product});
+ $vars->{highest_status_firefox} = _get_highest_status_firefox($flags);
}
elsif ($file eq 'bug/edit.html.tmpl'|| $file eq 'bug/show.xml.tmpl'
|| $file eq 'email/bugmail.html.tmpl' || $file eq 'email/bugmail.txt.tmpl')
@@ -140,6 +142,38 @@ sub _flags_to_json {
return encode_json($json);
}
+sub _flags_to_components {
+ my ($flags, $product) = @_;
+
+ # for each component, generate a list of visible tracking flags
+ my $json = {};
+ foreach my $component (@{ $product->components }) {
+ next unless $component->is_active;
+ foreach my $flag (@$flags) {
+ foreach my $visibility (@{ $flag->visibility }) {
+ if ($visibility->product_id == $product->id
+ && (!$visibility->component_id || $visibility->component_id == $component->id))
+ {
+ $json->{$component->name} //= [];
+ push @{ $json->{$component->name} }, $flag->name;
+ }
+ }
+ }
+ }
+ return encode_json($json);
+}
+
+sub _get_highest_status_firefox {
+ my ($flags) = @_;
+
+ my @status_flags =
+ sort { $b <=> $a }
+ map { $_->name =~ /(\d+)$/; $1 }
+ grep { $_->is_active && $_->name =~ /^cf_status_firefox\d/ }
+ @$flags;
+ return @status_flags ? $status_flags[0] : undef;
+}
+
sub db_schema_abstract_schema {
my ($self, $args) = @_;
$args->{'schema'}->{'tracking_flags'} = {
diff --git a/extensions/TrackingFlags/template/en/default/hook/bug/create/create-form.html.tmpl b/extensions/TrackingFlags/template/en/default/hook/bug/create/create-form.html.tmpl
index 59fe1d0ec..c027c6b7f 100644
--- a/extensions/TrackingFlags/template/en/default/hook/bug/create/create-form.html.tmpl
+++ b/extensions/TrackingFlags/template/en/default/hook/bug/create/create-form.html.tmpl
@@ -6,58 +6,43 @@
# defined by the Mozilla Public License, v. 2.0.
#%]
-[% IF tracking_flags.size %]
- [% tracking_flag_names = [] %]
- [% FOREACH flag = tracking_flags %]
- [% tracking_flag_names.push(flag.name) %]
- [% END %]
-
- <script type="text/javascript">
- [% js_filtered_names = [] %]
- [% FOREACH flag = tracking_flag_names %]
- [% js_filtered = flag FILTER js %]
- [% js_filtered_names.push(js_filtered) %]
- [% END %]
- var tracking_flag_names = ['[% js_filtered_names.join("','") FILTER none %]'];
- var tracking_flags = new Array([% product.components.size %]);
+[% RETURN UNLESS tracking_flag_components %]
- [% count = 0 %]
- [% FOREACH c = product.components %]
- [% NEXT IF NOT c.is_active %]
- [% tracking_flag_list = [] %]
- [% FOREACH flag = tracking_flags %]
- [% FOREACH v = flag.visibility %]
- [% IF v.product_id == product.id
- && (!v.component_id.defined || v.component_id == c.id) %]
- [% tracking_flag_list.push(flag.name) %]
- [% END %]
- [% END %]
- [% END %]
- [% js_filtered_flags = [] %]
- [% FOREACH flag = tracking_flag_list %]
- [% js_filtered = flag FILTER js %]
- [% js_filtered_flags.push(js_filtered) %]
- [% END %]
- tracking_flags[[% count %]] = ['[% js_filtered_flags.join("','") FILTER none %]'];
- [% count = count + 1 %]
- [% END %]
+<script type="text/javascript">
+ $(function() {
+ var tracking_flag_components = [% tracking_flag_components FILTER none %];
+ var highest_status_firefox = '[% highest_status_firefox FILTER js %]';
- function update_tracking_flags () {
- var component = document.getElementById('component');
- // First, we disable all flags.
- for (var i = 0; i < tracking_flag_names.length; i++) {
- var flagField = document.getElementById(tracking_flag_names[i]);
- flagField.disabled = true;
- }
- // Now enable flags available for the selected component.
- var index = component.selectedIndex;
- for (var i = 0; i < tracking_flags[index].length; i++) {
- var flagField = document.getElementById(tracking_flags[index][i]);
- flagField.disabled = false;
- }
- }
+ $('#component')
+ .click(function() {
+ // First, we disable all flags.
+ $('table.tracking_flags select').attr('disabled', true);
+ // Now enable flags available for the selected component.
+ var component = $('#component').val();
+ if (!component || !tracking_flag_components[component])
+ return;
+ $.each(tracking_flag_components[component], function(i, v) {
+ $('#' + v).attr('disabled', false);
+ });
+ }).click();
- YAHOO.util.Event.onDOMReady(update_tracking_flags);
- YAHOO.util.Event.addListener("component", "change", update_tracking_flags);
- </script>
-[% END %]
+ [% IF highest_status_firefox %]
+ $('#version, #bug_status')
+ .change(function() {
+ var version = $('#version').val();
+ if ($('#bug_status').val() != 'UNCONFIRMED'
+ && (
+ version.toLowerCase() == 'trunk'
+ || version == highest_status_firefox + ' Branch'
+ || version == 'Firefox ' + highest_status_firefox
+ ))
+ {
+ $('#cf_status_firefox' + highest_status_firefox).val('affected');
+ }
+ else {
+ $('#cf_status_firefox' + highest_status_firefox).val('---');
+ }
+ }).change();
+ [% END %]
+ });
+</script>