|
@@ -7,6 +7,13 @@ if(!$contentData || !isset($contentData['items']) || !count($contentData['items'
|
|
|
"strength" => "",
|
|
|
"frequency" => "",
|
|
|
"detail" => "",
|
|
|
+ "notes" => ["", ""],
|
|
|
+
|
|
|
+ "type" => "",
|
|
|
+ "updated_note_uid" => "",
|
|
|
+ "created_note_uid" => "",
|
|
|
+ "removed_note_uid" => "",
|
|
|
+
|
|
|
]
|
|
|
]
|
|
|
];
|
|
@@ -52,7 +59,7 @@ $formID = rand(0, 100000);
|
|
|
<thead>
|
|
|
<tr class="bg-light">
|
|
|
<th class="px-2 text-secondary border-bottom-0 width-30px text-center">#</th>
|
|
|
- <th class="px-2 text-secondary border-bottom-0 width-30px text-center">Active</th>
|
|
|
+ <th class="px-2 text-secondary border-bottom-0 width-30px text-left">Type</th>
|
|
|
<th class="px-2 text-secondary border-bottom-0 w-25">
|
|
|
<div class="d-flex align-items-center font-weight-normal">
|
|
|
<span>Title</span>
|
|
@@ -90,13 +97,10 @@ $formID = rand(0, 100000);
|
|
|
</tr>
|
|
|
</thead>
|
|
|
<tbody>
|
|
|
- <tr v-for="(item, index) in items">
|
|
|
- <td class="px-2 pt-2 text-center text-sm font-weight-bold">@{{ index + 1 }}</td>
|
|
|
- <td>
|
|
|
- <label class="d-block text-center py-2">
|
|
|
- <input type="checkbox" v-model="item.is_currently_active">
|
|
|
- </label>
|
|
|
- </td>
|
|
|
+ <tr v-for="(item, index) in items" :class="item.type === 'removed' ? 'on-hover-opaque' : ''">
|
|
|
+ <td class="px-2 pt-2 text-center font-weight-bold text-secondary">@{{ index + 1 }}</td>
|
|
|
+ <td class="px-2 pt-2 text-left text-capitalize text-nowrap" :data-type="item.type"
|
|
|
+ v-html="(item.type === 'prescribed today' || item.type === 'updated' ? '*' : '') + ' ' + item.type"></td>
|
|
|
<td>
|
|
|
<input type="text" :data-index="index"
|
|
|
class="form-control form-control-sm canvas-rx-title"
|
|
@@ -123,31 +127,36 @@ $formID = rand(0, 100000);
|
|
|
<textarea class="form-control form-control-sm" v-model="item.notes[item.notes.length-1].text"></textarea>
|
|
|
</td>
|
|
|
<td class="px-2 text-nowrap">
|
|
|
- <a href="#"
|
|
|
- v-if="!isFavorite(item)" v-on:click.prevent="addToFavorites(item)"
|
|
|
- class="mt-1 d-inline-block mr-1 text-secondary on-hover-opaque"
|
|
|
- title="Add to favorites">
|
|
|
- <i class="fa fa-star"></i>
|
|
|
- </a>
|
|
|
- <a href="#"
|
|
|
- v-if="isFavorite(item)" v-on:click.prevent="removeFromFavorites(item)"
|
|
|
- class="mt-1 d-inline-block mr-1 text-warning"
|
|
|
- title="Remove from favorites">
|
|
|
- <i class="fa fa-star"></i>
|
|
|
- </a>
|
|
|
- <a href="#" v-on:click.prevent="removeItem(index)"
|
|
|
- class="on-hover-opaque text-danger mt-1 d-inline-block">
|
|
|
- <i class="fa fa-trash-alt"></i>
|
|
|
- </a>
|
|
|
+ <div v-if="item.type !== 'removed'">
|
|
|
+ <a href="#"
|
|
|
+ v-if="!isFavorite(item)" v-on:click.prevent="addToFavorites(item)"
|
|
|
+ class="mt-1 d-inline-block mr-1 text-secondary on-hover-opaque"
|
|
|
+ title="Add to favorites">
|
|
|
+ <i class="fa fa-star"></i>
|
|
|
+ </a>
|
|
|
+ <a href="#"
|
|
|
+ v-if="isFavorite(item)" v-on:click.prevent="removeFromFavorites(item)"
|
|
|
+ class="mt-1 d-inline-block mr-1 text-warning"
|
|
|
+ title="Remove from favorites">
|
|
|
+ <i class="fa fa-star"></i>
|
|
|
+ </a>
|
|
|
+ <a href="#" v-on:click.prevent="removeItem(index)"
|
|
|
+ class="on-hover-opaque text-danger mt-1 d-inline-block">
|
|
|
+ <i class="fa fa-trash-alt"></i>
|
|
|
+ </a>
|
|
|
+ </div>
|
|
|
</td>
|
|
|
</tr>
|
|
|
</tbody>
|
|
|
</table>
|
|
|
|
|
|
- <div class="form-group my-2">
|
|
|
- <button type="button" class="btn btn-sm btn-default text-primary border border-primary mr-2"
|
|
|
- v-on:click.prevent="addItem()"
|
|
|
- >+ New Entry</button>
|
|
|
+ <div class="form-group my-2 d-flex">
|
|
|
+ <button type="button" class="btn btn-sm btn-default text-success border border-success mr-2"
|
|
|
+ v-on:click.prevent="addItem('prescribed today')"
|
|
|
+ >+ Entry: <b>Prescribed Today</b></button>
|
|
|
+ <button type="button" class="btn btn-sm btn-default text-primary border border-primary mr-2"
|
|
|
+ v-on:click.prevent="addItem('existing')"
|
|
|
+ >+ Entry: <b>Existing</b></button>
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
@@ -157,11 +166,12 @@ $formID = rand(0, 100000);
|
|
|
for (let i = 0; i < favorites.length; i++) {
|
|
|
favorites[i].data = JSON.parse(favorites[i].data);
|
|
|
}
|
|
|
- let dbItems = <?= json_encode($contentData['items']) ?>;
|
|
|
+ let dbItems = <?= json_encode($contentData['items']) ?>,
|
|
|
+ originalItems = JSON.parse(JSON.stringify(dbItems));
|
|
|
for (let i = 0; i < dbItems.length; i++) {
|
|
|
- if(typeof dbItems[i].is_currently_active === 'undefined') {
|
|
|
- dbItems[i].is_currently_active = true;
|
|
|
- }
|
|
|
+ // if(typeof dbItems[i].is_currently_active === 'undefined') {
|
|
|
+ // dbItems[i].is_currently_active = true;
|
|
|
+ // }
|
|
|
if(typeof dbItems[i].notes === 'undefined') {
|
|
|
dbItems[i].notes = [];
|
|
|
}
|
|
@@ -169,6 +179,9 @@ $formID = rand(0, 100000);
|
|
|
date: '{{@$note ? $note->effective_dateest : date('Y-m-d')}}',
|
|
|
text: '',
|
|
|
});
|
|
|
+ if(dbItems[i].type !== 'removed' && dbItems[i].updated_note_uid !== '{{@$note->uid}}') {
|
|
|
+ dbItems[i].type = 'existing';
|
|
|
+ }
|
|
|
}
|
|
|
function init() {
|
|
|
window.clientRXApp_{{$formID}} = new Vue({
|
|
@@ -176,6 +189,7 @@ $formID = rand(0, 100000);
|
|
|
data: {
|
|
|
items: dbItems,
|
|
|
favorites: favorites,
|
|
|
+ skipWatcher: false,
|
|
|
},
|
|
|
mounted: function() {
|
|
|
this.initRTE();
|
|
@@ -186,6 +200,25 @@ $formID = rand(0, 100000);
|
|
|
watch: {
|
|
|
$data: {
|
|
|
handler: function(val, oldVal) {
|
|
|
+ if(this.skipWatcher) {
|
|
|
+ console.log('ALIX skipWatcher');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ /*// if any "existing" item has changes, change it to "updated"
|
|
|
+ this.skipWatcher = true;
|
|
|
+ for (let i = 0; i < this.items.length; i++) {
|
|
|
+ let item = this.items[i];
|
|
|
+ if(item.type === 'existing') {
|
|
|
+ if(item.title !== originalItems[i].title ||
|
|
|
+ item.strength !== originalItems[i].strength ||
|
|
|
+ item.frequency !== originalItems[i].frequency ||
|
|
|
+ item.detail !== originalItems[i].detail) {
|
|
|
+ item.type = 'updated';
|
|
|
+ item.updated_note_uid = '{{@$note->uid}}';
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.skipWatcher = false;*/
|
|
|
let payload = JSON.parse(JSON.stringify(this.cleanArray(this.items)));
|
|
|
for (let i = 0; i < payload.length; i++) {
|
|
|
payload[i].notes = payload[i].notes.filter(_x => {
|
|
@@ -200,9 +233,10 @@ $formID = rand(0, 100000);
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
- addItem: function() {
|
|
|
+ addItem: function(_type) {
|
|
|
let self = this;
|
|
|
this.items.push({
|
|
|
+ type: _type,
|
|
|
title: '',
|
|
|
strength: '',
|
|
|
frequency: '',
|
|
@@ -213,7 +247,9 @@ $formID = rand(0, 100000);
|
|
|
date: '{{@$note ? $note->effective_dateest : date('Y-m-d')}}',
|
|
|
text: '',
|
|
|
}
|
|
|
- ]
|
|
|
+ ],
|
|
|
+ created_note_uid: '{{@$note->uid}}',
|
|
|
+ updated_note_uid: '{{@$note->uid}}',
|
|
|
});
|
|
|
Vue.nextTick(function() {
|
|
|
self.initRTE();
|
|
@@ -222,7 +258,19 @@ $formID = rand(0, 100000);
|
|
|
});
|
|
|
},
|
|
|
removeItem: function(_index) {
|
|
|
- this.items.splice(_index, 1);
|
|
|
+ let item = this.items[_index];
|
|
|
+ debugger
|
|
|
+ if(item.type === 'prescribed today') {
|
|
|
+ this.items.splice(_index, 1);
|
|
|
+ }
|
|
|
+ else if(item.type === 'existing') {
|
|
|
+ if(!(item.notes[item.notes.length - 1].text)) {
|
|
|
+ alert('Please provide reason for removal/discontinuing.');
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ item.type = 'removed';
|
|
|
+ item.removed_note_uid = '{{@$note->uid}}';
|
|
|
+ }
|
|
|
},
|
|
|
cleanArray: function(_source) {
|
|
|
let plItems = [], plObject = {};
|