[Rt-commit] rt branch, 4.6/article-refactor, repushed
? sunnavy
sunnavy at bestpractical.com
Thu Apr 18 17:23:13 EDT 2019
The branch 4.6/article-refactor was deleted and repushed:
was 930da784cab2dc974a8295c51bd7493396c446a7
now 1e1f275084abbd5ec5bc6f703b53a393bcd62fda
1: cfb23fd15 = 1: 668d7a23f Add default value for Articles in Queues
2: a287e701f ! 2: 58e02cdb5 Add autocomplete for articles
@@ -81,7 +81,7 @@
+<%ARGS>
+$QueueObj => undef
+$Default => undef
-+$Name => 'Article'
++$Name => 'IncludeArticleId'
+</%ARGS>
diff --git a/share/html/Helpers/Autocomplete/Articles b/share/html/Helpers/Autocomplete/Articles
3: da505e97e = 3: de0dd40a2 Test default article content on ticket create
4: b37c96760 = 4: c2446dc75 Push default article loading toward create
5: e8893c27b ! 5: f2124f372 Refactor ticket create and update to use new SelectArticle
@@ -93,7 +93,8 @@
- if $ARGS{'Name'}
- && grep rindex($_, "$ARGS{'Name'}-Articles-", 0) == 0,
- keys %$parent_args;
--
++if ( $ret && $article->Id ){
+
-my $Ticket = $ARGS{Ticket};
-if ( !$Ticket and $parent_args->{id} and $parent_args->{id} ne 'new' ) {
- $Ticket = RT::Ticket->new($session{'CurrentUser'});
@@ -105,12 +106,20 @@
-
-foreach my $arg ( keys %$parent_args ) {
- next if $name_prefix && substr($arg, 0, length($name_prefix)) ne $name_prefix;
--
++ my $Ticket = $ARGS{Ticket};
++ my $parent_args = $m->caller_args(-1);
+
- my $Queue = RT::Queue->new($session{CurrentUser});
- if ($Ticket && $Ticket->Id) {
- $Queue = $Ticket->QueueObj;
-- }
--
++ if ( !$Ticket and $parent_args->{id} and $parent_args->{id} ne 'new' ) {
++ $Ticket = RT::Ticket->new($session{'CurrentUser'});
++ $Ticket->Load($parent_args->{id});
++ unless ( $Ticket->id ) {
++ $RT::Logger->error("Couldn't load ticket ". $parent_args->{id} );
++ }
+ }
+
- my $article = RT::Article->new($session{'CurrentUser'});
- $article->LoadByInclude(
- Field => substr($arg, length($name_prefix)),
@@ -134,23 +143,25 @@
- if ($ret) {
- push (@articles, $article);
- }
-- }
++ my $queue_id;
++ $queue_id = $QueueObj->id if $QueueObj && $QueueObj->id;
++ $queue_id ||= $Ticket->Queue if $Ticket && $Ticket->Queue;
++ if ( $queue_id
++ && !$article->ClassObj->IsApplied(0)
++ && !$article->ClassObj->IsApplied($queue_id) )
++ {
++ RT->Logger->warning( "The Class of the Article #$IncludeArticleId is not applied to the Queue #$queue_id" );
++ return;
+ }
-}
--
+
-foreach my $article (@articles) {
-+if ( $ret && $article->Id ){
my $formatted_article = $m->scomp('/Articles/Article/Elements/Preformatted',
- Article => $article, Ticket => $Ticket
+ Article => $article
);
-- $m->callback( Article => $article, Ticket => $Ticket, formatted_article => \$formatted_article );
-+ # Ticket is provided in this callback for backward compatibility.
-+ # However, after refactoring, less work is done to make sure a Ticket is available
-+ $m->callback( Article => $article, Ticket => $ARGS{'Ticket'}, formatted_article => \$formatted_article );
-
- if (RT->Config->Get('MessageBoxRichText', $session{'CurrentUser'})) {
- $formatted_article =~ s/>/>/g;
+ $m->callback( Article => $article, Ticket => $Ticket, formatted_article => \$formatted_article, ARGSRef => \%ARGS );
@@
$formatted_article =~ s/\n/\n<br \/>/g;
}
@@ -164,6 +175,7 @@
</%INIT>
+<%ARGS>
+$IncludeArticleId => undef
++$QueueObj => undef
+</%ARGS>
diff --git a/share/html/Elements/MessageBox b/share/html/Elements/MessageBox
@@ -174,7 +186,7 @@
%# END BPS TAGGED BLOCK }}}
<textarea autocomplete="off" class="messagebox <% $Type eq 'text/html' ? 'richtext' : '' %>" <% $width_attr %>="<% $Width %>" rows="<% $Height %>" <% $wrap_type |n %> name="<% $Name %>" id="<% $Name %>" placeholder="<% $Placeholder %>">
-% $m->comp('/Articles/Elements/IncludeArticle', %ARGS, ArticleId => $article_id) if $IncludeArticle;
-+% $m->comp('/Articles/Elements/IncludeArticle', %ARGS, IncludeArticleId => $article_id) if $IncludeArticle;
++% $m->comp('/Articles/Elements/IncludeArticle', %ARGS, IncludeArticleId => $article_id, QueueObj => $QueueObj) if $IncludeArticle;
% $m->callback( %ARGS, SignatureRef => \$signature, DefaultRef => \$Default, MessageRef => \$message );
% if (RT->Config->Get("SignatureAboveQuote", $session{'CurrentUser'})) {
<% $Default || '' %><% $signature %><% $message %></textarea>
@@ -247,9 +259,25 @@
<%ARGS>
$QueueObj => undef
$Default => undef
- $Name => 'Article'
+ $Name => 'IncludeArticleId'
+$AutoSubmit => 1
</%ARGS>
+
+diff --git a/share/html/Ticket/Create.html b/share/html/Ticket/Create.html
+--- a/share/html/Ticket/Create.html
++++ b/share/html/Ticket/Create.html
+@@
+ % }
+ % $m->callback( %ARGS, QueueObj => $QueueObj, CallbackName => 'BeforeMessageBox' );
+ % if (exists $ARGS{Content}) {
+-<& /Elements/MessageBox, Default => $ARGS{Content}, IncludeSignature => 0, IncludeDefaultArticle => 0 &>
++<& /Elements/MessageBox, QueueObj => $QueueObj, Default => $ARGS{Content}, IncludeSignature => 0, IncludeDefaultArticle => 0 &>
+ % } elsif ( $QuoteTransaction ) {
+-<& /Elements/MessageBox, QuoteTransaction => $QuoteTransaction, IncludeDefaultArticle => 0 &>
++<& /Elements/MessageBox, QueueObj => $QueueObj, QuoteTransaction => $QuoteTransaction, IncludeDefaultArticle => 0 &>
+ % } else {
+ <& /Elements/MessageBox, QueueObj => $QueueObj, IncludeDefaultArticle => 1 &>
+ %}
diff --git a/t/articles/queue-specific-class.t b/t/articles/queue-specific-class.t
--- a/t/articles/queue-specific-class.t
6: 3e142bfc1 = 6: 72c3f3bbb Add articles notes to upgrading docs
7: 4b0149720 = 7: 529176dc9 Remove article loading now handled in SelectArticle
8: 5652cbd63 ! 8: 0bf47b163 Update article to ticket linking with new args
@@ -18,14 +18,12 @@
- Value => $ARGS{$arg},
- );
- if ($article->Id) {
-- $uri{$article->URI}++;
-- }
+ my $article = RT::Article->new($session{'CurrentUser'});
+ my ($ret, $msg) = $article->Load($ARGS{'IncludeArticleId'});
+
+ if ($ret && $article->Id) {
-+ $uri{$article->URI}++;
++ unless ( $QueueObj && !$article->ClassObj->IsApplied(0) && !$article->ClassObj->IsApplied( $QueueObj->id ) ) {
+ $uri{$article->URI}++;
+ }
}
- }
-
9: fc6a8f84f ! 9: e673409fe Update tests for new articles configuration
@@ -26,6 +26,19 @@
+diff --git a/t/articles/set-subject.t b/t/articles/set-subject.t
+--- a/t/articles/set-subject.t
++++ b/t/articles/set-subject.t
+@@
+ is($m->form_number(3)->find_input('UpdateSubject')->value,$ticket->Subject,'Ticket Subject Found');
+ $m->submit_form(
+ form_number => 3,
+- fields => { 'Articles-Include-Article-Named' => $article->Name },
++ fields => { 'IncludeArticleId' => $article->id },
+ );
+ is($m->form_number(3)->find_input('UpdateSubject')->value,$article->FirstCustomFieldValue("Subject-$$"),'Ticket Subject Clobbered');
+
+
diff --git a/t/web/articles-links.t b/t/web/articles-links.t
--- a/t/web/articles-links.t
+++ b/t/web/articles-links.t
10: 06480e703 < --: ------- Drop the hacky hidden "SubmitTicket" input on ticket create page
11: 930da784c ! 10: b583b1aa1 Drop HotList column for Classes
@@ -2,8 +2,7 @@
Drop HotList column for Classes
- With the new article selection UI, all the articles applied accordingly
- will show up.
+ With the new SelectArticle UI, all the articles applied will show up.
diff --git a/etc/initialdata b/etc/initialdata
--- a/etc/initialdata
@@ -221,3 +220,4 @@
);
$m->content_contains( "Modify the Class $name",
+
--: ------- > 11: c00dddbc4 Update SubjectOverride for new SelectArticle UI
--: ------- > 12: 02fb0b1e3 Update CheckSkipCreate for new SelectArticle UI
--: ------- > 13: 1e1f27508 Deprecate RT::Article::LoadByInclude that was for old article selection UI
More information about the rt-commit
mailing list