[Rt-commit] rtir branch 5.0/use-x-rt-interafce-header-for-how-reported created. 5.0.1-23-g861751ba
BPS Git Server
git at git.bestpractical.com
Fri Oct 8 18:24:39 UTC 2021
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "rtir".
The branch, 5.0/use-x-rt-interafce-header-for-how-reported has been created
at 861751ba17e200d803475db6fcf85cba5d017e8a (commit)
- Log -----------------------------------------------------------------
commit 861751ba17e200d803475db6fcf85cba5d017e8a
Author: sunnavy <sunnavy at bestpractical.com>
Date: Sat Oct 9 01:28:20 2021 +0800
Default "How Reported" to "Web" if no default values are set on create page
Note that even without this change, the value still could be set to
"Web" correctly via action RTIR_SetHowReported. This commit is to
clearly show user that the value will be set to "Web" on create page.
diff --git a/html/RTIR/Create.html b/html/RTIR/Create.html
index 4e6f11ce..d2e1972f 100644
--- a/html/RTIR/Create.html
+++ b/html/RTIR/Create.html
@@ -431,6 +431,19 @@ if (!$QueueObj->Name) {
$Lifecycle ||= $QueueObj->Lifecycle;
+my $cfs = $QueueObj->TicketCustomFields;
+$cfs->Limit( FIELD => 'Name', VALUE => 'How Reported', CASESENSITIVE => 0 );
+if ( my $cf = $cfs->First ) {
+ my $id = $cf->Id;
+
+ # Do not override if the cf has default values or is set already
+ if ( !$cf->DefaultValues( Object => $QueueObj ) && !grep {/^Object-RT::Ticket--CustomField.*-$id-Value/}
+ keys %ARGS )
+ {
+ $CFDefaults{"CustomField-$id"} = 'Web';
+ }
+}
+
my $ticket = RT::Ticket->new($session{'CurrentUser'}); # empty ticket object
commit ae4129da3e4c67503de0cc2394c583b43dd6e8da
Author: sunnavy <sunnavy at bestpractical.com>
Date: Sat Oct 9 01:26:53 2021 +0800
Set "How Reported" CF from "X-RT-Interface" when possible
Fixes: I#32162
diff --git a/lib/RT/Action/RTIR_SetHowReported.pm b/lib/RT/Action/RTIR_SetHowReported.pm
index beccad46..7c25ff52 100644
--- a/lib/RT/Action/RTIR_SetHowReported.pm
+++ b/lib/RT/Action/RTIR_SetHowReported.pm
@@ -64,9 +64,18 @@ sub Commit {
$cf->LoadByNameAndQueue(Queue => $self->TicketObj->QueueObj->Id, Name => 'How Reported');
return unless $cf->Id;
+ my $interface;
+ if ( my $msg = $self->TransactionObj->Message->First ) {
+ $interface = $msg->GetHeader('X-RT-Interface');
+ }
+ return unless $interface;
+
+ # Don't distinguish if it's Mobile UI or not.
+ $interface = 'Web' if $interface eq 'Mobile';
+
my $Values = $self->TicketObj->CustomFieldValues( $cf->id );
unless ( $Values->Count ) {
- $self->TicketObj->AddCustomFieldValue( Field => $cf->id, Value => "Email" );
+ $self->TicketObj->AddCustomFieldValue( Field => $cf->id, Value => $interface );
}
return 1;
}
commit d65756a06a195ffb2a02d508fb8fa5b106815de5
Author: sunnavy <sunnavy at bestpractical.com>
Date: Sat Oct 9 01:25:43 2021 +0800
Add more RT standard interfaces to "How Reported" CF
diff --git a/etc/initialdata b/etc/initialdata
index 277fe1f6..20052994 100644
--- a/etc/initialdata
+++ b/etc/initialdata
@@ -95,9 +95,12 @@ die "Please add RT::IR to your Plugins configuration before initializing the dat
Description =>
'How the incident was reported for Incident Reports RTIR queue',
Values => [
- { Name => "Email", SortOrder => 1 },
- { Name => "Telephone", SortOrder => 2 },
- { Name => "Other", SortOrder => 3 },
+ { Name => "API", SortOrder => 1 },
+ { Name => "Email", SortOrder => 2 },
+ { Name => "REST", SortOrder => 3 },
+ { Name => "Telephone", SortOrder => 4 },
+ { Name => "Web", SortOrder => 5 },
+ { Name => "Other", SortOrder => 6 },
]
},
{ Name => 'Reporter Type',
diff --git a/etc/upgrade/5.0.2/content b/etc/upgrade/5.0.2/content
new file mode 100644
index 00000000..cd9db14a
--- /dev/null
+++ b/etc/upgrade/5.0.2/content
@@ -0,0 +1,56 @@
+use strict;
+use warnings;
+
+our @Final = (
+ sub {
+ my $cf = RT::CustomField->new( RT->SystemUser );
+ $cf->Load('How Reported');
+ if ( $cf->Id ) {
+ my %sort_order = (
+ API => 1,
+ Email => 2,
+ REST => 3,
+ Telephone => 4,
+ Web => 5,
+ Other => 6,
+ );
+ my %current = map { $_->Name => $_ } @{ $cf->Values->ItemsArrayRef || [] };
+
+ for my $item ( sort keys %sort_order ) {
+ if ( $current{$item} ) {
+ if ( ( $current{$item}->SortOrder // 0 ) != $sort_order{$item} ) {
+ my ( $ret, $msg ) = $current{$item}->SetSortOrder( $sort_order{$item} );
+ if ( !$ret ) {
+ RT->Logger->error("Could not set sort order for $item: $msg");
+ }
+ }
+ delete $current{$item};
+ }
+ else {
+ my ( $ret, $msg ) = $cf->AddValue( Name => $item, SortOrder => $sort_order{$item} );
+ if ( !$ret ) {
+ RT->Logger->error("Could not create new value $item: $msg");
+ }
+ }
+ }
+
+ # Adjust SortOrder for non-core ones added by users.
+ my $next_sort_order = 7;
+ for my $item (
+ sort { ( $current{$a}->SortOrder // 0 ) <=> ( $current{$b}->SortOrder // 0 ) }
+ keys %current
+ )
+ {
+ if ( ( $current{$item}->SortOrder // 0 ) != $next_sort_order ) {
+ my ( $ret, $msg ) = $current{$item}->SetSortOrder($next_sort_order);
+ if ( !$ret ) {
+ RT->Logger->error("Could not set sort order for $item: $msg");
+ }
+ }
+ $next_sort_order++;
+ }
+ }
+ },
+);
+
+1;
-----------------------------------------------------------------------
hooks/post-receive
--
rtir
More information about the rt-commit
mailing list