This commit is contained in:
@@ -2,17 +2,12 @@ import authorizationroles from "./authorizationroles";
|
|||||||
const role = authorizationroles.AUTHORIZATION_ROLES;
|
const role = authorizationroles.AUTHORIZATION_ROLES;
|
||||||
export default {
|
export default {
|
||||||
registry: [
|
registry: [
|
||||||
// {
|
{
|
||||||
// id: "TestListWidgetsPriciest",
|
id: "dash-today-reminders-wo",
|
||||||
// roles: [
|
roles: [role.Tech, role.TechRestricted],
|
||||||
// role.BizAdmin,
|
title: "ReminderList",
|
||||||
// role.BizAdminRestricted,
|
type: "GzDashTodayReminders"
|
||||||
// role.Sales,
|
},
|
||||||
// role.SalesRestricted
|
|
||||||
// ],
|
|
||||||
// title: "Priciest widgets (all time) ",
|
|
||||||
// type: "GzDashTestListWidgetsPriciest"
|
|
||||||
// },
|
|
||||||
{
|
{
|
||||||
id: "dash-today-scheduled-wo",
|
id: "dash-today-scheduled-wo",
|
||||||
roles: [role.Tech, role.TechRestricted],
|
roles: [role.Tech, role.TechRestricted],
|
||||||
@@ -20,6 +15,7 @@ export default {
|
|||||||
type: "GzDashTodayScheduledWo",
|
type: "GzDashTodayScheduledWo",
|
||||||
scheduleableUserOnly: true
|
scheduleableUserOnly: true
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
id: "TestBarWidgetCountByUserType",
|
id: "TestBarWidgetCountByUserType",
|
||||||
roles: [
|
roles: [
|
||||||
|
|||||||
@@ -181,7 +181,7 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
this.refresh();
|
//this.refresh();
|
||||||
if (this.updateFrequency > 0) {
|
if (this.updateFrequency > 0) {
|
||||||
this.timer = setInterval(() => {
|
this.timer = setInterval(() => {
|
||||||
this.refresh();
|
this.refresh();
|
||||||
|
|||||||
150
ayanova/src/components/dash-today-reminders.vue
Normal file
150
ayanova/src/components/dash-today-reminders.vue
Normal file
@@ -0,0 +1,150 @@
|
|||||||
|
<template>
|
||||||
|
<gz-dash
|
||||||
|
icon="$ayiStickyNote"
|
||||||
|
:add-url="'home-reminders/0'"
|
||||||
|
:show-more-button="false"
|
||||||
|
:update-frequency="65000"
|
||||||
|
:error-message="errorMessage"
|
||||||
|
v-bind="$attrs"
|
||||||
|
@dash-refresh="getDataFromApi()"
|
||||||
|
v-on="$listeners"
|
||||||
|
>
|
||||||
|
<template slot="main">
|
||||||
|
<v-calendar
|
||||||
|
ref="calendar"
|
||||||
|
color="primary"
|
||||||
|
type="day"
|
||||||
|
hide-header
|
||||||
|
:now="now"
|
||||||
|
:interval-count="intervalCount"
|
||||||
|
:first-time="startAt"
|
||||||
|
:events="events"
|
||||||
|
:event-color="getEventColor"
|
||||||
|
:locale="languageName"
|
||||||
|
@click:event="showEvent"
|
||||||
|
>
|
||||||
|
<template v-slot:event="{ event, eventSummary }">
|
||||||
|
<div>
|
||||||
|
<!-- eslint-disable vue/no-v-html -->
|
||||||
|
<span
|
||||||
|
:class="event.textColor + '--text'"
|
||||||
|
v-html="eventSummary()"
|
||||||
|
/><v-icon v-if="!event.editable" x-small :color="event.textColor">
|
||||||
|
$ayiLock</v-icon
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</v-calendar>
|
||||||
|
</template>
|
||||||
|
</gz-dash>
|
||||||
|
</template>
|
||||||
|
<script>
|
||||||
|
import GzDash from "./dash-base.vue";
|
||||||
|
|
||||||
|
export default {
|
||||||
|
components: {
|
||||||
|
GzDash
|
||||||
|
},
|
||||||
|
props: {
|
||||||
|
maxListItems: { type: Number, default: 10 }
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
events: [],
|
||||||
|
errorMessage: null,
|
||||||
|
timeZoneName: window.$gz.locale.getResolvedTimeZoneName(),
|
||||||
|
languageName: window.$gz.locale.getResolvedLanguage(),
|
||||||
|
hour12: window.$gz.locale.getHour12(),
|
||||||
|
startAt: "00:00",
|
||||||
|
intervalCount: 24,
|
||||||
|
now: null
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
|
computed: {},
|
||||||
|
async mounted() {
|
||||||
|
//must be called from mounted to have refs available
|
||||||
|
await this.getDataFromApi();
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
getEventColor(event) {
|
||||||
|
return event.color;
|
||||||
|
},
|
||||||
|
showEvent({ nativeEvent, event }) {
|
||||||
|
nativeEvent.stopPropagation();
|
||||||
|
|
||||||
|
window.$gz.eventBus.$emit("openobject", {
|
||||||
|
type: event.type,
|
||||||
|
id: event.id
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
async getDataFromApi() {
|
||||||
|
let now = new Date();
|
||||||
|
|
||||||
|
//set now for the calendar to trigger a refresh
|
||||||
|
//if this doesn't work then need to trigger the change event: https://vuetifyjs.com/en/api/v-calendar/#events
|
||||||
|
this.now = now.toLocaleString("sv-SE", {
|
||||||
|
timeZone: this.timeZoneName
|
||||||
|
});
|
||||||
|
|
||||||
|
this.$refs.calendar.scrollToTime({
|
||||||
|
hour: now.getHours(),
|
||||||
|
minute: 0
|
||||||
|
});
|
||||||
|
|
||||||
|
try {
|
||||||
|
this.errorMessage = null;
|
||||||
|
const now = window.$gz.locale.nowUTC8601String(this.timeZoneName);
|
||||||
|
const res = await window.$gz.api.post("schedule/personal", {
|
||||||
|
view: 1,
|
||||||
|
dark: this.$store.state.darkMode,
|
||||||
|
start: window.$gz.locale.addDurationToUTC8601String(now, {
|
||||||
|
hours: -24
|
||||||
|
}),
|
||||||
|
end: window.$gz.locale.addDurationToUTC8601String(now, { hours: 24 }),
|
||||||
|
wisu: false,
|
||||||
|
reviews: false,
|
||||||
|
reminders: true
|
||||||
|
});
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
||||||
@@ -50,8 +50,6 @@ export default {
|
|||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
obj: [],
|
|
||||||
initialized: false,
|
|
||||||
events: [],
|
events: [],
|
||||||
errorMessage: null,
|
errorMessage: null,
|
||||||
timeZoneName: window.$gz.locale.getResolvedTimeZoneName(),
|
timeZoneName: window.$gz.locale.getResolvedTimeZoneName(),
|
||||||
@@ -64,6 +62,9 @@ export default {
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {},
|
computed: {},
|
||||||
|
async mounted() {
|
||||||
|
await this.getDataFromApi();
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
getEventColor(event) {
|
getEventColor(event) {
|
||||||
return event.color;
|
return event.color;
|
||||||
@@ -78,14 +79,7 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
async getDataFromApi() {
|
async getDataFromApi() {
|
||||||
//because dash base calls refresh before created can fire here
|
|
||||||
//need to init this way instead
|
|
||||||
if (!this.initialized) {
|
|
||||||
await initialize(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
let now = new Date();
|
let now = new Date();
|
||||||
|
|
||||||
//set now for the calendar to trigger a refresh
|
//set now for the calendar to trigger a refresh
|
||||||
//if this doesn't work then need to trigger the change event: https://vuetifyjs.com/en/api/v-calendar/#events
|
//if this doesn't work then need to trigger the change event: https://vuetifyjs.com/en/api/v-calendar/#events
|
||||||
this.now = now.toLocaleString("sv-SE", {
|
this.now = now.toLocaleString("sv-SE", {
|
||||||
@@ -107,7 +101,6 @@ export default {
|
|||||||
hours: -24
|
hours: -24
|
||||||
}),
|
}),
|
||||||
end: window.$gz.locale.addDurationToUTC8601String(now, { hours: 24 }),
|
end: window.$gz.locale.addDurationToUTC8601String(now, { hours: 24 }),
|
||||||
wisuColorSource: this.formUserOptions.wisuColorSource,
|
|
||||||
wisu: true, //workorder item scheduled user records
|
wisu: true, //workorder item scheduled user records
|
||||||
reviews: false,
|
reviews: false,
|
||||||
reminders: false
|
reminders: false
|
||||||
@@ -152,36 +145,4 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
async function initialize(vm) {
|
|
||||||
await fetchTranslatedText();
|
|
||||||
await getFormUserOptions(vm);
|
|
||||||
vm.initialized = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
async function getFormUserOptions(vm) {
|
|
||||||
const res = await window.$gz.api.get(`form-user-options/home-schedule`);
|
|
||||||
if (res.error) {
|
|
||||||
vm.formState.serverError = res.error;
|
|
||||||
window.$gz.form.setErrorBoxErrors(vm);
|
|
||||||
} else {
|
|
||||||
if (res.data == null) {
|
|
||||||
//make a default
|
|
||||||
vm.formUserOptions = {
|
|
||||||
firstTime: "00:00",
|
|
||||||
excludeDaysOfWeek: 0,
|
|
||||||
wisuColorSource: "2",
|
|
||||||
wisu: true,
|
|
||||||
reviews: true,
|
|
||||||
reminders: true
|
|
||||||
};
|
|
||||||
} else {
|
|
||||||
vm.formUserOptions = JSON.parse(res.data.options);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function fetchTranslatedText() {
|
|
||||||
await window.$gz.translation.cacheTranslations(["DashboardScheduled"]);
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -80,13 +80,16 @@ import GzDashTestBarWidgetCountByUserType from "../components/dash-test-bar-widg
|
|||||||
import GzDashTestLineWidgetMonthlyTotalPrice from "../components/dash-test-line-widget-monthly-total-price.vue";
|
import GzDashTestLineWidgetMonthlyTotalPrice from "../components/dash-test-line-widget-monthly-total-price.vue";
|
||||||
import GzDashTestDayCalendarWidget from "../components/dash-test-day-calendar-widget.vue";
|
import GzDashTestDayCalendarWidget from "../components/dash-test-day-calendar-widget.vue";
|
||||||
import GzDashTodayScheduledWo from "../components/dash-today-scheduled-wo.vue";
|
import GzDashTodayScheduledWo from "../components/dash-today-scheduled-wo.vue";
|
||||||
|
import GzDashTodayReminders from "../components/dash-today-reminders.vue";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
//GzDashTestListWidgetsPriciest,
|
//GzDashTestListWidgetsPriciest,
|
||||||
GzDashTestBarWidgetCountByUserType,
|
GzDashTestBarWidgetCountByUserType,
|
||||||
GzDashTestLineWidgetMonthlyTotalPrice,
|
GzDashTestLineWidgetMonthlyTotalPrice,
|
||||||
GzDashTestDayCalendarWidget,
|
GzDashTestDayCalendarWidget,
|
||||||
GzDashTodayScheduledWo
|
GzDashTodayScheduledWo,
|
||||||
|
GzDashTodayReminders
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
|||||||
Reference in New Issue
Block a user