Commit a43231dd authored by mkanat%bugzilla.org's avatar mkanat%bugzilla.org

Bug 456922: Now that Bugzilla::Field::Choice is complete, clean up…

Bug 456922: Now that Bugzilla::Field::Choice is complete, clean up editvalues.cgi and error messages Patch By Max Kanat-Alexander <mkanat@bugzilla.org> r=bbaetz, a=mkanat
parent b03fc560
...@@ -174,18 +174,17 @@ sub remove_from_db { ...@@ -174,18 +174,17 @@ sub remove_from_db {
my $self = shift; my $self = shift;
if ($self->is_default) { if ($self->is_default) {
ThrowUserError('fieldvalue_is_default', ThrowUserError('fieldvalue_is_default',
{ field => $self->field, value => $self->name, { field => $self->field, value => $self,
param_name => $self->DEFAULT_MAP->{$self->field->name}, param_name => $self->DEFAULT_MAP->{$self->field->name},
}); });
} }
if ($self->is_static) { if ($self->is_static) {
ThrowUserError('fieldvalue_not_deletable', ThrowUserError('fieldvalue_not_deletable',
{ field => $self->field, value => $self->name }); { field => $self->field, value => $self });
} }
if ($self->bug_count) { if ($self->bug_count) {
ThrowUserError("fieldvalue_still_has_bugs", ThrowUserError("fieldvalue_still_has_bugs",
{ field => $self->field, value => $self->name, { field => $self->field, value => $self });
count => $self->bug_count });
} }
$self->SUPER::remove_from_db(); $self->SUPER::remove_from_db();
} }
...@@ -272,7 +271,7 @@ sub _check_value { ...@@ -272,7 +271,7 @@ sub _check_value {
&& $invocant->is_static) && $invocant->is_static)
{ {
ThrowUserError('fieldvalue_not_editable', ThrowUserError('fieldvalue_not_editable',
{ field => $field, old_value => $invocant->name }); { field => $field, old_value => $invocant });
} }
ThrowUserError('fieldvalue_undefined') if !defined $value || $value eq ""; ThrowUserError('fieldvalue_undefined') if !defined $value || $value eq "";
...@@ -282,7 +281,7 @@ sub _check_value { ...@@ -282,7 +281,7 @@ sub _check_value {
my $exists = $invocant->type($field)->new({ name => $value }); my $exists = $invocant->type($field)->new({ name => $value });
if ($exists && (!blessed($invocant) || $invocant->id != $exists->id)) { if ($exists && (!blessed($invocant) || $invocant->id != $exists->id)) {
ThrowUserError('fieldvalue_already_exists', ThrowUserError('fieldvalue_already_exists',
{ field => $field, value => $value }); { field => $field, value => $exists });
} }
return $value; return $value;
......
...@@ -14,18 +14,14 @@ ...@@ -14,18 +14,14 @@
#%] #%]
[%# INTERFACE: [%# INTERFACE:
# value: string; The field value being deleted. # value: Bugzilla::Field::Choice; The field value being deleted.
# bug_count: number; The number of bugs that have this field value. # value_count: number; The number of values available for this field.
# value_count: number; The number of values left for this field, including
# this value.
# field: object; the field the value is being deleted from. # field: object; the field the value is being deleted from.
# param_name: string; The name of the parameter (defaultxxx) associated
# with the field.
#%] #%]
[% title = BLOCK %] [% title = BLOCK %]
Delete Value '[% value FILTER html %]' from the '[% field.description FILTER html %]' Delete Value '[% value.name FILTER html %]' from the
([% field.name FILTER html %]) field '[% field.description FILTER html %]' ([% field.name FILTER html %]) field
[% END %] [% END %]
[% PROCESS global/header.html.tmpl [% PROCESS global/header.html.tmpl
...@@ -44,15 +40,18 @@ ...@@ -44,15 +40,18 @@
</tr> </tr>
<tr> <tr>
<td valign="top">Field Value:</td> <td valign="top">Field Value:</td>
<td valign="top">[% value FILTER html %]</td> <td valign="top">[% value.name FILTER html %]</td>
</tr> </tr>
<tr> <tr>
<td valign="top">[% terms.Bugs %]:</td> <td valign="top">[% terms.Bugs %]:</td>
<td valign="top"> <td valign="top">
[% IF bug_count %] [% IF value.bug_count %]
<a title="List of [% terms.bugs %] where '[% field.description FILTER html %]' is ' <a title="List of [% terms.bugs %] where '
[% value FILTER html %]'" [%- field.description FILTER html %]' is '
href="buglist.cgi?[% field.name FILTER url_quote %]=[%- value FILTER url_quote %]">[% bug_count FILTER html %]</a> [%- value.name FILTER html %]'"
href="buglist.cgi?[% field.name FILTER url_quote %]=
[%- value.name FILTER url_quote %]">
[%- value.bug_count FILTER html %]</a>
[% ELSE %] [% ELSE %]
None None
[% END %] [% END %]
...@@ -62,44 +61,52 @@ ...@@ -62,44 +61,52 @@
<h2>Confirmation</h2> <h2>Confirmation</h2>
[% IF (param_name.defined && Param(param_name) == value) || bug_count || (value_count == 1) %] [% IF value.is_default || value.bug_count || (value_count == 1) %]
<p>Sorry, but the '[% value FILTER html %]' value cannot be deleted <p>Sorry, but the '[% value.name FILTER html %]' value cannot be deleted
from the '[% field.description FILTER html %]' field for the following reason(s):</p> from the '[% field.description FILTER html %]' field for the following
reason(s):</p>
<ul class="warningmessages"> <ul class="warningmessages">
[% IF param_name.defined && Param(param_name) == value %] [% IF value.is_default %]
<li>'[% value FILTER html %]' is the default value for <li>'[% value.name FILTER html %]' is the default value for
the '[% field.description FILTER html %]' field. the '[% field.description FILTER html %]' field.
[% IF user.in_group('tweakparams') %] [% IF user.in_group('tweakparams') %]
You first have to <a href="editparams.cgi?section=bugfields# You first have to <a href="editparams.cgi?section=bugfields">change
[%- param_name FILTER url_quote %]">change the default value</a> for the default value</a> for this field before you can delete
this field before you can delete this value. this value.
[% END %] [% END %]
</li>
[% END %] [% END %]
[% IF bug_count %] [% IF value.bug_count %]
<li>There <li>
[% IF bug_count > 1 %] [% IF value.bug_count > 1 %]
are [% bug_count FILTER html %] [%+ terms.bugs %] There are [% value.bug_count FILTER html %] [%+ terms.bugs %]
[% ELSE %] with this field value.
is 1 [% terms.bug %] [% ELSE %]
[% END %] There is is 1 [% terms.bug %] with this field value.
with this field value. You must change the field value on [% END %]
<a title="List of [% terms.bugs %] where '[% field.description FILTER html %]' is '[% value FILTER html %]'" You must change the field value on
href="buglist.cgi?[% field.name FILTER url_quote %]=[% value FILTER url_quote %]"> <a title="List of [% terms.bugs %] where '
[% IF bug_count > 1 %] [%- field.description FILTER html %]' is '
[%- value.name FILTER html %]'"
href="buglist.cgi?[% field.name FILTER url_quote %]=
[%- value.name FILTER url_quote %]">
[% IF value.bug_count > 1 %]
those [% terms.bugs %] those [% terms.bugs %]
[% ELSE %] [% ELSE %]
that [% terms.bug %] that [% terms.bug %]
[% END %] [% END %]
</a> </a>
to another value before you can delete this value. to another value before you can delete this value.
</li>
[% END %] [% END %]
[% IF value_count == 1 %] [% IF value_count == 1 %]
<li>'[% value FILTER html %]' is the last value for <li>'[% value.name FILTER html %]' is the last value for
'[%- field.description FILTER html %]', and so it can not be deleted. '[%- field.description FILTER html %]', and so it can not be deleted.
</li>
[% END %] [% END %]
</ul> </ul>
...@@ -111,7 +118,7 @@ ...@@ -111,7 +118,7 @@
<input type="submit" value="Yes, delete" id="delete"> <input type="submit" value="Yes, delete" id="delete">
<input type="hidden" name="action" value="delete"> <input type="hidden" name="action" value="delete">
<input type="hidden" name="field" value="[% field.name FILTER html %]"> <input type="hidden" name="field" value="[% field.name FILTER html %]">
<input type="hidden" name="value" value="[% value FILTER html %]"> <input type="hidden" name="value" value="[% value.name FILTER html %]">
<input type="hidden" name="token" value="[% token FILTER html %]"> <input type="hidden" name="token" value="[% token FILTER html %]">
</form> </form>
......
...@@ -26,26 +26,27 @@ ...@@ -26,26 +26,27 @@
%] %]
<p> <p>
This page allows you to add a new value for the '[% field.description FILTER html %]' field. This page allows you to add a new value for the
'[% field.description FILTER html %]' field.
</p> </p>
<form method="post" action="editvalues.cgi"> <form method="post" action="editvalues.cgi">
<table border="0" cellpadding="4" cellspacing="0"> <table border="0" cellpadding="4" cellspacing="0">
<tr> <tr>
<th align="right"><label for="value">Value:</label></th> <th align="right"><label for="value">Value:</label></th>
<td><input id="value" size="30" maxlength="60" name="value" <td><input id="value" name="value" size="30"
value=""></td> maxlength="[% constants.MAX_FIELD_VALUE_SIZE %]"></td>
</tr> </tr>
<tr> <tr>
<th align="right"><label for="sortkey">Sortkey:</label></th> <th align="right"><label for="sortkey">Sortkey:</label></th>
<td><input id="sortkey" size="10" maxlength="20" name="sortkey" <td><input id="sortkey" name="sortkey" size="6" maxlength="6"></td>
value=""></td>
</tr> </tr>
[% IF field.name == "bug_status" %] [% IF field.name == "bug_status" %]
<tr> <tr>
<th align="right"><label for="is_open">Status Type:</label></th> <th align="right"><label for="is_open">Status Type:</label></th>
<td> <td>
<input type="radio" id="open_status" name="is_open" value="1" checked="checked"> <input type="radio" id="open_status" name="is_open" value="1"
checked="checked">
<label for="open_status">Open</label><br> <label for="open_status">Open</label><br>
<input type="radio" id="closed_status" name="is_open" value="0"> <input type="radio" id="closed_status" name="is_open" value="0">
<label for="closed_status">Closed (requires a Resolution)</label> <label for="closed_status">Closed (requires a Resolution)</label>
......
...@@ -14,16 +14,15 @@ ...@@ -14,16 +14,15 @@
#%] #%]
[%# INTERFACE: [%# INTERFACE:
# value: string; The field value we are editing. # value: Bugzilla::Field::Choice; The field value we are editing.
# sortkey: number; Sortkey of the field value we are editing. # field: Bugzilla::Field; The field this value belongs to.
# field: object; The field this value belongs to.
#%] #%]
[% PROCESS global/variables.none.tmpl %] [% PROCESS global/variables.none.tmpl %]
[% title = BLOCK %] [% title = BLOCK %]
Edit Value '[% value FILTER html %]' for the '[% field.description FILTER html %]' Edit Value '[% value.name FILTER html %]' for the
([% field.name FILTER html %]) field '[% field.description FILTER html %]' ([% field.name FILTER html %]) field
[% END %] [% END %]
[% PROCESS global/header.html.tmpl [% PROCESS global/header.html.tmpl
title = title title = title
...@@ -33,32 +32,33 @@ ...@@ -33,32 +32,33 @@
<table border="0" cellpadding="4" cellspacing="0"> <table border="0" cellpadding="4" cellspacing="0">
<tr> <tr>
<th valign="top"><label for="value">Field Value:</label></th> <th valign="top"><label for="value_new">Field Value:</label></th>
<td> <td>
[% IF is_static %] [% IF value.is_static %]
<input type="hidden" name="value" value="[% value FILTER html %]"> <input type="hidden" name="value_new" id="value_new"
[% value FILTER html %] value="[% value.name FILTER html %]">
[%- value.name FILTER html %]
[% ELSE %] [% ELSE %]
<input id="value" size="20" maxlength="60" name="value" value=" <input id="value_new" name="value_new" size="20"
[%- value FILTER html %]"> maxlength="[% constants.MAX_FIELD_VALUE_SIZE %]"
value="[% value.name FILTER html %]">
[% END %] [% END %]
</td> </td>
</tr> </tr>
<tr> <tr>
<th align="right"><label for="sortkey">Sortkey:</label></th> <th align="right"><label for="sortkey">Sortkey:</label></th>
<td><input id="sortkey" size="20" maxlength="20" name="sortkey" value=" <td><input id="sortkey" size="6" maxlength="6" name="sortkey"
[%- sortkey FILTER html %]"></td> value="[%- value.sortkey FILTER html %]"></td>
</tr> </tr>
[% IF field.name == "bug_status" %] [% IF field.name == "bug_status" %]
<tr> <tr>
<th align="right"><label for="is_open">Status Type:</label></th> <th align="right"><label for="is_open">Status Type:</label></th>
<td>[% IF is_open %]Open[% ELSE %]Closed[% END %]</td> <td>[% IF value.is_open %]Open[% ELSE %]Closed[% END %]</td>
</tr> </tr>
[% END %] [% END %]
</table> </table>
<input type="hidden" name="valueold" value="[% value FILTER html %]"> <input type="hidden" name="value" value="[% value.name FILTER html %]">
<input type="hidden" name="sortkeyold" value="[% sortkey FILTER html %]">
<input type="hidden" name="action" value="update"> <input type="hidden" name="action" value="update">
<input type="hidden" name="field" value="[% field.name FILTER html %]"> <input type="hidden" name="field" value="[% field.name FILTER html %]">
<input type="hidden" name="token" value="[% token FILTER html %]"> <input type="hidden" name="token" value="[% token FILTER html %]">
......
...@@ -35,13 +35,14 @@ ...@@ -35,13 +35,14 @@
[%- field.name FILTER url_quote %]">Add</a> a value. [%- field.name FILTER url_quote %]">Add</a> a value.
[% END %] [% END %]
[% IF value && !no_edit_link %] [% IF value.defined && !no_edit_link %]
Edit value <a Edit value <a
title="Edit value '[% value FILTER html %]' for the ' title="Edit value '[% value.name FILTER html %]' for the '
[%- field.name FILTER html %]' field" [%- field.name FILTER html %]' field"
href="editvalues.cgi?action=edit&amp;field= href="editvalues.cgi?action=edit&amp;field=
[%- field.name FILTER url_quote %]&amp;value=[% value FILTER url_quote %]"> [%- field.name FILTER url_quote %]&amp;value=
'[% value FILTER html %]'</a>. [%- value.name FILTER url_quote %]">
'[% value.name FILTER html %]'</a>.
[% END %] [% END %]
[% UNLESS no_edit_other_link %] [% UNLESS no_edit_other_link %]
......
...@@ -58,26 +58,13 @@ ...@@ -58,26 +58,13 @@
} ] } ]
%] %]
[% IF default.defined %]
[% overrides.action = [ {
match_value => "$default"
match_field => 'name'
override_content => 1
content => "(Default value)"
override_contentlink => 1
contentlink => undef
} ]
%]
[% END %]
[% IF static.size %] [% SET overrides.action = [] %]
[% UNLESS overrides.action.size %] [% FOREACH check_value = values %]
[% overrides.action = [] %]
[% END %]
[% FOREACH static_value = static %] [% IF check_value.is_static %]
[% overrides.action.push({ [% overrides.action.push({
match_value => "$static_value" match_value => check_value.name
match_field => 'name' match_field => 'name'
override_content => 1 override_content => 1
content => "(Non-deletable value)" content => "(Non-deletable value)"
...@@ -85,7 +72,17 @@ ...@@ -85,7 +72,17 @@
contentlink => undef contentlink => undef
}) })
%] %]
[% ELSIF check_value.is_default %]
[% overrides.action.push({
match_value => check_value.name
match_field => 'name'
override_content => 1
content => "(Default value)"
override_contentlink => 1
contentlink => undef })
%]
[% END %] [% END %]
[% END %] [% END %]
[% PROCESS admin/table.html.tmpl [% PROCESS admin/table.html.tmpl
......
...@@ -298,31 +298,31 @@ ...@@ -298,31 +298,31 @@
[% ELSIF message_tag == "field_value_created" %] [% ELSIF message_tag == "field_value_created" %]
[% title = "New Field Value Created" %] [% title = "New Field Value Created" %]
The value <em>[% value FILTER html %]</em> has been added as a valid choice The value <em>[% value.name FILTER html %]</em> has been added as a
for the <em>[% field.description FILTER html %]</em> valid choice for the <em>[% field.description FILTER html %]</em>
(<em>[% field.name FILTER html %]</em>) field. (<em>[% field.name FILTER html %]</em>) field.
[% IF field.name == "bug_status" %] [% IF field.name == "bug_status" %]
You should now visit the <a href="editworkflow.cgi">status workflow page</a> You should now visit the <a href="editworkflow.cgi">status workflow
to include your new [% terms.bug %] status. page</a> to include your new [% terms.bug %] status.
[% END %] [% END %]
[% ELSIF message_tag == "field_value_deleted" %] [% ELSIF message_tag == "field_value_deleted" %]
[% title = "Field Value Deleted" %] [% title = "Field Value Deleted" %]
The value <em>[% value FILTER html %]</em> of the The value <em>[% value.name FILTER html %]</em> of the
<em>[% field.description FILTER html %]</em> <em>[% field.description FILTER html %]</em>
(<em>[% field.name FILTER html %]</em>) field has been deleted. (<em>[% field.name FILTER html %]</em>) field has been deleted.
[% ELSIF message_tag == "field_value_updated" %] [% ELSIF message_tag == "field_value_updated" %]
[% title = "Field Value Updated" %] [% title = "Field Value Updated" %]
[% IF changes.keys.size %] [% IF changes.keys.size %]
The <em>[% value FILTER html %]</em> value of the The <em>[% value_old FILTER html %]</em> value of the
<em>[% field.description FILTER html %]</em> <em>[% field.description FILTER html %]</em>
(<em>[% field.name FILTER html %]</em>) field has been changed: (<em>[% field.name FILTER html %]</em>) field has been changed:
<ul> <ul>
[% IF changes.value %] [% IF changes.value %]
<li>Field value updated to <li>Field value updated to
<em>[% changes.value.1 FILTER html %]</em>. <em>[% changes.value.1 FILTER html %]</em>.
[% IF value_obj.is_default %] [% IF value.is_default %]
(Note that this value is the default for this field. All (Note that this value is the default for this field. All
references to the default value will now point to this new value.) references to the default value will now point to this new value.)
[% END %] [% END %]
...@@ -334,7 +334,7 @@ ...@@ -334,7 +334,7 @@
[% END %] [% END %]
</ul> </ul>
[% ELSE %] [% ELSE %]
No changes made to the field value <em>[% value FILTER html %]</em>. No changes made to the field value <em>[% value_old FILTER html %]</em>.
[% END %] [% END %]
[% ELSIF message_tag == "flag_cleared" %] [% ELSIF message_tag == "flag_cleared" %]
......
...@@ -422,26 +422,17 @@ ...@@ -422,26 +422,17 @@
[% ELSIF error == "fieldname_invalid" %] [% ELSIF error == "fieldname_invalid" %]
[% title = "Specified Field Does Not Exist" %] [% title = "Specified Field Does Not Exist" %]
The field '[% field FILTER html %]' does not exist or The field '[% field.name FILTER html %]' does not exist or
cannot be edited with this interface. cannot be edited with this interface.
[% ELSIF error == "fieldname_not_specified" %]
[% title = "Field Name Not Specified" %]
No field name specified when trying to edit field values.
[% ELSIF error == "fieldvalue_already_exists" %] [% ELSIF error == "fieldvalue_already_exists" %]
[% title = "Field Value Already Exists" %] [% title = "Field Value Already Exists" %]
The value '[% value FILTER html %]' already exists for the The value '[% value.name FILTER html %]' already exists for the
[%+ field.description FILTER html %] field. [%+ field.description FILTER html %] field.
[% ELSIF error == "fieldvalue_doesnt_exist" %]
[% title = "Specified Field Value Does Not Exist" %]
The value '[% value FILTER html %]' does not exist for
the '[% field FILTER html %]' field.
[% ELSIF error == "fieldvalue_is_default" %] [% ELSIF error == "fieldvalue_is_default" %]
[% title = "Specified Field Value Is Default" %] [% title = "Specified Field Value Is Default" %]
'[% value FILTER html %]' is the default value for '[% value.name FILTER html %]' is the default value for
the '[% field.description FILTER html %]' field and cannot be deleted. the '[% field.description FILTER html %]' field and cannot be deleted.
[% IF user.in_group('tweakparams') %] [% IF user.in_group('tweakparams') %]
You have to <a href="editparams.cgi?section=bugfields# You have to <a href="editparams.cgi?section=bugfields#
...@@ -456,20 +447,16 @@ ...@@ -456,20 +447,16 @@
[% ELSIF error == "fieldvalue_not_editable" %] [% ELSIF error == "fieldvalue_not_editable" %]
[% title = "Field Value Not Editable" %] [% title = "Field Value Not Editable" %]
The value '[% old_value FILTER html %]' cannot be renamed because The value '[% old_value.name FILTER html %]' cannot be renamed because
it plays some special role for the '[% field.description FILTER html %]' it plays some special role for the '[% field.description FILTER html %]'
field. field.
[% ELSIF error == "fieldvalue_not_deletable" %] [% ELSIF error == "fieldvalue_not_deletable" %]
[% title = "Field Value Not Deletable" %] [% title = "Field Value Not Deletable" %]
The value '[% value FILTER html %]' cannot be removed because The value '[% value.name FILTER html %]' cannot be removed because
it plays some special role for the '[% field.description FILTER html %]' it plays some special role for the '[% field.description FILTER html %]'
field. field.
[% ELSIF error == "fieldvalue_not_specified" %]
[% title = "Field Value Not Specified" %]
No field value specified when trying to edit a field value.
[% ELSIF error == "fieldvalue_reserved_word" %] [% ELSIF error == "fieldvalue_reserved_word" %]
[% title = "Reserved Word Not Allowed" %] [% title = "Reserved Word Not Allowed" %]
You cannot use the value '[% value FILTER html %]' for the You cannot use the value '[% value FILTER html %]' for the
...@@ -484,9 +471,9 @@ ...@@ -484,9 +471,9 @@
[% ELSIF error == "fieldvalue_still_has_bugs" %] [% ELSIF error == "fieldvalue_still_has_bugs" %]
[% title = "You Cannot Delete This Field Value" %] [% title = "You Cannot Delete This Field Value" %]
You cannot delete the value '[% value FILTER html %]' from the You cannot delete the value '[% value.name FILTER html %]' from the
[% field.description FILTER html %] field, because there are still [% field.description FILTER html %] field, because there are still
[%+ count FILTER html %] [%+ terms.bugs %] using it. [%+ value.bug_count FILTER html %] [%+ terms.bugs %] using it.
[% ELSIF error == "fieldvalue_undefined" %] [% ELSIF error == "fieldvalue_undefined" %]
[% title = "Undefined Value Not Allowed" %] [% title = "Undefined Value Not Allowed" %]
......
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