Przeglądaj źródła

Initialize sections with default for notes created from note-template

Vijayakrishnan Krishnan 4 lat temu
rodzic
commit
a91ecf3e24

+ 10 - 0
public/css/style.css

@@ -594,3 +594,13 @@ input.search_field, textarea.search_field {
     padding: 0;
     padding: 0;
     border: 1px solid #ccc;
     border: 1px solid #ccc;
 }
 }
+.mask-text-addition {
+    position: fixed;
+    bottom: calc(50% - 60px);
+    left: 0;
+    width: 100%;
+    text-align: center;
+    font-size: 12px;
+    z-index: 9999999;
+    color: #000;
+}

+ 5 - 1
public/js/yemi.js

@@ -4,14 +4,18 @@ if (typeof focusOn == 'undefined') {
 
 
 var ajaxGoing = false;
 var ajaxGoing = false;
 
 
-var showMask = function () {
+var showMask = function (_text = '') {
     $('body').css('opacity', 0.6);
     $('body').css('opacity', 0.6);
     $('#mask').show();
     $('#mask').show();
+    if(!!_text) {
+        $('<div class="mask-text-addition" />').text('Initializing note. Please wait...').appendTo('body');
+    }
 }
 }
 
 
 var hideMask = function () {
 var hideMask = function () {
     $('body').css('opacity', 1);
     $('body').css('opacity', 1);
     $('#mask').hide();
     $('#mask').hide();
+    $('.mask-text-addition').remove();
 }
 }
 
 
 var showMoeFormMask = function () {
 var showMoeFormMask = function () {

+ 33 - 1
resources/views/app/patient/note/dashboard.blade.php

@@ -237,7 +237,9 @@
                         $shortcuts = $packed;
                         $shortcuts = $packed;
                         ?>
                         ?>
                         @foreach($note->sections as $section)
                         @foreach($note->sections as $section)
-                        <div class="p-3 border-bottom note-section">
+                        <div class="p-3 border-bottom note-section {{ $section->is_initialized ? '' : 'pending-initialization' }}"
+                             data-section-uid="{{ $section->uid }}"
+                             data-section-template-name="{{ $section->sectionTemplate->internal_name }}">
                             <div class="d-flex align-items-start">
                             <div class="d-flex align-items-start">
                                 <a class="font-weight-bold mb-2 d-flex align-items-center c-pointer">
                                 <a class="font-weight-bold mb-2 d-flex align-items-center c-pointer">
                                     {{$section->sectionTemplate->title}}
                                     {{$section->sectionTemplate->title}}
@@ -391,6 +393,9 @@
     <div class="note-templates-underlay"></div>
     <div class="note-templates-underlay"></div>
     <script>
     <script>
         (function() {
         (function() {
+
+            let numSectionsPendingInitialization = 0;
+
             function init() {
             function init() {
                 $('textarea[rte]').each(function() {
                 $('textarea[rte]').each(function() {
 
 
@@ -635,6 +640,33 @@
                         return false;
                         return false;
                     });
                     });
 
 
+                let sectionsPendingInitialization = $('.note-section.pending-initialization');
+                numSectionsPendingInitialization = sectionsPendingInitialization.length;
+                if(numSectionsPendingInitialization > 0) {
+                    showMask('Initializing note. Please wait...');
+                    sectionsPendingInitialization.each(function() {
+                        initializeSection(
+                            $(this).attr('data-section-uid'),
+                            $(this).attr('data-section-template-name')
+                        );
+                    });
+                }
+
+            }
+
+            function initializeSection(_sectionUid, _sectionTemplateName) {
+                $.get('/get-default-section-data/' + _sectionTemplateName + '/{{$patient->uid}}' , function(_data) {
+                    $.post('/process_form_submit', {
+                        section_uid: _sectionUid,
+                        value: _data.value
+                    }, function(_data) {
+                        console.log('done: ', _sectionTemplateName);
+                        numSectionsPendingInitialization--;
+                        if(numSectionsPendingInitialization <= 0) {
+                            fastReload();
+                        }
+                    });
+                }, 'json');
             }
             }
 
 
             function loadTemplateSet(_chooser) {
             function loadTemplateSet(_chooser) {