From 2bf0fb971abac9fa4d23bb704960c2be55b1e464 Mon Sep 17 00:00:00 2001 From: inportb Date: Tue, 16 May 2023 23:23:45 -0400 Subject: [PATCH] Linkable schedules --- htdocs/App.vue | 1 + htdocs/RouteSchedule.vue | 30 ++++++++++++++++++++++++++++-- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/htdocs/App.vue b/htdocs/App.vue index d3ddf83..53a3bff 100644 --- a/htdocs/App.vue +++ b/htdocs/App.vue @@ -88,6 +88,7 @@ else { [ { path: '/', component: RouteSchedule }, + { path: '/schedule/:from?/:to?', component: RouteSchedule }, { path: '/lookup', component: RouteLookup }, { path: '/patient/:id', component: RoutePatient, children: [ { path: '', component: RoutePatientDetail }, diff --git a/htdocs/RouteSchedule.vue b/htdocs/RouteSchedule.vue index 22c6009..b20d738 100644 --- a/htdocs/RouteSchedule.vue +++ b/htdocs/RouteSchedule.vue @@ -4,7 +4,7 @@
Schedule Select clinics - +
@@ -21,6 +21,12 @@ return new Date(date.getFullYear(), date.getMonth(), date.getDate()); } + function localtime(s) { + var date = new Date(s); + date.setTime(date.getTime() + 60000*date.getTimezoneOffset()); + return date; + } + export default { components: { Subtitle, DateRangePicker, ViewSchedule @@ -31,11 +37,31 @@ data() { return { date: dateonly(new Date()), - date_end: dateonly(new Date()) + date_end: dateonly(new Date()), + range: '1D' }; }, computed: { selection() { return (this.client) && (this.client.remotestate.resources) ? (this.client.remotestate.resources.split(',').filter(x => x) || []) : [] } + }, + watch: { + '$route.params.from': { + handler(value) { + this.date = dateonly(value ? localtime(value) : new Date()); + }, immediate: true + }, + '$route.params.to': { + handler(value) { + if(value) { + var date = localtime(value); + if(isNaN(date)) this.range = value; + else { + this.range = 'Range'; + this.date_end = dateonly(date); + } + } else this.range = '1D'; + }, immediate: true + } } };