ソースを参照

Custom items logic updtes

Vijayakrishnan 3 年 前
コミット
510cf17288

+ 1 - 1
resources/views/app/patient/segment-templates/_custom_items/edit.blade.php

@@ -27,7 +27,7 @@
                            v-model="item.value">
                     <div class="ml-2 pr-3">
                         <div>
-                            <span class="mr-2">@{{ item.label }}</span>
+                            <span class="mr-2 custom-item">@{{ item.label }}</span>
                             <div moe relative no-mask v-show="item.value" >
                                 <a href="#" start show>
                                     <i class="fa-comment" :class="item.comments ? 'fas' : 'far'"></i>

+ 55 - 0
resources/views/app/patient/segment-templates/_custom_items/script.blade.php

@@ -0,0 +1,55 @@
+saveCustomItem: function(_label) {
+    if(!_label) return false;
+    let self = this;
+
+    // check for duplicates
+    let found = false;
+    $(this.$el).find('.common-item').each(function() {
+        if($.trim($(this).text()).toLowerCase() === $.trim(_label).toLowerCase()) {
+            found = true;
+            return false;
+        }
+    });
+    if(found) {
+        toastr.error(_label + ' is already available in common items.');
+        return false;
+    }
+    found = false;
+    $(this.$el).find('.custom-item').each(function() {
+        if($.trim($(this).text()).toLowerCase() === $.trim(_label).toLowerCase()) {
+            found = true;
+            return false;
+        }
+    });
+    if(found) {
+        toastr.error(_label + ' is already available in custom items.');
+        return false;
+    }
+
+    showMask();
+    $.post('/api/clientCanvasCustomItem/create', {
+        proUid: '{{ $pro->uid }}',
+        key: self.itemKey,
+        label: _label
+    }, function(_data) {
+        hideMask();
+        if(_data && _data.success) {
+            hideMoeFormMask();
+            $('[custom-item-form]').hide();
+            self.customFields.push({
+                label: _label,
+                value: '',
+                comments: '',
+            });
+        }
+        else {
+            toastr.error(_data.message);
+        }
+    }, 'json')
+    return false;
+},
+cancelCustomItem: function() {
+    hideMoeFormMask();
+    $('[custom-item-form]').hide();
+    return false;
+},

+ 4 - 32
resources/views/app/patient/segment-templates/history_social/edit.blade.php

@@ -83,7 +83,7 @@ for ($i = 0; $i < count($fields); $i++) {
                                                    v-model="common['{{$fName}}']">
                                             <div class="ml-2">
                                                 <div>
-                                                    <span class="mr-2">{{ $values[$k] }}</span>
+                                                    <span class="mr-2 common-item">{{ $values[$k] }}</span>
                                                     <div moe relative no-mask v-show="common['{{$fName}}']" >
                                                         <a href="#" start show>
                                                             <i class="fa-comment" :class="common['{{$fName}}__comments'] ? 'fas' : 'far'"></i>
@@ -185,6 +185,8 @@ for ($i = 0; $i < count($fields); $i++) {
                 return a.label.localeCompare(b.label);
             });
 
+            model.itemKey = 'sochx';
+
             new Vue({
                 el: '#edit-univ_history_social-container',
                 delimiters: ["@{{","}}"],
@@ -203,37 +205,7 @@ for ($i = 0; $i < count($fields); $i++) {
                     }
                 },
                 methods: {
-                    saveCustomItem: function(_label) {
-                        if(!_label) return false;
-                        showMask();
-                        let self = this;
-                        $.post('/api/clientCanvasCustomItem/create', {
-                            proUid: '{{ $pro->uid }}',
-                            key: 'sochx',
-                            label: _label
-                        }, function(_data) {
-                            hideMask();
-                            if(_data && _data.success) {
-                                hideMoeFormMask();
-                                $('[custom-item-form]').hide();
-                                // $('.custom-items-container').closest('.visit-segment').find('.refresh-segment').trigger('click');
-                                self.customFields.push({
-                                    label: _label,
-                                    value: '',
-                                    comments: '',
-                                });
-                            }
-                            else {
-                                toastr.error(_data.message);
-                            }
-                        }, 'json')
-                        return false;
-                    },
-                    cancelCustomItem: function() {
-                        hideMoeFormMask();
-                        $('[custom-item-form]').hide();
-                        return false;
-                    }
+                    @include('app.patient.segment-templates._custom_items.script')
                 }
             });
 

