summaryrefslogtreecommitdiffstats
path: root/Bugzilla/Field
diff options
context:
space:
mode:
authormkanat%bugzilla.org <>2009-06-21 21:33:40 +0200
committermkanat%bugzilla.org <>2009-06-21 21:33:40 +0200
commit6a23b8335dd9e0786cf2c6ea90c8574ac0c6f28f (patch)
tree09210e7401d57785effcc9b8bd86c2642f8a1d8d /Bugzilla/Field
parent4c3c583a411a59ae42df2652c8122fcfd5364c52 (diff)
downloadbugzilla-6a23b8335dd9e0786cf2c6ea90c8574ac0c6f28f.tar.gz
bugzilla-6a23b8335dd9e0786cf2c6ea90c8574ac0c6f28f.tar.xz
Bug 463598: Improve the performance of the JavaScript that adjusts field values based on the value of another field
Patch by Max Kanat-Alexander <mkanat@bugzilla.org> r=wicked, a=mkanat
Diffstat (limited to 'Bugzilla/Field')
-rw-r--r--Bugzilla/Field/Choice.pm22
1 files changed, 16 insertions, 6 deletions
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<Bugzilla::Field> object that this field value belongs to.
+=item C<controlled_values>
+
+Tells you which values in B<other> 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<Bugzilla::Field::Choice> objects,
+representing values that this value controls the visibility of, for
+that field.
+
=back