Reactive state cookie

This commit is contained in:
2022-09-26 18:33:21 -04:00
parent 030487d728
commit 6ae57cfd79
5 changed files with 39 additions and 32 deletions

View File

@@ -45,7 +45,7 @@
</template>
<script>
import cookie from './cookie.mjs';
import { state } from './vistax.mjs';
import { groupByArray, strtr_unscramble, strHashHSL, strftime_vista, debounce } from './util.mjs';
import ViewResourceLookup from './ViewResourceLookup.vue';
@@ -62,7 +62,7 @@
client: Object
},
data() {
var resources = cookie.get('vista.resources');
var resources = state.resources;
var today = dateonly(new Date());
return {
selection: resources ? (resources.split(',').filter(x => x) || []) : [],
@@ -95,7 +95,7 @@
},
created() {
this.debounced_selection = debounce(async function(value) {
cookie.set('vista.resources', value.join(','), 7);
state.resources = value.join(',');
var patients = this.selection.length > 0 ? groupByArray(await this.client.SDEC_CLINLET(this.selection.join('|') + '|', strftime_vista(this.date_begin), strftime_vista(this.date_end)), x => x.HRN) : [], now = new Date(), group, values, appt;
for(var i = patients.length - 1; i >= 0; --i) {
group = patients[i];