Debounce
This commit is contained in:
parent
9687d9638e
commit
7f42be2e64
@ -46,7 +46,7 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import cookie from './cookie.mjs';
|
import cookie from './cookie.mjs';
|
||||||
import { groupByArray, strHashHSL, strftime_vista } from './util.mjs';
|
import { groupByArray, strHashHSL, strftime_vista, debounce } from './util.mjs';
|
||||||
|
|
||||||
import ViewResourceLookup from './ViewResourceLookup.vue';
|
import ViewResourceLookup from './ViewResourceLookup.vue';
|
||||||
|
|
||||||
@ -91,7 +91,21 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
async selection(value) {
|
selection(value) {
|
||||||
|
this.debounced_selection(value);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
strHashHSL,
|
||||||
|
unscramble(name) {
|
||||||
|
return name.length > 0 ? (name.charAt(0) + strtr(name.substring(1), 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'LKJIHGFEDCBAZYXWVUTSRQPONM')) : name;
|
||||||
|
},
|
||||||
|
datefmt(date) {
|
||||||
|
return date ? date.toLocaleDateString('en-CA') : '';
|
||||||
|
}
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
this.debounced_selection = debounce(async function(value) {
|
||||||
cookie.set('vista.resources', value.join(','), 7);
|
cookie.set('vista.resources', value.join(','), 7);
|
||||||
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;
|
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) {
|
for(var i = patients.length - 1; i >= 0; --i) {
|
||||||
@ -109,16 +123,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.patients = patients.sort((a, b) => a.Time - b.Time);
|
this.patients = patients.sort((a, b) => a.Time - b.Time);
|
||||||
}
|
}, 500);
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
strHashHSL,
|
|
||||||
unscramble(name) {
|
|
||||||
return name.length > 0 ? (name.charAt(0) + strtr(name.substring(1), 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'LKJIHGFEDCBAZYXWVUTSRQPONM')) : name;
|
|
||||||
},
|
|
||||||
datefmt(date) {
|
|
||||||
return date ? date.toLocaleDateString('en-CA') : '';
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
async mounted() {
|
async mounted() {
|
||||||
this.production = (await this.client.serverinfo()).result.production == '1';
|
this.production = (await this.client.serverinfo()).result.production == '1';
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import cookie from './cookie.mjs';
|
import cookie from './cookie.mjs';
|
||||||
import { uniq, strHashHSL } from './util.mjs';
|
import { uniq, strHashHSL, debounce } from './util.mjs';
|
||||||
|
|
||||||
import Autocomplete from './Autocomplete.vue';
|
import Autocomplete from './Autocomplete.vue';
|
||||||
|
|
||||||
@ -66,8 +66,8 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
async params(value) {
|
params(value) {
|
||||||
this.appointments = value.selection.length > 0 ? (await this.client.SDEC_CLINLET(value.selection.join('|') + '|', datefm(value.date_begin), datefm(value.date_end))).sort((a, b) => (new Date(a.ApptDate)) - (new Date(b.ApptDate))) : [];
|
this.debounced_params(value);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
@ -80,6 +80,9 @@
|
|||||||
cookie.set('vista.practitioner', JSON.stringify(this.practitioner), 1);
|
cookie.set('vista.practitioner', JSON.stringify(this.practitioner), 1);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
created() {
|
||||||
|
this.debounced_params = debounce(async function(value) { this.appointments = value.selection.length > 0 ? (await this.client.SDEC_CLINLET(value.selection.join('|') + '|', datefm(value.date_begin), datefm(value.date_end))).sort((a, b) => (new Date(a.ApptDate)) - (new Date(b.ApptDate))) : []; }, 500);
|
||||||
|
},
|
||||||
async mounted() {
|
async mounted() {
|
||||||
var practitioner = cookie.get('vista.practitioner');
|
var practitioner = cookie.get('vista.practitioner');
|
||||||
if(practitioner) this.practitioner = JSON.parse(practitioner);
|
if(practitioner) this.practitioner = JSON.parse(practitioner);
|
||||||
|
Loading…
Reference in New Issue
Block a user