This commit is contained in:
2021-06-30 19:17:14 +00:00
parent 5e54d8e4ec
commit ceb79a48ca
6 changed files with 180 additions and 114 deletions

View File

@@ -65,6 +65,9 @@ todo: workorders - need to set billing and service address from customers on mig
bugbug: direct notification errors out bugbug: direct notification errors out
user->direct notification user->direct notification
todo: Customer login should show notifications in app screen always just like regular users in the event that a direct notification is sent
i.e. right now it assumes only needs to show it if they have subscription ability but in-app should always show for direct or error or what have you.
todo: notifications screen add delete all menu item that will just remove all the notifications present todo: notifications screen add delete all menu item that will just remove all the notifications present
Maybe a checkbox and delete selected and select all?? That way can also be a dual useful feature Maybe a checkbox and delete selected and select all?? That way can also be a dual useful feature
also should delete *from* the client so that it deletes only what it has in view so user doesn't accidentally delete unseen yet to be delivered ones? also should delete *from* the client so that it deletes only what it has in view so user doesn't accidentally delete unseen yet to be delivered ones?
@@ -416,20 +419,16 @@ todo: many biz objects are not using new PUT methodology
CURRENTLY DOING: make sure tags is fixed fully after created change CURRENTLY DOING:
todo: User duplicate locally, improvements, port to customer user form identically
todo: User duplicate not working, error about optionsobj
Message:_vm.optionsObj is undefined
probably need to populate that object as well as main obj on dupe
doesn't work on devops either, broken for a while
also dupe check on the customer contact object too
todo: purchase order dupe code at server is a bit sus. todo: purchase order dupe code at server is a bit sus.
it has a todo to set qty to zero but doesn't for some reason so it effectively it has a todo to set qty to zero but doesn't for some reason so it effectively
is affecting inventory on duplicate?? is affecting inventory on duplicate??
Look into it. Look into it.
IDEALLY REPLACE WITH LOCAL COPY LIKE WO
todo: workorder "template" replacement via duplicate requires some changes: todo: workorder "template" replacement via duplicate requires some changes:
V7 notes: V7 notes:

View File

@@ -152,8 +152,8 @@
> >
</v-toolbar-title> </v-toolbar-title>
<v-spacer></v-spacer> <v-spacer></v-spacer>
<!-- v-if="$store.state.notifyAvailable" -->
<template v-if="$store.state.notifyAvailable"> <template>
<v-btn text icon to="/home-notifications" data-cy="notification"> <v-btn text icon to="/home-notifications" data-cy="notification">
<v-badge color="deep-purple" :value="newNotificationCount() > 0"> <v-badge color="deep-purple" :value="newNotificationCount() > 0">
<template v-slot:badge> <template v-slot:badge>

View File

