Преглед изворни кода

Lab/Imaging: auto-open edit-clinical after create

Vijayakrishnan пре 3 година
родитељ
комит
8a2c108c37

+ 4 - 1
public/js/option-list.js

@@ -14,7 +14,10 @@
     function init() {
         $(document)
             .off('mousedown.option-list', '.data-option-list>div')
-            .on('mousedown.option-list', '.data-option-list>div', function() {
+            .on('mousedown.option-list', '.data-option-list>div', function(_e) {
+                _e.stopPropagation();
+                _e.preventDefault();
+                markEventAsConsumed(_e);
                 $(this).parent().prev('input[data-option-list]').val('').focus();
                 document.execCommand('insertText', false, $(this).text());
                 $(this).closest('.data-option-list').hide();

+ 3 - 3
public/js/stag-popup.js

@@ -184,9 +184,9 @@ function hasResponseError(_data) {
 (function() {
     window.initStagPopupEvents = function () {
         $(document)
-            .off('click.stag-popup-discard', '.stag-popup')
-            .on('click.stag-popup-discard', '.stag-popup', function(_e) {
-                if($(_e.target).is('.stag-popup')) {
+            .off('mousedown.stag-popup-discard', '.stag-popup')
+            .on('mousedown.stag-popup-discard', '.stag-popup', function(_e) {
+                if($(_e.target).is('.stag-popup') && !isEventConsumed(_e)) {
                     closeStagPopup();
                     return false;
                 }

+ 26 - 3
resources/views/app/patient/prescriptions/list.blade.php

@@ -647,7 +647,31 @@ GROUP BY erx_category");
                         };
                         $.post('/api/erx/create', payload, _data => {
                             if(!hasResponseError(_data)) {
-                                fastReload();
+                                // fastReload();
+
+                                // don't reload the page; add new obj to list and open it's edit-clinical
+                                if(!this.prescriptions) {
+                                    this.prescriptions = [];
+                                }
+                                this.prescriptions.unshift({
+                                    clinical_detail_json: null,
+                                    created_at_friendly: "{{friendly_date(date('Y-m-d'))}}",
+                                    created_at_friendly_short: "{{friendly_date(date('Y-m-d'))}}",
+                                    erx_category: "LAB",
+                                    hcpProDisplayName: "{{$pro->displayName()}}",
+                                    hcpProUid: "{{$pro->uid}}",
+                                    hcp_pro_id: {{$pro->id}},
+                                    hcp_pro_signed_at: null,
+                                    hcp_pro_signed_by_session_id: null,
+                                    note_id: {{$note->id}},
+                                    uid: _data.data,
+                                    version_number: 1,
+                                });
+                                this.currentPrescription = this.prescriptions[0];
+
+                                Vue.nextTick(() => {
+                                    this.editClinicalDetails(this.currentPrescription);
+                                });
                             }
                         }, 'json');
                         return false;
@@ -930,8 +954,7 @@ GROUP BY erx_category");
                                         // debugger
                                         toastr.success('Prescription updated');
                                         closeStagPopup();
-                                        // fastReload();
-
+                                        fastReload();
                                     }
                                 }, 'json');
                                 break;