From 1f6ff3a1a2b5f646de1b595b189865f7e586f39d Mon Sep 17 00:00:00 2001 From: Dave Lawrence Date: Fri, 15 Nov 2013 17:36:37 -0500 Subject: Bug 932034 - Ember.show API doesn't return can_edit property for dupe_of, blocks, and depends on fields --- extensions/Ember/lib/WebService.pm | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'extensions/Ember/lib') diff --git a/extensions/Ember/lib/WebService.pm b/extensions/Ember/lib/WebService.pm index 38ebfa707..278b56fd4 100644 --- a/extensions/Ember/lib/WebService.pm +++ b/extensions/Ember/lib/WebService.pm @@ -217,6 +217,8 @@ sub show { name => $key, current_value => $bug_hash->{$key} }; + my $name = Bugzilla::Bug::FIELD_MAP()->{$key} || $key; + $field->{can_edit} = $self->_can_change_field($name, $bug); push(@fields, $field); } } @@ -503,20 +505,21 @@ sub _get_field_values { sub _can_change_field { my ($self, $field, $bug, $value) = @_; my $user = Bugzilla->user; + my $field_name = blessed $field ? $field->name : $field; # Cannot set resolution on bug creation - return $self->type('boolean', 0) if ($field->name eq 'resolution' && !$bug->{bug_id}); + return $self->type('boolean', 0) if ($field_name eq 'resolution' && !$bug->{bug_id}); # Cannot edit an obsolete or inactive custom field - return $self->type('boolean', 0) if ($field->custom && $field->obsolete); + return $self->type('boolean', 0) if (blessed $field && $field->custom && $field->obsolete); # If not a multi-select or single-select, value is not provided # and we just check if the field itself is editable by the user. if (!defined $value) { - return $self->type('boolean', $bug->check_can_change_field($field->name, 1, 0)); + return $self->type('boolean', $bug->check_can_change_field($field_name, 0, 1)); } - return $self->type('boolean', $bug->check_can_change_field($field->name, '', $value)); + return $self->type('boolean', $bug->check_can_change_field($field_name, '', $value)); } sub _flag_to_hash { -- cgit v1.2.3-24-g4f1b