[Bps-public-commit] RT-Extension-QuickCalls branch allow-multiple-custom-quickcall-portlets-via-config created. 1.03-6-g2749b9e

BPS Git Server git at git.bestpractical.com
Thu Sep 28 21:46:07 UTC 2023


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "RT-Extension-QuickCalls".

The branch, allow-multiple-custom-quickcall-portlets-via-config has been created
        at  2749b9e6944185dabf73b0068476e973edb1fa1a (commit)

- Log -----------------------------------------------------------------
commit 2749b9e6944185dabf73b0068476e973edb1fa1a
Author: Brad Embree <brad at bestpractical.com>
Date:   Thu Sep 28 14:42:21 2023 -0700

    Add QuickCreate QuickCalls config option
    
    If QuickCreate is set then create the ticket immediately and refresh the
    page the QuickCalls portlet was on.

diff --git a/html/Helpers/QuickCalls b/html/Helpers/QuickCalls
index a56ca69..6834e6e 100644
--- a/html/Helpers/QuickCalls
+++ b/html/Helpers/QuickCalls
@@ -45,7 +45,23 @@
 %# those contributions and any derivatives thereof.
 %# 
 %# END BPS TAGGED BLOCK }}}
+% if ( $quick_create ) {
+<form id="quick-calls-quick-create-form" method="post" action="<% $quick_create_path %>">
+  <input type="hidden" class="hidden" name="QuickCreate" value="1" />
+% foreach my $key ( keys %$quick_create_values ) {
+  <input type="hidden" class="hidden" name="<% $key %>" value="<% $quick_create_values->{$key} %>" />
+% }
+</form>
+<script type="text/javascript">
+  window.self.onload = function() {
+    document.getElementById("quick-calls-quick-create-form").submit();
+  };
+</script>
+% }
 <%init>
