[Rt-commit] [rtir] 01/01: popup select queues for RTIR ticket create

Dustin Graves dustin at bestpractical.com
Wed Mar 2 18:49:06 EST 2016


This is an automated email from the git hooks/post-receive script.

dustin pushed a commit to branch 3.4/popup-ticket-create
in repository rtir.

commit fd62e672b1a4029ee2348ce095fc6140c2b90ec5
Author: Dustin Graves <dustin at bestpractical.com>
Date:   Sat Feb 27 00:28:52 2016 +0000

    popup select queues for RTIR ticket create
    
    Fixes: I#31743, I#31750
---
 html/RTIR/Create.html                              | 12 ++--
 html/RTIR/Elements/CreateInRTIRQueueModal          | 70 +++++++++++++++++++++
 html/RTIR/Elements/CreateInRTIRQueueModalIncidents | 72 ++++++++++++++++++++++
 html/RTIR/Helpers/CreateInRTIRQueueModal           | 49 +++++++++++++++
 html/RTIR/Helpers/CreateInRTIRQueueModalIncidents  | 49 +++++++++++++++
 html/RTIR/Incident/Create.html                     | 30 +++------
 html/RTIR/Incident/Elements/ShowChildren           |  3 +-
 html/RTIR/Investigation/Elements/Create            |  9 +--
 lib/RT/IR.pm                                       |  1 +
 static/js/rtir.js                                  | 62 +++++++++++++++++++
 10 files changed, 320 insertions(+), 37 deletions(-)

diff --git a/html/RTIR/Create.html b/html/RTIR/Create.html
index 6c14392..1f27811 100644
--- a/html/RTIR/Create.html
+++ b/html/RTIR/Create.html
@@ -64,6 +64,7 @@
 <form action="<%RT::IR->HREFTo("Split.html") %>" method="post" enctype="multipart/form-data" name="TicketCreate">
 % }
 <input type="hidden" name="id" value="new" />