@@ -8,7 +8,6 @@
<v-form ref="form"> <v-form ref="form">
<v-tabs mobile-breakpoint="100" v-model="tab"> <v-tabs mobile-breakpoint="100" v-model="tab">
<v-tab>{{ $ay.t("User") }}</v-tab> <v-tab>{{ $ay.t("User") }}</v-tab>
<!-- v-if="obj.id != 0 || isUnsavedDuplicate" -->
<v-tab>{{ $ay.t("UserSettings") }}</v-tab> <v-tab>{{ $ay.t("UserSettings") }}</v-tab>
<v-tabs-items v-model="tab"> <v-tabs-items v-model="tab">
@@ -460,7 +459,7 @@ export default {
this.obj.name = `${this.obj.name} - ${window.$gz.translation.get( this.obj.name = `${this.obj.name} - ${window.$gz.translation.get(
"Copy" "Copy"
)}`; )}`;
this.password = window.$gz.util.getRandomPassword();
setDirty = true; setDirty = true;
} }
} }
@@ -843,7 +842,6 @@ export default {
window.$gz.form.setErrorBoxErrors(vm); window.$gz.form.setErrorBoxErrors(vm);
} else { } else {
vm.optionsObj = res.data; vm.optionsObj = res.data;
// vm.activeTranslationId = res.data.translationId;
//Update the form status //Update the form status
window.$gz.form.setFormState({ window.$gz.form.setFormState({
@@ -868,9 +866,8 @@ export default {
let vm = this; let vm = this;
if (vm.canSave) { if (vm.canSave) {
vm.formState.loading = true; vm.formState.loading = true;
let url = null;
url = `user-option/${vm.obj.id}`; let url = `user-option/${vm.obj.id}`;
//clear any errors vm might be around from previous submit //clear any errors vm might be around from previous submit
window.$gz.form.deleteAllErrorBoxErrors(vm); window.$gz.form.deleteAllErrorBoxErrors(vm);

View File

@@ -8,7 +8,7 @@
<v-form ref="form"> <v-form ref="form">
<v-tabs mobile-breakpoint="100" v-model="tab"> <v-tabs mobile-breakpoint="100" v-model="tab">
<v-tab>{{ $ay.t("Contact") }}</v-tab> <v-tab>{{ $ay.t("Contact") }}</v-tab>
<v-tab v-if="obj.id != 0">{{ $ay.t("UserSettings") }}</v-tab> <v-tab>{{ $ay.t("UserSettings") }}</v-tab>
<v-tabs-items v-model="tab"> <v-tabs-items v-model="tab">
<v-tab-item class="mt-4 ml-2"> <v-tab-item class="mt-4 ml-2">
@@ -199,7 +199,7 @@
></v-col> ></v-col>
</v-row> </v-row>
</v-tab-item> </v-tab-item>
<v-tab-item v-if="obj.id != 0" class="mt-4 ml-2"> <v-tab-item class="mt-4 ml-2">
<v-row> <v-row>
<v-col cols="12" sm="6" lg="4" xl="3"> <v-col cols="12" sm="6" lg="4" xl="3">
<v-select <v-select
@@ -419,6 +419,52 @@ export default {
vm.formState.readOnly = !vm.rights.change; vm.formState.readOnly = !vm.rights.change;
window.$gz.eventBus.$on("menu-click", clickHandler); window.$gz.eventBus.$on("menu-click", clickHandler);
// //id 0 means create or duplicate to new
// if (vm.$route.params.recordid != 0) {
// //is there already an obj from a prior operation?
// if (this.$route.params.obj) {
// //yes, no need to fetch it
// this.obj = this.$route.params.obj;
// this.optionsObj = this.$route.params.optionsObj;
// vm.formState.loading = false; //here we handle it immediately
// } else {
// await vm.getDataFromApi(vm.$route.params.recordid); //let getdata handle loading
// }
// } else {
// vm.password = window.$gz.util.getRandomPassword();
// // vm.login = window.$gz.util.getRandomPassword();
// /* Customer = 3,
// HeadOffice = 4, */
// if (vm.$route.params.customerid && vm.$route.params.customerid != 0) {
// vm.obj.customerId = vm.$route.params.customerid;
// vm.obj.userType = 3;
// } else if (
// vm.$route.params.headofficeid &&
// vm.$route.params.headofficeid != 0
// ) {
// vm.obj.headOfficeId = vm.$route.params.headofficeid;
// vm.obj.userType = 4;
// } else {
// //no customer or headoffice id, can't proceed
// // navigate backwards
// vm.$router.go(-1);
// //if above turns out to be problematic just go to customers list instead
// // vm.$router.push({
// // name: "cust-customers"
// // });
// }
// vm.formState.loading = false; //here we handle it immediately
// }
// //set initial form status
// window.$gz.form.setFormState({
// vm: vm,
// dirty: false,
// valid: true
// });
let setDirty = false;
let setValid = true;
//id 0 means create or duplicate to new //id 0 means create or duplicate to new
if (vm.$route.params.recordid != 0) { if (vm.$route.params.recordid != 0) {
//is there already an obj from a prior operation? //is there already an obj from a prior operation?
@@ -426,40 +472,54 @@ export default {
//yes, no need to fetch it //yes, no need to fetch it
this.obj = this.$route.params.obj; this.obj = this.$route.params.obj;
this.optionsObj = this.$route.params.optionsObj; this.optionsObj = this.$route.params.optionsObj;
vm.formState.loading = false; //here we handle it immediately
} else { } else {
await vm.getDataFromApi(vm.$route.params.recordid); //let getdata handle loading await vm.getDataFromApi(vm.$route.params.recordid); //let getdata handle loading
} }
} else { } else {
vm.password = window.$gz.util.getRandomPassword(); //Might be a duplicate and contain another record
// vm.login = window.$gz.util.getRandomPassword(); if (this.$route.params.obj) {
/* Customer = 3, this.obj = this.$route.params.obj;
HeadOffice = 4, */ this.optionsObj = this.$route.params.optionsObj;
if (vm.$route.params.customerid && vm.$route.params.customerid != 0) { this.obj.concurrency = undefined;
vm.obj.customerId = vm.$route.params.customerid; this.optionsObj.concurrency = undefined;
vm.obj.userType = 3; this.obj.id = 0;
} else if ( this.optionsObj.id = 0;
vm.$route.params.headofficeid && this.obj.name = `${this.obj.name} - ${window.$gz.translation.get(
vm.$route.params.headofficeid != 0 "Copy"
) { )}`;
vm.obj.headOfficeId = vm.$route.params.headofficeid; this.password = window.$gz.util.getRandomPassword();
vm.obj.userType = 4; setDirty = true;
} else { } else {
//no customer or headoffice id, can't proceed vm.password = window.$gz.util.getRandomPassword();
// navigate backwards
vm.$router.go(-1); /* Customer = 3,
//if above turns out to be problematic just go to customers list instead HeadOffice = 4, */
// vm.$router.push({ if (vm.$route.params.customerid && vm.$route.params.customerid != 0) {
// name: "cust-customers" vm.obj.customerId = vm.$route.params.customerid;
// }); vm.obj.userType = 3;
} else if (
vm.$route.params.headofficeid &&
vm.$route.params.headofficeid != 0
) {
vm.obj.headOfficeId = vm.$route.params.headofficeid;
vm.obj.userType = 4;
} else {
//no customer or headoffice id, can't proceed
// navigate backwards
vm.$router.go(-1);
//if above turns out to be problematic just go to customers list instead
// vm.$router.push({
// name: "cust-customers"
// });
}
} }
vm.formState.loading = false; //here we handle it immediately
} }
//set initial form status
window.$gz.form.setFormState({ window.$gz.form.setFormState({
vm: vm, vm: vm,
dirty: false, loading: false,
valid: true dirty: setDirty,
valid: setValid
}); });
generateMenu(vm); generateMenu(vm);
@@ -525,12 +585,12 @@ export default {
phone2: null, phone2: null,
phone3: null, phone3: null,
mapUrlTemplate: null, mapUrlTemplate: null,
uiColor: null, uiColor: "#000000",
languageOverride: null, languageOverride: null,
timeZoneOverride: null, timeZoneOverride: null,
currencyName: null, currencyName: "USD",
hour12: null, hour12: true,
translationId: null translationId: 1
}, },
login: null, login: null,
password: null, password: null,
@@ -675,17 +735,16 @@ export default {
window.$gz.form.deleteAllErrorBoxErrors(vm); window.$gz.form.deleteAllErrorBoxErrors(vm);
//add in password and login if changed //add in password and login if changed
let submitObject = vm.obj;
if (vm.password != null && vm.password != "") { if (vm.password != null && vm.password != "") {
submitObject.password = vm.password; vm.obj.password = vm.password;
} }
if (vm.login != null && vm.login != "") { if (vm.login != null && vm.login != "") {
submitObject.login = vm.login; vm.obj.login = vm.login;
} }
if (submitObject.roles == null) { if (vm.obj.roles == null) {
submitObject.roles = 0; vm.obj.roles = 0;
} }
let res = await window.$gz.api.upsert(url, submitObject); let res = await window.$gz.api.upsert(url, vm.obj);
if (res.error) { if (res.error) {
vm.formState.serverError = res.error; vm.formState.serverError = res.error;
window.$gz.form.setErrorBoxErrors(vm); window.$gz.form.setErrorBoxErrors(vm);
@@ -694,7 +753,8 @@ export default {
if (res.data.id) { if (res.data.id) {
//POST - whole new object returned //POST - whole new object returned
vm.obj = res.data; vm.obj = res.data;
await vm.getUserOptionsDataFromApi(); vm.optionsObj.userId = res.data.id;
await vm.submitOptions();
//Change URL to new record //Change URL to new record
//NOTE: will not cause a page re-render, almost nothing does unless forced with a KEY property or using router.GO() //NOTE: will not cause a page re-render, almost nothing does unless forced with a KEY property or using router.GO()
@@ -764,36 +824,47 @@ export default {
vm.formState.loading = false; vm.formState.loading = false;
} }
}, },
async duplicate() { duplicate() {
let vm = this; //Navigate to new record
if (!vm.canDuplicate || vm.$route.params.recordid == 0) { this.$router.push({
return; name: "cust-user",
} params: {
vm.formState.loading = true; recordid: 0,
let url = API_BASE_URL + "duplicate/" + vm.$route.params.recordid; obj: this.obj, // pass data object to new form
optionsObj: this.optionsObj
try {
window.$gz.form.deleteAllErrorBoxErrors(vm);
let res = await window.$gz.api.upsert(url);
if (res.error) {
vm.formState.serverError = res.error;
window.$gz.form.setErrorBoxErrors(vm);
} else {
//Navigate to new record
this.$router.push({
name: "adm-user",
params: {
recordid: res.data.id,
obj: res.data // pass data object to new form
}
});
} }
} catch (ex) { });
window.$gz.errorHandler.handleFormError(ex, vm);
} finally {
vm.formState.loading = false;
}
}, },
// async duplicate() {
// let vm = this;
// if (!vm.canDuplicate || vm.$route.params.recordid == 0) {
// return;
// }
// vm.formState.loading = true;
// let url = API_BASE_URL + "duplicate/" + vm.$route.params.recordid;
// try {
// window.$gz.form.deleteAllErrorBoxErrors(vm);
// let res = await window.$gz.api.upsert(url);
// if (res.error) {
// vm.formState.serverError = res.error;
// window.$gz.form.setErrorBoxErrors(vm);
// } else {
// //Navigate to new record
// this.$router.push({
// name: "adm-user",
// params: {
// recordid: res.data.id,
// obj: res.data // pass data object to new form
// }
// });
// }
// } catch (ex) {
// window.$gz.errorHandler.handleFormError(ex, vm);
// } finally {
// vm.formState.loading = false;
// }
// },
async getUserOptionsDataFromApi() { async getUserOptionsDataFromApi() {
let vm = this; let vm = this;
vm.formState.loading = true; vm.formState.loading = true;
@@ -812,7 +883,6 @@ export default {
window.$gz.form.setErrorBoxErrors(vm); window.$gz.form.setErrorBoxErrors(vm);
} else { } else {
vm.optionsObj = res.data; vm.optionsObj = res.data;
// vm.activeTranslationId = res.data.translationId;
//Update the form status //Update the form status
window.$gz.form.setFormState({ window.$gz.form.setFormState({
@@ -843,7 +913,7 @@ export default {
//clear any errors vm might be around from previous submit //clear any errors vm might be around from previous submit
window.$gz.form.deleteAllErrorBoxErrors(vm); window.$gz.form.deleteAllErrorBoxErrors(vm);
try { try {
let res = await window.$gz.api.upsert(url, vm.optionsObj); let res = await window.$gz.api.put(url, vm.optionsObj);
vm.formState.loading = false; vm.formState.loading = false;
if (res.error) { if (res.error) {
@@ -928,12 +998,12 @@ async function clickHandler(menuItem) {
case "delete": case "delete":
m.vm.remove(); m.vm.remove();
break; break;
case "new": // case "new":
m.vm.$router.push({ // m.vm.$router.push({
name: "adm-user", // name: "adm-user",
params: { recordid: 0 } // params: { recordid: 0 }
}); // });
break; // break;
case "duplicate": case "duplicate":
m.vm.duplicate(); m.vm.duplicate();
break; break;
@@ -1054,14 +1124,14 @@ function generateMenu(vm) {
}); });
} }
if (vm.rights.change) { // if (vm.rights.change) {
menuOptions.menuItems.push({ // menuOptions.menuItems.push({
title: "New", // title: "New",
icon: "$ayiPlus", // icon: "$ayiPlus",
key: FORM_KEY + ":new", // key: FORM_KEY + ":new",
vm: vm // vm: vm
}); // });
} // }
if (vm.rights.change && vm.$route.params.recordid != 0) { if (vm.rights.change && vm.$route.params.recordid != 0) {
menuOptions.menuItems.push({ menuOptions.menuItems.push({

View File

@@ -56,12 +56,12 @@ async function clickHandler(menuItem) {
let m = window.$gz.menu.parseMenuItem(menuItem); let m = window.$gz.menu.parseMenuItem(menuItem);
if (m.owner == FORM_KEY && !m.disabled) { if (m.owner == FORM_KEY && !m.disabled) {
switch (m.key) { switch (m.key) {
case "new": // case "new":
m.vm.$router.push({ // m.vm.$router.push({
name: "cust-user", // name: "cust-user",
params: { recordid: 0 } // params: { recordid: 0 }
}); // });
break; // break;
case "extensions": case "extensions":
let res = await m.vm.$refs.extensions.open( let res = await m.vm.$refs.extensions.open(
m.vm.$refs.gzdatatable.getDataListSelection(window.$gz.type.User) m.vm.$refs.gzdatatable.getDataListSelection(window.$gz.type.User)
@@ -140,15 +140,15 @@ function generateMenu(vm) {
} }
}; };
if (vm.rights.change) { // if (vm.rights.change) {
menuOptions.menuItems.push({ // menuOptions.menuItems.push({
title: "New", // title: "New",
icon: "$ayiPlus", // icon: "$ayiPlus",
surface: true, // surface: true,
key: FORM_KEY + ":new", // key: FORM_KEY + ":new",
vm: vm // vm: vm
}); // });
} // }
//REPORTS //REPORTS
//Report not Print, print is a further option //Report not Print, print is a further option

View File

@@ -77,9 +77,9 @@ export default {
vm.formState.ready = true; vm.formState.ready = true;
} }
}, },
beforeRouteEnter(to, from, next) { // beforeRouteEnter(to, from, next) {
next(window.$gz.store.state.notifyAvailable); // next(window.$gz.store.state.notifyAvailable);
}, // },
beforeDestroy() { beforeDestroy() {
window.$gz.eventBus.$off("menu-click", clickHandler); window.$gz.eventBus.$off("menu-click", clickHandler);
}, },