+
+my ( $quick_create, $quick_create_path, $quick_create_values );
+
 if ($QuickCall) {
     my $custom = RT->Config->Get('QuickCallsPages');
     my $quickcalls;
@@ -64,12 +80,19 @@ if ($QuickCall) {
     delete $QuickCall->{SetOwnerToCurrentUser};
     delete $QuickCall->{Name};
 
+    $quick_create = delete $QuickCall->{QuickCreate};
+    $quick_create_path = $ARGS{QuickCallsPath};
+
     # Anon subrefs can be used to generate dynamic values
     $QuickCall->{$_} = $QuickCall->{$_}->()
         for grep {ref $QuickCall->{$_} eq "CODE"} keys %{$QuickCall};
 
-    my $query = $m->comp( '/Elements/QueryString', %$QuickCall);
-    RT::Interface::Web::Redirect($RT::WebURL."Ticket/Create.html?$query");
+    if ( $quick_create ) {
+        $quick_create_values = { %$QuickCall };
+    } else {
+        my $query = $m->comp( '/Elements/QueryString', %$QuickCall);
+        RT::Interface::Web::Redirect($RT::WebURL."Ticket/Create.html?$query");
+    }
 }
 </%init>
 <%args>

commit c6d687f4773a20d88f8f8e28e351692d3ece31de
Author: Brad Embree <brad at bestpractical.com>
Date:   Thu Sep 28 14:31:44 2023 -0700

    Add QuickCallsPath hidden input for quick create
    
    /Helpers/QuickCalls needs the path the QuickCalls portlet is on for the
    new quick create option so it can reload the page after the ticket is
    created.

diff --git a/html/Elements/QuickCalls b/html/Elements/QuickCalls
index 62b6a21..9a0f413 100644
--- a/html/Elements/QuickCalls
+++ b/html/Elements/QuickCalls
@@ -56,6 +56,7 @@
 % if ( $page ) {
     <input type="hidden" class="hidden" name="QuickCallsPage" value="<% $page %>">
 % }
+    <input type="hidden" class="hidden" name="QuickCallsPath" value="<%RT->Config->Get('WebPath')%><% $r->path_info %>">
     <select name="QuickCall" class="selectpicker form-control">
 %     foreach my $QuickCall (@$quickcalls) {
       <option value="<%$QuickCall->{Name}%>"><%$QuickCall->{Name}%>

commit 5b414e7a1b0f447bde083301d3b7aafffdb8212a
Author: Brad Embree <brad at bestpractical.com>
Date:   Thu Sep 28 14:41:19 2023 -0700

    Check for QuickCallsPage arg for custom QuickCalls config
    
    If passed a QuickCallsPage argument use the config from the
    QuickCallsPages config.

diff --git a/html/Helpers/QuickCalls b/html/Helpers/QuickCalls
index f15f6c4..a56ca69 100644
--- a/html/Helpers/QuickCalls
+++ b/html/Helpers/QuickCalls
@@ -47,7 +47,16 @@
 %# END BPS TAGGED BLOCK }}}
 <%init>
 if ($QuickCall) {
-    my ($QuickCall) = grep { $_->{Name} eq $QuickCall} @{$RT::QuickCalls||[]};
+    my $custom = RT->Config->Get('QuickCallsPages');
+    my $quickcalls;
+    my $page;
+    if ( $page = $ARGS{QuickCallsPage} ) {
+        $quickcalls = $custom->{$page} || [];
+    }
+    else {
+        $quickcalls = $RT::QuickCalls || [];
+    }
+    my ( $QuickCall ) = grep { $_->{Name} eq $QuickCall } @$quickcalls;
     # copy so we don't nuke the config variable
     $QuickCall = { map { $_ => $QuickCall->{$_} } keys %$QuickCall };
     $QuickCall->{Subject} ||= $QuickCall->{Name};

commit a30575bf406a7afef065336969d42075166b7ee3
Author: Brad Embree <brad at bestpractical.com>
Date:   Thu Sep 28 08:54:46 2023 -0700

    Check for QuickCallsPage argument to show custom portlet
    
    Check if passed a QuickCallsPage argument and if so show actions for
    that Page from the new QuickCallsPages config option.
    
    If not passed a QuickCallsPage argument behave as before and show
    actions from the QuickCalls config option.

diff --git a/html/Elements/QuickCalls b/html/Elements/QuickCalls
index 6ed493a..62b6a21 100644
--- a/html/Elements/QuickCalls
+++ b/html/Elements/QuickCalls
@@ -48,13 +48,16 @@
 
 % if ( RT::Handle::cmp_version($RT::VERSION, '5.0.0') >= 0 ) {
 % # RT 5 version
-<&| /Widgets/TitleBox, title => loc('Quick Calls') &>
+<&| /Widgets/TitleBox, title => $title &>
 <div class="form-row">
   <div class="col-auto">
     <form method="post"
           action="<%$RT::WebPath%>/Helpers/QuickCalls">
+% if ( $page ) {
+    <input type="hidden" class="hidden" name="QuickCallsPage" value="<% $page %>">
+% }
     <select name="QuickCall" class="selectpicker form-control">
-%     foreach my $QuickCall (@{$RT::QuickCalls||[]}) {
+%     foreach my $QuickCall (@$quickcalls) {
       <option value="<%$QuickCall->{Name}%>"><%$QuickCall->{Name}%>
 %     }
     </select>
@@ -71,7 +74,7 @@
 <&| /Widgets/TitleBox, title => loc('Quick Calls') &>
 <form action="<%$RT::WebPath%>/Helpers/QuickCalls">
 <select name="QuickCall">
-% foreach my $QuickCall (@{$RT::QuickCalls||[]}) {
+% foreach my $QuickCall (@$quickcalls) {
     <option value="<%$QuickCall->{Name}%>"><%$QuickCall->{Name}%>
 % }
 </select>
@@ -79,3 +82,17 @@
 </form>
 </&>
 % }
+<%INIT>
+my $title = loc('Quick Calls');
+my $custom = RT->Config->Get('QuickCallsPages');
+my $quickcalls;
+my $page;
+if ( $page = $ARGS{QuickCallsPage} ) {
+  $quickcalls = $custom->{$page} || [];
+  $title .= " - $page";
+}
+else {
+  $quickcalls = $RT::QuickCalls || [];
+}
+
+</%INIT>

commit c5b87ffb0cde282acd6a005566465f8c3e7f8d6c
Author: Brad Embree <brad at bestpractical.com>
Date:   Thu Sep 28 08:52:19 2023 -0700

    Dynamically create custom portlets based on config
    
    Add a new config QuickCallsPages that lets users configure multiple
    custom QuickCalls portlets with different actions on each one.
    
    This lets users group actions together and create different portlets for
    different users/groups.

diff --git a/lib/RT/Extension/QuickCalls.pm b/lib/RT/Extension/QuickCalls.pm
index a0740d7..37c95f7 100644
--- a/lib/RT/Extension/QuickCalls.pm
+++ b/lib/RT/Extension/QuickCalls.pm
@@ -2,8 +2,37 @@ package RT::Extension::QuickCalls;
 use warnings;
 use strict;
 
+require File::Spec;
+require Cwd;
+
 our $VERSION = '1.03';
 
+my $path = Cwd::abs_path(__FILE__);
+$path =~ s{lib/RT/Extension/QuickCalls.pm$}{};
+$path = File::Spec->catfile( $path, 'html', 'Elements' );
+
+my $HomepageComponents = RT->Config->Get('HomepageComponents');
+my $custom = RT->Config->Get('QuickCallsPages') || {};
+foreach my $page ( keys %$custom ) {
+    # the component name cannot have special characters
+    my $component = $page;
+    $component =~ s/ /_/g;
+    $component =~ s/'|"|//g;
+
+    # the page name needs to map to the entry in the config but must escape single quotes
+    $page =~ s/'/\\'/g;
+
+    push @$HomepageComponents, "QuickCalls-$component";
+
+    my $filename = File::Spec->catfile( $path, "QuickCalls-$component" );
+    my $content = '% $m->comp( \'/Elements/QuickCalls\', QuickCallsPage => \'' . $page . '\' );' . "\n";
+    open my $fh, '>', $filename
+        or RT->Logger->error("Could not open file '$filename' to write custom portlet: $!");
+    print $fh $content;
+    close $fh;
+}
+RT->Config->Set( 'HomepageComponents', $HomepageComponents );
+
 =head1 NAME
 
 RT::Extension::QuickCalls - Quickly create tickets in specific queues with default values

commit 072844b133979544bb5e53f1224fdf2dabddcabb
Author: Brad Embree <brad at bestpractical.com>
Date:   Thu Sep 28 08:50:58 2023 -0700

    Delete unnecessary file

diff --git a/html/Elements/.#QuickCalls b/html/Elements/.#QuickCalls
deleted file mode 120000
index b0228d0..0000000
--- a/html/Elements/.#QuickCalls
+++ /dev/null
@@ -1 +0,0 @@
-chmrr at umgah.localdomain.14071:1403105031
\ No newline at end of file

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


hooks/post-receive
-- 
RT-Extension-QuickCalls


More information about the Bps-public-commit mailing list