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

? sunnavy sunnavy at bestpractical.com
Sun Mar 9 11:09:23 EDT 2014


The branch, 4.4/cf-entry-hint has been created
        at  f16cdc5791ddf285eaf410cad9fb2ca707d3a4e7 (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 5476004ecf2a137692b6a4ec5248d1ba555eb923
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Sun Mar 9 19:59:03 2014 +0800

    FallbackToDefaultEntryHint option so we can default EntryHint to FriendlyType
    
    when js is enabled, our EntryHint input could be updated correspondingly when
    Type is changed, which is good enough. sadly that our tests don't have js
    right now, which makes some cf tests fail because EntryHint is set to be
    empty. this commit makes tests pass again by defaulting EntryHint to
    FriendlyType in this case(without js).
    
    we need to support empty EntryHint in real life, so we can't fix this by doing
    something like "$args{EntryHint} ||= $self->FriendlyType;".  I chose to add
    input "FallbackToDefaultEntryHint" and it's removed automatically when js is
    available, so it doesn't affect real usage.

diff --git a/lib/RT/CustomField.pm b/lib/RT/CustomField.pm
index 70acf19..4cb850c 100644
--- a/lib/RT/CustomField.pm
+++ b/lib/RT/CustomField.pm
@@ -255,6 +255,7 @@ sub Create {
         LinkValueTo => '',
         IncludeContentForValue => '',
         EntryHint   => undef,
+        FallbackToDefaultEntryHint => 0,
         @_,
     );
 
@@ -344,6 +345,11 @@ sub Create {
             $self->SetLinkValueTo($args{'LinkValueTo'});
         }
 
+        # empty EntryHint is allowed, but if FallbackToDefaultEntryHint is true,
+        # use the default one instead when EntryHint is empty.
+        # this is a workaround as web form values can't elegantly be undef :/
+        $args{EntryHint} = $self->FriendlyType
+            if defined $args{EntryHint} && !length $args{EntryHint} && $args{FallbackToDefaultEntryHint};
         $self->SetEntryHint( $args{EntryHint} // $self->FriendlyType );
 
         if ( exists $args{'IncludeContentForValue'}) {
diff --git a/share/html/Admin/CustomFields/Modify.html b/share/html/Admin/CustomFields/Modify.html
index 30dcbb1..ce17f69 100644
--- a/share/html/Admin/CustomFields/Modify.html
+++ b/share/html/Admin/CustomFields/Modify.html
@@ -112,9 +112,11 @@ jQuery( function() {
 % if ( $id eq 'new' && not defined $EntryHint) {
     hint_input.val(default_hint);
 % }
+    jQuery('input[name=FallbackToDefaultEntryHint]').remove();
 });
 </script>
 
+<input type="hidden" name="FallbackToDefaultEntryHint" value="1">
 <tr><td class="label"><&|/l&>Entry Hint</&></td>
 <td><input name="EntryHint" value="<% $CustomFieldObj->EntryHint // $EntryHint // '' %>" size="80" /></td></tr>
 
@@ -202,6 +204,7 @@ else {
             BasedOn       => $BasedOn,
             Disabled      => ($Enabled ? 0 : 1),
             EntryHint     => $EntryHint,
+            FallbackToDefaultEntryHint => $FallbackToDefaultEntryHint,
         );
         if (!$val) {
             push @results, loc("Could not create CustomField: [_1]", $msg);
@@ -363,4 +366,5 @@ $LinkValueTo => undef
 $IncludeContentForValue => undef
 $BasedOn => undef
 $EntryHint => undef
+$FallbackToDefaultEntryHint => undef
 </%ARGS>

commit 5b789b2d405102c263ca4b99d4dee812a4e777ed
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 f16cdc5791ddf285eaf410cad9fb2ca707d3a4e7
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:#'}

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


More information about the rt-commit mailing list