[Rt-commit] rt branch, 3.8-trunk, updated. rt-3.8.7-51-g096c03e
sartak at bestpractical.com
sartak at bestpractical.com
Thu Dec 17 14:44:53 EST 2009
The branch, 3.8-trunk has been updated
via 096c03ed631632bcfcdbd33c6c5c5f6b1e2b6edb (commit)
from d5846df7c24b54b27ff446f99ad4ee446e2229e5 (commit)
Summary of changes:
share/html/Elements/ShowLinks | 37 ++++++--------------
.../TicketBookmark => Elements/ShowRelationLabel} | 16 ++++++--
2 files changed, 23 insertions(+), 30 deletions(-)
copy share/html/{Helpers/Toggle/TicketBookmark => Elements/ShowRelationLabel} (82%)
- Log -----------------------------------------------------------------
commit 096c03ed631632bcfcdbd33c6c5c5f6b1e2b6edb
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Thu Dec 17 14:43:48 2009 -0500
Refactor the anonymous function into an Element
diff --git a/share/html/Elements/ShowLinks b/share/html/Elements/ShowLinks
index 6a974d7..ad370c7 100755
--- a/share/html/Elements/ShowLinks
+++ b/share/html/Elements/ShowLinks
@@ -47,7 +47,7 @@
%# END BPS TAGGED BLOCK }}}
<table>
<tr>
- <td class="labeltop"><% $relation_label->(loc('Depends on'), 'DependsOn') |n %>: (<a href="<%$clone->{'DependsOn-new'}%>"><% loc('Create') %></a>)</td>
+ <td class="labeltop"><& ShowRelationLabel, id => $id, Label => loc('Depends on'), Relation => 'DependsOn' &>: (<a href="<%$clone->{'DependsOn-new'}%>"><% loc('Create') %></a>)</td>
<td class="value">
<%PERL>
@@ -77,7 +77,7 @@ for my $link ( @{ $Ticket->DependsOn->ItemsArrayRef } ) {
</td>
</tr>
<tr>
- <td class="labeltop"><% $relation_label->(loc('Depended on by'), 'DependedOnBy') |n %>: (<a href="<%$clone->{'new-DependsOn'}%>"><% loc('Create') %></a>)</td>
+ <td class="labeltop"><& ShowRelationLabel, id => $id, Label => loc('Depended on by'), Relation => 'DependedOnBy' &>: (<a href="<%$clone->{'new-DependsOn'}%>"><% loc('Create') %></a>)</td>
<td class="value">
<ul>
% while (my $Link = $Ticket->DependedOnBy->Next) {
@@ -87,15 +87,15 @@ for my $link ( @{ $Ticket->DependsOn->ItemsArrayRef } ) {
</td>
</tr>
<tr>
- <td class="labeltop"><% $relation_label->(loc('Parents'), 'Parents') |n %>: (<a href="<%$clone->{'MemberOf-new'}%>"><% loc('Create') %></a>)</td>
+ <td class="labeltop"><& ShowRelationLabel, id => $id, Label => loc('Parents'), Relation => 'Parents' &>: (<a href="<%$clone->{'MemberOf-new'}%>"><% loc('Create') %></a>)</td>
<td class="value"><& /Ticket/Elements/ShowParents, Ticket => $Ticket &></td>
</tr>
<tr>
- <td class="labeltop"><% $relation_label->(loc('Children'), 'Children') |n %>: (<a href="<%$clone->{'new-MemberOf'}%>"><% loc('Create') %></a>)</td>
+ <td class="labeltop"><& ShowRelationLabel, id => $id, Label => loc('Children'), Relation => 'Children' &>: (<a href="<%$clone->{'new-MemberOf'}%>"><% loc('Create') %></a>)</td>
<td class="value"><& /Ticket/Elements/ShowMembers, Ticket => $Ticket &></td>
</tr>
<tr>
- <td class="labeltop"><% $relation_label->(loc('Refers to'), 'RefersTo') |n %>: (<a href="<%$clone->{'RefersTo-new'}%>"><% loc('Create') %></a>)</td>
+ <td class="labeltop"><& ShowRelationLabel, id => $id, Label => loc('Refers to'), Relation => 'RefersTo' &>: (<a href="<%$clone->{'RefersTo-new'}%>"><% loc('Create') %></a>)</td>
<td class="value">
<ul>
% while (my $Link = $Ticket->RefersTo->Next) {
@@ -105,7 +105,7 @@ for my $link ( @{ $Ticket->DependsOn->ItemsArrayRef } ) {
</td>
</tr>
<tr>
- <td class="labeltop"><% $relation_label->(loc('Referred to by'), 'ReferredToBy') |n %>: (<a href="<%$clone->{'new-RefersTo'}%>"><% loc('Create') %></a>)</td>
+ <td class="labeltop"><& ShowRelationLabel, id => $id, Label => loc('Referred to by'), Relation => 'ReferredToBy' &>: (<a href="<%$clone->{'new-RefersTo'}%>"><% loc('Create') %></a>)</td>
<td class="value">
<ul>
% while (my $Link = $Ticket->ReferredToBy->Next) {
@@ -124,14 +124,15 @@ for my $link ( @{ $Ticket->DependsOn->ItemsArrayRef } ) {
<%INIT>
+my $id = $Ticket->id;
+
my $clone = {};
my $path
= RT->Config->Get('WebPath')
. '/Ticket/Create.html?Queue='
. $Ticket->Queue
. '&CloneTicket='
- . $Ticket->id;
-
+ . $id;
for my $relation (
qw(RefersTo ReferredToBy)) {
@@ -142,32 +143,16 @@ for my $relation (
$clone->{$field}
= $path . "&$field="
. join( '%20',
- ( map { $_->$other() } @{ $Ticket->$relation->ItemsArrayRef } ),
- $Ticket->id );
+ ( map { $_->$other() } @{ $Ticket->$relation->ItemsArrayRef } ), $id );
}
for my $relation ( qw(MemberOf Members DependsOn DependedOnBy)) {
my $mode = $RT::Ticket::LINKTYPEMAP{$relation}->{Mode};
my $type = $RT::Ticket::LINKTYPEMAP{$relation}->{Type};
my $field = $mode eq 'Base' ? 'new-' . $type : $type . '-new';
- $clone->{$field} = $path . "&$field=". $Ticket->id ;
+ $clone->{$field} = $path . "&$field=$id";
}
-my $relation_label = sub {
- my $name = shift;
- my $relation = shift;
-
- my $typemap = RT::Ticket->LINKTYPEMAP->{$relation};
- my $search_mode = $typemap->{Mode};
- my $search_type = $typemap->{Type};
- my $search_relation = RT::Ticket->LINKDIRMAP->{$search_type}{$search_mode};
-
- my $Query = $search_relation . ' = ' . $Ticket->id;
- my $SearchURL = RT->Config->Get('WebPath') . '/Search/Results.html?' . $m->comp('/Elements/QueryString', Query => $Query);
-
- return '<a href="' . $SearchURL . '">' . $name . '</a>';
-};
-
</%INIT>
<%ARGS>
diff --git a/share/html/Elements/ShowRelationLabel b/share/html/Elements/ShowRelationLabel
new file mode 100644
index 0000000..3c1ed15
--- /dev/null
+++ b/share/html/Elements/ShowRelationLabel
@@ -0,0 +1,62 @@
+%# BEGIN BPS TAGGED BLOCK {{{
+%#
+%# COPYRIGHT:
+%#
+%# This software is Copyright (c) 1996-2009 Best Practical Solutions, LLC
+%# <jesse at bestpractical.com>
+%#
+%# (Except where explicitly superseded by other copyright notices)
+%#
+%#
+%# LICENSE:
+%#
+%# This work is made available to you under the terms of Version 2 of
+%# the GNU General Public License. A copy of that license should have
+%# been provided with this software, but in any event can be snarfed
+%# from www.gnu.org.
+%#
+%# This work is distributed in the hope that it will be useful, but
+%# WITHOUT ANY WARRANTY; without even the implied warranty of
+%# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+%# General Public License for more details.
+%#
+%# You should have received a copy of the GNU General Public License
+%# along with this program; if not, write to the Free Software
+%# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+%# 02110-1301 or visit their web page on the internet at
+%# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
+%#
+%#
+%# CONTRIBUTION SUBMISSION POLICY:
+%#
+%# (The following paragraph is not intended to limit the rights granted
+%# to you to modify and distribute this software under the terms of
+%# the GNU General Public License and is only of importance to you if
+%# you choose to contribute your changes and enhancements to the
+%# community by submitting them to Best Practical Solutions, LLC.)
+%#
+%# By intentionally submitting any modifications, corrections or
+%# derivatives to this work, or any other work intended for use with
+%# Request Tracker, to Best Practical Solutions, LLC, you confirm that
+%# you are the copyright holder for those contributions and you grant
+%# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable,
+%# royalty-free, perpetual, license to use, copy, create derivative
+%# works based on those contributions, and sublicense and distribute
+%# those contributions and any derivatives thereof.
+%#
+%# END BPS TAGGED BLOCK }}}
+<a href="<%$SearchURL |n %>"><%$Label%></a>
+<%INIT>
+my $typemap = RT::Ticket->LINKTYPEMAP->{$Relation};
+my $search_mode = $typemap->{Mode};
+my $search_type = $typemap->{Type};
+my $search_relation = RT::Ticket->LINKDIRMAP->{$search_type}{$search_mode};
+
+my $Query = $search_relation . ' = ' . $id;
+my $SearchURL = RT->Config->Get('WebPath') . '/Search/Results.html?' . $m->comp('/Elements/QueryString', Query => $Query);
+</%INIT>
+<%ARGS>
+$id
+$Label
+$Relation
+</%ARGS>
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list