1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152
|
%# BEGIN BPS TAGGED BLOCK {{{
%#
%# COPYRIGHT:
%#
%# This software is Copyright (c) 1996-2024 Best Practical Solutions, LLC
%# <sales@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 }}}
<%args>
$Object => undef
$CustomFields => undef
$ARGSRef => $DECODED_ARGS
</%args>
<%init>
my $id = ($Object and $Object->id)
? $Object->id
: "new";
my $autocomplete = qq|data-autocomplete="LinkTargets" data-autocomplete-multiple="1"|;
my @excludes;
push @excludes, ( $Object->isa('RT::Asset') ? 'asset:' : '' ) . $id
if $id ne 'new';
my %exclude_links = (
Depend => [ qw( DependsOn DependedOnBy ) ],
Member => [ qw( MemberOf Members ) ],
Refer => [ qw( RefersTo ReferredToBy ) ],
);
foreach my $exclude_type ( keys %exclude_links ) {
my @ids;
if ( $id ne 'new' ) {
foreach my $link_type ( @{ $exclude_links{$exclude_type} } ) {
my $links = $Object->$link_type;
while ( my $link = $links->Next ) {
my $LinkedObj = $link->TargetObj;
# if $LinkedObj is same as $Object we want the BaseObj
$LinkedObj = $link->BaseObj
if (
( ref($Object) eq ref($LinkedObj) )
&&
( $id == $LinkedObj->id )
);
if ( $LinkedObj ) {
my $prefix = '';
if ( $LinkedObj->isa('RT::Asset') ) {
$prefix = 'asset:';
}
elsif ( $LinkedObj->isa('RT::Article') ) {
$prefix = 'a:';
}
elsif ( $LinkedObj->isa('RT::Group') ) {
$prefix = 'group:';
}
elsif ( $LinkedObj->isa('RT::User') ) {
$prefix = 'user:';
}
push @ids, $prefix . $LinkedObj->id;
}
}
}
}
$exclude_links{$exclude_type} = 'data-autocomplete-exclude="' . join( ' ', @excludes, @ids ) . '"'
if @excludes || @ids;
}
</%init>
% if (ref($Object) eq 'RT::Ticket') {
<i><&|/l&>Enter tickets or URIs to link tickets to. Separate multiple entries with spaces.</&>
<br /><&|/l&>You may enter links to Articles as "a:###", where ### represents the number of the Article.</&>
<br /><&|/l&>Enter links to assets as "asset:###", where ### represents the asset ID.</&>
<br /><&|/l&>Enter links to groups as "group:###", where ### represents the group ID.</&>
<br /><&|/l&>Enter links to users as "user:###", where ### represents the user ID.</&>
% $m->callback( CallbackName => 'ExtraLinkInstructions' );
</i><br />
% } elsif (ref($Object) eq 'RT::Queue') {
<i><&|/l&>Enter queues or URIs to link queues to. Separate multiple entries with spaces.</&>
</i><br />
% } else {
<i><&|/l&>Enter objects or URIs to link objects to. Separate multiple entries with spaces.</&></i><br />
% }
<div>
<&| /Elements/LabeledValue, RawLabel => $m->scomp('ShowRelationLabel', Object => $Object, Label => loc('Depends on'), Relation => 'DependsOn') &>
<input type="text" class="form-control" name="<%$id%>-DependsOn" value="<% $ARGSRef->{"$id-DependsOn"} || '' %>" <% $autocomplete |n %> <% $exclude_links{Depend} |n%>/>
</&>
<&| /Elements/LabeledValue, RawLabel => $m->scomp('ShowRelationLabel', Object => $Object, Label => loc('Depended on by'), Relation => 'DependedOnBy') &>
<input type="text" class="form-control" name="DependsOn-<%$id%>" value="<% $ARGSRef->{"DependsOn-$id"} || '' %>" <% $autocomplete |n %> <% $exclude_links{Depend} |n%>/>
</&>
<&| /Elements/LabeledValue, RawLabel => $m->scomp('ShowRelationLabel', Object => $Object, Label => loc('Parents'), Relation => 'Parents') &>
<input type="text" class="form-control" name="<%$id%>-MemberOf" value="<% $ARGSRef->{"$id-MemberOf"} || '' %>" <% $autocomplete |n %> <% $exclude_links{Member} |n%>/>
</&>
<&| /Elements/LabeledValue, RawLabel => $m->scomp('ShowRelationLabel', Object => $Object, Label => loc('Children'), Relation => 'Children') &>
<input type="text" class="form-control" name="MemberOf-<%$id%>" value="<% $ARGSRef->{"MemberOf-$id"} || '' %>" <% $autocomplete |n %> <% $exclude_links{Member} |n%>/>
</&>
<&| /Elements/LabeledValue, RawLabel => $m->scomp('ShowRelationLabel', Object => $Object, Label => loc('Refers to'), Relation => 'RefersTo') &>
<input type="text" class="form-control" name="<%$id%>-RefersTo" value="<% $ARGSRef->{"$id-RefersTo"} || '' %>" <% $autocomplete |n %> <% $exclude_links{Refer} |n%>/>
</&>
<&| /Elements/LabeledValue, RawLabel => $m->scomp('ShowRelationLabel', Object => $Object, Label => loc('Referred to by'), Relation => 'ReferredToBy') &>
<input type="text" class="form-control" name="RefersTo-<%$id%>" value="<% $ARGSRef->{"RefersTo-$id"} || '' %>" <% $autocomplete |n %> <% $exclude_links{Refer} |n%>/>
</&>
<& /Elements/EditCustomFields,
Object => $Object,
Grouping => 'Links',
InTable => 1,
($CustomFields
? (CustomFields => $CustomFields)
: ()),
&>
% $m->callback( CallbackName => 'NewLink' );
</div>
|