[Rt-commit] rt branch, 4.2/quickcreate-reload, created. rt-4.2.13-53-g7e3e7ff

Dustin Collins strega at bestpractical.com
Tue Sep 13 15:14:33 EDT 2016


The branch, 4.2/quickcreate-reload has been created
        at  7e3e7ff17a02057def0c982d3d9f06e93301a37f (commit)

- Log -----------------------------------------------------------------
commit 7e3e7ff17a02057def0c982d3d9f06e93301a37f
Author: Dustin Collins <strega at bestpractical.com>
Date:   Sun Sep 4 00:45:34 2016 -0400

    Make QuickCreate return to Dashboard
    
    Using QuickCreate from any dashboard takes users back to 'RT at a
    glance'. In order to keep users in their current dashboard, QuickCreate
    is moved to a shared location.
    
    Fixes I#25573

diff --git a/lib/RT/Interface/Web.pm b/lib/RT/Interface/Web.pm
index cbf10d2..f1d503f 100644
--- a/lib/RT/Interface/Web.pm
+++ b/lib/RT/Interface/Web.pm
@@ -3797,6 +3797,79 @@ sub ProcessColumnMapValue {
     }
 }
 
+    sub ProcessQuickCreate {
+        my %params = @_;
+        my %ARGS = %{ $params{ARGSRef} };
+        my $path = $params{Path};
+        my @results;
+
+        if ( $ARGS{'QuickCreate'} ) {
+            my $QueueObj = RT::Queue->new($session{'CurrentUser'});
+            $QueueObj->Load($ARGS{Queue}) or Abort(loc("Queue could not be loaded."));
+
+            my $CFs = $QueueObj->TicketCustomFields();
+
+            my ($ValidCFs, @msg) = $m->comp(
+            '/Elements/ValidateCustomFields',
+            CustomFields        => $CFs,
+            ARGSRef             => \%ARGS,
+            ValidateUnsubmitted => 1,
+            );
+
+
+            my $created;
+            if ( $ValidCFs ) {
+                my ($t, $msg) = CreateTicket(
+                Queue => $ARGS{'Queue'},
+                Owner => $ARGS{'Owner'},
+                Status => $ARGS{'Status'},
+                # yes! it's Requestors, not Requestor
+                Requestors => $ARGS{'Requestors'},
+                Content => $ARGS{'Content'},
+                Subject => $ARGS{'Subject'});
+                push @results, $msg;
+
+                if ( $t && $t->Id ) {
+                    $created = 1;
+                    if ( RT->Config->Get('DisplayTicketAfterQuickCreate', $session{'CurrentUser'}) ) {
+                        MaybeRedirectForResults(
+                        Actions   => \@results,
+                        Path      => '/Ticket/Display.html',
+                        Arguments => { id => $t->Id },
+                        );
+                    }
+                }
+            }
+            else {
+                push @results, loc("Can't quickly create ticket in queue [_1] because custom fields are required.  Please finish by using the normal ticket creation page.", $QueueObj->Name);
+                push @results, @msg;
+
+                MaybeRedirectForResults(
+                Actions     => \@results,
+                Path        => "/Ticket/Create.html",
+                Arguments   => {
+                    (map { $_ => $ARGS{$_} } qw(Queue Owner Status Content Subject)),
+                    Requestors => $ARGS{Requestors},
+                    # From is set above when CFs are OK, but not here since we're
+                    # not calling CreateTicket() directly.  The proper place to set
+                    # a default for From, if desired in the future, is in
+                    # CreateTicket() itself, or at least /Ticket/Display.html
+                    # (which processes /Ticket/Create.html).  From is rarely used
+                    # overall.
+                },
+                );
+            }
+
+            $session{QuickCreate} = \%ARGS unless $created;
+
+            MaybeRedirectForResults(
+            Actions   => \@results,
+            Path      => $path,
+            );
+        }
+        return @results;
+    }
+
 =head2 GetPrincipalsMap OBJECT, CATEGORIES
 
 Returns an array suitable for passing to /Admin/Elements/EditRights with the
diff --git a/share/html/Dashboards/Render.html b/share/html/Dashboards/Render.html
index 93eaa3e..10501f5 100644
--- a/share/html/Dashboards/Render.html
+++ b/share/html/Dashboards/Render.html
@@ -55,6 +55,8 @@
 <& /Elements/Tabs &>
 % }
 
+<& /Elements/ListActions, actions => \@results &>
+
 % $m->callback(CallbackName => 'BeforeTable', Dashboard => $Dashboard, show_cb => $show_cb);
 
 <table class="dashboard" id="dashboard-<%$id%>">
@@ -92,13 +94,24 @@
 % }
 
 <%INIT>
+my @results;
+my $skip_create = 0;
 
