[Rt-commit] rt branch, 4.4/include-article-queue, created. rt-4.4.2-69-g0906f983a

Craig Kaiser craig at bestpractical.com
Wed Jan 31 13:57:12 EST 2018


The branch, 4.4/include-article-queue has been created
        at  0906f983a89cd49048d5d59ed96591882fc631be (commit)

- Log -----------------------------------------------------------------
commit 5aaa240d5222220569eb6876acbe7d54565ecc45
Author: Shawn M Moore <shawn at bestpractical.com>
Date:   Fri Aug 18 17:47:41 2017 +0000

    Avoid spuriously unchecking all recipient checkboxes
    
    This 4.4.2 regression, introduced in
    f0a7105da8bc8f00a54bcdb5bfd48d788bbb888b and
    4b11cf37360ad5084f6428c62553ccc6858313a7, could happen if you caused a
    second refresh while the first one was still running. serializeArray()
    doesn't include disabled form fields, so what the AJAX request reported
    to the server made it look like the user had explicitly unchecked
    recipients.
    
    Fixes: I#33027

diff --git a/share/html/Ticket/Update.html b/share/html/Ticket/Update.html
index 075940306..8b4ba94c2 100644
--- a/share/html/Ticket/Update.html
+++ b/share/html/Ticket/Update.html
@@ -217,8 +217,18 @@ jQuery( function() {
        jQuery('#recipients div.titlebox-content').addClass('refreshing');
        jQuery('#previewscrips div.titlebox-content').addClass('refreshing');
 
+       /* temporarily re-enable the checkboxes so they will be included in
+          payload */
+       jQuery("#recipients input[name=TxnSendMailToAll], #recipients input[name=TxnSendMailTo]").attr('disabled', false);
+       jQuery("#previewscrips input[name=TxnSendMailToAll], #previewscrips input[name=TxnSendMailTo]").attr('disabled', false);
+
+       var payload = jQuery('form[name=TicketUpdate]').serializeArray();
+
+       jQuery("#recipients input[name=TxnSendMailToAll], #recipients input[name=TxnSendMailTo]").attr('disabled', true);
+       jQuery("#previewscrips input[name=TxnSendMailToAll], #previewscrips input[name=TxnSendMailTo]").attr('disabled', true);
+
        jQuery('#recipients div.titlebox-content').load( '<% RT->Config->Get('WebPath')%>/Helpers/ShowSimplifiedRecipients',
-           jQuery('form[name=TicketUpdate]').serializeArray(),
+           payload,
            function() {
                jQuery('#recipients div.titlebox-content').removeClass('refreshing');
                var txn_send_field = jQuery("#recipients input[name=TxnSendMailTo]");
@@ -232,7 +242,7 @@ jQuery( function() {
        );
 
        jQuery('#previewscrips div.titlebox-content').load( '<% RT->Config->Get('WebPath')%>/Helpers/PreviewScrips',
-           jQuery('form[name=TicketUpdate]').serializeArray(),
+           payload,
            function() {
                jQuery('#previewscrips div.titlebox-content').removeClass('refreshing');
                var txn_send_field = jQuery("#previewscrips input[name=TxnSendMailTo]");
@@ -244,9 +254,6 @@ jQuery( function() {
                }
            }
        );
-
-       jQuery("#recipients input[name=TxnSendMailToAll], #recipients input[name=TxnSendMailTo]").attr('disabled', true);
-       jQuery("#previewscrips input[name=TxnSendMailToAll], #previewscrips input[name=TxnSendMailTo]").attr('disabled', true);
    };
    updateScrips();
 

commit 51731a684c9fc2d7ab94d6eb47b5d72210cedea7
Author: Maureen E. Mirville <maureen at bestpractical.com>
Date:   Tue Jan 23 14:03:58 2018 -0500

    Make RT owner dropdown limit a config option
    
    The Owner dropdown menu, used in various places in RT, automatically
    changes from a dropdown menu to an autocomplete field once there are
    greater than 50 values. As some users may want to change this limit,
    a new config option was added so it can easily be updated, rather
    than using a callback. Existing callbacks on this limit will continue
    to work as expected.

diff --git a/etc/RT_Config.pm.in b/etc/RT_Config.pm.in
index 48fd0fe52..4ef8f0979 100644
--- a/etc/RT_Config.pm.in
+++ b/etc/RT_Config.pm.in
@@ -1575,8 +1575,11 @@ builder are replaced by text fields that autocomplete.  This can
 alleviate the sometimes huge owner list for installations where many
 users have the OwnTicket right.
 
-Autocompleter is automatically turned on if list contains more than
-50 users, but penalty of executing potentially slow query is still paid.
+The Owner entry is automatically converted to an autocomplete box if the list
+of owners exceeds C<$DropdownMenuLimit> items. However, the query to generate
+the list of owners is still run and this can increase page load times. If
+your owner lists exceed the limit and you are using the autocomplete box, you
+can improve performance by explicitly setting C<$AutocompleteOwners>.
 
 Drop down doesn't show unprivileged users. If your setup allows unprivileged
 to own ticket then you have to enable autocompleting.
@@ -1585,6 +1588,22 @@ to own ticket then you have to enable autocompleting.
 
 Set($AutocompleteOwners, 0);
 
+=item C<$DropdownMenuLimit>
+
+The Owner dropdown menu, used in various places in RT including the Query
+Builder and ticket edit pages, automatically changes from a dropdown menu to
+an autocomplete field once the menu holds more than the C<$DropdownMenuLimit>
+owners. Dropdown menus become more difficult to use when they contain a large
+number of values and the autocomplete textbox can be more usable.
+
+If you have very large numbers of users who can be owners, this can cause
+slow page loads on pages with an Owner selection. See L</$AutocompleteOwners>
+for a way to potentially speed up page loads.
+
+=cut
+
+Set($DropdownMenuLimit, 50);
+
 =item C<$AutocompleteOwnersForSearch>
 
 If set to 1, the owner drop-downs for the query builder are always
diff --git a/share/html/Elements/SelectOwnerDropdown b/share/html/Elements/SelectOwnerDropdown
index 57f364125..a20a7c343 100644
--- a/share/html/Elements/SelectOwnerDropdown
+++ b/share/html/Elements/SelectOwnerDropdown
@@ -79,7 +79,7 @@ foreach my $object (@$Objects) {
     }
 }
 
-my $dropdown_limit = 50;
+my $dropdown_limit = RT->Config->Get( 'DropdownMenuLimit' ) || 50;
 $m->callback( CallbackName => 'ModifyDropdownLimit', DropdownLimit => \$dropdown_limit );
 
 if (keys(%user_uniq_hash) > $dropdown_limit ) {

commit 4c5a93ceaf4dd589f89253a4558722b2e73e3390
Author: Craig Kaiser <craig at bestpractical.com>
Date:   Wed Jan 31 10:46:02 2018 -0500

    Add Default Article option for Queues
    
    Currently there is not a simple way to apply boilerplate text to
    tickets automatically on initial create. By selecting a Default Article for a Queue, any
    ticket created in that Queue will automatically have the Article content
    added to the Ticket create page message box.

diff --git a/lib/RT/Queue.pm b/lib/RT/Queue.pm
index 4c2f5fb62..574ba16f3 100644
--- a/lib/RT/Queue.pm
+++ b/lib/RT/Queue.pm
@@ -155,6 +155,7 @@ sub Create {
         CorrespondAddress => '',
         CommentAddress    => '',
         Lifecycle         => 'default',
+        QueueDefaultArticle    => undef,
         SubjectTag        => undef,
         Sign              => undef,
         SignAuto          => undef,
@@ -199,7 +200,7 @@ sub Create {
     }
     $RT::Handle->Commit;
 
-    for my $attr (qw/Sign SignAuto Encrypt SLA/) {
+    for my $attr (qw/Sign SignAuto Encrypt SLA QueueDefaultArticle/) {
         next unless defined $args{$attr};
         my $set = "Set" . $attr;
         my ($status, $msg) = $self->$set( $args{$attr} );
@@ -212,7 +213,48 @@ sub Create {
     return ( $id, $self->loc("Queue created") );
 }
 
+=head2 QueueDefaultArticle
 
+Returns ID for Default Article for Queue.
+
+=cut
+
+sub QueueDefaultArticle {
+    my $self = shift;
+
+    my $attr = $self->FirstAttribute('QueueDefaultArticle') ;
+    my $content = $attr ? $attr->Content : undef;
+    return $content;
+ }
+
+=head2 SetQueueDefaultArticle
+
+Takes ID value for Article and sets Queue attribute QueueDefaultArticle to that
+ID.
+
+=cut
+
+sub SetQueueDefaultArticle{
+    my $self = shift;
+    my $value = shift;
+
+    my $article = RT::Article->new( RT->SystemUser );
+
+    if ( $value ne "" ){
+        my ($ret, $msg) = $article->Load( $value );
+        return (0, $msg) unless ($ret);
+    }
+
+    my ($status, $msg) = $self->SetAttribute(
+        Name        => 'QueueDefaultArticle',
+        Content     => $value,
+    );
+    return ($status, $msg) unless $status;
+
+    # If Default Article set to none we expect 'undef' as value
+    my $ret_val = $value ne "" ? 'updated to ' . $article->Name : 'removed';
+    return (1, $self->loc("Default Article [_1]", $ret_val));
+}
 
 sub Delete {
     my $self = shift;
diff --git a/share/html/Admin/Queues/Modify.html b/share/html/Admin/Queues/Modify.html
index 75b0e658a..dda14522d 100644
--- a/share/html/Admin/Queues/Modify.html
+++ b/share/html/Admin/Queues/Modify.html
@@ -80,6 +80,10 @@
 % }
 </td></tr>
 
+<tr><td align="right"><&|/l&>Default Article</&>:</td><td colspan="3">
+<& /Elements/ArticleSelect, QueueObj => $QueueObj &>
+</td></tr>
+
 <tr><td align="right"><&|/l&>Subject Tag</&>:</td>
 <td colspan="3"><input name="SubjectTag" value="<% $ARGS{'SubjectTag'} || ($Create ? "" : $QueueObj->SubjectTag || '' ) %>" size="60" /></td>
 </tr>
@@ -189,7 +193,7 @@ unless ($Create) {
 if ( $QueueObj->Id ) {
     $title = loc('Configuration for queue [_1]', $QueueObj->Name );
     my @attribs= qw(Description CorrespondAddress CommentAddress Name SortOrder
-        Sign SignAuto Encrypt Lifecycle SubjectTag SLADisabled Disabled);
+        Sign SignAuto Encrypt Lifecycle QueueDefaultArticle SubjectTag SLADisabled Disabled);
 
     # we're asking about enabled on the web page but really care about disabled
     if ( $SetEnabled ) {
@@ -265,6 +269,7 @@ $CorrespondAddress => undef
 $CommentAddress => undef
 $SetSLAEnabled => undef
 $SetEnabled => undef
+$QueueDefaultArticle => undef
 $SetCrypt => undef
 $SLAEnabled => undef
 $Enabled => undef

commit a3bea53bc79f46b6cfbb5be6bf9fef80dcba660f
Author: Craig Kaiser <craig at bestpractical.com>
Date:   Wed Jan 31 10:49:35 2018 -0500

    Make default Article content show on Ticket create
    
    It is important that, if a default Article is selected for a Queue. Then
    on Create.html, the content of the Article should be shown in the
    message box.

diff --git a/share/html/Articles/Elements/IncludeArticle b/share/html/Articles/Elements/IncludeArticle
index 5307875cf..8a0665790 100644
--- a/share/html/Articles/Elements/IncludeArticle
+++ b/share/html/Articles/Elements/IncludeArticle
@@ -78,6 +78,19 @@ foreach my $arg ( keys %$parent_args ) {
         Value => $parent_args->{$arg},
         Queue => $Queue->Id,
     );
+
+    my %args = %$parent_args;
+    if ( !$args{'id'} ){
+        my $queue_id = $args{'Queue'};
+
+        my $QueueObj = RT::Queue->new($session{'CurrentUser'});
+        $QueueObj->Load( $queue_id );
+
+        if ($QueueObj->QueueDefaultArticle){
+            $article->Load( $QueueObj->QueueDefaultArticle );
+        }
+    }
+
     next unless $article && $article->id;
 
     my $formatted_article = $m->scomp('/Articles/Article/Elements/Preformatted',

commit 0906f983a89cd49048d5d59ed96591882fc631be
Author: Craig Kaiser <craig at bestpractical.com>
Date:   Wed Jan 31 10:52:16 2018 -0500

    Add test for default Article content on create.html
    
    Test to ensure that the default Articles content is rendered on
    Create.html for Tickets in that Queue.

diff --git a/t/ticket/queue-default-article.t b/t/ticket/queue-default-article.t
new file mode 100644
index 000000000..5804e4b07
--- /dev/null
+++ b/t/ticket/queue-default-article.t
@@ -0,0 +1,30 @@
+use strict;
+use warnings;
+
+use RT::Test tests => undef;
+
+my $m = RT::Test->started_ok;
+my $url = $m->rt_base_url;
+diag('Started server at ' . $url);
+
+my $article = RT::Article->new($RT::SystemUser);
+my ( $id, $msg ) = $article->Create(
+    Class   => 'General',
+    Name    => 'My Article',
+    'CustomField-Content' => 'My Article Test Content',
+);
+ok( $id, $msg );
+(my $ret, $msg) = $article->Load(1);
+ok ($ret, $msg);
+
+my $queue = RT::Queue->new(RT->SystemUser);
+$queue->Load('General');
+ok( $queue, 'Loaded General Queue' );
+($ret, $msg) = $queue->SetQueueDefaultArticle($article->id);
+ok( $ret, $msg );
+
+ok $m->login(root => 'password'), "logged in";
+$m->goto_create_ticket('General');
+$m->scraped_id_is('Content', '#1: My Article <br />-------------- <br />Content: <br />------- <br />My Article Test Content <br />');
+
+done_testing;

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


More information about the rt-commit mailing list