summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormkanat%bugzilla.org <>2008-08-22 06:58:43 +0200
committermkanat%bugzilla.org <>2008-08-22 06:58:43 +0200
commitbfcc230e3bf4b8876816f20911a46505dea0f61a (patch)
treeb33c3adf71b6b555ac3c574e24551d43dff8e4a8
parentfed8e66bbd70a815fee8c7f16936dd77651bd31f (diff)
downloadbugzilla-bfcc230e3bf4b8876816f20911a46505dea0f61a.tar.gz
bugzilla-bfcc230e3bf4b8876816f20911a46505dea0f61a.tar.xz
Bug 287334: Ability to add custom "Bug ID" fields
Patch By Elliotte Martin <elliotte_martin@yahoo.com> r=mkanat, a=mkanat
-rw-r--r--Bugzilla/Bug.pm9
-rw-r--r--Bugzilla/Constants.pm2
-rw-r--r--Bugzilla/Field.pm3
-rw-r--r--template/en/default/bug/field.html.tmpl24
-rw-r--r--template/en/default/global/field-descs.none.tmpl2
5 files changed, 39 insertions, 1 deletions
diff --git a/Bugzilla/Bug.pm b/Bugzilla/Bug.pm
index b367954e6..d82b6f6e6 100644
--- a/Bugzilla/Bug.pm
+++ b/Bugzilla/Bug.pm
@@ -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
#####################################################################
diff --git a/Bugzilla/Constants.pm b/Bugzilla/Constants.pm
index b0dd0b6f6..e06fee00c 100644
--- a/Bugzilla/Constants.pm
+++ b/Bugzilla/Constants.pm
@@ -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;
diff --git a/Bugzilla/Field.pm b/Bugzilla/Field.pm
index 0d7479034..4b801f13d 100644
--- a/Bugzilla/Field.pm
+++ b/Bugzilla/Field.pm
@@ -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;
}
diff --git a/template/en/default/bug/field.html.tmpl b/template/en/default/bug/field.html.tmpl
index 1ba0b1784..7720ea0f8 100644
--- a/template/en/default/bug/field.html.tmpl
+++ b/template/en/default/bug/field.html.tmpl
@@ -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 %]
diff --git a/template/en/default/global/field-descs.none.tmpl b/template/en/default/global/field-descs.none.tmpl
index 08587a462..f669df6df 100644
--- a/template/en/default/global/field-descs.none.tmpl
+++ b/template/en/default/global/field-descs.none.tmpl
@@ -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",