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

Craig Kaiser craig at bestpractical.com
Wed Feb 7 15:40:56 EST 2018


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

- Log -----------------------------------------------------------------
commit f2d31f1dbc6c6764a15d410210e43b62699df9db
Author: Brian C. Duggan <brian at bestpractical.com>
Date:   Tue Dec 12 11:50:37 2017 -0500

    Add test for 'Order by' dropdown content
    
    Test the presence of both core and custom field sortable ticket values
    in the 'Order by' dropdown in search builder.

diff --git a/t/web/query_builder.t b/t/web/query_builder.t
index dbe909939..2c11801a0 100644
--- a/t/web/query_builder.t
+++ b/t/web/query_builder.t
@@ -3,7 +3,7 @@ use warnings;
 use HTTP::Request::Common;
 use HTTP::Cookies;
 use LWP;
-use RT::Test tests => 70;
+use RT::Test tests => undef;
 
 my $cookie_jar = HTTP::Cookies->new;
 my ($baseurl, $agent) = RT::Test->started_ok;
@@ -219,6 +219,7 @@ diag "click advanced, enter 'C1 OR ( C2 AND C3 )', apply, aggregators should sta
         "no changes, no duplicate condition with badly encoded text"
     );
 
+   $cf->SetDisabled(1);
 }
 
 diag "input a condition, select (several conditions), click delete";
@@ -324,3 +325,75 @@ diag "make sure skipped order by field doesn't break search";
         url_regex => qr{/Ticket/Display\.html},
     ), "link to the ticket" );
 }
+
+diag "make sure the list of columns available in the 'Order by' dropdowns are complete";
+{
+    $agent->get_ok($url . 'Search/Build.html');
+
+    my @orderby = qw(
+        AdminCc.EmailAddress
+        Cc.EmailAddress
+        Created
+        Creator
+        Custom.Ownership
+        Due
+        FinalPriority
+        InitialPriority
+        LastUpdated
+        LastUpdatedBy
+        Owner
+        Priority
+        Queue
+        Requestor.EmailAddress
+        Resolved
+        SLA
+        Started
+        Starts
+        Status
+        Subject
+        TimeEstimated
+        TimeLeft
+        TimeWorked
+        Told
+        Type
+        id
+    );
+
+    my $orderby = join(' ', sort @orderby);
+
+    my @scraped_orderbys = $agent->scrape_text_by_attr('name', 'OrderBy');
+
+    my $first_orderby = shift @scraped_orderbys;
+    is ($first_orderby, $orderby);
+
+    foreach my $scraped_orderby ( @scraped_orderbys ) {
+            is ($scraped_orderby, '[none] '.$orderby);
+    }
+
+    my $cf = RT::Test->load_or_create_custom_field(
+        Name  => 'Location',
+        Queue => 'General',
+        Type  => 'FreeformSingle', );
+    isa_ok( $cf, 'RT::CustomField' );
+
+    ok($agent->form_name('BuildQuery'), "found the form");
+    $agent->field("ValueOfQueue", "General");
+    $agent->submit;
+
+    push @orderby, 'CustomField.{Location}';
+
+    $orderby = join(' ', sort @orderby);
+
+    @scraped_orderbys = $agent->scrape_text_by_attr('name', 'OrderBy');
+
+    $first_orderby = shift @scraped_orderbys;
+    is ($first_orderby, $orderby);
+
+    foreach my $scraped_orderby ( @scraped_orderbys ) {
+        is ($scraped_orderby, '[none] '.$orderby);
+    }
+
+    $cf->SetDisabled(1);
+}
+
+done_testing;

commit 0494b952992874acb1d1cdb0b90d7ef95842c2bb
Author: Brian C. Duggan <brian at bestpractical.com>
Date:   Tue Dec 12 09:50:31 2017 -0500

    Re-add Queue to 'Order by' dropdown in Search Builder
    
    Commit 8d0e8cf80f added support for searching by LIKE and NOT LIKE on
    queue. /Search/Elements/EditSort filters ticket fields by whether they
    have an ENUM key, among others. This change removed the ENUM key from
    the value for Queue in %FIELD_METADATA in /lib/RT/Tickets.pm. As a
    side effect, EditSort filtered Queue out of the fields to display in
    'Order by' dropdown in the Search Builder.
    
    This change adds the 'QUEUE' key, which Queue has in Tickets.pm, to
    the list of keys EditSort selects from ticket fields. This makes Queue
    available in the 'Order by' dropdown again.

diff --git a/share/html/Search/Elements/EditSort b/share/html/Search/Elements/EditSort
index 4853e17f2..8b6467145 100644
--- a/share/html/Search/Elements/EditSort
+++ b/share/html/Search/Elements/EditSort
@@ -104,7 +104,7 @@ my %fields;
 
 for my $field (keys %FieldDescriptions) {
     next if $field eq 'EffectiveId';
-    next unless $FieldDescriptions{$field}->[0] =~ /^(?:ENUM|INT|DATE|STRING|ID)$/;
+    next unless $FieldDescriptions{$field}->[0] =~ /^(?:ENUM|QUEUE|INT|DATE|STRING|ID)$/;
     $fields{$field} = $field;
 }
 

