re-factor / cleanup
This commit is contained in:
@@ -6,13 +6,13 @@
|
||||
<gz-error :error-box-message="formState.errorBoxMessage"></gz-error>
|
||||
<v-col cols="12" sm="6" lg="4" xl="3">
|
||||
<v-select
|
||||
ref="translationId"
|
||||
v-model="obj.translationId"
|
||||
:items="selectLists.translations"
|
||||
item-text="name"
|
||||
item-value="id"
|
||||
:readonly="formState.readOnly"
|
||||
:label="$ay.t('Translation')"
|
||||
ref="translationId"
|
||||
:error-messages="form().serverErrors(this, 'translationId')"
|
||||
@input="fieldValueChanged('translationId')"
|
||||
></v-select>
|
||||
@@ -20,13 +20,13 @@
|
||||
|
||||
<v-col cols="12" sm="6" lg="4" xl="3">
|
||||
<gz-email
|
||||
ref="emailAddress"
|
||||
v-model="obj.emailAddress"
|
||||
:readonly="formState.readOnly"
|
||||
:label="$ay.t('UserEmailAddress')"
|
||||
:error-messages="form().serverErrors(this, 'emailAddress')"
|
||||
ref="emailAddress"
|
||||
@input="fieldValueChanged('emailAddress')"
|
||||
data-cy="emailAddress"
|
||||
@input="fieldValueChanged('emailAddress')"
|
||||
></gz-email>
|
||||
</v-col>
|
||||
<v-col
|
||||
@@ -37,10 +37,10 @@
|
||||
xl="3"
|
||||
>
|
||||
<gz-phone
|
||||
ref="phone1"
|
||||
v-model="obj.phone1"
|
||||
:readonly="formState.readOnly"
|
||||
:label="$ay.t('UserPhone1')"
|
||||
ref="phone1"
|
||||
data-cy="phone1"
|
||||
:error-messages="form().serverErrors(this, 'phone1')"
|
||||
@input="fieldValueChanged('phone1')"
|
||||
@@ -55,10 +55,10 @@
|
||||
xl="3"
|
||||
>
|
||||
<gz-phone
|
||||
ref="phone2"
|
||||
v-model="obj.phone2"
|
||||
:readonly="formState.readOnly"
|
||||
:label="$ay.t('UserPhone2')"
|
||||
ref="phone2"
|
||||
data-cy="phone2"
|
||||
:error-messages="form().serverErrors(this, 'phone2')"
|
||||
@input="fieldValueChanged('phone2')"
|
||||
@@ -73,10 +73,10 @@
|
||||
xl="3"
|
||||
>
|
||||
<gz-phone
|
||||
ref="phone3"
|
||||
v-model="obj.phone3"
|
||||
:readonly="formState.readOnly"
|
||||
:label="$ay.t('UserPageAddress')"
|
||||
ref="phone3"
|
||||
data-cy="phone3"
|
||||
:error-messages="form().serverErrors(this, 'phone3')"
|
||||
@input="fieldValueChanged('phone3')"
|
||||
@@ -85,15 +85,15 @@
|
||||
|
||||
<v-col cols="12" sm="6" lg="4" xl="3">
|
||||
<v-text-field
|
||||
ref="mapUrlTemplate"
|
||||
v-model="obj.mapUrlTemplate"
|
||||
:readonly="formState.readOnly"
|
||||
:label="$ay.t('MapUrlTemplate')"
|
||||
:error-messages="form().serverErrors(this, 'mapUrlTemplate')"
|
||||
ref="mapUrlTemplate"
|
||||
@input="fieldValueChanged('mapUrlTemplate')"
|
||||
data-cy="mapUrlTemplate"
|
||||
:hint="obj.mapUrlTemplate == null ? 'Google maps' : ''"
|
||||
persistent-hint
|
||||
@input="fieldValueChanged('mapUrlTemplate')"
|
||||
></v-text-field>
|
||||
<v-select
|
||||
:items="selectLists.mapUrls"
|
||||
@@ -104,10 +104,10 @@
|
||||
</v-col>
|
||||
<v-col cols="12" sm="6" lg="4" xl="3">
|
||||
<v-checkbox
|
||||
ref="hour12"
|
||||
v-model="obj.hour12"
|
||||
:readonly="formState.readOnly"
|
||||
:label="$ay.t('Hour12')"
|
||||
ref="hour12"
|
||||
:error-messages="form().serverErrors(this, 'hour12')"
|
||||
@change="fieldValueChanged('hour12')"
|
||||
></v-checkbox>
|
||||
@@ -115,17 +115,18 @@
|
||||
|
||||
<v-col cols="12" sm="6" lg="4" xl="3">
|
||||
<v-checkbox
|
||||
ref="nativeDateTimeInput"
|
||||
v-model="nativeDateTimeInput"
|
||||
:readonly="formState.readOnly"
|
||||
:label="$ay.t('NativeDateTimeInput')"
|
||||
ref="nativeDateTimeInput"
|
||||
@change="nativeDateTimeInputChanged()"
|
||||
data-cy="nativeDateTimeInput"
|
||||
@change="nativeDateTimeInputChanged()"
|
||||
></v-checkbox>
|
||||
</v-col>
|
||||
|
||||
<v-col cols="12" sm="6" lg="4" xl="3">
|
||||
<v-text-field
|
||||
ref="currencyName"
|
||||
v-model="obj.currencyName"
|
||||
:hint="
|
||||
obj.currencyName == null || obj.currencyName == ''
|
||||
@@ -136,39 +137,38 @@
|
||||
:readonly="formState.readOnly"
|
||||
:label="$ay.t('CurrencyCode')"
|
||||
:error-messages="form().serverErrors(this, 'currencyName')"
|
||||
ref="currencyName"
|
||||
@input="fieldValueChanged('currencyName')"
|
||||
append-outer-icon="$ayiQuestionCircle"
|
||||
@input="fieldValueChanged('currencyName')"
|
||||
@click:append-outer="goHelp()"
|
||||
></v-text-field>
|
||||
</v-col>
|
||||
|
||||
<v-col cols="12" sm="6" lg="4" xl="3">
|
||||
<v-text-field
|
||||
ref="languageOverride"
|
||||
v-model="obj.languageOverride"
|
||||
:readonly="formState.readOnly"
|
||||
:label="$ay.t('LanguageCode')"
|
||||
:error-messages="form().serverErrors(this, 'languageOverride')"
|
||||
ref="languageOverride"
|
||||
@input="fieldValueChanged('languageOverride')"
|
||||
:hint="locale().getResolvedLanguage()"
|
||||
persistent-hint
|
||||
append-outer-icon="$ayiQuestionCircle"
|
||||
@input="fieldValueChanged('languageOverride')"
|
||||
@click:append-outer="goHelp()"
|
||||
></v-text-field>
|
||||
</v-col>
|
||||
|
||||
<v-col cols="12" sm="6" lg="4" xl="3">
|
||||
<v-text-field
|
||||
ref="timeZoneOverride"
|
||||
v-model="obj.timeZoneOverride"
|
||||
:readonly="formState.readOnly"
|
||||
:label="$ay.t('TimeZone')"
|
||||
:error-messages="form().serverErrors(this, 'timeZoneOverride')"
|
||||
ref="timeZoneOverride"
|
||||
@input="fieldValueChanged('timeZoneOverride')"
|
||||
:hint="locale().getResolvedTimeZoneName()"
|
||||
persistent-hint
|
||||
append-outer-icon="$ayiQuestionCircle"
|
||||
@input="fieldValueChanged('timeZoneOverride')"
|
||||
@click:append-outer="goHelp()"
|
||||
></v-text-field>
|
||||
</v-col>
|
||||
@@ -198,40 +198,6 @@ const FORM_KEY = "user-settings";
|
||||
const API_BASE_URL = "user-option/";
|
||||
const FORM_CUSTOM_TEMPLATE_KEY = "UserOptions";
|
||||
export default {
|
||||
async created() {
|
||||
const vm = this;
|
||||
try {
|
||||
await initForm(vm);
|
||||
|
||||
vm.rights = window.$gz.role.fullRightsObject();
|
||||
vm.formState.ready = true;
|
||||
window.$gz.eventBus.$on("menu-click", clickHandler);
|
||||
//UserOptions never creates a new one so this code is a little different than other forms
|
||||
//NOTE: FOR NOW GOING TO ASSUME THIS FORM WILL ONLY EVER BE USED TO EDIT *CURRENT* USER'S USEROPTIONS
|
||||
//SO NOT FOR EDITING OTHER USERS, WILL ASSUME THE USER EDITOR FORM FOR MANAGEMENT WILL HAVE A COMPACT VERSION
|
||||
//OF THESE SAME FIELDS FOR THAT PURPOSE
|
||||
//SO ALWAYS USER CURRENT LOGGED IN USER ID FOR THIS
|
||||
//id 0 means create or duplicate to new but thats not applicable here
|
||||
await vm.getDataFromApi();
|
||||
} catch (err) {
|
||||
vm.formState.ready = true;
|
||||
window.$gz.errorHandler.handleFormError(err, vm);
|
||||
}
|
||||
},
|
||||
async beforeRouteLeave(to, from, next) {
|
||||
if (!this.formState.dirty) {
|
||||
next();
|
||||
return;
|
||||
}
|
||||
if ((await window.$gz.dialog.confirmLeaveUnsaved()) === true) {
|
||||
next();
|
||||
} else {
|
||||
next(false);
|
||||
}
|
||||
},
|
||||
beforeDestroy() {
|
||||
window.$gz.eventBus.$off("menu-click", clickHandler);
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
formCustomTemplateKey: FORM_CUSTOM_TEMPLATE_KEY,
|
||||
@@ -269,6 +235,11 @@ export default {
|
||||
rights: window.$gz.role.defaultRightsObject()
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
canSave: function() {
|
||||
return this.formState.valid && this.formState.dirty;
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
formState: {
|
||||
handler: function(val) {
|
||||
@@ -285,11 +256,40 @@ export default {
|
||||
deep: true
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
canSave: function() {
|
||||
return this.formState.valid && this.formState.dirty;
|
||||
async created() {
|
||||
const vm = this;
|
||||
try {
|
||||
await initForm(vm);
|
||||
|
||||
vm.rights = window.$gz.role.fullRightsObject();
|
||||
vm.formState.ready = true;
|
||||
window.$gz.eventBus.$on("menu-click", clickHandler);
|
||||
//UserOptions never creates a new one so this code is a little different than other forms
|
||||
//NOTE: FOR NOW GOING TO ASSUME THIS FORM WILL ONLY EVER BE USED TO EDIT *CURRENT* USER'S USEROPTIONS
|
||||
//SO NOT FOR EDITING OTHER USERS, WILL ASSUME THE USER EDITOR FORM FOR MANAGEMENT WILL HAVE A COMPACT VERSION
|
||||
//OF THESE SAME FIELDS FOR THAT PURPOSE
|
||||
//SO ALWAYS USER CURRENT LOGGED IN USER ID FOR THIS
|
||||
//id 0 means create or duplicate to new but thats not applicable here
|
||||
await vm.getDataFromApi();
|
||||
} catch (err) {
|
||||
vm.formState.ready = true;
|
||||
window.$gz.errorHandler.handleFormError(err, vm);
|
||||
}
|
||||
},
|
||||
async beforeRouteLeave(to, from, next) {
|
||||
if (!this.formState.dirty) {
|
||||
next();
|
||||
return;
|
||||
}
|
||||
if ((await window.$gz.dialog.confirmLeaveUnsaved()) === true) {
|
||||
next();
|
||||
} else {
|
||||
next(false);
|
||||
}
|
||||
},
|
||||
beforeDestroy() {
|
||||
window.$gz.eventBus.$off("menu-click", clickHandler);
|
||||
},
|
||||
methods: {
|
||||
goHelp() {
|
||||
window.open(
|
||||
@@ -493,7 +493,7 @@ function generateMenu(vm) {
|
||||
//
|
||||
//
|
||||
async function initForm(vm) {
|
||||
await fetchTranslatedText(vm);
|
||||
await fetchTranslatedText();
|
||||
await populateSelectionLists(vm);
|
||||
}
|
||||
|
||||
@@ -501,7 +501,7 @@ async function initForm(vm) {
|
||||
//
|
||||
// Ensures UI translated text is available
|
||||
//
|
||||
async function fetchTranslatedText(vm) {
|
||||
async function fetchTranslatedText() {
|
||||
await window.$gz.translation.cacheTranslations([
|
||||
"CurrencyCode",
|
||||
"LanguageCode",
|
||||
|
||||
Reference in New Issue
Block a user