This commit is contained in:
2021-06-30 18:45:38 +00:00
parent e3a7d9aec1
commit 18707ae758

View File

@@ -4,11 +4,12 @@
<div v-if="formState.ready">
<gz-error :error-box-message="formState.errorBoxMessage"></gz-error>
{{ isUnsavedDuplicate }}
<v-form ref="form">
<v-tabs mobile-breakpoint="100" v-model="tab">
<v-tab>{{ $ay.t("User") }}</v-tab>
<v-tab v-if="obj.id != 0">{{ $ay.t("UserSettings") }}</v-tab>
<!-- v-if="obj.id != 0 || isUnsavedDuplicate" -->
<v-tab>{{ $ay.t("UserSettings") }}</v-tab>
<v-tabs-items v-model="tab">
<v-tab-item class="mt-4 ml-2">
@@ -213,10 +214,8 @@
></v-col>
</v-row>
</v-tab-item>
<v-tab-item
v-if="obj.id != 0 || isUnsavedDuplicate"
class="mt-4 ml-2"
>
<!-- v-if="obj.id != 0 || isUnsavedDuplicate" -->
<v-tab-item class="mt-4 ml-2">
<v-row>
<v-col cols="12" sm="6" lg="4" xl="3">
<v-select
@@ -436,27 +435,6 @@ 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.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;
@@ -482,7 +460,7 @@ export default {
this.obj.name = `${this.obj.name} - ${window.$gz.translation.get(
"Copy"
)}`;
this.isUnsavedDuplicate = true;
setDirty = true;
}
}
@@ -550,7 +528,11 @@ export default {
"timeZoneOverride": null,
"currencyName": "USD",
"hour12": true,
"userId": 1 */
"userId": 1
CurrencyName = "USD";
Hour12 = true;
UiColor = "#000000"*/
id: 0,
concurrency: 0,
emailAddress: null,
@@ -558,12 +540,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,
@@ -581,8 +563,7 @@ export default {
serverError: {}
},
rights: window.$gz.role.defaultRightsObject(),
ayaType: window.$gz.type.User,
isUnsavedDuplicate: false
ayaType: window.$gz.type.User
};
},
//WATCHERS
@@ -710,18 +691,16 @@ export default {
window.$gz.form.deleteAllErrorBoxErrors(vm);
//add in password and login if changed
//todo: unnecessary variable here, it's just a reference, not sure why it's coded this way
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);
@@ -730,18 +709,11 @@ export default {
if (res.data.id) {
//POST - whole new object returned
vm.obj = res.data;
vm.optionsObj.userId = res.data.id;
await vm.submitOptions();
//might be a duplicate, so rather than fetch here it would be another save like a put
if (vm.isUnsavedDuplicate) {
vm.optionsObj.userId = res.data.id;
await vm.submitOptions();
} else {
await vm.getUserOptionsDataFromApi();
}
//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()
this.$router.push({
name: "adm-user",
params: {