From e77c8283f5bd2832fcc7fcd66eea0dfc7b45d27b Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Tue, 22 Feb 2022 23:31:27 +0000 Subject: [PATCH] --- ayanova/src/api/dash-registry.js | 4 +- ayanova/src/api/locale.js | 23 ++++ ayanova/src/components/dash-base.vue | 18 ++- .../src/components/dash-scheduser-next-wo.vue | 111 +++++++++--------- ayanova/src/views/home-dashboard.vue | 4 +- 5 files changed, 97 insertions(+), 63 deletions(-) diff --git a/ayanova/src/api/dash-registry.js b/ayanova/src/api/dash-registry.js index 815f12d9..9eebe3f6 100644 --- a/ayanova/src/api/dash-registry.js +++ b/ayanova/src/api/dash-registry.js @@ -14,10 +14,10 @@ export default { // type: "GzDashTestListWidgetsPriciest" // }, { - id: "TestScheduleableOnly", + id: "NextSchedItems", roles: [role.Tech, role.TechRestricted], title: "TEST sched user widget", - type: "NextSchedItem", + type: "NextSchedItems", scheduleableUserOnly: true }, { diff --git a/ayanova/src/api/locale.js b/ayanova/src/api/locale.js index 88c9da81..ef9f22eb 100644 --- a/ayanova/src/api/locale.js +++ b/ayanova/src/api/locale.js @@ -408,6 +408,29 @@ export default { return dt.toUTC().toString(); }, /////////////////////////////////////////////// + // UTC ISO 8601 string add arbitrary value based + // on luxon duration format + // and return as UTC ISO 8601 string + //https://moment.github.io/luxon/api-docs/index.html#datetimeplus + // + addDurationToUTC8601String(val, duration) { + if (!val || val == "" || duration == null || !this.isObject(duration)) { + return val; + } + //instantiate a luxon date object from val which is assumed to be an iso string + let dt = window.$gz.DateTime.fromISO(val); + if (!dt.isValid) { + console.error("locale::addDurationToUTC8601String, input not valid:", { + val: val, + dt: dt + }); + return val; + } + //add minutes + dt = dt.plus(duration); + return dt.toUTC().toString(); + }, + /////////////////////////////////////////////// // parse UTC ISO 8601 strings, diff, return hours // diffHoursFromUTC8601String(start, stop) { diff --git a/ayanova/src/components/dash-base.vue b/ayanova/src/components/dash-base.vue index 54981b64..ec10bd64 100644 --- a/ayanova/src/components/dash-base.vue +++ b/ayanova/src/components/dash-base.vue @@ -120,7 +120,17 @@ - + {{ errorMessage }} + +
0; } }, created() { diff --git a/ayanova/src/components/dash-scheduser-next-wo.vue b/ayanova/src/components/dash-scheduser-next-wo.vue index 1bf4781d..6d43e2e6 100644 --- a/ayanova/src/components/dash-scheduser-next-wo.vue +++ b/ayanova/src/components/dash-scheduser-next-wo.vue @@ -4,6 +4,7 @@ :add-url="'widgets/0'" :show-more-button="true" :update-frequency="60000" + :error-message="errorMessage" v-bind="$attrs" @dash-refresh="getDataFromApi()" @dash-more-click="moreClick()" @@ -39,7 +40,7 @@ export default { data() { return { obj: [], - + errorMessage: null, timeZoneName: window.$gz.locale.getResolvedTimeZoneName(), languageName: window.$gz.locale.getResolvedLanguage(), hour12: window.$gz.locale.getHour12(), @@ -78,62 +79,58 @@ export default { // this.obj = []; // } //========================= commented out for release temporarily ===================== - // try { - // window.$gz.form.deleteAllErrorBoxErrors(this); - // const res = await window.$gz.api.post("schedule/personal", { - // view: window.$gz.util.calendarViewToAyaNovaEnum(this.viewType), - // dark: this.$store.state.darkMode, - // start: window.$gz.locale.localTimeDateStringToUTC8601String( - // `${start.date}T00:00:00`, - // this.timeZoneName - // ), - // end: window.$gz.locale.localTimeDateStringToUTC8601String( - // `${end.date}T23:59:59`, - // this.timeZoneName - // ), - // wisuColorSource: this.formUserOptions.wisuColorSource, - // wisu: this.formUserOptions.wisu, //workorder item scheduled user records - // reviews: this.formUserOptions.reviews, - // reminders: this.formUserOptions.reminders - // }); - // if (res.error) { - // this.formState.serverError = res.error; - // window.$gz.form.setErrorBoxErrors(this); - // } else { - // this.events.splice(0); - // const timeZoneName = this.timeZoneName; - // let i = res.data.length; - // while (i--) { - // const x = res.data[i]; - // this.events.push({ - // start: new Date( - // new Date(x.start) - // .toLocaleString("sv-SE", { - // timeZone: timeZoneName - // }) - // .replace(" ", "T") - // ).getTime(), - // end: new Date( - // new Date(x.end) - // .toLocaleString("sv-SE", { - // timeZone: timeZoneName - // }) - // .replace(" ", "T") - // ).getTime(), - // timed: true, - // name: x.name, - // color: x.color, - // textColor: x.textColor, - // type: x.type, - // id: x.id, - // editable: x.editable, - // userId: x.userId - // }); - // } - // } - // } catch (error) { - // window.$gz.errorHandler.handleFormError(error, this); - // } + try { + this.errorMessage = null; + const now = window.$gz.locale.nowUTC8601String(this.timeZoneName); + const res = await window.$gz.api.post("schedule/personal", { + view: window.$gz.util.calendarViewToAyaNovaEnum(this.viewType), + dark: this.$store.state.darkMode, + start: now, + end: window.$gz.locale.addDurationToUTC8601String(now, { hours: 24 }), + wisuColorSource: this.formUserOptions.wisuColorSource, + wisu: this.formUserOptions.wisu, //workorder item scheduled user records + reviews: this.formUserOptions.reviews, + reminders: this.formUserOptions.reminders + }); + if (res.error) { + this.errorMessage = res.error; + } else { + this.events.splice(0); + const timeZoneName = this.timeZoneName; + let i = res.data.length; + while (i--) { + const x = res.data[i]; + this.events.push({ + start: new Date( + new Date(x.start) + .toLocaleString("sv-SE", { + timeZone: timeZoneName + }) + .replace(" ", "T") + ).getTime(), + end: new Date( + new Date(x.end) + .toLocaleString("sv-SE", { + timeZone: timeZoneName + }) + .replace(" ", "T") + ).getTime(), + timed: true, + name: x.name, + color: x.color, + textColor: x.textColor, + type: x.type, + id: x.id, + editable: x.editable, + userId: x.userId + }); + } + } + } catch (error) { + this.errorMessage = error.toString(); + + //window.$gz.errorHandler.handleFormError(error, this); + } } } }; diff --git a/ayanova/src/views/home-dashboard.vue b/ayanova/src/views/home-dashboard.vue index a4ae942c..247d622a 100644 --- a/ayanova/src/views/home-dashboard.vue +++ b/ayanova/src/views/home-dashboard.vue @@ -79,14 +79,14 @@ import DashRegistry from "../api/dash-registry"; import GzDashTestBarWidgetCountByUserType from "../components/dash-test-bar-widget-count-by-usertype.vue"; import GzDashTestLineWidgetMonthlyTotalPrice from "../components/dash-test-line-widget-monthly-total-price.vue"; import GzDashTestDayCalendarWidget from "../components/dash-test-day-calendar-widget.vue"; -import NextSchedItem from "../components/dash-test-day-calendar-widget.vue"; +import NextSchedItems from "../components/dash-scheduser-next-wo.vue"; export default { components: { //GzDashTestListWidgetsPriciest, GzDashTestBarWidgetCountByUserType, GzDashTestLineWidgetMonthlyTotalPrice, GzDashTestDayCalendarWidget, - NextSchedItem + NextSchedItems }, data() { return {