[Rt-commit] rt branch, 4.4/include-article-queue, created. rt-4.4.2-70-ge3ad3cbb8
Craig Kaiser
craig at bestpractical.com
Thu Feb 1 15:08:16 EST 2018
The branch, 4.4/include-article-queue has been created
at e3ad3cbb896a353996815690c80bf7d5dc657cf0 (commit)
- Log -----------------------------------------------------------------
commit 2a78b2aa1fd19f3b2b213f2ffcaf01e85799e84a
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 6f3b34170a2530ae741f5942ed32355bd37b7745
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
diff --git a/share/html/Elements/ArticleSelect b/share/html/Elements/ArticleSelect
new file mode 100644
index 000000000..9d4f8a450
--- /dev/null
+++ b/share/html/Elements/ArticleSelect
@@ -0,0 +1,65 @@
+%# BEGIN BPS TAGGED BLOCK {{{
+%#
+%# COPYRIGHT:
+%#
+%# This software is Copyright (c) 1996-2017 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.
+%#
+
+<& "SelectArticle$Widget", articles => $articles, QueueObj => $QueueObj &>
+
+<%INIT>
+
+my $articles = RT::Articles->new( $session{'CurrentUser'} );
+$articles->LimitHotlistClasses;
+$articles->LimitAppliedClasses( Queue => $QueueObj );
+
+my $dropdown_limit = 50;
+$m->callback( CallbackName => 'ModifyDropdownLimit', DropdownLimit => \$dropdown_limit );
+
+my $Widget = $articles->Count > $dropdown_limit ? 'Search' : 'Dropdown';
+
+</%INIT>
+
+<%ARGS>
+$QueueObj
+</%ARGS>
diff --git a/share/html/Elements/SelectArticleDropdown b/share/html/Elements/SelectArticleDropdown
new file mode 100644
index 000000000..67071c133
--- /dev/null
+++ b/share/html/Elements/SelectArticleDropdown
@@ -0,0 +1,70 @@
+%# BEGIN BPS TAGGED BLOCK {{{
+%#
+%# COPYRIGHT:
+%#
+%# This software is Copyright (c) 1996-2017 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 }}}
+
+<select name='QueueDefaultArticle'>
+<option value="" selected><&|/l&><% $article_id->Name? $article_id->Name: '-'%></&></option>
+% if ( $article_id ) {
+<option value="">-</option>
+% }
+% while (my $article = $articles->Next) {
+% if ( $article && $article->Id eq $article->Id) {
+<option value="<% $article->Id %>"><% $article->Name|| loc('(no name)')%><%$article->Summary || ''%></option>
+% }
+% }
+</select>
+
+<%INIT>
+my $article_id = RT::Article->new($session{'CurrentUser'});
+$article_id->LoadByCol( id => $QueueObj->QueueDefaultArticle );
+</%INIT>
+
+<%ARGS>
+$QueueObj
+$articles
+</%ARGS>
+
diff --git a/share/html/Elements/SelectArticleSearch b/share/html/Elements/SelectArticleSearch
new file mode 100644
index 000000000..39044d8bb
--- /dev/null
+++ b/share/html/Elements/SelectArticleSearch
@@ -0,0 +1,57 @@
+%# BEGIN BPS TAGGED BLOCK {{{
+%#
+%# COPYRIGHT:
+%#
+%# This software is Copyright (c) 1996-2017 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 }}}
+
+<input name='QueueDefaultArticle' value="" selected placeholder="<% $article_id ? $article_id->Name : ''%>">
+
+<%INIT>
+my $article_id = RT::Article->new($session{'CurrentUser'});
+$article_id->LoadByCol( id => $QueueObj->QueueDefaultArticle );
+</%INIT>
+<%ARGS>
+$QueueObj
+</%ARGS>
\ No newline at end of file
commit aff15a0edc38ce65ab7a7a496eef26b6ec92bdbf
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 e3ad3cbb896a353996815690c80bf7d5dc657cf0
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