[Rt-commit] rt branch 5.0/ticket-create-reset-default-values-on-queue-change created. rt-5.0.2-61-g62ec7d202a
BPS Git Server
git at git.bestpractical.com
Fri Jan 28 21:47:37 UTC 2022
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 "rt".
The branch, 5.0/ticket-create-reset-default-values-on-queue-change has been created
at 62ec7d202aabd74894a2a04dabe41c5b4d43dbcc (commit)
- Log -----------------------------------------------------------------
commit 62ec7d202aabd74894a2a04dabe41c5b4d43dbcc
Author: sunnavy <sunnavy at bestpractical.com>
Date: Sat Jan 29 05:06:50 2022 +0800
Reset queue-level default values on queue change on ticket create page
Previously queue-level default values always got kept after queue
changes, which wrongly overrode new queue's default values.
This commit ignores those default values unless they are manually
touched, so new queue's default values could take over. Manually touched
ones are retained no matter how many times the queue is changed.
diff --git a/share/html/Ticket/Create.html b/share/html/Ticket/Create.html
index bded7f6e57..e30870bfd0 100644
--- a/share/html/Ticket/Create.html
+++ b/share/html/Ticket/Create.html
@@ -61,6 +61,17 @@
<input type="hidden" class="hidden" name="AddGroupCc" value="<% $ARGS{'AddGroupCc'} %>" />
% }
+% if ( $ARGS{'ChangedField'} ) {
+% for my $field ( ref $ARGS{ChangedField} eq 'ARRAY' ? @{ $ARGS{ChangedField} } : $ARGS{ChangedField} ) {
+ <input type="hidden" class="hidden" name="ChangedField" value="<% $field %>" />
+% }
+% }
+
+%# If user includes an article, it usually means the content changes.
+% if ( $ARGS{IncludeArticleId} ) {
+ <input type="hidden" class="hidden" name="ChangedField" value="Content" />
+% }
+
% $m->callback( CallbackName => 'FormStart', QueueObj => $QueueObj, ARGSRef => \%ARGS );
% if ($gnupg_widget) {
@@ -453,6 +464,18 @@ $m->scomp( '/Articles/Elements/SubjectOverride', ARGSRef => \%ARGS, QueueObj =>
$QueueObj->Disabled && Abort(loc("Cannot create tickets in a disabled queue."), Code => HTTP::Status::HTTP_NOT_FOUND);
+if ( $ARGS{QueueChanged} ) {
+ my %changed = map { $_ => 1 } ref $ARGS{ChangedField} eq 'ARRAY' ? @{ $ARGS{ChangedField} } : $ARGS{ChangedField}
+ if $ARGS{ChangedField};
+
+ for my $field ( qw/Content InitialPriority FinalPriority SLA Starts Due/, grep { /-CustomField-/ && !/-Magic$/ } sort keys %ARGS ) {
+ if ( !$changed{$field} ) {
+ delete $ARGS{$field};
+ delete $DECODED_ARGS->{$field}; # EditCustomField uses $DECODED_ARGS
+ }
+ }
+}
+
my $ticket = RT::Ticket->new($current_user); # empty ticket object
ProcessAttachments(ARGSRef => \%ARGS);
diff --git a/share/static/js/util.js b/share/static/js/util.js
index ddd122575f..802bd6b19f 100644
--- a/share/static/js/util.js
+++ b/share/static/js/util.js
@@ -863,6 +863,32 @@ jQuery(function() {
file_input.prop('checked', false);
});
});
+
+ jQuery('input[name=QueueChanged]').each(function() {
+ var form = jQuery(this).closest('form');
+ var mark_changed = function(name) {
+ if ( !form.find('input[name=ChangedField][value="' + name +'"]').length ) {
+ jQuery('<input type="hidden" name="ChangedField" value="' + name + '">').appendTo(form);
+ }
+ };
+
+ form.find(':input[name!=ChangedField]').change(function() {
+ mark_changed(jQuery(this).attr('name'));
+ });
+
+ var plainMessageBox = form.find('.messagebox');
+ var messageBoxId = plainMessageBox.attr('id');
+ if (CKEDITOR.instances && CKEDITOR.instances[messageBoxId]) {
+ var richTextEditor = CKEDITOR.instances[messageBoxId];
+ if ( richTextEditor ) {
+ richTextEditor.on('instanceReady', function () {
+ this.on('change', function () {
+ mark_changed(plainMessageBox.attr('name'));
+ });
+ });
+ }
+ }
+ });
});
/* inline edit */
-----------------------------------------------------------------------
hooks/post-receive
--
rt
More information about the rt-commit
mailing list