[Rt-commit] rt branch, 4.0/no-ticket-interface-for-approvals, updated. rt-4.0.4-120-ge26f6a3
Thomas Sibley
trs at bestpractical.com
Wed Dec 21 13:40:19 EST 2011
The branch, 4.0/no-ticket-interface-for-approvals has been updated
via e26f6a333bf75c0bd5d6ffc9df928bf1c6bb8d89 (commit)
from 48c9a7fe135419b8cadaf95dc452e313fdedbf65 (commit)
Summary of changes:
lib/RT/Interface/Web.pm | 39 +++++++++++++++++++++++++++++++++++++++
share/html/Ticket/autohandler | 20 ++++++++++++++++++++
share/html/m/ticket/autohandler | 8 ++++++++
3 files changed, 67 insertions(+), 0 deletions(-)
create mode 100644 share/html/Ticket/autohandler
create mode 100644 share/html/m/ticket/autohandler
- Log -----------------------------------------------------------------
commit e26f6a333bf75c0bd5d6ffc9df928bf1c6bb8d89
Author: Thomas Sibley <trs at bestpractical.com>
Date: Wed Dec 21 13:29:34 2011 -0500
Redirect to the approvals display from other normal ticket pages too
This includes the mobile display. A redirect from mobile to the full
approvals display is somewhat harsh (although not entirely wrong) and
could potentially be improved with an interstitial. That said,
interstitials can be really annoying. The problem is better solved by
the addition of a mobile approvals interface.
diff --git a/lib/RT/Interface/Web.pm b/lib/RT/Interface/Web.pm
index c880115..0e4f94d 100644
--- a/lib/RT/Interface/Web.pm
+++ b/lib/RT/Interface/Web.pm
@@ -1239,6 +1239,45 @@ sub MaybeRedirectForResults {
return RT::Interface::Web::Redirect($url);
}
+=head2 MaybeRedirectToApproval Path => 'path', Whitelist => REGEX, ARGSRef => HASHREF
+
+If the ticket specified by C<< $ARGSRef->{id} >> is an approval ticket,
+redirect to the approvals display page, preserving any arguments.
+
+C<Path>s matching C<Whitelist> are let through.
+
+This is a no-op if the C<ForceApprovalsView> option isn't enabled.
+
+=cut
+
+sub MaybeRedirectToApproval {
+ my %args = (
+ Path => $HTML::Mason::Commands::m->request_comp->path,
+ ARGSRef => {},
+ Whitelist => undef,
+ @_
+ );
+
+ my $id = $args{ARGSRef}->{id};
+
+ if ( RT->Config->Get('ForceApprovalsView')
+ and $id
+ and not $args{Path} =~ /$args{Whitelist}/)
+ {
+ my $ticket = RT::Ticket->new( $session{'CurrentUser'} );
+ $ticket->Load($id);
+
+ if ($ticket and $ticket->id and lc($ticket->Type) eq 'approval') {
+ MaybeRedirectForResults(
+ Path => "/Approvals/Display.html",
+ Force => 1,
+ Anchor => $args{ARGSRef}->{Anchor},
+ Arguments => $args{ARGSRef},
+ );
+ }
+ }
+}
+
=head2 CreateTicket ARGS
Create a new ticket, using Mason's %ARGS. returns @results.
diff --git a/share/html/Ticket/autohandler b/share/html/Ticket/autohandler
new file mode 100644
index 0000000..47f8776
--- /dev/null
+++ b/share/html/Ticket/autohandler
@@ -0,0 +1,20 @@
+<%init>
+# Redirect to the approvals view if we're trying to get an approvals ticket
+# Exceptions:
+# - Display handles redirecting for approvals itself after mobile redirect/processing
+# - Create doesn't have an existing ticket
+# - Forward and ShowEmailRecord are used by the approvals view
+# - anything not ending in a .html
+my $whitelist = qr{
+ (?:/(?:Display|Create|Forward|ShowEmailRecord)\.html
+ |(?<!\.html))
+ $
+}ix;
+
+MaybeRedirectToApproval(
+ Whitelist => $whitelist,
+ ARGSRef => \%ARGS,
+);
+
+$m->call_next;
+</%init>
diff --git a/share/html/m/ticket/autohandler b/share/html/m/ticket/autohandler
new file mode 100644
index 0000000..ac24959
--- /dev/null
+++ b/share/html/m/ticket/autohandler
@@ -0,0 +1,8 @@
+<%init>
+# Redirect to the approvals view if we're trying to get an approvals ticket
+MaybeRedirectToApproval(
+ Whitelist => qr{/(?:create|select_create_queue)$}i,
+ ARGSRef => \%ARGS,
+);
+$m->call_next;
+</%init>
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list