+$m->callback(ARGSRef => \%ARGS,
+             results => \@results,
+             CallbackName => 'Initial',
+             skip_create => \$skip_create);
 
 use RT::Dashboard;
 my $Dashboard = RT::Dashboard->new($session{'CurrentUser'});
 my ($ok, $msg) = $Dashboard->LoadById($id);
 $ok || Abort(loc("Couldn't load dashboard [_1]: [_2]", $id, $msg));
 
+my $path = '/Dashboards/' . $Dashboard->id . '/' . $Dashboard->Name;
+unless ( $skip_create ) {
+    push @results, ProcessQuickCreate( Path => $path, ARGSRef => \%ARGS );
+}
+
 my $SubscriptionObj = RT::Attribute->new($session{'CurrentUser'});
 my $rows;
 
diff --git a/share/html/Elements/QuickCreate b/share/html/Elements/QuickCreate
index be25b8d..466565d 100644
--- a/share/html/Elements/QuickCreate
+++ b/share/html/Elements/QuickCreate
@@ -49,7 +49,7 @@
 <&| /Widgets/TitleBox, title => loc('Quick ticket creation') &>
 <form
     method="post"
-    action="<%RT->Config->Get('WebPath')%>/index.html"
+    action="<%RT->Config->Get('WebPath')%><% $r->path_info %>"
 % $m->callback(CallbackName => 'InFormElement');
 >
 <input type="hidden" class="hidden" name="QuickCreate" value="1" />
diff --git a/share/html/index.html b/share/html/index.html
index bbf84c8..a42b307 100644
--- a/share/html/index.html
+++ b/share/html/index.html
@@ -88,73 +88,11 @@ my $skip_create = 0;
 
 $m->callback( ARGSRef => \%ARGS, results => \@results, CallbackName => 'Initial', 
               skip_create => \$skip_create );
-
-if ( $ARGS{'QuickCreate'} ) {
-    my $QueueObj = RT::Queue->new($session{'CurrentUser'});
-    $QueueObj->Load($ARGS{Queue}) or Abort(loc("Queue could not be loaded."));
-    
-    my $CFs = $QueueObj->TicketCustomFields();
-    
-    my ($ValidCFs, @msg) = $m->comp(
-        '/Elements/ValidateCustomFields',
-        CustomFields        => $CFs,
-        ARGSRef             => \%ARGS,
-        ValidateUnsubmitted => 1,
-    );
-
-
-    my $created;
-    if ( $ValidCFs && !$skip_create ) {
-        my ($t, $msg) = CreateTicket( 
-                        Queue => $ARGS{'Queue'},
-                        Owner => $ARGS{'Owner'},
-                        Status => $ARGS{'Status'},
-                        # yes! it's Requestors, not Requestor
-                        Requestors => $ARGS{'Requestors'},
-                        Content => $ARGS{'Content'},
-                        Subject => $ARGS{'Subject'});
-        push @results, $msg;
-
-        if ( $t && $t->Id ) {
-            $created = 1;
-            if ( RT->Config->Get('DisplayTicketAfterQuickCreate', $session{'CurrentUser'}) ) {
-                MaybeRedirectForResults(
-                    Actions   => \@results,
-                    Path      => '/Ticket/Display.html',
-                    Arguments => { id => $t->Id },
-                );
-            }
-        }
-    }
-    elsif ( !$ValidCFs ) {
-        push @results, loc("Can't quickly create ticket in queue [_1] because custom fields are required.  Please finish by using the normal ticket creation page.", $QueueObj->Name);
-        push @results, @msg;
-
-        MaybeRedirectForResults(
-            Actions     => \@results,
-            Path        => "/Ticket/Create.html",
-            Arguments   => {
-                (map { $_ => $ARGS{$_} } qw(Queue Owner Status Content Subject)),
-                Requestors => $ARGS{Requestors},
-                # From is set above when CFs are OK, but not here since we're
-                # not calling CreateTicket() directly.  The proper place to set
-                # a default for From, if desired in the future, is in
-                # CreateTicket() itself, or at least /Ticket/Display.html
-                # (which processes /Ticket/Create.html).  From is rarely used
-                # overall.
-            },
-        );
-    }
-
-    $session{QuickCreate} = \%ARGS unless $created;
-
-    MaybeRedirectForResults(
-        Actions   => \@results,
-        Path      => '/',
-    );
+ 
+unless ( $skip_create ) {
+    push @results, ProcessQuickCreate( Path => '/', ARGSRef => \%ARGS );
 }
 
-
 if ( $ARGS{'q'} ) {
     RT::Interface::Web::Redirect(RT->Config->Get('WebURL')."Search/Simple.html?q=".$m->interp->apply_escapes($ARGS{q}, 'u'));
 }

-----------------------------------------------------------------------


More information about the rt-commit mailing list