From eb8f56d70d921ca86d5c7bb71e8b49eb15167f27 Mon Sep 17 00:00:00 2001 From: vkoptev Date: Tue, 19 Nov 2013 13:16:41 +0000 Subject: [PATCH] Bug 138035 - fix ambiguity between showing all values and hiding in single product git-svn-id: svn://svn.office.custis.ru/3rdparty/bugzilla.org/trunk@1860 6955db30-a419-402b-8a0d-67ecbb4d7f56 --- Bugzilla/Field/Choice.pm | 14 ++++++++++++++ editvisibility.cgi | 7 +++---- .../admin/fieldvalues/control-list.html.tmpl | 8 ++++++++ 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/Bugzilla/Field/Choice.pm b/Bugzilla/Field/Choice.pm index d5f9a7efc..a330a904a 100644 --- a/Bugzilla/Field/Choice.pm +++ b/Bugzilla/Field/Choice.pm @@ -479,6 +479,20 @@ sub has_visibility_value return $hash->{$value}; } +sub visible_for_all +{ + my $self = shift; + my ($default) = @_; + $default = 0 if !defined $default; + return $default if $self->name eq '---' || !$self->field->value_field_id; + my $hash = Bugzilla->fieldvaluecontrol_hash + ->{$self->field->value_field_id} + ->{values} + ->{$self->field->id} + ->{$self->id}; + return !%$hash; +} + sub is_default_controlled_value { my $self = shift; diff --git a/editvisibility.cgi b/editvisibility.cgi index e383ffd72..f245a5419 100755 --- a/editvisibility.cgi +++ b/editvisibility.cgi @@ -83,7 +83,6 @@ unless ($action) { my $controlled_fields = { map { $_->id => $_ } values $field->controls_visibility_of() }; my @fields = Bugzilla->get_fields({custom => 1, sort => 1}); my $except_fields = { map { $_->id => { map { $_->id => 1 } values $_->controls_visibility_of } } @fields }; -# die(Dumper $except_fields); $vars->{'fields'} = [ map { { @@ -101,9 +100,8 @@ unless ($action) { exit; } -if ($action eq 'update') { -# check_token_data($token, 'change_visibility'); -# delete_token($token); +if ($action eq 'update' && $token) { + check_token_data($token, 'change_visibility'); my @fields = $cgi->param('fields[]'); my $controlled_fields = { map { $_->id => $_ } values $field->controls_visibility_of() }; @@ -167,6 +165,7 @@ if ($action eq 'update') { push @updated, $cfield->{field}->description; } } + delete_token($token); $vars->{'field'} = $field; $vars->{'value'} = $value; diff --git a/template/en/custom/admin/fieldvalues/control-list.html.tmpl b/template/en/custom/admin/fieldvalues/control-list.html.tmpl index 93e7f633b..a34309171 100644 --- a/template/en/custom/admin/fieldvalues/control-list.html.tmpl +++ b/template/en/custom/admin/fieldvalues/control-list.html.tmpl @@ -53,7 +53,15 @@ + [% IF value.visible_for_all() %] + +

+ Значение видимо для всех значений поля [% field.value_field.description FILTER html %]
+ Редактировать +

+ [% ELSE %] + [% END %]