diff --git a/ayanova/devdocs/todo.txt b/ayanova/devdocs/todo.txt index f80592e8..7a1dde7b 100644 --- a/ayanova/devdocs/todo.txt +++ b/ayanova/devdocs/todo.txt @@ -76,6 +76,8 @@ TO BE DETERMINED: workorderitempriority edit form missing NEW option, also probably woitemstatus and maybe wostatus too + + Dashboard / widgets Installer INNO version with postgres included, version without postgres included diff --git a/ayanova/src/api/gzutil.js b/ayanova/src/api/gzutil.js index 0e782b40..133248ec 100644 --- a/ayanova/src/api/gzutil.js +++ b/ayanova/src/api/gzutil.js @@ -943,6 +943,36 @@ export default { "https://yandex.ru/maps/?mode=search&text={ayaddress}&z=17<|>https://yandex.ru/maps/?ll={aylatitude},{aylongitude}&z=12&l=map" } ]; + }, + /////////////////////////////////////////////// + // v-calendar view to AyaNova scheduleview enum + // + // + calendarViewToAyaNovaEnum: function(view) { + /* + public enum ScheduleView : int + { + Day = 1, + Week = 2, + Month = 3, + Day4 = 4 + } + */ + switch (view) { + case "day": + return 1; + case "week": + return 2; + case "month": + return 3; + case "4day": + return 4; + + default: + throw new Error( + `gzutil->calendarViewtoAyaNovaEnum - Unknown view type '${view}'` + ); + } } /** diff --git a/ayanova/src/api/locale.js b/ayanova/src/api/locale.js index 4e2d2601..53c6d536 100644 --- a/ayanova/src/api/locale.js +++ b/ayanova/src/api/locale.js @@ -75,6 +75,41 @@ export default { getHour12() { return window.$gz.store.state.userOptions.hour12; }, + ////////////////////////////////////////////////// + // Get the user's chosen / auto time zone offset + // + getTZOffset(timeZoneName) { + if (!timeZoneName) { + timeZoneName = this.getResolvedTimeZoneName(); + } + let dtNow = window.$gz.DateTime.local(); + var rezoned = dtNow.setZone(timeZoneName); + return rezoned.offset; + }, + // /////////////////////////////////////////// + // // Convert timestamp utc epoch value + // // to local timestamp epoch value + // // + // utcEpochToLocalEpoch(value, timeZoneName) { + // if (!value) { + // return null; + // } + // if (!timeZoneName) { + // timeZoneName = this.getResolvedTimeZoneName(); + // } + + // let parsedDate = new Date(value); + + // //is it a valid date? + // if (!(parsedDate instanceof Date && !isNaN(parsedDate))) { + // return null; + // } + + // return parsedDate.toLocaleDateString(languageName, { + // timeZone: timeZoneName, + // dateStyle: "short" + // }); + // }, /////////////////////////////////////////// // Turn a utc date into a displayable // short date and time diff --git a/ayanova/src/views/home-schedule.vue b/ayanova/src/views/home-schedule.vue index 23962b76..666f03e9 100644 --- a/ayanova/src/views/home-schedule.vue +++ b/ayanova/src/views/home-schedule.vue @@ -60,6 +60,7 @@ :events="events" :event-color="getEventColor" :type="viewType" + :locale="languageName" @click:event="showEvent" @click:more="viewDay" @click:date="viewDay" @@ -79,7 +80,7 @@ > - + $ayiEdit @@ -92,7 +93,8 @@ - + {{ selectedEvent }} + @@ -156,16 +158,17 @@ SETTINGS: TODO NEXT: - move color calc for forecolor to server and provide as property so no need to calc here and can use for both icon and text - clean up display so it looks reasonable + + correct date/time adjusted (doesn't seem to be) make popup clickthrough to open wo just so make life easier for me testing and adjusting - Larger font, kinda small?? + settings / saving as form settings + use translations where possible + */ -const FORM_KEY = "home-schedule"; -const API_BASE_URL = "schedule/"; -const FORM_CUSTOM_TEMPLATE_KEY = "home-schedule"; //<-- Should always be CoreBizObject AyaType name here where possible + +const FORM_CUSTOM_TEMPLATE_KEY = "home-schedule"; export default { beforeCreate() { @@ -191,25 +194,6 @@ export default { selectedElement: null, selectedOpen: false, events: [], - colors: [ - "blue", - "indigo", - "deep-purple", - "cyan", - "green", - "orange", - "grey darken-1" - ], - names: [ - "Meeting", - "Holiday", - "PTO", - "Travel", - "Event", - "Birthday", - "Conference", - "Party" - ], formState: { ready: false, @@ -224,7 +208,6 @@ export default { rights: window.$gz.role.defaultRightsObject(), calendarHeight: 600, settingsDialog: false, - //cache display format stuff timeZoneName: window.$gz.locale.getResolvedTimeZoneName(), languageName: window.$gz.locale.getResolvedLanguage(), hour12: window.$gz.locale.getHour12() @@ -234,14 +217,6 @@ export default { this.$refs.calendar.checkChange(); }, methods: { - // getContrastYIQ(hexcolor) { - // hexcolor = hexcolor.replace("#", ""); - // var r = parseInt(hexcolor.substr(0, 2), 16); - // var g = parseInt(hexcolor.substr(2, 2), 16); - // var b = parseInt(hexcolor.substr(4, 2), 16); - // var yiq = (r * 299 + g * 587 + b * 114) / 1000; - // return yiq >= 128 ? "black" : "white"; - // }, onResize() { this.calendarHeight = window.innerHeight * 0.84; }, @@ -261,6 +236,12 @@ export default { next() { this.$refs.calendar.next(); }, + openScheduledItem() { + window.$gz.eventBus.$emit("openobject", { + type: this.selectedEvent.type, + id: this.selectedEvent.id + }); + }, showEvent({ nativeEvent, event }) { const open = () => { this.selectedEvent = event; @@ -280,13 +261,15 @@ export default { nativeEvent.stopPropagation(); }, async fetchEvents({ start, end }) { - //NOTE: Need to add six days at least on either side due to calendar potentially showing up to six days of end and start of adjacent months - //maybe easier if server does it and this just sticks to the + // console.log( + // "UPDATE RANGE:", + // JSON.stringify({ start: start.date, end: end.date }) + // ); - console.log( - "UPDATE RANGE:", - JSON.stringify({ start: start.date, end: end.date }) - ); + // console.log( + // "TZ Offset", + // window.$gz.locale.getTZOffset(this.timeZoneName) + // ); /* public enum PersonalScheduleWorkOrderColorSource : int { @@ -295,31 +278,15 @@ export default { WorkOrderItemStatus = 3, WorkOrderItemPriority = 4 } - public enum ScheduleView : int - { - Day = 1, - Week = 2, - Month = 3, - Day4 = 4 - } + */ - let v = 3; //month - default - switch (this.viewType) { - case "day": - v = 1; - break; - case "week": - v = 2; - break; - case "4day": - v = 4; - break; - } + try { window.$gz.form.deleteAllErrorBoxErrors(this); let res = await window.$gz.api.post("schedule/personal", { - view: v, + view: window.$gz.util.calendarViewToAyaNovaEnum(this.viewType), + tzOffset: window.$gz.locale.getTZOffset(this.timeZoneName), start: window.$gz.locale.localTimeDateStringToUTC8601String( `${start.date}T00:00:00`, this.timeZoneName @@ -343,44 +310,8 @@ export default { } catch (error) { window.$gz.errorHandler.handleFormError(error, this); } - - // const events = []; - - // const min = new Date(`${start.date}T00:00:00`); - // const max = new Date(`${end.date}T23:59:59`); - // const days = (max.getTime() - min.getTime()) / 86400000; - // const eventCount = this.rnd(days, days + 20); - - // for (let i = 0; i < eventCount; i++) { - // const allDay = this.rnd(0, 3) === 0; - // const firstTimestamp = this.rnd(min.getTime(), max.getTime()); - // const first = new Date(firstTimestamp - (firstTimestamp % 900000)); - // const secondTimestamp = this.rnd(2, allDay ? 288 : 8) * 900000; - // const second = new Date(first.getTime() + secondTimestamp); - - // events.push({ - // name: this.names[this.rnd(0, this.names.length - 1)], - // start: first, - // end: second, - // color: this.colors[this.rnd(0, this.colors.length - 1)], - // timed: !allDay - // }); - //} - - //this.events = events; - - /* - [ { "start": 1628046000, "end": 1628049600, "name": "3 Runte - Harris", "color": "#c0c000", "type": 41, "id": 26 }, { "start": 1628046000, "end": 1628053200, "name": "3 Runte - Harris", "color": "#c0c000", "type": 41, "id": 27 }, { "start": 1628046000, "end": 1628049600, "name": "3 Runte - Harris", "color": "#c0c000", "type": 41, "id": 24 }, { "start": 1628046000, "end": 1628049600, "name": "3 Runte - Harris", "color": "#c0c000", "type": 41, "id": 23 }, { "start": 1628046000, "end": 1628049600, "name": "3 Runte - Harris", "color": "#c0c000", "type": 41, "id": 22 }, { "start": 1628046000, "end": 1628049600, "name": "3 Runte - Harris", "color": "#c0c000", "type": 41, "id": 21 }, { "start": 1630040400, "end": 1630044000, "name": "7 Conroy Group", "color": "#ff00ff", "type": 41, "id": 46 }, { "start": 1630040400, "end": 1630044000, "name": "7 Conroy Group", "color": "#ff00ff", "type": 41, "id": 45 } ] - */ - }, - rnd(a, b) { - return Math.floor((b - a + 1) * Math.random()) + a; } + //eom } };