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

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