Commit b1fa012b authored by Max Kanat-Alexander's avatar Max Kanat-Alexander

Bug 577054: ChoiceInterface was denying the deletion of any value if

the field had *any* value-controlling values. r=LpSolit, a=LpSolit
parent e1109183
...@@ -39,11 +39,11 @@ sub FIELD_NAME { return $_[0]->DB_TABLE; } ...@@ -39,11 +39,11 @@ sub FIELD_NAME { return $_[0]->DB_TABLE; }
sub _check_if_controller { sub _check_if_controller {
my $self = shift; my $self = shift;
my $vis_fields = $self->controls_visibility_of_fields; my $vis_fields = $self->controls_visibility_of_fields;
my $values = $self->controlled_values; my $values = $self->controlled_values_array;
if (@$vis_fields || scalar(keys %$values)) { if (@$vis_fields || @$values) {
ThrowUserError('fieldvalue_is_controller', ThrowUserError('fieldvalue_is_controller',
{ value => $self, fields => [map($_->name, @$vis_fields)], { value => $self, fields => [map($_->name, @$vis_fields)],
vals => $values }); vals => $self->controlled_values });
} }
} }
...@@ -142,6 +142,12 @@ sub controlled_values { ...@@ -142,6 +142,12 @@ sub controlled_values {
return $self->{controlled_values}; return $self->{controlled_values};
} }
sub controlled_values_array {
my ($self) = @_;
my $values = $self->controlled_values;
return [map { @{ $values->{$_} } } keys %$values];
}
sub is_visible_on_bug { sub is_visible_on_bug {
my ($self, $bug) = @_; my ($self, $bug) = @_;
......
...@@ -63,7 +63,7 @@ ...@@ -63,7 +63,7 @@
[% IF value.is_default || value.bug_count || (value_count == 1) [% IF value.is_default || value.bug_count || (value_count == 1)
|| value.controls_visibility_of_fields.size || value.controls_visibility_of_fields.size
|| value.controlled_values.size || value.controlled_values_array.size
%] %]
<p>Sorry, but the '[% value.name FILTER html %]' value cannot be deleted <p>Sorry, but the '[% value.name FILTER html %]' value cannot be deleted
...@@ -123,7 +123,7 @@ ...@@ -123,7 +123,7 @@
</li> </li>
[% END %] [% END %]
[% IF value.controlled_values.size %] [% IF value.controlled_values_array.size %]
<li>This value controls the visibility of the following values in <li>This value controls the visibility of the following values in
other fields:<br> other fields:<br>
[% FOREACH field_name = value.controlled_values.keys %] [% FOREACH field_name = value.controlled_values.keys %]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment