Samson Mutunga 3 years ago
parent
commit
ebbd3b1f03

+ 6 - 0
public/css/style.css

@@ -3046,4 +3046,10 @@ body .vakata-context .vakata-context-separator>a {
 }
 [draggable] {
     cursor:all-scroll;
+}
+body.forced-masking {
+    opacity: 0.6 !important;
+}
+body.forced-masking #mask {
+    display: block !important;
 }

+ 25 - 3
resources/views/app/practice-management/visit-templates/visit-template-segment-templates/index.blade.php

@@ -87,7 +87,7 @@ var draggableVisitTemplateSegmentTemplates = null;
 
         recalculateRowsPositionIndexes: function(table, leftRightPosition){
             var self = this;
-            showMask();
+            self.forceShowMask();
             var currentRowsData = [];
             var rows = $(table).find('tbody tr');
             $.each(rows, function(i, row){
@@ -137,7 +137,11 @@ var draggableVisitTemplateSegmentTemplates = null;
                     toastr.error(response.message);
                 }
             }
+            
             fastReload();
+            setTimeout(function(){
+                self.forceHideMask();
+            },1000);
         },
         initDraggableTable: function(){
             var self = this;
@@ -173,19 +177,26 @@ var draggableVisitTemplateSegmentTemplates = null;
         },
         updateDraggedDeactivatedRecord: function(position){
             var self = this;
-            showMask();
+            self.forceShowMask();
             var positionUrl = position == 'LEFT' ? 'moveToLeft':'moveToRight';
-            $.post('/api/visitTemplateSegmentTemplate/reactivate', {uid: self.draggedDeactivatedRecordUid, memo:'Restored by drag & drop'}, function(response){
+            $.post('/api/visitTemplateSegmentTemplate/reactivate', {uid: self.draggedDeactivatedRecordUid, memo:''}, function(response){
                 if(response.success){
                   $.post('/api/visitTemplateSegmentTemplate/'+positionUrl, {uid:self.draggedDeactivatedRecordUid}, function(res){
                       if(res.success){
                           self.draggedDeactivatedRecordUid = null;
                           fastReload();
+                          self.forceHideMask();
                       }
                   },'json');  
                 }
             },'json');            
         },
+        forceShowMask: function(){
+            $('body').addClass('forced-masking');
+        },
+        forceHideMask: function(){
+            $('body').removeClass('forced-masking');
+        },
         init: function(){
             this.initDraggableTable();
             this.initOnDroppableSection();
@@ -199,6 +210,17 @@ var draggableVisitTemplateSegmentTemplates = null;
         (function() {
             function init() {
                 draggableVisitTemplateSegmentTemplates.init();
+                addMCHook('reArrangePositionIndexes', function() {
+                    draggableVisitTemplateSegmentTemplates.forceShowMask();
+                    fastReload();
+                    setTimeout(function(){
+                        var tables = $('.table-dnd');
+                        $.each(tables, function(i, table){
+                            var tableLeftRightPosition = $(table).data('position');
+                            draggableVisitTemplateSegmentTemplates.recalculateRowsPositionIndexes(table, tableLeftRightPosition);
+                        });
+                    },500);
+                });
             }
             addMCInitializer('visitTemplateSegmentTemplates', init, '#visitTemplateSegmentTemplates')
 

+ 1 - 1
resources/views/app/practice-management/visit-templates/visit-template-segment-templates/switch-position.blade.php

@@ -6,7 +6,7 @@
 		<span class="text-secondary" title="Move to Left"><i class="fas fa-hand-point-left"></i></span>
 		@endif
 	</a>
-	<form url="{{ @$position == 'LEFT' ? '/api/visitTemplateSegmentTemplate/moveToRight' : '/api/visitTemplateSegmentTemplate/moveToLeft' }}" class="mt-2" right>
+	<form url="{{ @$position == 'LEFT' ? '/api/visitTemplateSegmentTemplate/moveToRight' : '/api/visitTemplateSegmentTemplate/moveToLeft' }}" class="mt-2" hook="reArrangePositionIndexes" right>
 		<input type="hidden" name="uid" value="{{ $template->uid }}">
 		<div class="mb-2 w-100">
 			<label>Are you sure?</label>