This commit is contained in:
@@ -55,7 +55,9 @@ todo: //NEW NOTIFICATION SUBSCRIPTION EVENT TYPE:
|
|||||||
BACKEND
|
BACKEND
|
||||||
|
|
||||||
|
|
||||||
|
todo: remove fetched date column from notification table? (doesn't appear to be used in current system)
|
||||||
|
although, would be useful for bolding new items maybe?
|
||||||
|
|
||||||
todo: BAckend server routes for App notification fetch and clear etc
|
todo: BAckend server routes for App notification fetch and clear etc
|
||||||
|
|
||||||
todo: Back end notification related settings
|
todo: Back end notification related settings
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ export default {
|
|||||||
window.$gz.eventBus.$on("menu-click", clickHandler);
|
window.$gz.eventBus.$on("menu-click", clickHandler);
|
||||||
//NOTE: this would normally be in getDataFromAPI but this form doesn't really need that function so doing it here
|
//NOTE: this would normally be in getDataFromAPI but this form doesn't really need that function so doing it here
|
||||||
//modify the menu as necessary
|
//modify the menu as necessary
|
||||||
generateMenu(vm, false); //default is never read only and passing in this vm
|
generateMenu(vm);
|
||||||
//init disable save button so it can be enabled only on edit to show dirty form
|
//init disable save button so it can be enabled only on edit to show dirty form
|
||||||
window.$gz.eventBus.$emit("menu-disable-item", FORM_KEY + ":save");
|
window.$gz.eventBus.$emit("menu-disable-item", FORM_KEY + ":save");
|
||||||
window.$gz.eventBus.$emit("menu-disable-item", FORM_KEY + ":delete");
|
window.$gz.eventBus.$emit("menu-disable-item", FORM_KEY + ":delete");
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ export default {
|
|||||||
window.$gz.eventBus.$on("menu-click", clickHandler);
|
window.$gz.eventBus.$on("menu-click", clickHandler);
|
||||||
//NOTE: this would normally be in getDataFromAPI but this form doesn't really need that function so doing it here
|
//NOTE: this would normally be in getDataFromAPI but this form doesn't really need that function so doing it here
|
||||||
//modify the menu as necessary
|
//modify the menu as necessary
|
||||||
generateMenu(vm, false); //default is never read only and passing in this vm
|
generateMenu(vm);
|
||||||
//init disable save button so it can be enabled only on edit to show dirty form
|
//init disable save button so it can be enabled only on edit to show dirty form
|
||||||
window.$gz.eventBus.$emit("menu-disable-item", FORM_KEY + ":save");
|
window.$gz.eventBus.$emit("menu-disable-item", FORM_KEY + ":save");
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|||||||
@@ -447,7 +447,7 @@ export default {
|
|||||||
window.$gz.eventBus.$on("menu-click", clickHandler);
|
window.$gz.eventBus.$on("menu-click", clickHandler);
|
||||||
//NOTE: this would normally be in getDataFromAPI but this form doesn't really need that function so doing it here
|
//NOTE: this would normally be in getDataFromAPI but this form doesn't really need that function so doing it here
|
||||||
//modify the menu as necessary
|
//modify the menu as necessary
|
||||||
generateMenu(vm, false); //default is never read only and passing in this vm
|
generateMenu(vm);
|
||||||
//init disable save button so it can be enabled only on edit to show dirty form
|
//init disable save button so it can be enabled only on edit to show dirty form
|
||||||
window.$gz.eventBus.$emit("menu-disable-item", FORM_KEY + ":save");
|
window.$gz.eventBus.$emit("menu-disable-item", FORM_KEY + ":save");
|
||||||
vm.formState.loading = false;
|
vm.formState.loading = false;
|
||||||
|
|||||||
@@ -1,24 +1,157 @@
|
|||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<h1>New notification count: {{ newNotificationCount() }}</h1>
|
<h1>New notification count: {{ newNotificationCount() }}</h1>
|
||||||
|
<v-list three-line>
|
||||||
|
<v-list-item> </v-list-item>
|
||||||
|
</v-list>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
const FORM_KEY = "notification-subscriptions";
|
||||||
export default {
|
export default {
|
||||||
beforeCreate() {
|
async created() {
|
||||||
window.$gz.eventBus.$emit("menu-change", {
|
let vm = this;
|
||||||
isMain: true,
|
try {
|
||||||
icon: "fa-bell",
|
await initForm(vm);
|
||||||
title: "Notifications",
|
|
||||||
helpUrl: "form-home-notifications"
|
window.$gz.eventBus.$on("menu-click", clickHandler);
|
||||||
});
|
generateMenu(vm, false);
|
||||||
|
await vm.getDataFromApi();
|
||||||
|
} catch (err) {
|
||||||
|
window.$gz.errorHandler.handleFormError(err, vm);
|
||||||
|
} finally {
|
||||||
|
vm.formState.ready = true;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
beforeDestroy() {
|
||||||
|
window.$gz.eventBus.$off("menu-click", clickHandler);
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
rights: window.$gz.role.defaultRightsObject()
|
||||||
|
};
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
newNotificationCount() {
|
async getDataFromApi() {
|
||||||
return this.$store.state.newNotificationCount;
|
let vm = this;
|
||||||
|
|
||||||
|
|
||||||
|
let url = API_BASE_URL + recordId;
|
||||||
|
try {
|
||||||
|
window.$gz.form.deleteAllErrorBoxErrors(vm);
|
||||||
|
|
||||||
|
let res = await window.$gz.api.get(url);
|
||||||
|
|
||||||
|
if (res.error) {
|
||||||
|
//Not found?
|
||||||
|
if (res.error.code == "2010") {
|
||||||
|
//notify not found error then navigate backwards
|
||||||
|
window.$gz.eventBus.$emit("notify-error", vm.$ay.t("ErrorAPI2010"));
|
||||||
|
// navigate backwards
|
||||||
|
window.$gz._.delay(function() {
|
||||||
|
vm.$router.go(-1);
|
||||||
|
}, 2000);
|
||||||
|
}
|
||||||
|
vm.formState.serverError = res.error;
|
||||||
|
window.$gz.form.setErrorBoxErrors(vm);
|
||||||
|
} else {
|
||||||
|
vm.obj = res.data;
|
||||||
|
//modify the menu as necessary
|
||||||
|
generateMenu(vm);
|
||||||
|
//Update the form status
|
||||||
|
window.$gz.form.setFormState({
|
||||||
|
vm: vm,
|
||||||
|
dirty: false,
|
||||||
|
valid: true,
|
||||||
|
loading: false
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
window.$gz.errorHandler.handleFormError(error, vm);
|
||||||
|
} finally {
|
||||||
|
window.$gz.form.setFormState({
|
||||||
|
vm: vm,
|
||||||
|
loading: false
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/////////////////////////////
|
||||||
|
//
|
||||||
|
//
|
||||||
|
async function clickHandler(menuItem) {
|
||||||
|
if (!menuItem) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let m = window.$gz.menu.parseMenuItem(menuItem);
|
||||||
|
if (m.owner == FORM_KEY && !m.disabled) {
|
||||||
|
switch (m.key) {
|
||||||
|
// case "new":
|
||||||
|
// m.vm.$router.push({
|
||||||
|
// name: "home-notify-subscription",
|
||||||
|
// params: { recordid: 0 }
|
||||||
|
// });
|
||||||
|
// break;
|
||||||
|
// case "extensions":
|
||||||
|
// let res = await m.vm.$refs.extensions.open();
|
||||||
|
// break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
window.$gz.eventBus.$emit(
|
||||||
|
"notify-warning",
|
||||||
|
FORM_KEY + "::context click: [" + m.key + "]"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//////////////////////
|
||||||
|
//
|
||||||
|
//
|
||||||
|
function generateMenu(vm) {
|
||||||
|
let menuOptions = {
|
||||||
|
isMain: true,
|
||||||
|
icon: "fa-bell",
|
||||||
|
title: "Notifications",
|
||||||
|
helpUrl: "form-home-notifications",
|
||||||
|
menuItems: []
|
||||||
|
};
|
||||||
|
|
||||||
|
// if (vm.rights.change) {
|
||||||
|
// menuOptions.menuItems.push({
|
||||||
|
// title: "New",
|
||||||
|
// icon: "fa-plus",
|
||||||
|
// surface: true,
|
||||||
|
// key: FORM_KEY + ":new",
|
||||||
|
// vm: vm
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
|
||||||
|
// //STUB REPORTS
|
||||||
|
// //Report not Print, print is a further option
|
||||||
|
// menuOptions.menuItems.push({
|
||||||
|
// title: "Report",
|
||||||
|
// icon: "fa-file-alt",
|
||||||
|
// key: FORM_KEY + ":report",
|
||||||
|
// vm: vm
|
||||||
|
// });
|
||||||
|
|
||||||
|
// menuOptions.menuItems.push({
|
||||||
|
// title: "stub: Last report used",
|
||||||
|
// icon: "fa-file-alt",
|
||||||
|
// key: FORM_KEY + ":report:STUBlastusedreportid",
|
||||||
|
// vm: vm
|
||||||
|
// });
|
||||||
|
|
||||||
|
// menuOptions.menuItems.push({
|
||||||
|
// title: "Extensions",
|
||||||
|
// icon: "fa-puzzle-piece",
|
||||||
|
// key: FORM_KEY + ":extensions",
|
||||||
|
// vm: vm
|
||||||
|
// });
|
||||||
|
window.$gz.eventBus.$emit("menu-change", menuOptions);
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user