[Rt-commit] rt branch, 4.4/cf-entry-hint, created. rt-4.2.3-26-g786bb5b

? sunnavy sunnavy at bestpractical.com
Fri Mar 14 12:18:28 EDT 2014


The branch, 4.4/cf-entry-hint has been created
        at  786bb5b807b509ad2bfc57ecb39903f47428c950 (commit)

- Log -----------------------------------------------------------------
commit 4cfee5fd15f7ca5b8fa3e4bc7a349b1a38a09bb3
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Tue Feb 25 00:10:13 2014 +0800

    EntryHint column for CustomFields table

diff --git a/etc/schema.Oracle b/etc/schema.Oracle
index effefc5..58665c7 100755
--- a/etc/schema.Oracle
+++ b/etc/schema.Oracle
@@ -371,6 +371,7 @@ CREATE TABLE CustomFields (
         Description     VARCHAR2(255),
         SortOrder       NUMBER(11,0) DEFAULT 0 NOT NULL,
         LookupType      VARCHAR2(255),
+        EntryHint       VARCHAR2(255) NULL,
         Creator         NUMBER(11,0) DEFAULT 0 NOT NULL,
         Created         DATE,
         LastUpdatedBy   NUMBER(11,0) DEFAULT 0 NOT NULL,
diff --git a/etc/schema.Pg b/etc/schema.Pg
index e5e2a04..356441b 100755
--- a/etc/schema.Pg
+++ b/etc/schema.Pg
@@ -553,6 +553,7 @@ CREATE TABLE CustomFields (
   BasedOn integer NULL, 
   Pattern varchar(65536) NULL  ,
   LookupType varchar(255) NOT NULL  ,
+  EntryHint varchar(255) NULL,
   Description varchar(255) NULL  ,
   SortOrder integer NOT NULL DEFAULT 0  ,
 
diff --git a/etc/schema.SQLite b/etc/schema.SQLite
index c50e5b1..7ba11f7 100755
--- a/etc/schema.SQLite
+++ b/etc/schema.SQLite
@@ -400,6 +400,7 @@ CREATE TABLE CustomFields (
   Description varchar(255) collate NOCASE NULL  ,
   SortOrder integer NOT NULL DEFAULT 0  ,
   LookupType varchar(255) collate NOCASE NOT NULL,
+  EntryHint varchar(255) NULL,
 
   Creator integer NOT NULL DEFAULT 0  ,
   Created DATETIME NULL  ,
diff --git a/etc/schema.mysql b/etc/schema.mysql
index 610a79c..1030eb2 100755
--- a/etc/schema.mysql
+++ b/etc/schema.mysql
@@ -374,6 +374,7 @@ CREATE TABLE CustomFields (
   Description varchar(255) NULL  ,
   SortOrder integer NOT NULL DEFAULT 0  ,
   LookupType varchar(255) CHARACTER SET ascii NOT NULL,
+  EntryHint varchar(255) NULL,
 
   Creator integer NOT NULL DEFAULT 0  ,
   Created DATETIME NULL  ,
diff --git a/etc/upgrade/4.3.1/content b/etc/upgrade/4.3.1/content
new file mode 100644
index 0000000..9c46681
--- /dev/null
+++ b/etc/upgrade/4.3.1/content
@@ -0,0 +1,16 @@
+use strict;
+use warnings;
+
+our @Initial = (
+    sub {
+        use RT::CustomFields;
+        my $cfs = RT::CustomFields->new(RT->SystemUser);
+        $cfs->{'find_disabled_rows'} = 1;
+        $cfs->Limit( FIELD => 'EntryHint', VALUE => 'NULL', OPERATOR => 'IS' );
+        while ( my $cf = $cfs->Next ) {
+            my ($ret, $msg) = $cf->SetEntryHint($cf->FriendlyType);
+            RT->Logger->warning("Update Custom Field EntryHint for CF." . $cf->Id . " $msg");
+        }
+        return 1;
+    },
+);
diff --git a/etc/upgrade/4.3.1/schema.Oracle b/etc/upgrade/4.3.1/schema.Oracle
new file mode 100644
index 0000000..6056ee0
--- /dev/null
+++ b/etc/upgrade/4.3.1/schema.Oracle
@@ -0,0 +1 @@
+ALTER TABLE CustomFields ADD EntryHint VARCHAR2(255) NULL;
diff --git a/etc/upgrade/4.3.1/schema.Pg b/etc/upgrade/4.3.1/schema.Pg
new file mode 100644
index 0000000..92c28dc
--- /dev/null
+++ b/etc/upgrade/4.3.1/schema.Pg
@@ -0,0 +1 @@
+ALTER TABLE CustomFields ADD COLUMN EntryHint VARCHAR(255) NULL;
diff --git a/etc/upgrade/4.3.1/schema.SQLite b/etc/upgrade/4.3.1/schema.SQLite
new file mode 100644
index 0000000..92c28dc
--- /dev/null
+++ b/etc/upgrade/4.3.1/schema.SQLite
@@ -0,0 +1 @@
+ALTER TABLE CustomFields ADD COLUMN EntryHint VARCHAR(255) NULL;
diff --git a/etc/upgrade/4.3.1/schema.mysql b/etc/upgrade/4.3.1/schema.mysql
new file mode 100644
index 0000000..92c28dc
--- /dev/null
+++ b/etc/upgrade/4.3.1/schema.mysql
@@ -0,0 +1 @@
+ALTER TABLE CustomFields ADD COLUMN EntryHint VARCHAR(255) NULL;
diff --git a/lib/RT/CustomField.pm b/lib/RT/CustomField.pm
index fe4e5f6..6f52c4e 100644
--- a/lib/RT/CustomField.pm
+++ b/lib/RT/CustomField.pm
@@ -234,6 +234,7 @@ Create takes a hash of values and creates a row in the database:
   varchar(255) 'Description'.
   int(11) 'SortOrder'.
   varchar(255) 'LookupType'.
+  varchar(255) 'EntryHint'.
   smallint(6) 'Disabled'.
 
 C<LookupType> is generally the result of either
@@ -2043,6 +2044,16 @@ Returns (1, 'Status message') on success and (0, 'Error Message') on failure.
 
 =cut
 
+=head2 SetEntryHint VALUE
+
+
+Set EntryHint to VALUE.
+Returns (1, 'Status message') on success and (0, 'Error Message') on failure.
+(In the database, EntryHint will be stored as a varchar(255).)
+
+
+=cut
+
 
 =head2 Creator
 
@@ -2124,6 +2135,8 @@ sub _CoreAccessible {
         {read => 1, write => 1, sql_type => 4, length => 11,  is_blob => 0,  is_numeric => 1,  type => 'int(11)', default => '0'},
         LookupType => 
         {read => 1, write => 1, sql_type => 12, length => 255,  is_blob => 0,  is_numeric => 0,  type => 'varchar(255)', default => ''},
+        EntryHint =>
+        {read => 1, write => 1, sql_type => 12, length => 255,  is_blob => 0, is_numeric => 0,  type => 'varchar(255)', default => undef },
         Creator => 
         {read => 1, auto => 1, sql_type => 4, length => 11,  is_blob => 0,  is_numeric => 1,  type => 'int(11)', default => '0'},
         Created => 
diff --git a/share/html/Elements/RT__CustomField/ColumnMap b/share/html/Elements/RT__CustomField/ColumnMap
index d301214..f8b577e 100644
--- a/share/html/Elements/RT__CustomField/ColumnMap
+++ b/share/html/Elements/RT__CustomField/ColumnMap
@@ -63,7 +63,7 @@ my $COLUMN_MAP = {
             title     => $c, attribute => $c,
             value     => sub { return $_[0]->$c() },
         } }
-        qw(Name Description Type LookupType Pattern)
+        qw(Name Description Type LookupType Pattern EntryHint)
     ),
     map(
         { my $c = $_; my $short = $c; $short =~ s/^Friendly//;

commit f004637b3f3c7980a2e831a41ef8ce2b67110079
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Tue Feb 25 00:16:09 2014 +0800

    set EntryHint on create and default it to FriendlyType if not define

diff --git a/lib/RT/CustomField.pm b/lib/RT/CustomField.pm
index 6f52c4e..825dff5 100644
--- a/lib/RT/CustomField.pm
+++ b/lib/RT/CustomField.pm
@@ -254,6 +254,7 @@ sub Create {
         LookupType  => '',
         LinkValueTo => '',
         IncludeContentForValue => '',
+        EntryHint   => undef,
         @_,
     );
 
@@ -343,6 +344,8 @@ sub Create {
             $self->SetLinkValueTo($args{'LinkValueTo'});
         }
 
+        $self->SetEntryHint( $args{EntryHint} // $self->FriendlyType );
+
         if ( exists $args{'IncludeContentForValue'}) {
             $self->SetIncludeContentForValue($args{'IncludeContentForValue'});
         }

commit 7a98ff9ceb3e6a9d06d4bc0b37d2925666431c56
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Tue Feb 25 00:17:06 2014 +0800

    update EntryHint accordingly when Type is updated and EntryHint matches the old FriendlyType

diff --git a/lib/RT/CustomField.pm b/lib/RT/CustomField.pm
index 825dff5..70acf19 100644
--- a/lib/RT/CustomField.pm
+++ b/lib/RT/CustomField.pm
@@ -736,7 +736,11 @@ sub SetType {
         );
         $self->SetMaxValues($1 ? 1 : 0);
     }
-    $self->_Set(Field => 'Type', Value =>$type);
+    my $need_to_update_hint;
+    $need_to_update_hint = 1 if $self->EntryHint && $self->EntryHint eq $self->FriendlyType;
+    my ( $ret, $msg ) = $self->_Set( Field => 'Type', Value => $type );
+    $self->SetEntryHint($self->FriendlyType) if $need_to_update_hint && $ret;
+    return ( $ret, $msg );
 }
 
 =head2 SetPattern STRING

commit eb0ded73dedf4503a913bc2a8d3f847369bee7d3
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Tue Feb 25 00:49:12 2014 +0800

    EntryHint field edit support on cf admin page

diff --git a/share/html/Admin/CustomFields/Modify.html b/share/html/Admin/CustomFields/Modify.html
index 78995f3..30dcbb1 100644
--- a/share/html/Admin/CustomFields/Modify.html
+++ b/share/html/Admin/CustomFields/Modify.html
@@ -97,6 +97,28 @@
         Default => $CustomFieldObj->LookupType || $LookupType, &>
 </td></tr>
 
+<script type="text/javascript">
+jQuery( function() {
+    var select = jQuery('select[name=TypeComposite]');
+    var default_hint = select.find('option:selected').text();
+    var hint_input = jQuery('input[name=EntryHint]');
+    select.change(function() {
+        var new_hint = jQuery(this).find('option:selected').text();
+        if ( hint_input.val() == default_hint ) {
+            hint_input.val(new_hint);
+        }
+        default_hint = new_hint;
+    });
+% if ( $id eq 'new' && not defined $EntryHint) {
+    hint_input.val(default_hint);
+% }
+});
+</script>
+
+<tr><td class="label"><&|/l&>Entry Hint</&></td>
+<td><input name="EntryHint" value="<% $CustomFieldObj->EntryHint // $EntryHint // '' %>" size="80" /></td></tr>
+
+
 <tr class="edit_validation"><td class="label"><&|/l&>Validation</&></td>
 <td><& /Widgets/ComboBox,
     Name    => 'Pattern',
@@ -179,6 +201,7 @@ else {
             IncludeContentForValue => $IncludeContentForValue,
             BasedOn       => $BasedOn,
             Disabled      => ($Enabled ? 0 : 1),
+            EntryHint     => $EntryHint,
         );
         if (!$val) {
             push @results, loc("Could not create CustomField: [_1]", $msg);
@@ -201,7 +224,7 @@ if ( $ARGS{'Update'} && $id ne 'new' ) {
     #we're asking about enabled on the web page but really care about disabled.
     $ARGS{'Disabled'} = $Enabled? 0 : 1;
 
-    my @attribs = qw(Disabled Pattern Name TypeComposite LookupType Description LinkValueTo IncludeContentForValue);
+    my @attribs = qw(Disabled Pattern Name TypeComposite LookupType Description LinkValueTo IncludeContentForValue EntryHint);
     push @results, UpdateRecordObject(
         AttributesRef => \@attribs,
         Object        => $CustomFieldObj,
@@ -339,4 +362,5 @@ $RenderType => undef
 $LinkValueTo => undef
 $IncludeContentForValue => undef
 $BasedOn => undef
+$EntryHint => undef
 </%ARGS>

commit a7db13515f4bd1079947ab0d19d798008d778724
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Tue Feb 25 17:00:55 2014 +0800

    show EntryHint instead of FriendlyType on cf create/update

diff --git a/share/html/Articles/Article/Elements/EditCustomFields b/share/html/Articles/Article/Elements/EditCustomFields
index e3aaf3e..e951873 100644
--- a/share/html/Articles/Article/Elements/EditCustomFields
+++ b/share/html/Articles/Article/Elements/EditCustomFields
@@ -47,7 +47,7 @@
 %# END BPS TAGGED BLOCK }}}
 % while (my $CustomField = $CustomFields->Next()) {
 <tr>
-    <td class="labeltop"><b><%$CustomField->Name%></b><br /><i><%$CustomField->FriendlyType%></i></td>
+    <td class="labeltop"><b><%$CustomField->Name%></b><br /><i><%$CustomField->EntryHint // ''%></i></td>
     <td class="entry"><& /Elements/EditCustomField, 
         Object => $ArticleObj, 
         CustomField => $CustomField, 
diff --git a/share/html/Elements/BulkCustomFields b/share/html/Elements/BulkCustomFields
index 1eb3d59..292dbec 100644
--- a/share/html/Elements/BulkCustomFields
+++ b/share/html/Elements/BulkCustomFields
@@ -56,7 +56,7 @@
 % while (my $cf = $CustomFields->Next) {
 <tr class="<% ++$i%2 ? 'oddline': 'evenline' %>">
 <td class="label"><% $cf->Name %><br />
-<em>(<% $cf->FriendlyType %>)</em></td>
+<em>(<% $cf->EntryHint // '' %>)</em></td>
 % my $rows = 5;
 % my $cf_id = $cf->id;
 % my @add = (NamePrefix => 'Bulk-Add-CustomField-', CustomField => $cf, Rows => $rows,
diff --git a/share/html/Elements/EditCustomFields b/share/html/Elements/EditCustomFields
index 57cf673..161f94d 100644
--- a/share/html/Elements/EditCustomFields
+++ b/share/html/Elements/EditCustomFields
@@ -57,7 +57,7 @@
   <<% $FIELD %> class="edit-custom-field cftype-<% $Type %>">
     <<% $CELL %> class="cflabel">
       <span class="name"><% $CustomField->Name %>:</span><br />
-      <span class="type"><% $CustomField->FriendlyType %></span>
+      <span class="type"><% $CustomField->EntryHint // '' %></span>
     </<% $CELL %>>
     <<% $CELL %> class="entry">
 % my $default = $m->notes('Field-' . $CustomField->Id);
diff --git a/share/html/Search/Bulk.html b/share/html/Search/Bulk.html
index 69adea1..dbebc81 100644
--- a/share/html/Search/Bulk.html
+++ b/share/html/Search/Bulk.html
@@ -136,7 +136,7 @@ size="60" value="<% $ARGS{UpdateSubject} || "" %>" /></td></tr>
 <td><& /Elements/EditCustomField,
     CustomField => $CF,
     Object => RT::Transaction->new( $session{'CurrentUser'} ),
-    &><em><% $CF->FriendlyType %></em></td>
+    &><em><% $CF->EntryHint // '' %></em></td>
 </td></tr>
 % } # end if while
 
diff --git a/share/html/Ticket/Elements/EditTransactionCustomFields b/share/html/Ticket/Elements/EditTransactionCustomFields
index f64666a..49a5224 100644
--- a/share/html/Ticket/Elements/EditTransactionCustomFields
+++ b/share/html/Ticket/Elements/EditTransactionCustomFields
@@ -55,7 +55,7 @@
 <<% $FIELD %>>
 <<% $CELL %> class="label cflabel">
   <span class="name"><% $CF->Name %>:</span><br />
-  <span class="type"><% $CF->FriendlyType %></span>
+  <span class="type"><% $CF->EntryHint // '' %></span>
 </<% $CELL %>>
 <<% $CELL %>>
 <& /Elements/EditCustomField,

commit 5b7c18e8055d10c083766e2f08707bc125907959
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Sun Mar 9 21:09:54 2014 +0800

    incremental upgrade steps for 4.3.1(new EntryHint column for cf)

diff --git a/lib/RT/Migrate/Incremental.pm b/lib/RT/Migrate/Incremental.pm
index e5f723b..7b5a24b 100644
--- a/lib/RT/Migrate/Incremental.pm
+++ b/lib/RT/Migrate/Incremental.pm
@@ -652,6 +652,13 @@ This is a forward of ticket #{ $Ticket->id }
         },
     },
 
+    '4.3.1' => {
+        'RT::CustomField' => sub {
+            my ($ref) = @_;
+            $ref->{EntryHint} //= RT::CustomField->FriendlyType( $ref->{Type}, $ref->{MaxValues} );
+        },
+    },
+
 );
 
 1;

commit b2ed640e652e11dcf9dcdb73c52d72c44f35616b
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Sun Mar 9 21:28:44 2014 +0800

    use EntryHint instead of FriendlyType in %AdminSearchResultFormat by default

diff --git a/etc/RT_Config.pm.in b/etc/RT_Config.pm.in
index fe95a75..2ab5c06 100755
--- a/etc/RT_Config.pm.in
+++ b/etc/RT_Config.pm.in
@@ -2934,7 +2934,7 @@ Set(%AdminSearchResultFormat,
     CustomFields =>
         q{'<a href="__WebPath__/Admin/CustomFields/Modify.html?id=__id__">__id__</a>/TITLE:#'}
         .q{,'<a href="__WebPath__/Admin/CustomFields/Modify.html?id=__id__">__Name__</a>/TITLE:Name'}
-        .q{,__AddedTo__, __FriendlyType__, __FriendlyPattern__},
+        .q{,__AddedTo__, __EntryHint__, __FriendlyPattern__},
 
     Scrips =>
         q{'<a href="__WebPath__/Admin/Scrips/Modify.html?id=__id__">__id__</a>/TITLE:#'}

commit 786bb5b807b509ad2bfc57ecb39903f47428c950
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Sat Mar 15 00:08:42 2014 +0800

    fixed failed tests caused by the new Entryhint change
    
    in the cf admin page, the default EntryHint is bound to the type, but the
    binding is in js, which is not easy to include to our tests. so we have to
    manually set the default EntryHint in tests.
    
    the reason we can't simply default EntryHint to it's FriendlyType is we allow
    empty EntryHint, and it's not straightforward to distinguish undef from it in
    submitted values of web form.

diff --git a/t/articles/upload-customfields.t b/t/articles/upload-customfields.t
index 29bd677..6ce7086 100644
--- a/t/articles/upload-customfields.t
+++ b/t/articles/upload-customfields.t
@@ -44,6 +44,7 @@ $m->submit_form(
         LookupType => 'RT::Class-RT::Article',
         Name => 'img'.$$,
         Description => 'img',
+        EntryHint => 'Upload multiple images',
     },
 );
 $m->title_is(qq/Editing CustomField img$$/, 'admin-cf created');
diff --git a/t/web/cf_access.t b/t/web/cf_access.t
index 48ab5a2..c93057f 100644
--- a/t/web/cf_access.t
+++ b/t/web/cf_access.t
@@ -56,6 +56,7 @@ diag "Create a CF";
             LookupType => 'RT::Queue-RT::Ticket',
             Name => 'img',
             Description => 'img',
+            EntryHint => 'Upload multiple images',
         },
     );
     $m->text_contains('Object created');
diff --git a/t/web/cf_date.t b/t/web/cf_date.t
index ca014f3..0dcaa0d 100644
--- a/t/web/cf_date.t
+++ b/t/web/cf_date.t
@@ -21,6 +21,7 @@ diag "Create a CF";
             Name          => $cf_name,
             TypeComposite => 'Date-1',
             LookupType    => 'RT::Queue-RT::Ticket',
+            EntryHint     => 'Select date',
         },
     );
     $m->content_contains('Object created', 'created CF sucessfully' );
diff --git a/t/web/cf_datetime.t b/t/web/cf_datetime.t
index 6639a5c..b6b446a 100644
--- a/t/web/cf_datetime.t
+++ b/t/web/cf_datetime.t
@@ -31,6 +31,7 @@ diag "Create a CF";
             Name          => $cf_name,
             TypeComposite => 'DateTime-1',
             LookupType    => 'RT::Queue-RT::Ticket',
+            EntryHint     => 'Select datetime',
         },
     );
     $m->content_contains('Object created', 'created CF sucessfully' );
diff --git a/t/web/cf_image.t b/t/web/cf_image.t
index 355f259..d1c3944 100644
--- a/t/web/cf_image.t
+++ b/t/web/cf_image.t
@@ -12,6 +12,7 @@ $m->submit_form_ok({
         Name          => 'Images',
         TypeComposite => 'Image-1',
         LookupType    => 'RT::Queue-RT::Ticket',
+        EntryHint     => 'Upload one image',
     },
 });
 $m->content_contains("Object created");

-----------------------------------------------------------------------


More information about the rt-commit mailing list