[Rt-commit] rt branch, 4.6/inline-edit, updated. rt-4.4.1-161-g351fb2b

Shawn Moore shawn at bestpractical.com
Tue Sep 20 12:12:41 EDT 2016


The branch, 4.6/inline-edit has been updated
       via  351fb2b53459483853cee8b290189eb93b63ff96 (commit)
       via  c7ead649135e1fa4d1c8559cd69b1ceb6e16367f (commit)
       via  9c27aa83db1d644a6e70d6a72187026947ce87b0 (commit)
      from  9ce8a68e19f8db68ca98ef5b23a99f97661d5ad4 (commit)

Summary of changes:
 share/html/Elements/CollectionAsTable/Row          |  7 +++-
 share/static/css/base/collection.css               | 48 ----------------------
 .../css/base/{collection.css => inline-edit.css}   | 38 +++++------------
 share/static/css/base/main.css                     |  1 +
 share/static/js/util.js                            | 21 ++++++++--
 5 files changed, 34 insertions(+), 81 deletions(-)
 copy share/static/css/base/{collection.css => inline-edit.css} (54%)

- Log -----------------------------------------------------------------
commit 9c27aa83db1d644a6e70d6a72187026947ce87b0
Author: Shawn M Moore <shawn at bestpractical.com>
Date:   Tue Sep 20 15:47:11 2016 +0000

    Move inline-edit CSS into its own file

diff --git a/share/static/css/base/collection.css b/share/static/css/base/collection.css
index a0cb272..4e4b531 100644
--- a/share/static/css/base/collection.css
+++ b/share/static/css/base/collection.css
@@ -25,51 +25,3 @@ table.collection td:first-child, table.collection th:first-child {
     content: '\a0\a0\a0\a0';
 }
 
-td.editable > .value {
-    padding-top: 0;
-}
-
-td.editable > form.editor > img.loading {
-    height: 1em;
-    width: 1em;
-}
-
-td.editable.error {
-    color: red;
-    font-weight: bold;
-}
-
-td.editable > form.editor {
-    display: none;
-}
-
-td.editable.editing > form.editor,
-td.editable.loading > form.editor {
-    display: inline-block;
-}
-
-td.editable.editing > .value,
-td.editable.loading > .value {
-    display: none;
-}
-
-td.editable > form.editor > .loading {
-    display: none;
-}
-
-td.editable.loading > form.editor > .loading {
-    display: inline-block;
-}
-
-td.editable form.editor.wide {
-    position: fixed;
-    background: white;
-    border: 1px solid black;
-    padding: 10px;
-    z-index: 2;
-}
-
-tbody.list-item.refreshing {
-    opacity: 0.5;
-}
-
diff --git a/share/static/css/base/collection.css b/share/static/css/base/inline-edit.css
similarity index 54%
copy from share/static/css/base/collection.css
copy to share/static/css/base/inline-edit.css
index a0cb272..37fa9bc 100644
--- a/share/static/css/base/collection.css
+++ b/share/static/css/base/inline-edit.css
@@ -1,30 +1,3 @@
-table.collection td:first-child, table.collection th:first-child {
-    padding-left: 1em;
-}
-
-.collection-as-table ul.cf-values {
-    margin-top: 0;
-    margin-bottom: 0;
-}
-
-.collection-as-table .user a {
-    font-weight: inherit;
-}
-
-.collection-as-table .user a:visited {
-    color: inherit;
-}
-
-.results-count {
-    font-size: smaller;
-}
-/* four nbsps. can't use margin- or padding-left since it makes a gap in
-   the <a> tag's underline on hover, and can't use regular spaces since they
-   collapse into one because it's HTML, and can't use   because it's CSS */
-.results-count::before {
-    content: '\a0\a0\a0\a0';
-}
-
 td.editable > .value {
     padding-top: 0;
 }
diff --git a/share/static/css/base/main.css b/share/static/css/base/main.css
index 40a321a..58fbcda 100644
--- a/share/static/css/base/main.css
+++ b/share/static/css/base/main.css
@@ -28,6 +28,7 @@
 @import "charts.css";
 @import "chosen.css";
 @import "ticket-timer.css";
+ at import "inline-edit.css";
 @import "print.css";
 @import "dropzone.css";
 @import "dropzone.customized.css";

commit c7ead649135e1fa4d1c8559cd69b1ceb6e16367f
Author: Shawn M Moore <shawn at bestpractical.com>
Date:   Tue Sep 20 16:11:59 2016 +0000

    Use submitInlineEdit rather than submitting the form itself

