[Rt-commit] rt branch, 4.6/inline-edit, updated. rt-4.4.1-189-gcd80a38

Shawn Moore shawn at bestpractical.com
Wed Jan 18 19:39:14 EST 2017


The branch, 4.6/inline-edit has been updated
       via  cd80a38e9a29813ad79c5f87611a5eec70132db3 (commit)
      from  690d31a967b97ab028964352576b4022f4729cde (commit)

Summary of changes:
 share/html/Ticket/Elements/EditBasics  |  5 +++++
 share/html/Ticket/Elements/ShowSummary |  2 +-
 share/static/js/util.js                | 40 ++++++++++++++++++++++++++++++++++
 3 files changed, 46 insertions(+), 1 deletion(-)

- Log -----------------------------------------------------------------
commit cd80a38e9a29813ad79c5f87611a5eec70132db3
Author: Shawn M Moore <shawn at bestpractical.com>
Date:   Thu Jan 19 00:34:47 2017 +0000

    When submitting an inline edit form, include all forms' fields
    
    This way if the user edits multiple fields in different inline edit
    panels, the page submits all of the fields in each of the panels to the
    server.
    
    The usual approach of using a single <form> element surrounding the
    entire ticket display page wouldn't work because existing forms (like
    create reminders, and create linked ticket in queue) would cause nested
    forms, which is unsupported in HTML.
    
    We exclude owner and single-member custom roles from the Basics panel so
    that we don't offer multiple form inputs for the same field.
    
    Fixes: T#179970

diff --git a/share/html/Ticket/Elements/EditBasics b/share/html/Ticket/Elements/EditBasics
index 89d5ffe..958deb5 100644
--- a/share/html/Ticket/Elements/EditBasics
+++ b/share/html/Ticket/Elements/EditBasics
@@ -52,6 +52,7 @@ $QueueObj => undef
 $InTable => 0
 %defaults => ()
 $ExcludeCustomRoles => 0
+$ExcludeOwner => 0
 </%ARGS>
 <%INIT>
 if ($TicketObj) {
@@ -153,6 +154,10 @@ unless ($ExcludeCustomRoles) {
     }
 }
 
+if ($ExcludeOwner) {
+    @fields = grep { ($_->{name}||'') ne 'Owner' } @fields;
+}
+
 # inflate the marker for custom roles into the field specs for each one
 @fields = map { ($_->{special}||'') eq 'roles' ? @role_fields : $_ } @fields;
 
diff --git a/share/html/Ticket/Elements/ShowSummary b/share/html/Ticket/Elements/ShowSummary
index 4e5805a..3ab6aec 100644
--- a/share/html/Ticket/Elements/ShowSummary
+++ b/share/html/Ticket/Elements/ShowSummary
@@ -71,7 +71,7 @@ my $modify_behavior = $InlineEdit ? ($inline_edit_behavior{Basics} || $inline_ed
             <form class="inline-edit" action="<%RT->Config->Get('WebPath')%>/Ticket/Display.html" method="post">
                 <input type="hidden" class="hidden" name="id" value="<% $Ticket->id %>" />
                 <table>
-                    <& /Ticket/Elements/EditBasics, TicketObj => $Ticket, InTable => 1 &>
+                    <& /Ticket/Elements/EditBasics, TicketObj => $Ticket, InTable => 1, ExcludeOwner => 1, ExcludeCustomRoles => 1 &>
                     <& /Elements/EditCustomFields, Object => $Ticket, Grouping => 'Basics', InTable => 1 &>
                 </table>
                 <div align="right"><input type="submit" class="button" value="<&|/l&>Save</&>" /></div>
diff --git a/share/static/js/util.js b/share/static/js/util.js
index 4b73134..35d5901 100644
--- a/share/static/js/util.js
+++ b/share/static/js/util.js
@@ -813,6 +813,46 @@ jQuery(function () {
         }
         toggle_inline_edit(container.find('.inline-edit-toggle'));
     });
+
+    /* on submit, pull in all the other inline edit forms' fields into
+     * the currently-being-submitted form. that way we don't lose user
+     * input */
+    jQuery('form.inline-edit').submit(function (e) {
+        var currentForm = jQuery(this);
+
+        /* limit to currently-editing forms, since cancelling inline
+         * edit merely hides the form */
+        jQuery('.titlebox.editing form.inline-edit').each(function () {
+            var siblingForm = jQuery(this);
+
+            if (siblingForm.is(currentForm)) {
+                return;
+            }
+
+            siblingForm.find(':input').each(function () {
+                var field = jQuery(this);
+
+                if (field.attr('name') == "") {
+                    return;
+                }
+
+                /* skip duplicates, such as ticket id */
+                if (currentForm.find('[name="' + field.attr('name') + '"]').length > 0) {
+                    return;
+                }
+
+                var clone = field.clone().hide().appendTo(currentForm);
+
+                /* "For performance reasons, the dynamic state of certain
+                 * form elements (e.g., user data typed into textarea
+                 * and user selections made to a select) is not copied
+                 * to the cloned elements", so manually copy them */
+                if (clone.is('select, textarea')) {
+                    clone.val(field.val());
+                }
+            });
+        });
+    });
 });
 
 // focus jquery object in window, only moving the screen when necessary

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


More information about the rt-commit mailing list