From 6a23b8335dd9e0786cf2c6ea90c8574ac0c6f28f Mon Sep 17 00:00:00 2001 From: "mkanat%bugzilla.org" <> Date: Sun, 21 Jun 2009 19:33:40 +0000 Subject: Bug 463598: Improve the performance of the JavaScript that adjusts field values based on the value of another field Patch by Max Kanat-Alexander r=wicked, a=mkanat --- Bugzilla/Field/Choice.pm | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'Bugzilla/Field') diff --git a/Bugzilla/Field/Choice.pm b/Bugzilla/Field/Choice.pm index fe5c7bdcb..f23b0c46d 100644 --- a/Bugzilla/Field/Choice.pm +++ b/Bugzilla/Field/Choice.pm @@ -199,7 +199,7 @@ sub _check_if_controller { my $self = shift; my $vis_fields = $self->controls_visibility_of_fields; my $values = $self->controlled_values; - if (@$vis_fields || @$values) { + if (@$vis_fields || scalar(keys %$values)) { ThrowUserError('fieldvalue_is_controller', { value => $self, fields => [map($_->name, @$vis_fields)], vals => $values }); @@ -287,13 +287,13 @@ sub controlled_values { my $self = shift; return $self->{controlled_values} if defined $self->{controlled_values}; my $fields = $self->field->controls_values_of; - my @controlled_values; + my %controlled_values; foreach my $field (@$fields) { - my $controlled = Bugzilla::Field::Choice->type($field) - ->match({ visibility_value_id => $self->id }); - push(@controlled_values, @$controlled); + $controlled_values{$field->name} = + Bugzilla::Field::Choice->type($field) + ->match({ visibility_value_id => $self->id }); } - $self->{controlled_values} = \@controlled_values; + $self->{controlled_values} = \%controlled_values; return $self->{controlled_values}; } @@ -431,4 +431,14 @@ The key that determines the sort order of this item. The L object that this field value belongs to. +=item C + +Tells you which values in B fields appear (become visible) when this +value is set in its field. + +Returns a hashref of arrayrefs. The hash keys are the names of fields, +and the values are arrays of C objects, +representing values that this value controls the visibility of, for +that field. + =back -- cgit v1.2.3-24-g4f1b