diff --git a/share/static/js/util.js b/share/static/js/util.js
index 71c04b2..6a23592 100644
--- a/share/static/js/util.js
+++ b/share/static/js/util.js
@@ -725,18 +725,18 @@ jQuery(function () {
 
     jQuery(document).on('submit', 'td.editable.editing form', function (e) {
         e.preventDefault();
-        var editor = jQuery(this);
-        submitInlineEdit(editor);
+        submitInlineEdit(jQuery(this));
     });
 
     jQuery(document).on('focusout', 'td.editable.editing form', function () {
+        var editor = jQuery(this);
         if (!inlineEditingDate) {
-            jQuery(this).trigger('submit');
+            submitInlineEdit(editor);
         }
     });
 
     jQuery(document).on('change', 'td.editable.editing form select', function () {
-        jQuery(this).closest('form').trigger('submit');
+        submitInlineEdit(jQuery(this).closest('form'));
     });
 
     jQuery(document).on('datepicker:close', 'td.editable.editing form .datepicker', function () {

commit 351fb2b53459483853cee8b290189eb93b63ff96
Author: Shawn M Moore <shawn at bestpractical.com>
Date:   Tue Sep 20 16:12:22 2016 +0000

    Button for canceling inline edit

diff --git a/share/html/Elements/CollectionAsTable/Row b/share/html/Elements/CollectionAsTable/Row
index 3d279cb..e29900a 100644
--- a/share/html/Elements/CollectionAsTable/Row
+++ b/share/html/Elements/CollectionAsTable/Row
@@ -165,8 +165,11 @@ foreach my $column (@Format) {
     $m->out('>');
 
     if ($attrs{edit}) {
-        $m->out('<form method="POST" action="'.RT->Config->Get('WebPath').'/Helpers/TicketUpdate?id='.$record->id.'" class="editor">' . $attrs{edit} . '<img class="loading" src="'.RT->Config->Get('WebPath').'/static/images/loading.gif" alt="'.loc('Loading').'"/></form>');
-        $m->out('<div class="value">');
+        $m->out('<form method="POST" action="'.RT->Config->Get('WebPath').'/Helpers/TicketUpdate?id='.$record->id.'" class="editor">');
+        $m->out($attrs{edit});
+        $m->out('<a href="#" class="cancel"><img src="'.RT->Config->Get('WebPath').'/static/images/close.png" alt="'.loc('Cancel').'" title="'.loc('Cancel').'" /></a>');
+        $m->out('<img class="loading" src="'.RT->Config->Get('WebPath').'/static/images/loading.gif" alt="'.loc('Loading').'" title="'.loc('Loading').'" />');
+        $m->out('</form><div class="value">');
     }
 
     $m->out(@out) if @out;
diff --git a/share/static/css/base/inline-edit.css b/share/static/css/base/inline-edit.css
index 37fa9bc..ef248ee 100644
--- a/share/static/css/base/inline-edit.css
+++ b/share/static/css/base/inline-edit.css
@@ -46,3 +46,14 @@ tbody.list-item.refreshing {
     opacity: 0.5;
 }
 
+td.editable > form.editor > a.cancel {
+    display: inline-block;
+    height: 100%;
+    vertical-align: middle;
+}
+
+td.editable > form.editor > a.cancel > img {
+    height: 1.5em;
+    margin: .25em;
+    border-style: none;
+}
diff --git a/share/static/js/util.js b/share/static/js/util.js
index 6a23592..e8cb4ce 100644
--- a/share/static/js/util.js
+++ b/share/static/js/util.js
@@ -667,6 +667,10 @@ jQuery(function () {
         var tbody = cell.closest('tbody');
         var table = tbody.closest('table');
 
+        if (!cell.hasClass('editing')) {
+            return;
+        }
+
         var params = editor.serialize();
 
         editor.find(':input').attr('disabled', 'disabled');
@@ -731,10 +735,19 @@ jQuery(function () {
     jQuery(document).on('focusout', 'td.editable.editing form', function () {
         var editor = jQuery(this);
         if (!inlineEditingDate) {
-            submitInlineEdit(editor);
+            // delay submit to give the `td.editable a.cancel` click handler
+            // a chance to run
+            setTimeout(function () {
+                submitInlineEdit(editor);
+            }, 100);
         }
     });
 
+    jQuery(document).on('click', 'td.editable a.cancel', function (e) {
+        e.preventDefault();
+        cancelInlineEdit(jQuery(this).closest('form'));
+    });
+
     jQuery(document).on('change', 'td.editable.editing form select', function () {
         submitInlineEdit(jQuery(this).closest('form'));
     });

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


More information about the rt-commit mailing list