commit d2eef49ea631947275bdf82eb7d5688cab5cc34a
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..f5cf88447 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,60 @@ 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 ? $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 );
+    my $no_value = $self->loc("(no value)");
+    my $new_value;
+    my $old_value;
+
+    # If unsetting Default Article $value will come in as empty string, do not load that.
+    if ( $value && $value ne "" ){
+        my ($ret, $msg) = $article->Load( $value );
+        return ($ret, $msg) unless $ret;
+        $new_value = $article->Name;
+    }
+
+    if ( length($self->QueueDefaultArticle()) ) {
+        my ($ret, $msg) = $article->Load( $self->QueueDefaultArticle() );
+        return ($ret, $msg) unless $ret;
+        $old_value = $article->Name;
+    }
+
+    my ($ret, $msg) = $self->SetAttribute(
+        Name        => 'QueueDefaultArticle',
+        Content     => $value,
+    );
+    return ($ret, $msg) unless $ret;
+
+    return (1,
+        $self->loc("Default Article changed from [_1] to [_2]",
+            $old_value ? "'" . $old_value . "'" : $no_value,
+            $new_value ? "'" . $new_value . "'" : $no_value));
+}
 
 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..d88d7c724
--- /dev/null
+++ b/share/html/Elements/SelectArticleDropdown
@@ -0,0 +1,75 @@
+%# 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'});
+
+# Default Article is "" if no value selected
+if ( defined $QueueObj->QueueDefaultArticle && $QueueObj->QueueDefaultArticle ne "") {
+    my ($ret, $msg) = $article_id->LoadByCol( id => $QueueObj->QueueDefaultArticle );
+    RT::Logger->error($msg) unless $ret;
+}
+</%INIT>
+
+<%ARGS>
+$QueueObj
+$articles
+</%ARGS>
+
diff --git a/share/html/Elements/SelectArticleSearch b/share/html/Elements/SelectArticleSearch
new file mode 100644
index 000000000..2d0bc8347
--- /dev/null
+++ b/share/html/Elements/SelectArticleSearch
@@ -0,0 +1,58 @@
+%# 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'});
+my ($ret, $msg) = $article_id->LoadByCol( id => $QueueObj->QueueDefaultArticle );
+RT::Logger->error($msg) unless $ret;
+</%INIT>
+<%ARGS>
+$QueueObj
+</%ARGS>

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

    Make default Article content show on Ticket create
    
    If the Queue has a Defulat Article, show it on Ticket create.

diff --git a/share/html/Articles/Elements/IncludeArticle b/share/html/Articles/Elements/IncludeArticle
index 5307875cf..5aab9f189 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,
     );
+
+    # Check if Ticket id is present, if it is not we know we are creating a Ticket
+    if ( !$parent_args->{'id'} ){
+        my $queue_id = $parent_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 aa84fca657ae3d3454528d96aebe88768d696320
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/api/queue.t b/t/api/queue.t
index e3c4fd2ce..0ba8d1043 100644
--- a/t/api/queue.t
+++ b/t/api/queue.t
@@ -115,4 +115,44 @@ ok ($group->Id, "Found the AdminCc object for this Queue");
     is($WithSLA->SLA, 'standard', 'SLA is updated');
 }
 
+{
+    my $class = RT::Class->new(RT->SystemUser);
+    my ($ret, $msg) = $class->Create( Name => 'General' );
+    ok($ret, $msg);
+
+    my $queue = RT::Queue->new(RT->SystemUser);
+    ($ret, $msg) = $queue->Create( Name => 'Test');
+    ok($ret, $msg);
+
+    my $article = RT::Article->new($RT::SystemUser);
+    ( $ret, $msg ) = $article->Create(
+        Class   => 'General',
+        Name    => 'My Article',
+    );
+    ok( $ret, $msg );
+
+    ($ret, $msg) = $article->Load(1);
+    ok ($ret, $msg);
+
+    is($queue->QueueDefaultArticle(), undef, 'No set Default Article value returns undef');
+
+    $queue->SetQueueDefaultArticle(2);
+    is($queue->QueueDefaultArticle(), undef, 'No value set for invalid Default Article id');
+
+    $queue->SetQueueDefaultArticle(1);
+    is($queue->QueueDefaultArticle(), 1, 'Valid Article ID is set and stored');
+
+    $queue->SetQueueDefaultArticle("");
+    is($queue->QueueDefaultArticle(), undef, 'Return undef when Default Article removed');
+
+    $queue->SetQueueDefaultArticle(undef);
+    is($queue->QueueDefaultArticle(), undef, 'Return undef when undef is given as input for SetQueueDefaultArticle');
+    
+    ($ret, $msg) = $queue->SetQueueDefaultArticle(1);
+    is($msg, 'Default Article changed from (no value) to \'My Article\'', 'Correct message when Default Article value changed from none');
+
+    ($ret, $msg) = $queue->SetQueueDefaultArticle('');
+    is($msg, 'Default Article changed from \'My Article\' to (no value)', 'Correct message when Default Article value changed from value to no value');
+}
+
 done_testing;
diff --git a/t/web/ticket-create-utf8.t b/t/web/ticket-create-utf8.t
index ebb2d5eab..b5877138e 100644
--- a/t/web/ticket-create-utf8.t
+++ b/t/web/ticket-create-utf8.t
@@ -2,7 +2,7 @@
 use strict;
 use warnings;
 
-use RT::Test tests => 43;
+use RT::Test tests => 49;
 
 my $ru_test = "\x{442}\x{435}\x{441}\x{442}";
 my $ru_support = "\x{43f}\x{43e}\x{434}\x{434}\x{435}\x{440}\x{436}\x{43a}\x{430}";
@@ -86,3 +86,23 @@ foreach my $test_str ( $ru_test, $l1_test ) {
     }
 }
 
+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 />');
+

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


More information about the rt-commit mailing list