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
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
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?
@@ -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 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: User duplicate locally, improvements, port to customer user form identically
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
is affecting inventory on duplicate??
Look into it.
IDEALLY REPLACE WITH LOCAL COPY LIKE WO
todo: workorder "template" replacement via duplicate requires some changes:
V7 notes:

View File

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

View File

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

View File

@@ -8,7 +8,7 @@
<v-form ref="form">
<v-tabs mobile-breakpoint="100" v-model="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-tab-item class="mt-4 ml-2">
@@ -199,7 +199,7 @@
></v-col>
</v-row>
</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-col cols="12" sm="6" lg="4" xl="3">
<v-select
@@ -419,6 +419,52 @@ export default {
vm.formState.readOnly = !vm.rights.change;
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
if (vm.$route.params.recordid != 0) {
//is there already an obj from a prior operation?
@@ -426,40 +472,54 @@ export default {
//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;
//Might be a duplicate and contain another record
if (this.$route.params.obj) {
this.obj = this.$route.params.obj;
this.optionsObj = this.$route.params.optionsObj;
this.obj.concurrency = undefined;
this.optionsObj.concurrency = undefined;
this.obj.id = 0;
this.optionsObj.id = 0;
this.obj.name = `${this.obj.name} - ${window.$gz.translation.get(
"Copy"
)}`;
this.password = window.$gz.util.getRandomPassword();
setDirty = true;
} 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.password = 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
loading: false,
dirty: setDirty,
valid: setValid
});
generateMenu(vm);
@@ -525,12 +585,12 @@ export default {
phone2: null,
phone3: null,
mapUrlTemplate: null,
uiColor: null,
uiColor: "#000000",
languageOverride: null,
timeZoneOverride: null,
currencyName: null,
hour12: null,
translationId: null
currencyName: "USD",
hour12: true,
translationId: 1
},
login: null,
password: null,
@@ -675,17 +735,16 @@ export default {
window.$gz.form.deleteAllErrorBoxErrors(vm);
//add in password and login if changed
let submitObject = vm.obj;
if (vm.password != null && vm.password != "") {
submitObject.password = vm.password;
vm.obj.password = vm.password;
}
if (vm.login != null && vm.login != "") {
submitObject.login = vm.login;
vm.obj.login = vm.login;
}
if (submitObject.roles == null) {
submitObject.roles = 0;
if (vm.obj.roles == null) {
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) {
vm.formState.serverError = res.error;
window.$gz.form.setErrorBoxErrors(vm);
@@ -694,7 +753,8 @@ export default {
if (res.data.id) {
//POST - whole new object returned
vm.obj = res.data;
await vm.getUserOptionsDataFromApi();
vm.optionsObj.userId = res.data.id;
await vm.submitOptions();
//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()
@@ -764,36 +824,47 @@ export default {
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
}
});
duplicate() {
//Navigate to new record
this.$router.push({
name: "cust-user",
params: {
recordid: 0,
obj: this.obj, // pass data object to new form
optionsObj: this.optionsObj
}
} 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() {
let vm = this;
vm.formState.loading = true;
@@ -812,7 +883,6 @@ export default {
window.$gz.form.setErrorBoxErrors(vm);
} else {
vm.optionsObj = res.data;
// vm.activeTranslationId = res.data.translationId;
//Update the form status
window.$gz.form.setFormState({
@@ -843,7 +913,7 @@ export default {
//clear any errors vm might be around from previous submit
window.$gz.form.deleteAllErrorBoxErrors(vm);
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;
if (res.error) {
@@ -928,12 +998,12 @@ async function clickHandler(menuItem) {
case "delete":
m.vm.remove();
break;
case "new":
m.vm.$router.push({
name: "adm-user",
params: { recordid: 0 }
});
break;
// case "new":
// m.vm.$router.push({
// name: "adm-user",
// params: { recordid: 0 }
// });
// break;
case "duplicate":
m.vm.duplicate();
break;
@@ -1054,14 +1124,14 @@ function generateMenu(vm) {
});
}
if (vm.rights.change) {
menuOptions.menuItems.push({
title: "New",
icon: "$ayiPlus",
key: FORM_KEY + ":new",
vm: vm
});
}
// if (vm.rights.change) {
// menuOptions.menuItems.push({
// title: "New",
// icon: "$ayiPlus",
// key: FORM_KEY + ":new",
// vm: vm
// });
// }
if (vm.rights.change && vm.$route.params.recordid != 0) {
menuOptions.menuItems.push({

View File

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

View File

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