[Rt-commit] rt branch, 4.2/more-info-templates-admin-ui, created. rt-4.0.4-230-gacd7a28

Ruslan Zakirov ruz at bestpractical.com
Fri Sep 14 15:59:53 EDT 2012


The branch, 4.2/more-info-templates-admin-ui has been created
        at  acd7a28a2aa14515228b91527f42f946b33f151c (commit)

- Log -----------------------------------------------------------------
commit c343aa5742bf6ee9f8ac26e7e27494aed5543ef7
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Tue Nov 29 19:44:12 2011 +0400

    IsEmpty column map for templates

diff --git a/share/html/Elements/RT__Template/ColumnMap b/share/html/Elements/RT__Template/ColumnMap
index d9d55cf..b983d31 100644
--- a/share/html/Elements/RT__Template/ColumnMap
+++ b/share/html/Elements/RT__Template/ColumnMap
@@ -78,6 +78,10 @@ my $COLUMN_MAP = {
         title     => 'Queue', # loc
         value     => sub { $_[0]->Queue },
     },
+    IsEmpty => {
+        title     => 'Empty', # loc
+        value     => sub { $_[0]->IsEmpty? $_[0]->loc('Yes') : $_[0]->loc('No') },
+    },
 };
 
 </%ONCE>

commit 615e43a8f07b69617d3f662efb9542c85cd2ec69
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Tue Nov 29 19:47:40 2011 +0400

    UsedBy method and column map for Templates

diff --git a/lib/RT/Template.pm b/lib/RT/Template.pm
index 6f0251d..34fe671 100644
--- a/lib/RT/Template.pm
+++ b/lib/RT/Template.pm
@@ -260,6 +260,50 @@ sub Delete {
     return ( $self->SUPER::Delete(@_) );
 }
 
+=head2 UsedBy
+
+Returns L<RT::Scrips> limitted to scrips that use this template. Takes
+into account that template can be overriden in a queue.
+
+=cut
+
+sub UsedBy {
+    my $self = shift;
+
+    my $scrips = RT::Scrips->new( $self->CurrentUser );
+
+    if ( $self->Queue ) {
+        my $global = RT::Template->new( $self->CurrentUser );
+        $global->LoadGlobalTemplate( $self->Name );
+        $scrips->Limit( FIELD => 'Template', VALUE => $self->id );
+        $scrips->Limit( FIELD => 'Template', VALUE => $global->id ) if $global->id;
+        $scrips->Limit( FIELD => 'Queue',    VALUE => $self->Queue );
+        $scrips->Limit( FIELD => 'Queue',    VALUE => 0 );
+    }
+    else {
+        $scrips->Limit( FIELD => 'Template', VALUE => $self->id );
+        my $alias = $scrips->Join(
+            TYPE => 'LEFT',
+            FIELD1 => 'Queue',
+            TABLE2 => 'Templates',
+            FIELD2 => 'Queue',
+        );
+        $scrips->Limit( LEFTJOIN => $alias, FIELD => 'Name', VALUE => $self->Name );
+        $scrips->Limit( LEFTJOIN => $alias, FIELD => 'Queue', OPERATOR => '!=', VALUE => 0 );
+        $scrips->_OpenParen('UsedBy');
+        $scrips->Limit( SUBCLAUSE => 'UsedBy', FIELD => 'Queue', VALUE => 0 );
+        $scrips->Limit(
+            SUBCLAUSE => 'UsedBy',
+            ALIAS => $alias,
+            FIELD => 'id',
+            OPERATOR => 'IS',
+            VALUE => 'NULL',
+        );
+        $scrips->_CloseParen('UsedBy');
+    }
+    return $scrips;
+}
+
 =head2 IsEmpty
 
 Returns true value if content of the template is empty, otherwise
diff --git a/share/html/Elements/RT__Template/ColumnMap b/share/html/Elements/RT__Template/ColumnMap
index b983d31..f41b71f 100644
--- a/share/html/Elements/RT__Template/ColumnMap
+++ b/share/html/Elements/RT__Template/ColumnMap
@@ -82,6 +82,21 @@ my $COLUMN_MAP = {
         title     => 'Empty', # loc
         value     => sub { $_[0]->IsEmpty? $_[0]->loc('Yes') : $_[0]->loc('No') },
     },
+    UsedBy => {
+        title     => 'Used by scrips', # loc
+        value     => sub {
+            my @res;
+            my $scrips = $_[0]->UsedBy;
+            while ( my $scrip = $scrips->Next ) {
+                push @res, ', ' if @res;
+                push @res, \'<a href="', RT->Config->Get('WebPath'), '/Admin';
+                push @res, $scrip->Queue? '/Queues': '/Global';
+                push @res, '/Scrip.html?Queue='. ($scrip->Queue ||0) .'&id='. $scrip->id;
+                push @res, \'" title="', $scrip->Description, \'">', $scrip->id, \'</a>';
+            }
+            return @res;
+        },
+    },
 };
 
 </%ONCE>

commit acd7a28a2aa14515228b91527f42f946b33f151c
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Tue Nov 29 19:48:09 2011 +0400

    show UsedBy and IsEmpty columns in templates AdminUI

diff --git a/etc/RT_Config.pm.in b/etc/RT_Config.pm.in
index d8e8780..382f6d0 100755
--- a/etc/RT_Config.pm.in
+++ b/etc/RT_Config.pm.in
@@ -2473,7 +2473,7 @@ Set(%AdminSearchResultFormat,
     Templates =>
         q{'<a href="__WebPath__/__WebRequestPathDir__/Template.html?Queue=__QueueId__&Template=__id__">__id__</a>/TITLE:#'}
         .q{,'<a href="__WebPath__/__WebRequestPathDir__/Template.html?Queue=__QueueId__&Template=__id__">__Name__</a>/TITLE:Name'}
-        .q{,'__Description__'},
+        .q{,'__Description__','__UsedBy__','__IsEmpty__'},
     Classes =>
         q{ '<a href="__WebPath__/Admin/Articles/Classes/Modify.html?id=__id__">__id__</a>/TITLE:#'}
         .q{,'<a href="__WebPath__/Admin/Articles/Classes/Modify.html?id=__id__">__Name__</a>/TITLE:Name'}

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


More information about the Rt-commit mailing list