[Rt-commit] rtir branch, 3.4/popup-ticket-create, updated. 3.3.0-92-gb6d2022

Dustin Graves dustin at bestpractical.com
Mon May 23 19:02:54 EDT 2016


The branch, 3.4/popup-ticket-create has been updated
       via  b6d20227e3f20e84f84e347466068786d8acd6a4 (commit)
      from  8eaa52b4b4b507822f77bf54ff0eb3ad1c65733d (commit)

Summary of changes:
 html/Callbacks/RTIR/Elements/MakeClicky/Default    |  6 ++---
 .../RTIR/Elements/RT__Ticket/ColumnMap/Once        |  4 ++--
 html/Callbacks/RTIR/Elements/Tabs/Privileged       | 14 +++++------
 .../CreateInRTIRQueueModal => CreateInQueue.html}  | 18 +++++++++++++-
 html/RTIR/Elements/CreateInRTIRQueueModal          | 10 +++++---
 html/RTIR/Elements/ShowIncidents                   |  2 +-
 html/RTIR/Incident/Elements/ShowChildren           |  2 +-
 html/RTIR/Tools/Elements/LookupSummary             | 11 +++++----
 static/js/rtir.js                                  | 28 +++++++++++-----------
 9 files changed, 59 insertions(+), 36 deletions(-)
 copy html/RTIR/{Helpers/CreateInRTIRQueueModal => CreateInQueue.html} (81%)

- Log -----------------------------------------------------------------
commit b6d20227e3f20e84f84e347466068786d8acd6a4
Author: Dustin Graves <dustin at bestpractical.com>
Date:   Mon May 23 23:00:04 2016 +0000

    add js fallback ticket create page CreateInQueue
    
    this also fixes certain create conditions that were missing modal
    functionality

