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"> <div v-if="formState.ready">
<gz-error :error-box-message="formState.errorBoxMessage"></gz-error> <gz-error :error-box-message="formState.errorBoxMessage"></gz-error>
{{ isUnsavedDuplicate }}
<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-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-tabs-items v-model="tab">
<v-tab-item class="mt-4 ml-2"> <v-tab-item class="mt-4 ml-2">
@@ -213,10 +214,8 @@
></v-col> ></v-col>
</v-row> </v-row>
</v-tab-item> </v-tab-item>
<v-tab-item <!-- v-if="obj.id != 0 || isUnsavedDuplicate" -->
v-if="obj.id != 0 || isUnsavedDuplicate" <v-tab-item class="mt-4 ml-2">
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
@@ -436,27 +435,6 @@ 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.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 setDirty = false;
let setValid = true; let setValid = true;
@@ -482,7 +460,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.isUnsavedDuplicate = true;
setDirty = true; setDirty = true;
} }
} }
@@ -550,7 +528,11 @@ export default {
"timeZoneOverride": null, "timeZoneOverride": null,
"currencyName": "USD", "currencyName": "USD",
"hour12": true, "hour12": true,
"userId": 1 */ "userId": 1
CurrencyName = "USD";
Hour12 = true;
UiColor = "#000000"*/
id: 0, id: 0,
concurrency: 0, concurrency: 0,
emailAddress: null, emailAddress: null,
@@ -558,12 +540,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,
@@ -581,8 +563,7 @@ export default {
serverError: {} serverError: {}
}, },
rights: window.$gz.role.defaultRightsObject(), rights: window.$gz.role.defaultRightsObject(),
ayaType: window.$gz.type.User, ayaType: window.$gz.type.User
isUnsavedDuplicate: false
}; };
}, },
//WATCHERS //WATCHERS
@@ -710,18 +691,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
//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 != "") { 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);
@@ -730,18 +709,11 @@ 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;
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 //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()
this.$router.push({ this.$router.push({
name: "adm-user", name: "adm-user",
params: { params: {