[Rt-commit] rt branch, 4.4/include-article-queue, repushed
Craig Kaiser
craig at bestpractical.com
Wed Feb 21 12:53:40 EST 2018
The branch 4.4/include-article-queue was deleted and repushed:
was 7458fbe667da002c2135f9a87e001078c449bfb4
now 3c27b7ffb931c1b73da0edd2c7d463e7a9e438ff
1: 7177ac5c8 < -: ------- Add test for 'Order by' dropdown content
2: 06d49b393 < -: ------- Re-add Queue to 'Order by' dropdown in Search Builder
3: 9fa17efe4 = 1: 33ac84399 find idle port for ldap test server
4: 64676e64a ! 2: 83262b6f4 Add Article as a Queue Default value
@@ -1,10 +1,45 @@
Author: craig Kaiser <craig at bestpractical.com>
- Add support for Queue Default Article for web UI
+ Add Article as a Queue Default value
- For the Defaults page for Queues, add an option for a Default Article.
- Where the content of the Article will be loaded into the message box of
- any Ticket, on create in that Queue.
+ Add an Article as a Default value for Tickets created in Queue. Render
+ the content of the Article on Ticket create, in the message box.
+
+diff --git a/lib/RT/Queue.pm b/lib/RT/Queue.pm
+--- a/lib/RT/Queue.pm
++++ b/lib/RT/Queue.pm
+@@
+ $old_value = $old_content->{$args{Name}};
+ }
+
++ $new_value = $args{Value};
++ unless ( defined $new_value && length $new_value ) {
++ $new_value = $self->loc( '(no value)' );
++ }
++
+ unless ( defined $old_value && length $old_value ) {
+ $old_value = $self->loc('(no value)');
+ }
+
+- $new_value = $args{Value};
+- unless ( defined $new_value && length $new_value ) {
+- $new_value = $self->loc( '(no value)' );
++ if ( $args{Name} eq 'Article' && $args{Value} ) {
++ my $article = RT::Article->new($self->CurrentUser);
++ my ($ret, $msg) = $article->LoadByCols( Name => $args{Value} );
++
++ return ($ret, $msg) unless $ret;
++ $args{Value} = $article->Id;
++ }
++
++ if ( $args{Name} eq 'Article' && $old_value =~ /^\d+?$/ ) {
++ my $article = RT::Article->new($self->CurrentUser);
++ my ($ret, $msg) = $article->Load( $old_value );
++
++ $old_value = $article->Name;
+ }
+
+ return 1 if $new_value eq $old_value;
diff --git a/share/html/Admin/Queues/DefaultValues.html b/share/html/Admin/Queues/DefaultValues.html
--- a/share/html/Admin/Queues/DefaultValues.html
@@ -35,35 +70,49 @@
--- a/share/html/Articles/Elements/IncludeArticle
+++ b/share/html/Articles/Elements/IncludeArticle
@@
- && grep rindex($_, "$ARGS{'Name'}-Articles-", 0) == 0,
- keys %$parent_args;
-
-+my $article_included = 0;
- foreach my $arg ( keys %$parent_args ) {
- next if $name_prefix && substr($arg, 0, length($name_prefix)) ne $name_prefix;
-
+
+ my $parent_args = $m->caller_args(-1);
+
++my @articles;
++
+ my $name_prefix = '';
+ $name_prefix = $ARGS{'Name'} .'-'
+ if $ARGS{'Name'}
@@
Value => $parent_args->{$arg},
Queue => $Queue->Id,
);
+
-+ # Check if Ticket id is present, if it is not we know we are creating a Ticket
-+ if ( !$article_included && !$parent_args->{id} or $parent_args->{id} eq 'new' && $article && $article->id ){
-+ my $queue_id = $parent_args->{'Queue'};
-+
-+ my $QueueObj = RT::Queue->new($session{'CurrentUser'});
-+ $QueueObj->Load( $queue_id );
-+
-+ if ($QueueObj->DefaultValue('Article') ){
-+ $article->Load( $QueueObj->DefaultValue('Article') );
-+ }
-+
-+ $article_included = 1;
-+ }
-+
next unless $article && $article->id;
-
++ push (@articles, $article);
++}
++
++if ( ( !$parent_args->{id} || $parent_args->{id} eq 'new' ) && $parent_args->{'Queue'} ) {
++ my $queue_id = $parent_args->{'Queue'};
++ my $article = RT::Article->new($session{'CurrentUser'});
++ my $QueueObj = RT::Queue->new($session{'CurrentUser'});
++ my ($ret, $msg) = $QueueObj->Load( $queue_id );
++ return ($ret, $msg) unless $ret;
+
++ if ($QueueObj->DefaultValue('Article') ){
++ my ($ret, $msg) = $article->Load( $QueueObj->DefaultValue('Article') );
++ return ($ret, $msg) unless $ret;
++ push (@articles, $article);
++ }
++}
++
++foreach my $article (@articles) {
my $formatted_article = $m->scomp('/Articles/Article/Elements/Preformatted',
+ Article => $article, Ticket => $Ticket
+ );
+@@
+ $formatted_article =~ s/\n/\n<br \/>/g;
+ }
+ $m->print($formatted_article);
+-
+ }
+ return;
+ </%INIT>
diff --git a/share/html/Elements/SelectArticle b/share/html/Elements/SelectArticle
new file mode 100644
@@ -117,38 +166,32 @@
+%# those contributions and any derivatives thereof.
+%#
+%# END BPS TAGGED BLOCK }}}
-+% if ( $autocomplete ) {
-+<& "SelectArticleAutocomplete", articles => $articles, QueueObj => $QueueObj, Default => $Default &>
-+% } else {
+<select name='Article'>
+<option value="">-</option>
+% while (my $article = $articles->Next) {
+<option <% ( $article->Name eq $Default) ? qq[ selected="selected"] : '' |n %>
-+ value="<%$article->Id%>"
++ value="<%$article->Name%>"
+><% $article->Name %></option>
+% }
+</select>
-+% }
+
+<%INIT>
+my $articles = RT::Articles->new( $session{'CurrentUser'} );
+$articles->LimitHotlistClasses;
+$articles->LimitAppliedClasses( Queue => $QueueObj );
+
-+my $dropdown_limit = 50;
++my $dropdown_limit = 0;
+$m->callback( CallbackName => 'ModifyDropdownLimit', DropdownLimit => \$dropdown_limit );
+
+my $Default = '';
+
-+my $autocomplete = $articles->Count > $dropdown_limit ? 1 : 0;
-+
+my $default_article = RT::Article->new($session{'CurrentUser'});
-+# Default Article is "" if no value selected
-+if ( defined $QueueObj->DefaultValue('Article') && $QueueObj->DefaultValue($Name) ne "") {
-+ my ($ret, $msg) = $default_article->Load( $QueueObj->DefaultValue('Article') );
++
++if ( $QueueObj->DefaultValue($Name) ) {
++ my ($ret, $msg) = $default_article->Load( $QueueObj->DefaultValue($Name) );
+ if ($ret) {
+ $Default = $default_article->Name;
-+ } else{
++ } else{
+ RT::Logger->error($msg);
+ }
+}
@@ -159,63 +202,3 @@
+$Name => 'Article'
+</%ARGS>
-diff --git a/share/html/Elements/SelectArticleAutocomplete b/share/html/Elements/SelectArticleAutocomplete
-new file mode 100644
---- /dev/null
-+++ b/share/html/Elements/SelectArticleAutocomplete
-@@
-+%# 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 data-autocomplete="Articles" data-autocomplete-limit_queue=<% $QueueObj %> data-autocomplete-return="Name" name='Article' value="<% $Default %>" selected>
-+
-+<%ARGS>
-+$QueueObj => ""
-+$Default => ""
-+</%ARGS>
-\ No newline at end of file
-
5: 6704b2405 ! 3: 6e0ff0507 Add Autocomplete for Articles
@@ -1,6 +1,97 @@
Author: craig Kaiser <craig at bestpractical.com>
- Add autocomplete for Articles
+ Add Autocomplete for Articles
+
+diff --git a/share/html/Elements/SelectArticle b/share/html/Elements/SelectArticle
+--- a/share/html/Elements/SelectArticle
++++ b/share/html/Elements/SelectArticle
+@@
+ %# those contributions and any derivatives thereof.
+ %#
+ %# END BPS TAGGED BLOCK }}}
++% if ( $autocomplete ) {
++<& "SelectArticleAutocomplete", articles => $articles, QueueObj => $QueueObj, Default => $Default &>
++% } else {
+ <select name='Article'>
+ <option value="">-</option>
+ % while (my $article = $articles->Next) {
+@@
+ ><% $article->Name %></option>
+ % }
+ </select>
++% }
+
+ <%INIT>
+ my $articles = RT::Articles->new( $session{'CurrentUser'} );
+@@
+
+ my $Default = '';
+
++my $autocomplete = $articles->Count > $dropdown_limit ? 1 : 0;
++
+ my $default_article = RT::Article->new($session{'CurrentUser'});
+
+ if ( $QueueObj->DefaultValue($Name) ) {
+
+diff --git a/share/html/Elements/SelectArticleAutocomplete b/share/html/Elements/SelectArticleAutocomplete
+new file mode 100644
+--- /dev/null
++++ b/share/html/Elements/SelectArticleAutocomplete
+@@
++%# 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 id='SelectArticleAutocomplete' data-autocomplete="Articles" data-autocomplete-queue=<% $QueueObj->Id %> data-autocomplete-return="Name" name='Article' value="<% $Default %>">
++
++<%ARGS>
++$QueueObj => ""
++$Default => ""
++</%ARGS>
+\ No newline at end of file
diff --git a/share/html/Helpers/Autocomplete/Articles b/share/html/Helpers/Autocomplete/Articles
new file mode 100644
@@ -63,7 +154,7 @@
+$op => 'STARTSWITH'
+$right => undef
+$return => 'Name'
-+$limit_queue => undef
++$queue => undef
+</%ARGS>
+<%INIT>
+# Only allow certain return fields
@@ -81,8 +172,8 @@
+
+my $articles = RT::Articles->new( $session{CurrentUser} );
+$articles->LimitHotlistClasses;
-+if( $limit_queue ) {
-+ $articles->LimitAppliedClasses( Queue => $limit_queue );
++if( $queue ) {
++ $articles->LimitAppliedClasses( Queue => $queue );
+}
+
+$articles->RowsPerPage( $max );
@@ -117,4 +208,14 @@
};
window.RT.Autocomplete.bind = function(from) {
-
+@@
+ };
+ }
+
++ var queue = input.attr("data-autocomplete-queue");
++ if (queue) queryargs.push("queue=" + queue);
++
+ var checkRight = input.attr("data-autocomplete-checkright");
+ if (checkRight) queryargs.push("right=" + checkRight);
+
+
6: 7458fbe66 ! 4: 3c27b7ffb Add tests for Default Article content on create
@@ -1,9 +1,6 @@
Author: craig Kaiser <craig at bestpractical.com>
- Test Ticket create web UI when Default Article
-
- Test that when a Queue Default Value is selected for Article, the
- content of the Article is loaded on the Ticket create page.
+ Add tests for Default Article content on create
diff --git a/t/web/ticket-create-utf8.t b/t/web/ticket-create-utf8.t
--- a/t/web/ticket-create-utf8.t
More information about the rt-commit
mailing list