[Rt-commit] rt branch, 5.0/allow-ticket-unmerging, updated. rt-5.0.0-228-g769f1ebc7e
Dianne Skoll
dianne at bestpractical.com
Thu Jan 21 10:18:31 EST 2021
The branch, 5.0/allow-ticket-unmerging has been updated
via 769f1ebc7eef1f8fac82db68d2c84c80c9284ef9 (commit)
via e833148f4f80c8d5036b8fc48cbdf1ce451f44f3 (commit)
via c8e3008e9e9f9a75d45bf2e59042d489ecb65f4a (commit)
from eb01bd597e26d0b7e2f588af3fccbde740bd293f (commit)
Summary of changes:
lib/RT/Interface/Web.pm | 34 ++++++++++++++
share/html/Ticket/Elements/EditMerge | 2 +-
.../Elements/UnMerge} | 54 ++++++++--------------
share/html/Ticket/ModifyLinks.html | 43 +++++++++++++++++
share/static/css/elevator-light/ticket.css | 14 ++++++
5 files changed, 112 insertions(+), 35 deletions(-)
copy share/html/{Reports/ResolvedByOwner.html => Ticket/Elements/UnMerge} (72%)
- Log -----------------------------------------------------------------
commit c8e3008e9e9f9a75d45bf2e59042d489ecb65f4a
Author: Dianne Skoll <dianne at bestpractical.com>
Date: Thu Jan 21 08:43:42 2021 -0500
Bring in CSS from RT-Extension-UnmergeTickets
diff --git a/share/static/css/elevator-light/ticket.css b/share/static/css/elevator-light/ticket.css
index 1aeacc09ea..ea313ced6f 100644
--- a/share/static/css/elevator-light/ticket.css
+++ b/share/static/css/elevator-light/ticket.css
@@ -166,3 +166,17 @@ ul.select-queue li a:visited {
.TicketFinalPriority {
display: none;
}
+
+/* Unmerge Tickets */
+.merged-tickets {
+ border-spacing: 5px;
+}
+
+.merge-header {
+ font-weight: bold;
+}
+
+.merge-link {
+ font-weight: bold;
+ padding-left: 10px;
+}
commit e833148f4f80c8d5036b8fc48cbdf1ce451f44f3
Author: Dianne Skoll <dianne at bestpractical.com>
Date: Thu Jan 21 08:46:39 2021 -0500
Remove warning that merging tickets is non-reversible
diff --git a/share/html/Ticket/Elements/EditMerge b/share/html/Ticket/Elements/EditMerge
index 886b2fa983..9e6148acbc 100644
--- a/share/html/Ticket/Elements/EditMerge
+++ b/share/html/Ticket/Elements/EditMerge
@@ -46,7 +46,7 @@
%#
%# END BPS TAGGED BLOCK }}}
<div class='ticket-merge-text <% $MergeTextClass %>'>
-<&|/l&>Warning: merging is a non-reversible action! Enter a single ticket number to be merged into.</&>
+<&|/l&>Enter a single ticket number to be merged into.</&>
</div>
<div>
<div class="form-row">
commit 769f1ebc7eef1f8fac82db68d2c84c80c9284ef9
Author: Dianne Skoll <dianne at bestpractical.com>
Date: Thu Jan 21 10:17:33 2021 -0500
Implement unmerge functionality in RT web interface
diff --git a/lib/RT/Interface/Web.pm b/lib/RT/Interface/Web.pm
index 96cbd51251..9ef05af62e 100644
--- a/lib/RT/Interface/Web.pm
+++ b/lib/RT/Interface/Web.pm
@@ -3680,7 +3680,41 @@ sub ProcessTicketDates {
return (@results);
}
+=head2 ProcessTicketUnmerge ( TicketObj => $Ticket, ARGSRef => \%ARGS );
+Processes a ticket un-merge request and returns an array of results messages.
+
+=cut
+sub ProcessTicketUnmerge
+{
+ my %args = (
+ TicketObj => undef,
+ ARGSRef => undef,
+ @_
+ );
+ my $TicketObj = $args{'TicketObj'};
+ my $ARGSRef = $args{'ARGSRef'};
+ my @results;
+
+ return @results unless $ARGSRef;
+ return @results unless $ARGSRef->{Action} && $ARGSRef->{Action} eq 'Unmerge';
+ return @results unless $ARGSRef->{Unmerge};
+
+ # $TicketObj is the current ticket (the active one)
+ # $merged is the merged one
+ my $merged = RT::Ticket->new($session{CurrentUser});
+ my( $ret, $msg ) = $merged->LoadById( $ARGSRef->{Unmerge} );
+
+ unless( $ret ) {
+ push @results, "Unable to load ticket " . $ARGSRef->{Unmerge} . " to unmerge";
+ RT->Logger->error("Unable to load ticket " . $ARGSRef->{Unmerge} . " to unmerge: $msg");
+ return;
+ }
+
+ ( $ret, $msg ) = $merged->UnmergeFrom( $TicketObj );
+ push @results, $msg;
+ return @results;
+}
=head2 ProcessTicketLinks ( TicketObj => $Ticket, ARGSRef => \%ARGS );
diff --git a/share/html/Ticket/ModifyLinks.html b/share/html/Ticket/Elements/UnMerge
similarity index 52%
copy from share/html/Ticket/ModifyLinks.html
copy to share/html/Ticket/Elements/UnMerge
index bfc0ebbeed..6aae8a537c 100644
--- a/share/html/Ticket/ModifyLinks.html
+++ b/share/html/Ticket/Elements/UnMerge
@@ -45,55 +45,29 @@
%# those contributions and any derivatives thereof.
%#
%# END BPS TAGGED BLOCK }}}
-<& /Elements/Header, Title => loc("Link ticket #[_1]: [_2]", $Ticket->Id, $Ticket->Subject) &>
-<& /Elements/Tabs &>
-
-% $m->callback(CallbackName => 'BeforeActionList', Actions => \@results, ARGSRef => \%ARGS, Ticket => $Ticket);
-<& /Elements/ListActions, actions => \@results &>
-
-<form action="ModifyLinks.html" name="ModifyLinks" method="post">
-<input type="hidden" class="hidden" name="id" value="<%$Ticket->id%>" />
-% $m->callback( CallbackName => 'FormStart', ARGSRef => \%ARGS );
-% my $alt = loc('Graph ticket links');
-% my (@extra);
-% push @extra, titleright_raw => '<a href="' . RT->Config->Get('WebPath') . '/Ticket/Graphs/index.html?id=' . $Ticket->id . '"><span class="fas fa-project-diagram icon-bordered fa-2x" alt="' . $alt . '" data-toggle="tooltip" data-placement="top" data-original-title="' . $alt . '"></span></a>' unless RT->Config->Get('DisableGraphViz');
-<&| /Widgets/TitleBox, title => loc('Edit Links'), class=>'ticket-info-links', @extra &>
-<& /Elements/EditLinks, Object => $Ticket &>
-</&>
-
-<&| /Widgets/TitleBox, title => loc('Merge'), class=>'ticket-info-merge' &>
-<& Elements/EditMerge, Ticket => $Ticket, %ARGS &>
-</&>
+% my $title = @$mergeref > 1 ? loc('Merged tickets') : loc('Merged ticket');
+<div class='merged-tickets'>
<div class="form-row">
- <div class="col-12">
- <& /Elements/Submit, Name => 'SubmitTicket', Label => loc('Save Changes') &>
- </div>
+ <div class="col-2"><% $title %></div>
+ <div class="col-2"><% loc('Ticket') %></div>
+ <div class="col-3"><% loc('Subject') %></div>
+ <div class="col-3"><% loc('Merged Date') %></div>
+ <div class="col-2"></div>
</div>
-</form>
-
-% $m->callback(CallbackName => 'AfterForm', ARGSRef => \%ARGS, Ticket => $Ticket);
-
-<%INIT>
-my $Ticket = LoadTicket($id);
-
-my @results;
-$Ticket->Atomic(sub{
- $m->callback( TicketObj => $Ticket, ARGSRef => \%ARGS, Results => \@results );
- push @results, ProcessTicketLinks( TicketObj => $Ticket, ARGSRef => \%ARGS );
- push @results, ProcessObjectCustomFieldUpdates( Object => $Ticket, ARGSRef => \%ARGS );
-});
-
-MaybeRedirectForResults(
- Actions => \@results,
- Arguments => { id => $id },
-);
+% foreach my $merged (@$mergeref) {
+ <div class="form-row">
+ <div class="col-2"><% $Ticket->Id %></div>
+ <div class="col-2"><% $merged->{id} %></div>
+ <div class="col-3"><% $merged->{subject} %></div>
+ <div class="col-3"><% $merged->{date} %></div>
+ <div class="col-2"><a class='merge-link' href="<% RT->Config->Get('WebPath') %>/Ticket/ModifyLinks.html?Action=Unmerge&id=<% $Ticket->Id %>&Unmerge=<% $merged->{id} %>"><% loc( 'Unmerge' ) %></a></div>
+ </div>
+% }
-$Ticket->CurrentUser->AddRecentlyViewedTicket($Ticket);
+</div>
-</%INIT>
-
-
<%ARGS>
-$id => undef
+$Ticket
+$mergeref
</%ARGS>
diff --git a/share/html/Ticket/ModifyLinks.html b/share/html/Ticket/ModifyLinks.html
index bfc0ebbeed..59adf01323 100644
--- a/share/html/Ticket/ModifyLinks.html
+++ b/share/html/Ticket/ModifyLinks.html
@@ -65,6 +65,12 @@
<& Elements/EditMerge, Ticket => $Ticket, %ARGS &>
</&>
+% if ( @merged ) {
+<&| /Widgets/TitleBox, title => loc('Unmerge'), class => 'ticket-info-merge' &>
+<& Elements/UnMerge, Ticket => $Ticket, mergeref => \@merged, %ARGS &>
+</&>
+% }
+
<div class="form-row">
<div class="col-12">
<& /Elements/Submit, Name => 'SubmitTicket', Label => loc('Save Changes') &>
@@ -80,6 +86,7 @@ my $Ticket = LoadTicket($id);
my @results;
$Ticket->Atomic(sub{
$m->callback( TicketObj => $Ticket, ARGSRef => \%ARGS, Results => \@results );
+ push @results, ProcessTicketUnmerge( TicketObj => $Ticket, ARGSRef => \%ARGS );
push @results, ProcessTicketLinks( TicketObj => $Ticket, ARGSRef => \%ARGS );
push @results, ProcessObjectCustomFieldUpdates( Object => $Ticket, ARGSRef => \%ARGS );
});
@@ -91,6 +98,42 @@ MaybeRedirectForResults(
$Ticket->CurrentUser->AddRecentlyViewedTicket($Ticket);
+# For merged tickets, prepare data for potential un-merging
+my @merged_ids = $Ticket->Merged;
+my @merged;
+
+foreach my $id (@merged_ids) {
+ my $merged_ticket = RT::Ticket->new( $session{'CurrentUser'} );
+
+ # Call LoadById to avoid the redirection to the merged ticket
+ my ($ret, $msg) = $merged_ticket->LoadById( $id );
+ unless ( $ret ) {
+ RT->Logger->error("Unable to load ticket with id $id : $msg");
+ next;
+ }
+
+ my $merge_transactions = RT::Transactions->new( $session{'CurrentUser'} );
+ $merge_transactions->Limit( FIELD => 'ObjectId', VALUE => $id);
+ $merge_transactions->Limit( FIELD => 'Type', VALUE => 'AddLink');
+ $merge_transactions->Limit( FIELD => 'Field', VALUE => 'MergedInto');
+ $merge_transactions->OrderBy( FIELD => 'Created', ORDER => 'DESC');
+ my $merge_transaction = $merge_transactions->First;
+
+ my $date = '';
+ if( $merge_transaction ) {
+ $date = $merge_transaction->Created;
+ }
+ else {
+ RT->Logger->error("Unable to load merge transaction for ticket $id");
+ }
+
+ push @merged, {
+ id => $id,
+ subject => $merged_ticket->Subject,
+ date => $date
+ };
+}
+
</%INIT>
-----------------------------------------------------------------------
More information about the rt-commit
mailing list