Browse Source

Tickets v1 (wip) - Fix "colors of undefined" timing bug

Vijayakrishnan 4 years ago
parent
commit
21dceeb501

+ 63 - 66
resources/views/app/patient/tickets.blade.php

@@ -142,6 +142,7 @@
                         newProUid: '',
                         reloading: false,
                         comment: '',
+                        preparing: false,
 
                         // debounced auto-saver
                         <?php for ($i=0; $i<count($categories); $i++) { ?>
@@ -186,23 +187,69 @@
                     },
                     methods: {
 
-                        erxShowPopup: function(_item) {
-                            this.erxPopupMode = _item ? 'edit' : 'add';
-                            this.erxPopupItem = _item ? JSON.parse(JSON.stringify(_item)) : JSON.parse(JSON.stringify(this.erxModel));
-                            this.erxPopupItem.assigned_pro_uid = '';
-                            this.erxPopupItem.ordering_pro_uid = '';
-                            if(!this.erxPopupItem.comments) this.erxPopupItem.comments = [];
+                        // common show popup
+                        preparePopup: function(_type, _item) {
+                            this.preparing = true;
+                            this[_type + 'PopupMode'] = _item ? 'edit' : 'add';
+                            this[_type + 'PopupItem'] = _item ? JSON.parse(JSON.stringify(_item)) : JSON.parse(JSON.stringify(this[_type + 'Model']));
+                            this[_type + 'PopupItem'].assigned_pro_uid = '';
+                            this[_type + 'PopupItem'].ordering_pro_uid = '';
+                            if(!this[_type + 'PopupItem'].data.comments) {
+                                this[_type + 'PopupItem'].data.comments = [];
+                            }
+                            else if(this[_type + 'PopupItem'].data.comments.length === 1 && !this[_type + 'PopupItem'].data.comments[0].pro_id) {
+                                this[_type + 'PopupItem'].data.comments = [];
+                            }
                             this.comment = '';
-                            showStagPopup('erx-popup', true);
+                            this.preparing = false;
+                        },
+                        reinitProSuggest: function() {
+                            $('#ticketsApp [pro-suggest-initialized]').removeAttr('pro-suggest-initialized');
+                            initProSuggest();
+                        },
+                        postShowPopup: function(_type, _item) {
+                            if (_item) {
+                                this.currentCategory = _type;
+                                this.currentItemUid = _item.uid;
+                            }
+                        },
+
+                        // category specific show popup
+                        erxShowPopup: function(_item) {
+                            this.preparePopup('erx', _item);
                             Vue.nextTick(() => {
-                                $('#ticketsApp [pro-suggest-initialized]').removeAttr('pro-suggest-initialized');
-                                initProSuggest();
-                                if (_item) {
-                                    this.currentCategory = 'erx';
-                                    this.currentItemUid = _item.uid;
-                                }
+                                showStagPopup('erx-popup', true);
+                                this.reinitProSuggest();
+                                this.postShowPopup('erx', _item);
+                            });
+                        },
+                        labShowPopup: function(_item) {
+                            this.preparePopup('lab', _item);
+                            Vue.nextTick(() => {
+                                showStagPopup('lab-popup', true);
+                                this.reinitProSuggest();
+                                this.labInitICDAutoSuggest();
+                                this.postShowPopup('lab', _item);
+                            });
+                        },
+                        imagingShowPopup: function(_item) {
+                            this.preparePopup('imaging', _item);
+                            Vue.nextTick(() => {
+                                showStagPopup('imaging-popup', true);
+                                this.reinitProSuggest();
+                                this.imagingInitICDAutoSuggest();
+                                this.postShowPopup('imaging', _item);
+                            });
+                        },
+                        equipmentShowPopup: function(_item) {
+                            this.preparePopup('equipment', _item);
+                            Vue.nextTick(() => {
+                                showStagPopup('equipment-popup', true);
+                                this.reinitProSuggest();
+                                this.postShowPopup('equipment', _item);
                             });
                         },
+
                         erxSavePopupItem: function(_autoSave = false) {
                             let form = $('#ticketsApp [stag-popup-key="erx-popup"] form').first();
                             if(!_autoSave) {
@@ -254,24 +301,7 @@
                             this.erxPopupItem.data.comments.push(comment);
                             this.erxSavePopupItem(true);
                         },
-                        labShowPopup: function(_item) {
-                            this.labPopupMode = _item ? 'edit' : 'add';
-                            this.labPopupItem = _item ? JSON.parse(JSON.stringify(_item)) : JSON.parse(JSON.stringify(this.labModel));
-                            this.labPopupItem.assigned_pro_uid = '';
-                            this.labPopupItem.ordering_pro_uid = '';
-                            if(!this.labPopupItem.comments) this.labPopupItem.comments = [];
-                            this.comment = '';
-                            showStagPopup('lab-popup', true);
-                            Vue.nextTick(() => {
-                                $('#ticketsApp [pro-suggest-initialized]').removeAttr('pro-suggest-initialized');
-                                initProSuggest();
-                                this.labInitICDAutoSuggest();
-                                if (_item) {
-                                    this.currentCategory = 'lab';
-                                    this.currentItemUid = _item.uid;
-                                }
-                            });
-                        },
+
                         labSavePopupItem: function(_autoSave = false) {
                             let form = $('#ticketsApp [stag-popup-key="lab-popup"] form').first();
                             if(!_autoSave) {
@@ -323,24 +353,7 @@
                             this.labPopupItem.data.comments.push(comment);
                             this.labSavePopupItem(true);
                         },
-                        imagingShowPopup: function(_item) {
-                            this.imagingPopupMode = _item ? 'edit' : 'add';
-                            this.imagingPopupItem = _item ? JSON.parse(JSON.stringify(_item)) : JSON.parse(JSON.stringify(this.imagingModel));
-                            this.imagingPopupItem.assigned_pro_uid = '';
-                            this.imagingPopupItem.ordering_pro_uid = '';
-                            if(!this.imagingPopupItem.comments) this.imagingPopupItem.comments = [];
-                            this.comment = '';
-                            showStagPopup('imaging-popup', true);
-                            Vue.nextTick(() => {
-                                $('#ticketsApp [pro-suggest-initialized]').removeAttr('pro-suggest-initialized');
-                                initProSuggest();
-                                this.imagingInitICDAutoSuggest();
-                                if (_item) {
-                                    this.currentCategory = 'imaging';
-                                    this.currentItemUid = _item.uid;
-                                }
-                            });
-                        },
+
                         imagingSavePopupItem: function(_autoSave = false) {
                             let form = $('#ticketsApp [stag-popup-key="imaging-popup"] form').first();
                             if(!_autoSave) {
@@ -392,23 +405,7 @@
                             this.imagingPopupItem.data.comments.push(comment);
                             this.imagingSavePopupItem(true);
                         },
-                        equipmentShowPopup: function(_item) {
-                            this.equipmentPopupMode = _item ? 'edit' : 'add';
-                            this.equipmentPopupItem = _item ? JSON.parse(JSON.stringify(_item)) : JSON.parse(JSON.stringify(this.equipmentModel));
-                            this.equipmentPopupItem.assigned_pro_uid = '';
-                            this.equipmentPopupItem.ordering_pro_uid = '';
-                            if(!this.equipmentPopupItem.comments) this.equipmentPopupItem.comments = [];
-                            this.comment = '';
-                            showStagPopup('equipment-popup', true);
-                            Vue.nextTick(() => {
-                                $('#ticketsApp [pro-suggest-initialized]').removeAttr('pro-suggest-initialized');
-                                initProSuggest();
-                                if (_item) {
-                                    this.currentCategory = 'equipment';
-                                    this.currentItemUid = _item.uid;
-                                }
-                            });
-                        },
+
                         equipmentSavePopupItem: function(_autoSave = false) {
                             let form = $('#ticketsApp [stag-popup-key="equipment-popup"] form').first();
                             if(!_autoSave) {

+ 1 - 1
resources/views/app/patient/tickets/equipment.blade.php

@@ -52,7 +52,7 @@
             </tbody>
         </table>
     </div>
-    <div class="stag-popup stag-popup-sm stag-slide mcp-theme-1" stag-popup-key="equipment-popup">
+    <div v-if="!preparing" class="stag-popup stag-popup-sm stag-slide mcp-theme-1" stag-popup-key="equipment-popup">
         <form method="POST" action="" class="p-0">
             <h3 class="stag-popup-title mb-0 p-3 bg-light">
 

+ 1 - 1
resources/views/app/patient/tickets/erx.blade.php

@@ -79,7 +79,7 @@
             </tbody>
         </table>
     </div>
-    <div class="stag-popup stag-popup-sm stag-slide mcp-theme-1" stag-popup-key="erx-popup">
+    <div v-if="!preparing" class="stag-popup stag-popup-sm stag-slide mcp-theme-1" stag-popup-key="erx-popup">
         <form method="POST" action="" class="p-0">
             <h3 class="stag-popup-title mb-0 p-3 bg-light">
                 <span class="flex-grow-1 text-nowrap overflow-hidden text-ellipsis mr-3">@{{ erxPopupMode === 'add' ? 'Add ERx Ticket' : erxPopupItem.data.medication + '  •  ' + erxPopupItem.data.strength }}</span>

+ 1 - 1
resources/views/app/patient/tickets/imaging.blade.php

@@ -52,7 +52,7 @@
             </tbody>
         </table>
     </div>
-    <div class="stag-popup stag-popup-sm stag-slide mcp-theme-1" stag-popup-key="imaging-popup">
+    <div v-if="!preparing" class="stag-popup stag-popup-sm stag-slide mcp-theme-1" stag-popup-key="imaging-popup">
         <form method="POST" action="" class="p-0">
             <h3 class="stag-popup-title mb-0 p-3 bg-light">
                 <span v-if="imagingPopupMode === 'add'" class="flex-grow-1 text-nowrap overflow-hidden text-ellipsis mr-3">Add Imaging Ticket</span>

+ 1 - 1
resources/views/app/patient/tickets/lab.blade.php

@@ -52,7 +52,7 @@
             </tbody>
         </table>
     </div>
-    <div class="stag-popup stag-popup-sm stag-slide mcp-theme-1" stag-popup-key="lab-popup">
+    <div v-if="!preparing" class="stag-popup stag-popup-sm stag-slide mcp-theme-1" stag-popup-key="lab-popup">
         <form method="POST" action="" class="p-0">
             <h3 class="stag-popup-title mb-0 p-3 bg-light">