diff --git a/html/Callbacks/RTIR/Elements/MakeClicky/Default b/html/Callbacks/RTIR/Elements/MakeClicky/Default
index daf9553..760d5f8 100644
--- a/html/Callbacks/RTIR/Elements/MakeClicky/Default
+++ b/html/Callbacks/RTIR/Elements/MakeClicky/Default
@@ -105,8 +105,8 @@ my %actions;
         my $result .= qq{<a class="button" href="}. RT::IR->HREFTo("Tools/Lookup.html?".$args{lookup_params}."type=ip&q=".$escaped_host).qq{">}
                       .loc('Lookup IP') .q{</a>};
         if ( $args{incident} && !RT->Config->Get('RTIR_DisableBlocksQueue') ) {
-            $result .= qq{<a class="button" href="} .
-            RT::IR->HREFTo("Create.html?Incident=".$args{incident}."&Lifecycle=".RT::IR->lifecycle_countermeasure.qq{&IP-Value=$escaped_host})
+            $result .= qq{<a class="button create_child_blocks" href="} .
+            RT::IR->HREFTo("CreateInQueue.html?Incident=".$args{incident}."&Lifecycle=".RT::IR->lifecycle_countermeasure.qq{&IP-Value=$escaped_host})
             .qq{">block</a>};
         }
         if ( $args{'object'} && $args{'object'}->id ) {
@@ -156,7 +156,7 @@ my %actions;
                 $result .= qq{<input type="checkbox" name="Requestorbox-$escaped_email" unchecked />};
             }
             $result .= qq{<a class="button" href="}.
-                RT::IR->HREFTo( "Create.html"
+                RT::IR->HREFTo( "CreateInQueue.html"
                 . qq{?Incident=$args{'incident'}}
                 . qq{&Lifecycle=}.RT::IR->lifecycle_investigation
                 . "&Requestors=$escaped_email")
diff --git a/html/Callbacks/RTIR/Elements/RT__Ticket/ColumnMap/Once b/html/Callbacks/RTIR/Elements/RT__Ticket/ColumnMap/Once
index 06aab26..0cef225 100644
--- a/html/Callbacks/RTIR/Elements/RT__Ticket/ColumnMap/Once
+++ b/html/Callbacks/RTIR/Elements/RT__Ticket/ColumnMap/Once
@@ -153,9 +153,9 @@ $COLUMN_MAP->{'LookupToolIncidentActions'} = {
             ;
         }
         push @res, \'<a href="',
-            RT::IR->HREFTo('Create.html?Lifecycle='.RT::IR->lifecycle_investigation
+            RT::IR->HREFTo('CreateInQueue.html?Lifecycle='.RT::IR->lifecycle_investigation
             .'&Incident='. $t->id),
-            \'">',
+            \'" class="create_child_blocks">',
             '[' . $t->loc("Investigate") .']',
             \'</a>'
         ;
diff --git a/html/Callbacks/RTIR/Elements/Tabs/Privileged b/html/Callbacks/RTIR/Elements/Tabs/Privileged
index a8fa11e..24c99a1 100644
--- a/html/Callbacks/RTIR/Elements/Tabs/Privileged
+++ b/html/Callbacks/RTIR/Elements/Tabs/Privileged
@@ -110,21 +110,21 @@ $root->child(
     path => RT::IR->HREFTo('Search/Results.html?Lifecycle='.RT::IR->lifecycle_incident, IncludeWebPath => 0)
 )->child(
     create => title => loc('Create'),
-    path => RT::IR->HREFTo('Create.html?Lifecycle='.RT::IR->lifecycle_incident, IncludeWebPath => 0),
+    path => RT::IR->HREFTo('CreateInQueue.html?Lifecycle='.RT::IR->lifecycle_incident, IncludeWebPath => 0),
 );
 $root->child(
     reports => title => loc('Reports'),
     path => RT::IR->HREFTo('Search/Results.html?Lifecycle='. RT::IR->lifecycle_report, IncludeWebPath => 0)
 )->child(
     create => title => loc('Create'),
-    path => RT::IR->HREFTo('Create.html?Lifecycle='. RT::IR->lifecycle_report, IncludeWebPath => 0),
+    path => RT::IR->HREFTo('CreateInQueue.html?Lifecycle='. RT::IR->lifecycle_report, IncludeWebPath => 0),
 );
 $root->child(
     investigations => title => loc('Investigations'),
     path => RT::IR->HREFTo('Search/Results.html?Lifecycle='.RT::IR->lifecycle_investigation, IncludeWebPath => 0)
 )->child(
     launch => title => loc('Launch'),
-    path => RT::IR->HREFTo('Create.html?Lifecycle='.RT::IR->lifecycle_investigation, IncludeWebPath => 0),
+    path => RT::IR->HREFTo('CreateInQueue.html?Lifecycle='.RT::IR->lifecycle_investigation, IncludeWebPath => 0),
 );
 unless ( RT->Config->Get('RTIR_DisableBlocksQueue') ) {
     $root->child(
@@ -132,7 +132,7 @@ unless ( RT->Config->Get('RTIR_DisableBlocksQueue') ) {
         path => RT::IR->HREFTo('Search/Results.html?Lifecycle='.RT::IR->lifecycle_countermeasure, IncludeWebPath => 0)
     )->child(
         create => title => loc('Create'),
-        path => RT::IR->HREFTo('Create.html?Lifecycle='.RT::IR->lifecycle_countermeasure, IncludeWebPath => 0),
+        path => RT::IR->HREFTo('CreateInQueue.html?Lifecycle='.RT::IR->lifecycle_countermeasure, IncludeWebPath => 0),
     );
 }
 
@@ -348,8 +348,8 @@ if ( $request_path =~ m{(?:$re_rtir_path)(?:$re_rtir_types/)?(Display|Edit|Updat
     PageMenu()->child(
         new => title => loc("New [_1]", RT::IR::TicketType( Lifecycle => $lifecycle || RT::IR->lifecycle_incident ) ),
         path => !$lifecycle
-            ? RT::IR->HREFTo("Create.html?Child=$id&Lifecycle=".RT::IR->lifecycle_incident, IncludeWebPath => 0)
-            : RT::IR->HREFTo("Create.html?". $query_string->( Incident => $id, Lifecycle => $lifecycle ), IncludeWebPath => 0)
+            ? RT::IR->HREFTo("CreateInQueue.html?Child=$id&Lifecycle=".RT::IR->lifecycle_incident, IncludeWebPath => 0)
+            : RT::IR->HREFTo("CreateInQueue.html?". $query_string->( Incident => $id, Lifecycle => $lifecycle ), IncludeWebPath => 0)
         ,
     );
     PageMenu()->child(
@@ -370,7 +370,7 @@ if ( $request_path =~ m{(?:$re_rtir_path)(?:$re_rtir_types/)?(Display|Edit|Updat
 
     PageMenu()->child(
         new => title => loc("New [_1]",RT::IR::TicketType( Lifecycle => $lifecycle ) ),
-        path => RT::IR->HREFTo("Create.html?". $query_string->( Incident => $id, Lifecycle => $lifecycle ), IncludeWebPath => 0),
+        path => RT::IR->HREFTo("CreateInQueue.html?". $query_string->( Incident => $id, Lifecycle => $lifecycle ), IncludeWebPath => 0),
     );
     PageMenu()->child(
         back => title => loc('Back to [_1] #[_2]', lc RT::IR::TicketType( Lifecycle => $ticket->QueueObj->Lifecycle), $id),
diff --git a/html/RTIR/Elements/CreateInRTIRQueueModal b/html/RTIR/CreateInQueue.html
similarity index 57%
copy from html/RTIR/Elements/CreateInRTIRQueueModal
copy to html/RTIR/CreateInQueue.html
index 7c7a9c2..e79f746 100644
--- a/html/RTIR/Elements/CreateInRTIRQueueModal
+++ b/html/RTIR/CreateInQueue.html
@@ -45,54 +45,21 @@
 %# those contributions and any derivatives thereof.
 %#
 %# END BPS TAGGED BLOCK }}}
-<form action="<% RT::IR->HREFTo('Create.html') %>" id="CreateInQueue">
-% if ($Incident) {
-<input type="hidden" name="Incident" value="<%$Incident%>"/>
-% }
-% if ($Child) {
-<input type="hidden" name="Child" value="<%$Child%>"/>
-% }
-  <&|/l_unsafe, $LifecycleDesc,
-      $m->scomp('/RTIR/Elements/SelectRTIRQueue',
-        Name => 'Queue',
-        Lifecycle => $Lifecycle,
-        ShowNullOption => 0,
-        LimitToConstituency => $limit_to_constituency,
-        Constituency => $m->{'RTIR_ConstituencyFilter'} || $linked_constituency)
+<& /RTIR/Elements/Header,
+    Title => $title,
+&>
+<& /Elements/Tabs &>
 
-    &>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>
-<%INIT>
-$Lifecycle = $Lifecycle->[0] if (ref $Lifecycle eq 'ARRAY');
-
-my ($linked_ticket, $linked_constituency);
-
-if ($Incident) {
-    $linked_ticket = RT::Ticket->new( $session{CurrentUser} );
-    $linked_ticket->Load($Incident);
-}
+<& /RTIR/Elements/CreateInRTIRQueueModal, %ARGS &>
 
-if ($Child) {
-    $linked_ticket = RT::Ticket->new( $session{CurrentUser} );
-    $linked_ticket->Load($Child);
-}
-
-if ($linked_ticket && $linked_ticket->id) {
-    $linked_constituency = RT::IR->ConstituencyFor($linked_ticket);
-}
+<%INIT>
+my $lifecycle_desc = $Lifecycle eq 'incidents'        ? 'Incident'        :
+                     $Lifecycle eq 'incident_reports' ? 'Incident Report' :
+                     $Lifecycle eq 'blocks'           ? 'Block'           :
+                     $Lifecycle eq 'investigations'   ? 'Investigation'   : '';
 
-my $limit_to_constituency =
-    # Limit no matter what if we have a filter
-    $m->{'RTIR_ConstituencyFilter'} ||
-    # Also limit if we have a linked constituency and StrictConstituencyLinking is set
-    (RT::IR->StrictConstituencyLinking && $linked_constituency)
-    ? 1:0;
+my $title = "Select Queue for New $lifecycle_desc";
 </%INIT>
 <%ARGS>
 $Lifecycle
-$LifecycleDesc => $Lifecycle
-$Incident => undef
-$Child => undef
 </%ARGS>
-
diff --git a/html/RTIR/Elements/CreateInRTIRQueueModal b/html/RTIR/Elements/CreateInRTIRQueueModal
index 7c7a9c2..764b953 100644
--- a/html/RTIR/Elements/CreateInRTIRQueueModal
+++ b/html/RTIR/Elements/CreateInRTIRQueueModal
@@ -52,7 +52,7 @@
 % if ($Child) {
 <input type="hidden" name="Child" value="<%$Child%>"/>
 % }
-  <&|/l_unsafe, $LifecycleDesc,
+  <&|/l_unsafe, $lifecycle_desc,
       $m->scomp('/RTIR/Elements/SelectRTIRQueue',
         Name => 'Queue',
         Lifecycle => $Lifecycle,
@@ -61,7 +61,7 @@
         Constituency => $m->{'RTIR_ConstituencyFilter'} || $linked_constituency)
 
     &>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) &>
+  <& /Elements/Submit, Label => loc("Go"), Caption => loc("This will take you to a partially prefilled [_1] creation form.", $lifecycle_desc) &>
 </form>
 <%INIT>
 $Lifecycle = $Lifecycle->[0] if (ref $Lifecycle eq 'ARRAY');
@@ -88,10 +88,14 @@ my $limit_to_constituency =
     # Also limit if we have a linked constituency and StrictConstituencyLinking is set
     (RT::IR->StrictConstituencyLinking && $linked_constituency)
     ? 1:0;
+
+my $lifecycle_desc = $Lifecycle eq 'incidents'        ? 'incident'        :
+                     $Lifecycle eq 'incident_reports' ? 'incident report' :
+                     $Lifecycle eq 'blocks'           ? 'block'           :
+                     $Lifecycle eq 'investigations'   ? 'investigation'   : '';
 </%INIT>
 <%ARGS>
 $Lifecycle
-$LifecycleDesc => $Lifecycle
 $Incident => undef
 $Child => undef
 </%ARGS>
diff --git a/html/RTIR/Elements/ShowIncidents b/html/RTIR/Elements/ShowIncidents
index dffb5a5..0ff6b86 100644
--- a/html/RTIR/Elements/ShowIncidents
+++ b/html/RTIR/Elements/ShowIncidents
@@ -58,7 +58,7 @@
 <div class="actions">
 % unless ( $action ) {
 <a class="button" id="link-incident" href="<% RT::IR->HREFTo('Link/ToIncident/?id='. $id ) %>">Link</a>
-<a class="button" id="create-incident" href="<% RT::IR->HREFTo('Incident/Create.html?Child='. $id ) %>">New</a>
+<a class="button" id="create-incident" href="<% RT::IR->HREFTo('Incident/CreateInQueue.html?Child='. $id ) %>">New</a>
 % } elsif ( $action ne 'No' ) {
 <a class="button" href="<% RT::IR->HREFTo('Display.html?Action='. $action.'&id='. $id) %>"><% loc( $action ) %></a>
 % }
diff --git a/html/RTIR/Incident/Elements/ShowChildren b/html/RTIR/Incident/Elements/ShowChildren
index fe6b278..681655e 100644
--- a/html/RTIR/Incident/Elements/ShowChildren
+++ b/html/RTIR/Incident/Elements/ShowChildren
@@ -116,7 +116,7 @@ if ( $IncidentObj->CurrentUserHasRight('ModifyTicket') ) {
         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),
+            path => RT::IR->HREFTo("CreateInQueue.html?Incident=$id&Lifecycle=".$Lifecycle),
         };
     }
     push @box_actions, {
diff --git a/html/RTIR/Tools/Elements/LookupSummary b/html/RTIR/Tools/Elements/LookupSummary
index 36a3418..88f4db4 100644
--- a/html/RTIR/Tools/Elements/LookupSummary
+++ b/html/RTIR/Tools/Elements/LookupSummary
@@ -109,7 +109,8 @@ if ( $TicketObj && RT::IR->IsIncidentQueue($TicketObj->QueueObj)
     if ($Lifecycle eq RT::IR->lifecycle_investigation && $LookupType eq 'email') {
         push @box_actions, {
             title => loc('Launch'),
-            path => RT::IR->HREFTo("Create.html?". $m->comp('/Elements/QueryString',
+            class => 'create_child' . ($Lifecycle ? '_'.$Lifecycle : ''),
+            path => RT::IR->HREFTo("CreateInQueue.html?". $m->comp('/Elements/QueryString',
                 Incident => $TicketObj->id,
                 Lifecycle => $Lifecycle,
                 Requestors => $q,
@@ -118,7 +119,8 @@ if ( $TicketObj && RT::IR->IsIncidentQueue($TicketObj->QueueObj)
     } elsif ( $Lifecycle eq RT::IR->lifecycle_countermeasure && $LookupType eq 'ip' && !RT->Config->Get('RTIR_DisableBlocksQueue') ) {
         push @box_actions, {
             title => loc('Create'),
-            path => RT::IR->HREFTo("Create.html?". $m->comp('/Elements/QueryString',
+            class => 'create_child' . ($Lifecycle ? '_'.$Lifecycle : ''),
+            path => RT::IR->HREFTo("CreateInQueue.html?". $m->comp('/Elements/QueryString',
                 Incident => $TicketObj->id,
                 Lifecycle => $Lifecycle,
                 'IP-Value' => $q,
@@ -131,14 +133,15 @@ elsif ( $TicketObj && !RT::IR->IsIncidentQueue($TicketObj->QueueObj)
 ) {
     push @box_actions, {
         title => loc('Create'),
-        path => RT::IR->HREFTo("Create.html?". $m->comp('/Elements/QueryString',
+        class => 'create_child' . ($Lifecycle ? '_'.$Lifecycle : ''),
+        path => RT::IR->HREFTo("CreateInQueue.html?". $m->comp('/Elements/QueryString',
             Child => $TicketObj->id,
             Lifecycle => $Lifecycle
         )),
     };
 }
 my $box_actions = join ' 'x3,
-    map qq{<a href="}.  $_->{'path'} .q{">}
+    map qq{<a href="} . $_->{'path'} . q{"} . ( $_->{'class'} ? q{ class="} . $_->{'class'} . q{"} : '' ) . '>'
         . $m->interp->apply_escapes( $_->{title}, 'h' ) . q{</a>},
     @box_actions;
 
diff --git a/static/js/rtir.js b/static/js/rtir.js
index 9bb4fe7..c88f4c2 100644
--- a/static/js/rtir.js
+++ b/static/js/rtir.js
@@ -7,7 +7,7 @@ jQuery(function() {
         return href.substring(questionMarkIndex+1);
     };
 
-    var showModal = function(lifecycle, lifecycleDesc, triggeringObject) {
+    var showModal = function(lifecycle, triggeringObject) {
         var queryString = getQueryString(triggeringObject);
         var constituency = '';
 
@@ -20,7 +20,7 @@ jQuery(function() {
         }
 
         jQuery.get(
-            RT.Config.WebHomePath + '/RTIR' + constituency + '/Helpers/CreateInRTIRQueueModal?Lifecycle=' + lifecycle + '&LifecycleDesc=' + lifecycleDesc + '&' + queryString,
+            RT.Config.WebHomePath + '/RTIR' + constituency + '/Helpers/CreateInRTIRQueueModal?Lifecycle=' + lifecycle + '&' + queryString,
             function(html) {
                 // If there's only one queue, just create a ticket in it and skip the modal
                 var queues = jQuery(html).find("select[name='Queue'] > option");
@@ -39,31 +39,31 @@ jQuery(function() {
 
     var showReportsModal = function(e) {
         e.preventDefault();
-        showModal('incident_reports', 'report', this);
+        showModal('incident_reports', this);
     };
 
     var showInvestigationsModal = function(e) {
         e.preventDefault();
-        showModal('investigations', 'investigation', this);
+        showModal('investigations', this);
     };
 
     var showBlocksModal = function(e) {
         e.preventDefault();
-        showModal('blocks', 'block', this);
+        showModal('blocks', this);
     };
 
     var showIncidentsModal = function(e) {
         e.preventDefault();
-        showModal('incidents', 'incident', this);
+        showModal('incidents', this);
     };
 
-    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('body').on('click', '#reports-create', showReportsModal);
+    jQuery('body').on('click', '#investigations-launch', showInvestigationsModal);
+    jQuery('body').on('click', '#blocks-create', showBlocksModal);
+    jQuery('body').on('click', '#incidents-create', showIncidentsModal);
+    jQuery('body').on('click', '#create-incident', showIncidentsModal);
 
-    jQuery(".create_child_incident_reports").click(showReportsModal);
-    jQuery(".create_child_investigations").click(showInvestigationsModal);
-    jQuery(".create_child_blocks").click(showBlocksModal);
+    jQuery('body').on('click', '.create_child_incident_reports', showReportsModal);
+    jQuery('body').on('click', '.create_child_investigations', showInvestigationsModal);
+    jQuery('body').on('click', '.create_child_blocks', showBlocksModal);
 });

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


More information about the rt-commit mailing list