[Rt-commit] rt branch, 4.6/inline-edit, updated. rt-4.4.1-155-g3f304b2

Shawn Moore shawn at bestpractical.com
Fri Sep 16 15:24:32 EDT 2016


The branch, 4.6/inline-edit has been updated
       via  3f304b2990d44f572839b37f462eb4e4dd9c3f66 (commit)
       via  e8efb5ebbc58477badd66353e979aa7b1dc8a74f (commit)
       via  e0e1d5764076e3f3ed63d82281b97683b0dc0c21 (commit)
       via  472e5ed9d14b9b5a6f3a5655f7567aaa4dca3814 (commit)
      from  7dab12d6b4a750a6076855041b73976a0ad94e81 (commit)

Summary of changes:
 share/static/js/util.js | 37 +++++++++++++++++++++++++------------
 1 file changed, 25 insertions(+), 12 deletions(-)

- Log -----------------------------------------------------------------
commit 472e5ed9d14b9b5a6f3a5655f7567aaa4dca3814
Author: Shawn M Moore <shawn at bestpractical.com>
Date:   Fri Sep 16 19:08:35 2016 +0000

    Reset editingInlineDate sooner
    
    This way we correctly reset it to false when the form is submitted without
    any changes (meaning no POST or row refresh will be done)

diff --git a/share/static/js/util.js b/share/static/js/util.js
index fb4bb83..8286c81 100644
--- a/share/static/js/util.js
+++ b/share/static/js/util.js
@@ -596,6 +596,8 @@ jQuery(function () {
         var table = tbody.closest('table');
         var value = cell.find('.value');
 
+        inlineEditingDate = false;
+
         if (!editor.data('changed')) {
             editor.removeClass('wide');
             cell.removeClass('editing').removeAttr('height');
@@ -604,7 +606,6 @@ jQuery(function () {
 
         var params = editor.serialize();
 
-        inlineEditingDate = false;
         editor.find(':input').attr('disabled', 'disabled');
         cell.removeClass('editing').addClass('loading');
         tbody.addClass('refreshing');

commit e0e1d5764076e3f3ed63d82281b97683b0dc0c21
Author: Shawn M Moore <shawn at bestpractical.com>
Date:   Fri Sep 16 19:09:31 2016 +0000

    Bail out if there is any editing widget
    
    This helps avoid corner cases causing multiple concurrent inline edits

diff --git a/share/static/js/util.js b/share/static/js/util.js
index 8286c81..396eac2 100644
--- a/share/static/js/util.js
+++ b/share/static/js/util.js
@@ -653,7 +653,7 @@ jQuery(function () {
         var value = cell.find('.value');
         var editor = cell.find('.editor');
 
-        if (cell.hasClass('editing')) {
+        if (jQuery('td.editable.editing').length) {
             return;
         }
 

commit e8efb5ebbc58477badd66353e979aa7b1dc8a74f
Author: Shawn M Moore <shawn at bestpractical.com>
Date:   Fri Sep 16 19:10:05 2016 +0000

    Instead of inspecting the datepicker div, inspect the form fields
    
    This way we can do it instantly, without waiting for a browser tick

diff --git a/share/static/js/util.js b/share/static/js/util.js
index 396eac2..7ed245e 100644
--- a/share/static/js/util.js
+++ b/share/static/js/util.js
@@ -673,11 +673,9 @@ jQuery(function () {
 
         editor.find(':input:visible:enabled:first').focus();
 
-        setTimeout(function () {
-            if (jQuery('#ui-datepicker-div').css('display') != 'none') {
-                inlineEditingDate = true;
-            }
-        }, 0);
+        if (editor.find('.datepicker').length) {
+            inlineEditingDate = true;
+        }
     });
 
     jQuery(document).on('change', 'td.editable.editing form :input', function () {
@@ -702,9 +700,7 @@ jQuery(function () {
 
     jQuery(document).on('datepicker:close', 'td.editable.editing form .datepicker', function () {
         var editor = jQuery(this);
-        setTimeout(function () {
-            editor.closest('form').trigger('submit');
-        }, 0);
+        editor.closest('form').trigger('submit');
     });
 
     jQuery('table.collection-as-table').each(function () {

commit 3f304b2990d44f572839b37f462eb4e4dd9c3f66
Author: Shawn M Moore <shawn at bestpractical.com>
Date:   Fri Sep 16 19:11:10 2016 +0000

    Scroll wide fanout fields along with the window
    
    This is also careful to remove the onscroll event after the field is gone,
    since onscroll has performance implications

diff --git a/share/static/js/util.js b/share/static/js/util.js
index 7ed245e..d1cf489 100644
--- a/share/static/js/util.js
+++ b/share/static/js/util.js
@@ -585,6 +585,7 @@ jQuery(function () {
     };
 
     var inlineEditingDate = false;
+    var scrollHandler = null;
 
     var submitInlineEdit = function (editor) {
         if (!inlineEditEnabled) {
@@ -599,8 +600,11 @@ jQuery(function () {
         inlineEditingDate = false;
 
         if (!editor.data('changed')) {
-            editor.removeClass('wide');
             cell.removeClass('editing').removeAttr('height');
+            editor.removeClass('wide');
+            if (scrollHandler) {
+                jQuery(window).off('scroll', scrollHandler);
+            }
             return;
         }
 
@@ -622,10 +626,13 @@ jQuery(function () {
                 refreshCollectionListRow(
                     tbody,
                     table,
-                    function () { },
+                    function () {
+                        jQuery(window).off('scroll', scrollHandler);
+                    },
                     function (xhr, error) {
                         jQuery.jGrowl(error, { sticky: true, themeState: 'none' });
                         cell.addClass('error').html(loc_key('error'));
+                        jQuery(window).off('scroll', scrollHandler);
                         disableInlineEdit();
                     }
                 );
@@ -633,6 +640,7 @@ jQuery(function () {
             error   : function (xhr, error) {
                 jQuery.jGrowl(error, { sticky: true, themeState: 'none' });
                 cell.addClass('error').html(loc_key('error'));
+                jQuery(window).off('scroll', scrollHandler);
                 disableInlineEdit();
             }
         });
@@ -669,6 +677,14 @@ jQuery(function () {
             var top = rect.top - parseInt(editor.css('padding-top')) - parseInt(editor.css('border-top-width'));
             var left = rect.left - parseInt(editor.css('padding-left')) - parseInt(editor.css('border-left-width'));
             editor.css({ top: top, left: left });
+
+            var $window = jQuery(window);
+            var initialScrollTop = $window.scrollTop();
+
+            scrollHandler = function (e) {
+                editor.css('top', top + initialScrollTop - $window.scrollTop());
+            };
+            jQuery(window).scroll(scrollHandler);
         }
 
         editor.find(':input:visible:enabled:first').focus();

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


More information about the rt-commit mailing list