[Rt-commit] rt branch, 4.2/link-api-refactoring, updated. rt-4.0.6-454-g5efbb00
Thomas Sibley
trs at bestpractical.com
Wed Oct 31 19:25:11 EDT 2012
The branch, 4.2/link-api-refactoring has been updated
via 5efbb007a16a965f8bdef997ce5028c3dba63c5f (commit)
from 76a9d8dc934c014c86279b1c3b716a9b40609df7 (commit)
Summary of changes:
share/html/Elements/EditLinks | 24 ++++++++++++------------
share/html/Elements/ShowLinks | 12 ++++++------
share/html/Elements/ShowRelationLabel | 26 ++++++++++++++++++++++----
3 files changed, 40 insertions(+), 22 deletions(-)
- Log -----------------------------------------------------------------
commit 5efbb007a16a965f8bdef997ce5028c3dba63c5f
Author: Thomas Sibley <trs at bestpractical.com>
Date: Wed Oct 31 16:21:23 2012 -0700
Only link relationship labels to ticket searches when editing ticket links
EditLinks supports other object types than RT::Ticket and shouldn't
display nonsensical links to ticket searches when the object in question
isn't a ticket.
Pass Object to ShowRelationLabel instead of id so ShowRelationLabel can
make a more informed decision about display.
diff --git a/share/html/Elements/EditLinks b/share/html/Elements/EditLinks
index b3075a0..f3af89f 100755
--- a/share/html/Elements/EditLinks
+++ b/share/html/Elements/EditLinks
@@ -52,7 +52,7 @@
<table>
<tr>
- <td class="labeltop"><& ShowRelationLabel, id => $id, Label => loc('Depends on'), Relation => 'DependsOn' &>:</td>
+ <td class="labeltop"><& ShowRelationLabel, Object => $Object, Label => loc('Depends on'), Relation => 'DependsOn' &>:</td>
<td class="value">
% while (my $link = $Object->DependsOn->Next) {
<input type="checkbox" class="checkbox" name="DeleteLink--<%$link->Type%>-<%$link->Target%>" value="1" />
@@ -61,7 +61,7 @@
</td>
</tr>
<tr>
- <td class="labeltop"><& ShowRelationLabel, id => $id, Label => loc('Depended on by'), Relation => 'DependedOnBy' &>:</td>
+ <td class="labeltop"><& ShowRelationLabel, Object => $Object, Label => loc('Depended on by'), Relation => 'DependedOnBy' &>:</td>
<td class="value">
% while (my $link = $Object->DependedOnBy->Next) {
<input type="checkbox" class="checkbox" name="DeleteLink-<%$link->Base%>-<%$link->Type%>-" value="1" />
@@ -70,7 +70,7 @@
</td>
</tr>
<tr>
- <td class="labeltop"><& ShowRelationLabel, id => $id, Label => loc('Parents'), Relation => 'Parents' &>:</td>
+ <td class="labeltop"><& ShowRelationLabel, Object => $Object, Label => loc('Parents'), Relation => 'Parents' &>:</td>
<td class="value">
% while (my $link = $Object->MemberOf->Next) {
<input type="checkbox" class="checkbox" name="DeleteLink--<%$link->Type%>-<%$link->Target%>" value="1" />
@@ -79,7 +79,7 @@
</td>
</tr>
<tr>
- <td class="labeltop"><& ShowRelationLabel, id => $id, Label => loc('Children'), Relation => 'Children' &>:</td>
+ <td class="labeltop"><& ShowRelationLabel, Object => $Object, Label => loc('Children'), Relation => 'Children' &>:</td>
<td class="value">
% while (my $link = $Object->Members->Next) {
<input type="checkbox" class="checkbox" name="DeleteLink-<%$link->Base%>-<%$link->Type%>-" value="1" />
@@ -88,7 +88,7 @@
</td>
</tr>
<tr>
- <td class="labeltop"><& ShowRelationLabel, id => $id, Label => loc('Refers to'), Relation => 'RefersTo' &>:</td>
+ <td class="labeltop"><& ShowRelationLabel, Object => $Object, Label => loc('Refers to'), Relation => 'RefersTo' &>:</td>
<td class="value">
% while (my $link = $Object->RefersTo->Next) {
<input type="checkbox" class="checkbox" name="DeleteLink--<%$link->Type%>-<%$link->Target%>" value="1" />
@@ -97,7 +97,7 @@
</td>
</tr>
<tr>
- <td class="labeltop"><& ShowRelationLabel, id => $id, Label => loc('Referred to by'), Relation => 'ReferredToBy' &>:</td>
+ <td class="labeltop"><& ShowRelationLabel, Object => $Object, Label => loc('Referred to by'), Relation => 'ReferredToBy' &>:</td>
<td class="value">
% while (my $link = $Object->ReferredToBy->Next) {
% # Skip reminders
@@ -135,27 +135,27 @@
</tr>
% }
<tr>
- <td class="label"><& ShowRelationLabel, id => $id, Label => loc('Depends on'), Relation => 'DependsOn' &>:</td>
+ <td class="label"><& ShowRelationLabel, Object => $Object, Label => loc('Depends on'), Relation => 'DependsOn' &>:</td>
<td class="entry"><input name="<%$id%>-DependsOn" /></td>
</tr>
<tr>
- <td class="label"><& ShowRelationLabel, id => $id, Label => loc('Depended on by'), Relation => 'DependedOnBy' &>:</td>
+ <td class="label"><& ShowRelationLabel, Object => $Object, Label => loc('Depended on by'), Relation => 'DependedOnBy' &>:</td>
<td class="entry"><input name="DependsOn-<%$id%>" /></td>
</tr>
<tr>
- <td class="label"><& ShowRelationLabel, id => $id, Label => loc('Parents'), Relation => 'Parents' &>:</td>
+ <td class="label"><& ShowRelationLabel, Object => $Object, Label => loc('Parents'), Relation => 'Parents' &>:</td>
<td class="entry"><input name="<%$id%>-MemberOf" /></td>
</tr>
<tr>
- <td class="label"><& ShowRelationLabel, id => $id, Label => loc('Children'), Relation => 'Children' &>:</td>
+ <td class="label"><& ShowRelationLabel, Object => $Object, Label => loc('Children'), Relation => 'Children' &>:</td>
<td class="entry"> <input name="MemberOf-<%$id%>" /></td>
</tr>
<tr>
- <td class="label"><& ShowRelationLabel, id => $id, Label => loc('Refers to'), Relation => 'RefersTo' &>:</td>
+ <td class="label"><& ShowRelationLabel, Object => $Object, Label => loc('Refers to'), Relation => 'RefersTo' &>:</td>
<td class="entry"><input name="<%$id%>-RefersTo" /></td>
</tr>
<tr>
- <td class="label"><& ShowRelationLabel, id => $id, Label => loc('Referred to by'), Relation => 'ReferredToBy' &>:</td>
+ <td class="label"><& ShowRelationLabel, Object => $Object, Label => loc('Referred to by'), Relation => 'ReferredToBy' &>:</td>
<td class="entry"> <input name="RefersTo-<%$id%>" /></td>
</tr>
% $m->callback( CallbackName => 'NewLink' );
diff --git a/share/html/Elements/ShowLinks b/share/html/Elements/ShowLinks
index 9a9536c..5e2ae1d 100755
--- a/share/html/Elements/ShowLinks
+++ b/share/html/Elements/ShowLinks
@@ -47,7 +47,7 @@
%# END BPS TAGGED BLOCK }}}
<table>
<tr>
- <td class="labeltop"><& ShowRelationLabel, id => $id, Label => loc('Depends on'), Relation => 'DependsOn' &>:\
+ <td class="labeltop"><& ShowRelationLabel, Object => $Ticket, Label => loc('Depends on'), Relation => 'DependsOn' &>:\
% if ($can_create) {
<span class="create">(<a href="<%$clone->{'DependsOn-new'}%>"><% loc('Create') %></a>)</span>
% }
@@ -80,7 +80,7 @@ while ( my $link = $depends_on->Next ) {
</td>
</tr>
<tr>
- <td class="labeltop"><& ShowRelationLabel, id => $id, Label => loc('Depended on by'), Relation => 'DependedOnBy' &>:\
+ <td class="labeltop"><& ShowRelationLabel, Object => $Ticket, Label => loc('Depended on by'), Relation => 'DependedOnBy' &>:\
% if ($can_create) {
<span class="create">(<a href="<%$clone->{'new-DependsOn'}%>"><% loc('Create') %></a>)</span>
% }
@@ -94,7 +94,7 @@ while ( my $link = $depends_on->Next ) {
</td>
</tr>
<tr>
- <td class="labeltop"><& ShowRelationLabel, id => $id, Label => loc('Parents'), Relation => 'Parents' &>:\
+ <td class="labeltop"><& ShowRelationLabel, Object => $Ticket, Label => loc('Parents'), Relation => 'Parents' &>:\
% if ($can_create) {
<span class="create">(<a href="<%$clone->{'MemberOf-new'}%>"><% loc('Create') %></a>)</span>
% }
@@ -102,7 +102,7 @@ while ( my $link = $depends_on->Next ) {
<td class="value"><& /Ticket/Elements/ShowParents, Ticket => $Ticket &></td>
</tr>
<tr>
- <td class="labeltop"><& ShowRelationLabel, id => $id, Label => loc('Children'), Relation => 'Children' &>:\
+ <td class="labeltop"><& ShowRelationLabel, Object => $Ticket, Label => loc('Children'), Relation => 'Children' &>:\
% if ($can_create) {
<span class="create">(<a href="<%$clone->{'new-MemberOf'}%>"><% loc('Create') %></a>)</span>
% }
@@ -110,7 +110,7 @@ while ( my $link = $depends_on->Next ) {
<td class="value"><& /Ticket/Elements/ShowMembers, Ticket => $Ticket &></td>
</tr>
<tr>
- <td class="labeltop"><& ShowRelationLabel, id => $id, Label => loc('Refers to'), Relation => 'RefersTo' &>:\
+ <td class="labeltop"><& ShowRelationLabel, Object => $Ticket, Label => loc('Refers to'), Relation => 'RefersTo' &>:\
% if ($can_create) {
<span class="create">(<a href="<%$clone->{'RefersTo-new'}%>"><% loc('Create') %></a>)</span>
% }
@@ -124,7 +124,7 @@ while ( my $link = $depends_on->Next ) {
</td>
</tr>
<tr>
- <td class="labeltop"><& ShowRelationLabel, id => $id, Label => loc('Referred to by'), Relation => 'ReferredToBy' &>:\
+ <td class="labeltop"><& ShowRelationLabel, Object => $Ticket, Label => loc('Referred to by'), Relation => 'ReferredToBy' &>:\
% if ($can_create) {
<span class="create">(<a href="<%$clone->{'new-RefersTo'}%>"><% loc('Create') %></a>)</span>
% }
diff --git a/share/html/Elements/ShowRelationLabel b/share/html/Elements/ShowRelationLabel
index cf872c4..6e6abda 100644
--- a/share/html/Elements/ShowRelationLabel
+++ b/share/html/Elements/ShowRelationLabel
@@ -45,18 +45,36 @@
%# those contributions and any derivatives thereof.
%#
%# END BPS TAGGED BLOCK }}}
-<a href="<%$SearchURL |n %>"><%$Label%></a>
+% if ($SearchURL) {
+<a href="<% $SearchURL %>"><% $Label %></a>
+% } else {
+<% $Label %>
+% }
<%INIT>
my $typemap = $RT::Link::TYPEMAP{$Relation};
my $search_mode = $typemap->{Mode};
my $search_type = $typemap->{Type};
my $search_relation = $RT::Link::DIRMAP{$search_type}->{$search_mode};
+my $SearchURL;
-my $Query = $search_relation . ' = ' . $id;
-my $SearchURL = RT->Config->Get('WebPath') . '/Search/Results.html?' . $m->comp('/Elements/QueryString', Query => $Query);
+if ($Object and $Object->id) {
+ my $id = $Object->id;
+
+ if ($Object->isa("RT::Ticket")) {
+ $SearchURL = RT->Config->Get('WebPath')
+ . '/Search/Results.html?'
+ . $m->comp('/Elements/QueryString', Query => "$search_relation = $id");
+ }
+}
+
+$m->callback(
+ CallbackName => "ModifySearchURL",
+ SearchURL => \$SearchURL,
+ ARGSRef => \%ARGS,
+);
</%INIT>
<%ARGS>
-$id
+$Object => undef
$Label
$Relation
</%ARGS>
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list