This commit is contained in:
2020-07-29 17:55:34 +00:00
parent d647adfa54
commit a1d0b7b5df
3 changed files with 174 additions and 28 deletions

View File

@@ -11,7 +11,10 @@ ____________
## CURRENT STAGE:
todo: notification general default created on general notify is creating every time, not just if it's needed
todo: Notify subscription grid showing all notifications for all users due to no way to filter to just current user automatically
I could add a system to inject a where clause into the query
or I could convert that view and any that are not based on core biz objects into a simple list and datagrid without sort and filter additions
like the backup list or other lists recently worked on
todo: notification system docs
It's complex and needs a clear documentation about how it all works
@@ -19,6 +22,11 @@ todo: notification system docs
Big overview then drill down
##########################
todo: Am I forgetting to unsubscribe from event handler in every form for menu click?
See home-notify-subscriptions beforeDestroy() event which has a block to unsubscribe to clicks
Make sure that's the case everywhere
todo: generated user names have numbers in them and are not the same as the id. Do they need numbers? Can it just keep an internal list of used names and bump
or query the db to see if it's already used because there are not that many generated users generally.
@@ -183,6 +191,10 @@ todo: INSTALLER
This stage is to consolidate the basics and set the final shell form.
A lot of it might be rundundent
TODO: GRIDS I'm still on the fence with the grid sort and filter system
Filter is ok, it's complex and people don't expect it to be super easy, but sort is a bit of a palaver
it seems too difficult to make a quick sort change, can it be supported to just click on column headings?
todo: Go through all cases, just glance over them and make sure nothing was missed that impacts the basic shell stuff before I get into the real world objects
todo: notification system?

View File

@@ -278,7 +278,18 @@ export default {
source.slice(start + Math.abs(delCount))
);
},
///////////////////////////////
// Format tags for display
//
//
// @param {String} tags raw from server
// @return {string} A new string with the tags formatted or an empty string if no tags
formatTags: function(tags) {
if (tags && tags.length > 0) {
return tags.join(", ");
}
return "";
},
///////////////////////////////
// ICON FOR *ALL* OBJECT TYPES
//(used for search results and event log / history)

View File

@@ -1,47 +1,122 @@
<template>
<div>
<!-- <gz-extensions
:ayaType="ayType"
:selectedItems="selectedItems"
ref="extensions"
<v-data-table
:headers="headers"
:items="obj"
class="elevation-1"
:disable-pagination="true"
:disable-filtering="true"
hide-default-footer
@click:row="rowClick"
>
</gz-extensions> -->
<gz-data-table
formKey="notification-subscriptions"
:dataListKey="dataListKey"
:dataListFilter="dataListFilter"
:dataListSort="dataListSort"
v-on:selection-change="handleSelected"
>
</gz-data-table>
</v-data-table>
</div>
</template>
<script>
const FORM_KEY = "notification-subscriptions";
export default {
created() {
this.rights = window.$gz.role.getRights(window.$gz.type.NotifySubscription);
window.$gz.eventBus.$on("menu-click", clickHandler);
generateMenu(this);
async created() {
let vm = this;
try {
await initForm(vm);
vm.formState.readOnly = false;
vm.formState.ready = true;
window.$gz.eventBus.$on("menu-click", clickHandler);
await vm.getDataFromApi();
vm.formState.loading = false;
} catch (err) {
vm.formState.ready = true;
window.$gz.errorHandler.handleFormError(err, vm);
}
},
beforeDestroy() {
window.$gz.eventBus.$off("menu-click", clickHandler);
},
data() {
return {
currentListViewId: 1,
dataListKey: "NotifySubscriptionDataList",
dataListFilter: "",
dataListSort: "",
rights: window.$gz.role.defaultRightsObject(),
ayType: window.$gz.type.NotifySubscription,
selectedItems: []
obj: [],
headers: [],
formState: {
ready: false,
loading: true,
errorBoxMessage: null,
appError: null,
serverError: {}
},
rights: window.$gz.role.fullRightsObject() //users always have full rights to their own notification subscriptions
};
},
methods: {
handleSelected(selected) {
this.selectedItems = selected;
rowClick(item) {
//nav to item.id
window.$gz.eventBus.$emit("openobject", {
type: window.$gz.type.NotifySubscription,
id: item.id
});
},
async getDataFromApi() {
let vm = this;
vm.formState.loading = true;
window.$gz.form.deleteAllErrorBoxErrors(vm);
try {
let res = await window.$gz.api.get("notify-subscription/list");
if (res.error) {
if (res.error.code == "2010") {
window.$gz.eventBus.$emit("notify-error", vm.$ay.t("ErrorAPI2010"));
window.$gz._.delay(function() {
vm.$router.go(-1);
}, 2000);
}
vm.formState.serverError = res.error;
window.$gz.form.setErrorBoxErrors(vm);
} else {
if (res.data) {
/* z.Id,
z.UserId,
z.EventType,
z.AyaType,
z.DeliveryMethod,
z.DeliveryAddress,
z.Tags */
let ret = [];
for (let i = 0; i < res.data.length; i++) {
let o = res.data[i];
ret.push({
id: o.id,
eventType: window.$gz.enums.get("NotifyEventType", o.eventType),
ayaType: window.$gz.enums.get("core", o.ayaType),
deliveryMethod: window.$gz.enums.get(
"NotifyDeliveryMethod",
o.deliveryMethod
),
deliveryAddress: o.deliveryAddress,
tags: window.$gz.util.formatTags(o.tags)
});
}
vm.obj = ret;
} else {
vm.obj = [];
}
window.$gz.form.setFormState({
vm: vm,
dirty: false,
valid: true,
loading: false
});
generateMenu(vm);
}
} catch (error) {
window.$gz.form.setFormState({
vm: vm,
loading: false
});
window.$gz.errorHandler.handleFormError(error, vm);
}
}
}
};
@@ -124,4 +199,52 @@ function generateMenu(vm) {
// });
window.$gz.eventBus.$emit("menu-change", menuOptions);
}
/////////////////////////////////
//
//
async function initForm(vm) {
await fetchTranslatedText(vm);
await cacheEnums(vm);
await createTableHeaders(vm);
}
//////////////////////////////////////////////////////////
//
// Ensures UI translated text is available
//
async function fetchTranslatedText(vm) {
await window.$gz.translation.cacheTranslations([
"NotifyEventType",
"ID",
"AyaType",
"NotifyDeliveryMethod",
"NotifyDeliveryAddress",
"Tags"
]);
}
//////////////////////
//
//
async function cacheEnums(vm) {
//ensure the enum values required are pre-fetched
await window.$gz.enums.fetchEnumList("NotifyEventType");
await window.$gz.enums.fetchEnumList("NotifyDeliveryMethod");
await window.$gz.enums.fetchEnumList("core");
}
//////////////////////
//
//
async function createTableHeaders(vm) {
vm.headers = [
{ text: vm.$ay.t("ID"), value: "id" },
{ text: vm.$ay.t("NotifyEventType"), value: "eventType" },
{ text: vm.$ay.t("AyaType"), value: "ayaType" },
{ text: vm.$ay.t("NotifyDeliveryMethod"), value: "deliveryMethod" },
{ text: vm.$ay.t("NotifyDeliveryAddress"), value: "deliveryAddress" },
{ text: vm.$ay.t("Tags"), value: "tags" }
];
}
</script>