Просмотр исходного кода

Merge branch 'dev' of rav.triplestart.com:jmudaka/stagfe2 into dev

Josh 4 лет назад
Родитель
Сommit
75091ba927
1 измененных файлов с 12 добавлено и 6 удалено
  1. 12 6
      resources/views/app/patient/note/section_script.blade.php

+ 12 - 6
resources/views/app/patient/note/section_script.blade.php

@@ -48,11 +48,6 @@
                 doSave($(this).closest('.note-section'));
             });
 
-            // [name="data"] change listener
-            $('.note-section input[name="data"], .note-section input[name="items"]').each(function() {
-                initChangeListener($(this));
-            });
-
             @if(isset($guestAccessCode))
                 $('.note-section form').append("<input type='hidden' name='guest_access_code' value='{{$guestAccessCode}}'/>");
             @endif
@@ -67,6 +62,11 @@
                     toastr.success("The link " + copyText.val() + " has been copied to the clipboard");
                     return false;
                 });
+
+            // [name="data"] change listener
+            $('.note-section input[name="data"], .note-section input[name="items"]').each(function() {
+                initChangeListener($(this));
+            });
         }
 
         const debounce = (func, wait) => {
@@ -128,7 +128,13 @@
 
         function initChangeListener(_elem) {
             new MutationObserver(debounce(function() {
-                    doSave(_elem.closest('.note-section'))
+                    if(_elem.closest('.note-section').is('.edit')) {
+                        console.log('ALIX: In edit mode. Auto-saving', _elem.closest('.note-section').attr('data-section-template-name'))
+                        doSave(_elem.closest('.note-section'))
+                    }
+                    else {
+                        console.log('ALIX: Not in edit mode. Not auto-saving', _elem.closest('.note-section').attr('data-section-template-name'))
+                    }
                 }, 250))
                 .observe(_elem[0], {
                     attributes: true