[Rt-commit] rt branch, 5.0/add-viewonly-custom-field-column, created. rt-5.0.0-62-gaec69aede6

Dianne Skoll dianne at bestpractical.com
Fri Oct 30 13:32:32 EDT 2020


The branch, 5.0/add-viewonly-custom-field-column has been created
        at  aec69aede6f3251c800ff9bde876b8db28f4a9f1 (commit)

- Log -----------------------------------------------------------------
commit aec69aede6f3251c800ff9bde876b8db28f4a9f1
Author: Dianne Skoll <dianne at bestpractical.com>
Date:   Mon Oct 5 09:18:30 2020 -0400

    Add "CustomFieldView" column type for view-only (non-editable) custom fields.
    
    The idea here is to allow inline editing, but have the ability to turn off
    inline editing on a per-custom-field basis for search results.  This will
    eliminate slowness for custom fields whose "edit" rendering is expensive
    to compute while still permitting inline editing.

diff --git a/share/html/Elements/ColumnMap b/share/html/Elements/ColumnMap
index 17a39a0ec5..b784ee898b 100644
--- a/share/html/Elements/ColumnMap
+++ b/share/html/Elements/ColumnMap
@@ -236,7 +236,7 @@ $WCOLUMN_MAP = $COLUMN_MAP = {
     (map {
         my $value = RT->Config->Get($_);
         $_ => { value => sub { return \$value } };
-    
+
     } qw(WebPath WebBaseURL WebURL)),
     WebRequestPath    => { value => sub { substr( $m->request_path, 1 ) } },
     WebRequestPathDir => { value => sub { substr( $m->request_comp->dir_path, 1 ) } },
@@ -255,6 +255,15 @@ $WCOLUMN_MAP = $COLUMN_MAP = {
 
 $COLUMN_MAP->{'CF'} = $COLUMN_MAP->{'CustomField'};
 
+# Add a CustomFieldView column for custom fields, but with editing disabled
+$COLUMN_MAP->{'CustomFieldView'} = {};
+
+# We copy all keys from CF to CustomFieldView except for "edit"
+foreach my $key (keys(%{$COLUMN_MAP->{'CF'}})) {
+        next if $key eq 'edit';
+        $COLUMN_MAP->{'CustomFieldView'}->{$key} = $COLUMN_MAP->{'CF'}->{$key};
+}
+
 Scalar::Util::weaken($WCOLUMN_MAP);
 
 my $ROLE_MAP = {};
diff --git a/share/html/Search/Elements/BuildFormatString b/share/html/Search/Elements/BuildFormatString
index 5e32941657..de3592e3c7 100644
--- a/share/html/Search/Elements/BuildFormatString
+++ b/share/html/Search/Elements/BuildFormatString
@@ -106,6 +106,10 @@ if ( $Class eq 'RT::Transactions' ) {
 
     while ( my $CustomField = $CustomFields->Next ) {
         push @fields, "CustomField.{" . $CustomField->Name . "}";
+        # If inline editing is enabled, add a display-only version
+        if (RT->Config->Get('InlineEdit', $session{CurrentUser})) {
+            push @fields, "CustomFieldView.{" . $CustomField->Name . "}";
+        }
     }
 }
 elsif ( $Class eq 'RT::Assets' ) {
@@ -140,6 +144,10 @@ elsif ( $Class eq 'RT::Assets' ) {
     $CustomFields->LimitToCatalog(0);
     while ( my $CustomField = $CustomFields->Next ) {
         push @fields, "CustomField.{" . $CustomField->Name . "}";
+        # If inline editing is enabled, add a display-only version
+        if (RT->Config->Get('InlineEdit', $session{CurrentUser})) {
+            push @fields, "CustomFieldView.{" . $CustomField->Name . "}";
+        }
     }
 
 }
@@ -197,6 +205,10 @@ else {
 
     while ( my $CustomField = $CustomFields->Next ) {
         push @fields, "CustomField.{" . $CustomField->Name . "}";
+        # If inline editing is enabled, add a display-only version
+        if (RT->Config->Get('InlineEdit', $session{CurrentUser})) {
+            push @fields, "CustomFieldView.{" . $CustomField->Name . "}";
+        }
     }
 
     my $CustomRoles = RT::CustomRoles->new( $session{'CurrentUser'} );

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


More information about the rt-commit mailing list