+<input type="hidden" class="hidden" name="Queue" value="<% $QueueObj->Id %>" />
 <input type="hidden" class="hidden" name="Token" value="<% $ARGS{'Token'} %>" />
 % if ( $Split ) {
 <input type="hidden" name="Split" value="<% $SplitObj->id %>" />
@@ -100,15 +101,10 @@
     QueueObj => $QueueObj,
     fields  => [
         {   name => 'Queue',
-            comp => '/RTIR/Elements/SelectRTIRQueue',
+            comp => '/Ticket/Elements/ShowQueue',
             args => {
-                Name => 'Queue',
-                Default => $ARGS{'Queue'} || $QueueObj->Id,
-                ShowNullOption => 0,
-                Lifecycle => $QueueObj->Lifecycle,
-                LimitToConstituency => (RT::IR->StrictConstituencyLinking ? 1:0),
-                Constituency => $constituency
-            }
+                QueueObj => $QueueObj,
+            },
         },
         {
             name => 'Status',
diff --git a/html/RTIR/Elements/CreateInRTIRQueueModal b/html/RTIR/Elements/CreateInRTIRQueueModal
new file mode 100644
index 0000000..cf98050
--- /dev/null
+++ b/html/RTIR/Elements/CreateInRTIRQueueModal
@@ -0,0 +1,70 @@
+%# BEGIN BPS TAGGED BLOCK {{{
+%#
+%# COPYRIGHT:
+%#
+%# This software is Copyright (c) 1996-2016 Best Practical Solutions, LLC
+%#                                          <sales at 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>
+$Lifecycle
+$LifecycleDesc => $Lifecycle
+$Incident => undef
+</%ARGS>
+<%INIT>
+$Lifecycle = $Lifecycle->[0] if (ref $Lifecycle eq 'ARRAY');
+</%INIT>
+<form action="<% RT::IR->HREFTo('Create.html') %>" id="CreateInQueue">
+% if ($Incident) {
+<input type="hidden" name="Incident" value="<%$Incident%>"/>
+% }
+  <&|/l_unsafe, $LifecycleDesc,
+      $m->scomp('/RTIR/Elements/SelectRTIRQueue',
+        Name => 'Queue',
+        Lifecycle => $Lifecycle,
+        #%ARGS,
+        ShowNullOption => 0,
+        LimitToConstituency => $m->{'RTIR_ConstituencyFilter'} ? 1:0,
+        Constituency => $m->{'RTIR_ConstituencyFilter'})
+    &>Create a new [_1] in the queue [_2]</&>
+  <& /Elements/Submit, Label => loc("Go"), Caption => loc("This will take you to a partially prefilled [_1] creation form.", $LifecycleDesc) &>
+</form>
diff --git a/html/RTIR/Elements/CreateInRTIRQueueModalIncidents b/html/RTIR/Elements/CreateInRTIRQueueModalIncidents
new file mode 100644
index 0000000..2dcf91a
--- /dev/null
+++ b/html/RTIR/Elements/CreateInRTIRQueueModalIncidents
@@ -0,0 +1,72 @@
+%# BEGIN BPS TAGGED BLOCK {{{
+%#
+%# COPYRIGHT:
+%#
+%# This software is Copyright (c) 1996-2016 Best Practical Solutions, LLC
+%#                                          <sales at 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>
+$Child => undef
+</%ARGS>
+<%INIT>
+</%INIT>
+<form action="<% RT::IR->HREFTo('Create.html') %>" id="CreateInQueue">
+% if ($Child) {
+<input type="hidden" name="Child" value="<%$Child%>"/>
+% }
+  <&|/l_unsafe,
+      $m->scomp('/RTIR/Elements/SelectRTIRQueue',
+        Name => 'Queue',
+        Lifecycle => 'incidents',
+        ShowNullOption => 0,
+        LimitToConstituency => $m->{'RTIR_ConstituencyFilter'} ? 1:0,
+        Constituency => $m->{'RTIR_ConstituencyFilter'}),
+      $m->scomp('/RTIR/Elements/SelectRTIRQueue',
+        Name => 'InvestigationQueue',
+        Lifecycle => 'investigations',
+        ShowNullOption => 0,
+        LimitToConstituency => $m->{'RTIR_ConstituencyFilter'} ? 1:0,
+        Constituency => $m->{'RTIR_ConstituencyFilter'}),
+    &>Create a new incident in the queue [_1] with investigations queue [_2]</&>
+  <& /Elements/Submit, Label => loc("Go"), Caption => loc("This will take you to a partially prefilled incident creation form.") &>
+</form>
diff --git a/html/RTIR/Helpers/CreateInRTIRQueueModal b/html/RTIR/Helpers/CreateInRTIRQueueModal
new file mode 100644
index 0000000..39ef32a
--- /dev/null
+++ b/html/RTIR/Helpers/CreateInRTIRQueueModal
@@ -0,0 +1,49 @@
+%# BEGIN BPS TAGGED BLOCK {{{
+%#
+%# COPYRIGHT:
+%#
+%# This software is Copyright (c) 1996-2016 Best Practical Solutions, LLC
+%#                                          <sales at 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 }}}
+<& /RTIR/Elements/CreateInRTIRQueueModal, %ARGS &>
+% $m->abort;
diff --git a/html/RTIR/Helpers/CreateInRTIRQueueModalIncidents b/html/RTIR/Helpers/CreateInRTIRQueueModalIncidents
new file mode 100644
index 0000000..480367d
--- /dev/null
+++ b/html/RTIR/Helpers/CreateInRTIRQueueModalIncidents
@@ -0,0 +1,49 @@
+%# BEGIN BPS TAGGED BLOCK {{{
+%#
+%# COPYRIGHT:
+%#
+%# This software is Copyright (c) 1996-2016 Best Practical Solutions, LLC
+%#                                          <sales at 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 }}}
+<& /RTIR/Elements/CreateInRTIRQueueModalIncidents, %ARGS &>
+% $m->abort;
diff --git a/html/RTIR/Incident/Create.html b/html/RTIR/Incident/Create.html
index 3494189..c9aefce 100644
--- a/html/RTIR/Incident/Create.html
+++ b/html/RTIR/Incident/Create.html
@@ -72,6 +72,7 @@ if ( $ChildObj && $ChildObj->id && !$ChildObj->CurrentUserHasRight('ModifyTicket
 % }
 
 <input type="hidden" name="id"           value="new" />
+<input type="hidden" class="hidden" name="Queue" value="<% $QueueObj->Id %>" />
 <input type="hidden" class="hidden" name="Token" value="<% $ARGS{'Token'} %>" />
 % if ( $ChildObj ) {
 <input type="hidden" name="Child"        value="<% $Child %>" />
@@ -108,13 +109,7 @@ if ( $ChildObj && $ChildObj->id && !$ChildObj->CurrentUserHasRight('ModifyTicket
 <tr class="queue">
   <td class="label"><&|/l&>Queue</&>:</td>
   <td colspan="2">
-      <& /RTIR/Elements/SelectRTIRQueue,
-                Name => 'Queue',
-                Default => $ARGS{'Queue'} || $QueueObj->Id,
-                Lifecycle => RT::IR->lifecycle_incident,
-                LimitToConstituency => ($m->{'RTIR_ConstituencyFilter'} || RT::IR->StrictConstituencyLinking ) ? 1:0,
-                Constituency => $constituency
-    &>
+      <& /Ticket/Elements/ShowQueue, QueueObj => $QueueObj &>
   </td>
 </tr>
  
@@ -270,6 +265,7 @@ if ( $ChildObj && $ChildObj->id && !$ChildObj->CurrentUserHasRight('ModifyTicket
 <& /RTIR/Investigation/Elements/Create,
     %ARGS,
     NamePrefix => 'Investigation',
+    Queue => $ARGS{InvestigationQueue},
     Lifecycle => RT::IR->lifecycle_investigation,
     Constituency => $constituency,
     SkipField => { Owner => 1, Attachments => 1, DateFields => 1 },
@@ -332,22 +328,14 @@ for my $related_ticket ($ChildObj, $SplitObj) {
 }
 
 
-my $QueueObj;
+my $QueueObj = RT::Queue->new($session{'CurrentUser'});
+$QueueObj->Load( $ARGS{Queue} );
+
+if (!$QueueObj->Name) {
+Abort( loc("Queue '[_1]' could not be loaded.", $ARGS{Queue}) );
+ }
 
-# XXX TODO refactor this into library code
-# that 'finds the first plausible queue with the right constituency
-my $collection = RT::Queues->new($session{'CurrentUser'});
-$collection->Limit(FIELD => 'Lifecycle', VALUE => RT::IR->lifecycle_incident);
-while (my $queue = $collection->Next) {
-    if ((RT::IR->ConstituencyFor($queue)||'') eq ($constituency||'')) {
-        $QueueObj = $queue;
-        last;
-    }
-}
 
-if (!$QueueObj) {
-    Abort( loc("Queue could not be loaded.") );
-}
 
 
 my $ticket = RT::Ticket->new($session{'CurrentUser'}); # empty ticket object
diff --git a/html/RTIR/Incident/Elements/ShowChildren b/html/RTIR/Incident/Elements/ShowChildren
index 6402c72..fe6b278 100644
--- a/html/RTIR/Incident/Elements/ShowChildren
+++ b/html/RTIR/Incident/Elements/ShowChildren
@@ -115,6 +115,7 @@ if ( $IncidentObj->CurrentUserHasRight('ModifyTicket') ) {
     # $QueueObj->Id and $QueueObj->CurrentUserHasRight('CreateTicket') ) {
         push @box_actions, {
             title => $Lifecycle ne RT::IR->lifecycle_investigation? loc('Create') : loc('Launch'),
+            class => 'create_child' . ($Lifecycle ? '_'.$Lifecycle : ''),
             path => RT::IR->HREFTo("Create.html?Incident=$id&Lifecycle=".$Lifecycle),
         };
     }
@@ -131,7 +132,7 @@ if ( $total_count > $Rows ) {
     };
 }
 my $box_actions = join ' 'x3,
-    map qq{<a href="}. $_->{'path'} .q{">}
+    map q{<a href="} . $_->{'path'} . ( $_->{'class'} ? q{" class="} . $_->{'class'} : '' ) . q{">}
         . $m->interp->apply_escapes( $_->{title}, 'h' ) . q{</a>},
     @box_actions;
 
diff --git a/html/RTIR/Investigation/Elements/Create b/html/RTIR/Investigation/Elements/Create
index 06f3da6..2d28013 100644
--- a/html/RTIR/Investigation/Elements/Create
+++ b/html/RTIR/Investigation/Elements/Create
@@ -46,6 +46,7 @@
 %#
 %# END BPS TAGGED BLOCK }}}
 <input type="hidden" name="<% $NamePrefix %>Status" value="<% $ARGS{ $NamePrefix .'Status' } || $QueueObj->LifecycleObj->DefaultOnCreate %>" />
+<input type="hidden" class="hidden" name="<% $NamePrefix %>Queue" value="<% $QueueObj->Id %>" />
 
 <div class="ticket-create-basics">
 <&| /Widgets/TitleBox, title => loc("Basics"), class => 'ticket-info-basics' &>
@@ -60,13 +61,7 @@
 <tr class="queue">
   <td class="label"><&|/l&>Queue</&>:</td>
   <td>
-      <& /RTIR/Elements/SelectRTIRQueue,
-                Name => $NamePrefix.'Queue',
-                Default => $ARGS{'Queue'} || $QueueObj->Id,
-                Lifecycle => RT::IR->lifecycle_investigation,
-                LimitToConstituency => ($m->{'RTIR_ConstituencyFilter'} || RT::IR->StrictConstituencyLinking ) ? 1:0,
-                Constituency => $Constituency
-    &>
+      <& /Ticket/Elements/ShowQueue, QueueObj => $QueueObj &>
   </td>
 </tr>
 % unless ( $SkipField{'Owner'} || $HideField{'Owner'} ) {
diff --git a/lib/RT/IR.pm b/lib/RT/IR.pm
index c03f5cf..29b3b5f 100644
--- a/lib/RT/IR.pm
+++ b/lib/RT/IR.pm
@@ -132,6 +132,7 @@ use Parse::BooleanLogic;
 my $ticket_sql_parser = Parse::BooleanLogic->new;
 
 RT->AddJavaScript('jquery.uncheckable-radio-0.1.js');
+RT->AddJavaScript('rtir.js');
 RT->AddStyleSheets( 'rtir-styles.css' );
 
 # Add the RTIR search result page to the whitelist to allow
diff --git a/static/js/rtir.js b/static/js/rtir.js
new file mode 100644
index 0000000..1baf9cf
--- /dev/null
+++ b/static/js/rtir.js
@@ -0,0 +1,62 @@
+jQuery(function() {
+    var showModal = function(html) {
+        jQuery("<div class='modal'></div>")
+            .append(html).appendTo("body")
+            .bind('modal:close', function(ev,modal) { modal.elm.remove(); })
+            .modal();
+    };
+
+    var getQueryString = function(element) {
+        var href = jQuery(element).attr('href');
+        if (!href) return '';
+        var questionMarkIndex = href.indexOf('?');
+        if (!questionMarkIndex) return '';
+        return href.substring(questionMarkIndex+1);
+    };
+
+    var showReportsModal = function(e) {
+        e.preventDefault();
+        var queryString = getQueryString(this);
+        jQuery.get(
+            RT.Config.WebHomePath + '/RTIR/Helpers/CreateInRTIRQueueModal?Lifecycle=incident_reports&LifecycleDesc=report&' + queryString,
+            showModal
+        );
+    };
+
+    var showInvestigationsModal = function(e) {
+        e.preventDefault();
+        var queryString = getQueryString(this);
+        jQuery.get(
+            RT.Config.WebHomePath + '/RTIR/Helpers/CreateInRTIRQueueModal?Lifecycle=investigations&LifecycleDesc=investigation&' + queryString,
+            showModal
+        );
+    };
+
+    var showBlocksModal = function(e) {
+        e.preventDefault();
+        var queryString = getQueryString(this);
+        jQuery.get(
+            RT.Config.WebHomePath + '/RTIR/Helpers/CreateInRTIRQueueModal?Lifecycle=blocks&LifecycleDesc=block&' + queryString,
+            showModal
+        );
+    };
+
+    var showIncidentsModal = function(e) {
+        e.preventDefault();
+        var queryString = getQueryString(this);
+        jQuery.get(
+            RT.Config.WebHomePath + '/RTIR/Helpers/CreateInRTIRQueueModalIncidents?' + queryString,
+            showModal
+        );
+    };
+
+    jQuery("#reports-create").click(showReportsModal);
+    jQuery("#investigations-launch").click(showInvestigationsModal);
+    jQuery("#blocks-create").click(showBlocksModal);
+    jQuery("#incidents-create").click(showIncidentsModal);
+    jQuery("#create-incident").click(showIncidentsModal);
+
+    jQuery(".create_child_incident_reports").click(showReportsModal);
+    jQuery(".create_child_investigations").click(showInvestigationsModal);
+    jQuery(".create_child_blocks").click(showBlocksModal);
+});

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the rt-commit mailing list