This commit is contained in:
2022-02-22 23:31:27 +00:00
parent 904dc5259f
commit e77c8283f5
5 changed files with 97 additions and 63 deletions

View File

@@ -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
},
{

View File

@@ -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) {

View File

@@ -120,7 +120,17 @@
</v-menu>
</v-toolbar>
</slot>
<slot name="main"
<div v-if="hasError" class="mx-2 mt-4 d-flex align-center">
<v-alert
data-cy="dash-error"
color="error"
icon="$ayiExclamationTriangle"
class="multi-line"
outlined
>{{ errorMessage }}</v-alert
>
</div>
<slot v-if="!hasError" name="main"
><div class="ml-4 mt-1 d-flex align-center">
<div>
<span class="grey--text"
@@ -151,7 +161,8 @@ export default {
count: { type: Number, default: 0 },
updateFrequency: { type: Number, default: 60000 },
maxListItems: { type: Number, default: 10 },
icon: { type: String, default: "$ayiTachometer" }
icon: { type: String, default: "$ayiTachometer" },
errorMessage: { type: String, default: null }
},
data() {
return {
@@ -164,6 +175,9 @@ export default {
},
translatedTitle() {
return this.$ay.t(this.title);
},
hasError() {
return this.errorMessage != null && this.errorMessage.length > 0;
}
},
created() {

View File

@@ -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);
}
}
}
};

View File

@@ -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 {