+ 4 - 32
resources/views/app/patient/segment-templates/history_surgical/edit.blade.php

@@ -83,7 +83,7 @@ for ($i = 0; $i < count($fields); $i++) {
                                                    v-model="common['{{$fName}}']">
                                             <div class="ml-2">
                                                 <div>
-                                                    <span class="mr-2">{{ $values[$k] }}</span>
+                                                    <span class="mr-2 common-item">{{ $values[$k] }}</span>
                                                     <div moe relative no-mask v-show="common['{{$fName}}']" >
                                                         <a href="#" start show>
                                                             <i class="fa-comment" :class="common['{{$fName}}__comments'] ? 'fas' : 'far'"></i>
@@ -185,6 +185,8 @@ for ($i = 0; $i < count($fields); $i++) {
                 return a.label.localeCompare(b.label);
             });
 
+            model.itemKey = 'pshx';
+
             new Vue({
                 el: '#edit-univ_history_surgical-container',
                 delimiters: ["@{{","}}"],
@@ -203,37 +205,7 @@ for ($i = 0; $i < count($fields); $i++) {
                     }
                 },
                 methods: {
-                    saveCustomItem: function(_label) {
-                        if(!_label) return false;
-                        showMask();
-                        let self = this;
-                        $.post('/api/clientCanvasCustomItem/create', {
-                            proUid: '{{ $pro->uid }}',
-                            key: 'pshx',
-                            label: _label
-                        }, function(_data) {
-                            hideMask();
-                            if(_data && _data.success) {
-                                hideMoeFormMask();
-                                $('[custom-item-form]').hide();
-                                // $('.custom-items-container').closest('.visit-segment').find('.refresh-segment').trigger('click');
-                                self.customFields.push({
-                                    label: _label,
-                                    value: '',
-                                    comments: '',
-                                });
-                            }
-                            else {
-                                toastr.error(_data.message);
-                            }
-                        }, 'json')
-                        return false;
-                    },
-                    cancelCustomItem: function() {
-                        hideMoeFormMask();
-                        $('[custom-item-form]').hide();
-                        return false;
-                    }
+                    @include('app.patient.segment-templates._custom_items.script')
                 }
             });
 

+ 4 - 32
resources/views/app/patient/segment-templates/past_medical_history/edit.blade.php

@@ -113,7 +113,7 @@ for ($i = 0; $i < count($fields); $i++) {
                                                    v-model="common['{{$fName}}']">
                                             <div class="ml-2">
                                                 <div>
-                                                    <span class="mr-2">{{ $values[$k] }}</span>
+                                                    <span class="mr-2 common-item">{{ $values[$k] }}</span>
                                                     <div moe relative no-mask v-show="common['{{$fName}}']" >
                                                         <a href="#" start show>
                                                             <i class="fa-comment" :class="common['{{$fName}}__comments'] ? 'fas' : 'far'"></i>
@@ -225,6 +225,8 @@ for ($i = 0; $i < count($fields); $i++) {
                 return a.label.localeCompare(b.label);
             });
 
+            model.itemKey = 'pmhx';
+
             new Vue({
                 el: '#edit-univ_history_past_medical-container',
                 delimiters: ["@{{","}}"],
@@ -243,37 +245,7 @@ for ($i = 0; $i < count($fields); $i++) {
                     }
                 },
                 methods: {
-                    saveCustomItem: function(_label) {
-                        if(!_label) return false;
-                        showMask();
-                        let self = this;
-                        $.post('/api/clientCanvasCustomItem/create', {
-                            proUid: '{{ $pro->uid }}',
-                            key: 'pmhx',
-                            label: _label
-                        }, function(_data) {
-                            hideMask();
-                            if(_data && _data.success) {
-                                hideMoeFormMask();
-                                $('[custom-item-form]').hide();
-                                // $('.custom-items-container').closest('.visit-segment').find('.refresh-segment').trigger('click');
-                                self.customFields.push({
-                                    label: _label,
-                                    value: '',
-                                    comments: '',
-                                });
-                            }
-                            else {
-                                toastr.error(_data.message);
-                            }
-                        }, 'json')
-                        return false;
-                    },
-                    cancelCustomItem: function() {
-                        hideMoeFormMask();
-                        $('[custom-item-form]').hide();
-                        return false;
-                    }
+                    @include('app.patient.segment-templates._custom_items.script')
                 }
             });