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

Bug 287334: Ability to add custom "Bug ID" fields

Patch By Elliotte Martin <elliotte_martin@yahoo.com> r=mkanat, a=mkanat
parent fed8e66b
......@@ -150,6 +150,9 @@ sub VALIDATORS {
elsif ($field->type == FIELD_TYPE_FREETEXT) {
$validator = \&_check_freetext_field;
}
elsif ($field->type == FIELD_TYPE_BUG_ID) {
$validator = \&_check_bugid_field;
}
else {
$validator = \&_check_default_field;
}
......@@ -1643,6 +1646,12 @@ sub _check_select_field {
return $value;
}
sub _check_bugid_field {
my ($invocant, $value, $field) = @_;
return undef if !$value;
return $invocant->check($value, $field)->id;
}
#####################################################################
# Class Accessors
#####################################################################
......
......@@ -121,6 +121,7 @@ use File::Basename;
FIELD_TYPE_MULTI_SELECT
FIELD_TYPE_TEXTAREA
FIELD_TYPE_DATETIME
FIELD_TYPE_BUG_ID
USAGE_MODE_BROWSER
USAGE_MODE_CMDLINE
......@@ -348,6 +349,7 @@ use constant FIELD_TYPE_SINGLE_SELECT => 2;
use constant FIELD_TYPE_MULTI_SELECT => 3;
use constant FIELD_TYPE_TEXTAREA => 4;
use constant FIELD_TYPE_DATETIME => 5;
use constant FIELD_TYPE_BUG_ID => 6;
# The maximum number of days a token will remain valid.
use constant MAX_TOKEN_AGE => 3;
......
......@@ -125,6 +125,7 @@ use constant SQL_DEFINITIONS => {
DEFAULT => "'---'" },
FIELD_TYPE_TEXTAREA, { TYPE => 'MEDIUMTEXT' },
FIELD_TYPE_DATETIME, { TYPE => 'DATETIME' },
FIELD_TYPE_BUG_ID, { TYPE => 'INT3' },
};
# Field definitions for the fields that ship with Bugzilla.
......@@ -253,7 +254,7 @@ sub _check_type {
my $saved_type = $type;
# The constant here should be updated every time a new,
# higher field type is added.
(detaint_natural($type) && $type <= FIELD_TYPE_DATETIME)
(detaint_natural($type) && $type <= FIELD_TYPE_BUG_ID)
|| ThrowCodeError('invalid_customfield_type', { type => $saved_type });
return $type;
}
......
......@@ -17,6 +17,7 @@
#
# Contributor(s): Myk Melez <myk@mozilla.org>
# Max Kanat-Alexander <mkanat@bugzilla.org>
# Elliotte Martin <elliotte_martin@yahoo.com>
#%]
[%# INTERFACE:
......@@ -61,6 +62,25 @@
<script type="text/javascript">
createCalendar('[% field.name FILTER js %]')
</script>
[% CASE constants.FIELD_TYPE_BUG_ID %]
<span id="[% field.name FILTER html %]_input_area">
<input name="[% field.name FILTER html %]" id="[% field.name FILTER html %]"
value="[% value FILTER html %]" size="7">
</span>
[% IF bug.${field.name} %]
[% bug.${field.name} FILTER bug_link(bug.${field.name}) FILTER none %]
[% END %]
<span id="[% field.name FILTER html %]_edit_container" class="edit_me bz_default_hidden">
(<a href="#" id="[% field.name FILTER html %]_edit_action">edit</a>)
</span>
<script type="text/javascript">
hideEditableField('[% field.name FILTER html %]_edit_container',
'[% field.name FILTER html %]_input_area',
'[% field.name FILTER html %]_edit_action',
'[% field.name FILTER html %]',
"[% bug.${field.name} %]");
</script>
[% CASE [ constants.FIELD_TYPE_SINGLE_SELECT
constants.FIELD_TYPE_MULTI_SELECT ] %]
<select id="[% field.name FILTER html %]"
......@@ -103,6 +123,10 @@
[% ELSIF field.type == constants.FIELD_TYPE_TEXTAREA %]
<div class="uneditable_textarea">[% value FILTER wrap_comment(60)
FILTER html %]</div>
[% ELSIF field.type == constants.FIELD_TYPE_BUG_ID %]
[% IF bug.${field.name} %]
[% bug.${field.name} FILTER bug_link(bug.${field.name}) FILTER none %]
[% END %]
[% ELSE %]
[% value.join(', ') FILTER html %]
[% END %]
......
......@@ -16,6 +16,7 @@
# Rights Reserved.
#
# Contributor(s): Gervase Markham <gerv@gerv.net>
# Elliotte Martin <elliotte_martin@yahoo.com>
#%]
[%# Remember to PROCESS rather than INCLUDE this template. %]
......@@ -102,6 +103,7 @@
${constants.FIELD_TYPE_MULTI_SELECT} => "Multiple-Selection Box",
${constants.FIELD_TYPE_TEXTAREA} => "Large Text Box",
${constants.FIELD_TYPE_DATETIME} => "Date/Time",
${constants.FIELD_TYPE_BUG_ID} => "Bug ID",
} %]
[% status_descs = { "UNCONFIRMED" => "UNCONFIRMED",
......
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