]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 357315: Add the ability to create <textarea> fields
authormkanat%bugzilla.org <>
Mon, 17 Sep 2007 09:48:04 +0000 (09:48 +0000)
committermkanat%bugzilla.org <>
Mon, 17 Sep 2007 09:48:04 +0000 (09:48 +0000)
Patch By Max Kanat-Alexander <mkanat@bugzilla.org> r=LpSolit, a=LpSolit

Bugzilla/Constants.pm
Bugzilla/Field.pm
Bugzilla/Template.pm
Bugzilla/Util.pm
skins/standard/global.css
template/en/default/bug/field.html.tmpl
template/en/default/global/field-descs.none.tmpl

index 4406d741537c40cb5c1339bcbc753f7a4a60efa0..27a1b0d779f393f74a2cd135ea11ba47ff6365fc 100644 (file)
@@ -120,6 +120,7 @@ use File::Basename;
     FIELD_TYPE_FREETEXT
     FIELD_TYPE_SINGLE_SELECT
     FIELD_TYPE_MULTI_SELECT
+    FIELD_TYPE_TEXTAREA
 
     USAGE_MODE_BROWSER
     USAGE_MODE_CMDLINE
@@ -342,6 +343,7 @@ use constant FIELD_TYPE_UNKNOWN   => 0;
 use constant FIELD_TYPE_FREETEXT  => 1;
 use constant FIELD_TYPE_SINGLE_SELECT => 2;
 use constant FIELD_TYPE_MULTI_SELECT => 3;
+use constant FIELD_TYPE_TEXTAREA  => 4;
 
 # The maximum number of days a token will remain valid.
 use constant MAX_TOKEN_AGE => 3;
index 6555bba963ee053c2d9146f5ac35c008421df33f..34a1818de975cb81256e389d78a7d8c1f5797e44 100644 (file)
@@ -126,6 +126,7 @@ use constant SQL_DEFINITIONS => {
     FIELD_TYPE_FREETEXT,      { TYPE => 'varchar(255)' },
     FIELD_TYPE_SINGLE_SELECT, { TYPE => 'varchar(64)', NOTNULL => 1,
                                 DEFAULT => "'---'" },
+    FIELD_TYPE_TEXTAREA,      { TYPE => 'MEDIUMTEXT' },
 };
 
 # Field definitions for the fields that ship with Bugzilla.
@@ -254,7 +255,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_MULTI_SELECT)
+    (detaint_natural($type) && $type <= FIELD_TYPE_TEXTAREA)
       || ThrowCodeError('invalid_customfield_type', { type => $saved_type });
     return $type;
 }
index 386be82eac9ea7dc30cc4348737b51a0ee019360..c22502806f466c93efb205f68bc5692f94e69793 100644 (file)
@@ -665,7 +665,11 @@ sub create {
             },
 
             # Wrap a displayed comment to the appropriate length
-            wrap_comment => \&Bugzilla::Util::wrap_comment,
+            wrap_comment => [
+                sub {
+                    my ($context, $cols) = @_;
+                    return sub { wrap_comment($_[0], $cols) }
+                }, 1],
 
             # We force filtering of every variable in key security-critical
             # places; we have a none filter for people to use when they 
index 87caa0527c4175150e64828aac2f885aa15c5ca4..e15edc6b5b9513f5f74be088c8638eb28c440566 100644 (file)
@@ -312,11 +312,11 @@ sub diff_strings {
 }
 
 sub wrap_comment {
-    my ($comment) = @_;
+    my ($comment, $cols) = @_;
     my $wrappedcomment = "";
 
     # Use 'local', as recommended by Text::Wrap's perldoc.
-    local $Text::Wrap::columns = COMMENT_COLS;
+    local $Text::Wrap::columns = $cols || COMMENT_COLS;
     # Make words that are longer than COMMENT_COLS not wrap.
     local $Text::Wrap::huge    = 'overflow';
     # Don't mess with tabs.
@@ -332,6 +332,7 @@ sub wrap_comment {
       }
     }
 
+    chomp($wrappedcomment); # Text::Wrap adds an extra newline at the end.
     return $wrappedcomment;
 }
 
index ce1882827994bf2c5592f4e4a8be2a0d9e87443b..d7765dc885c385293d21c42c2afb0e8e1107a5ce 100644 (file)
@@ -317,6 +317,12 @@ dl dl > dt {
     padding-left: 1em;
 }
 
+/* For bug fields */
+.uneditable_textarea {
+    white-space: pre;
+    font-family: monospace;
+}
+
 div.user_match {
     margin-bottom: 1em;
 }
index 1652ffb0b6fba23a565b5e5739ab268068e7760e..7de659742f68e814451c6110bc8f86dc1c7d2084 100644 (file)
         [% IF field.type == constants.FIELD_TYPE_MULTI_SELECT %]
           <input type="hidden" name="defined_[% field.name FILTER html %]">
         [% END %]
+     [% CASE constants.FIELD_TYPE_TEXTAREA %]
+       [% INCLUDE global/textarea.html.tmpl
+           id = field.name name = field.name minrows = 4 maxrows = 8
+           cols = 60 defaultcontent = value %]
   [% END %]
+[% ELSIF field.type == constants.FIELD_TYPE_TEXTAREA %]
+  <div class="uneditable_textarea">[% value FILTER wrap_comment(60)
+                                            FILTER html %]</div>
 [% ELSE %]
   [% value.join(', ') FILTER html %]
 [% END %]
index dc688770749c5d0816c2a84563f5b7dc1f5056dc..64bf546e6c2d672f21494ce380cf33ab39ae3c49 100644 (file)
@@ -82,6 +82,7 @@
                    ${constants.FIELD_TYPE_FREETEXT}      => "Free Text",
                    ${constants.FIELD_TYPE_SINGLE_SELECT} => "Drop Down",
                    ${constants.FIELD_TYPE_MULTI_SELECT}  => "Multiple-Selection Box",
+                   ${constants.FIELD_TYPE_TEXTAREA}      => "Large Text Box",
                 } %]
 
 [% status_descs = { "UNCONFIRMED" => "UNCONFIRMED",