This commit is contained in:
@@ -18,6 +18,9 @@ export default {
|
||||
vm.appBar.title = ctx.title;
|
||||
|
||||
//Parse the formdata if present
|
||||
//FORMDATA is OPTIONAL and only required for forms that need to allow
|
||||
//viewing object history, attachments, custom fields, etc that kind of thing
|
||||
//usually CORE objects with an id, NOT utility type forms
|
||||
var formAyaType = 0;
|
||||
var formRecordId = 0;
|
||||
if (ctx.formData) {
|
||||
|
||||
@@ -301,7 +301,6 @@ function generateMenu(vm) {
|
||||
title: window.$gz.locale.get("Customize"),
|
||||
helpUrl: "form-ay-customize",
|
||||
formData: {
|
||||
formKey: FORM_KEY,
|
||||
ayaType: window.$gz.type.FormCustom,
|
||||
formCustomTemplateKey: undefined
|
||||
},
|
||||
|
||||
@@ -934,7 +934,6 @@ function generateMenu(vm) {
|
||||
title: window.$gz.locale.get("DataListView"),
|
||||
helpUrl: "form-ay-data-list-view",
|
||||
formData: {
|
||||
formKey: FORM_KEY,
|
||||
ayaType: window.$gz.type.FormCustom,
|
||||
formCustomTemplateKey: undefined
|
||||
},
|
||||
|
||||
@@ -1,21 +1,420 @@
|
||||
<template>
|
||||
<UnderConstruction />
|
||||
<v-container>
|
||||
<v-row v-if="formState.ready">
|
||||
<v-col>
|
||||
<v-form ref="form">
|
||||
<v-row>
|
||||
<v-col cols="12" mt-1 mb-2>
|
||||
<v-alert
|
||||
ref="errorbox"
|
||||
v-show="formState.errorBoxMessage"
|
||||
color="error"
|
||||
icon="fa-exclamation-circle "
|
||||
transition="scale-transition"
|
||||
class="multi-line"
|
||||
outlined
|
||||
>{{ formState.errorBoxMessage }}</v-alert
|
||||
>
|
||||
</v-col>
|
||||
|
||||
<v-col cols="12" sm="6" lg="4" xl="3">
|
||||
<v-text-field
|
||||
v-model="obj.emailAddress"
|
||||
:readonly="formState.readOnly"
|
||||
clearable
|
||||
@click:clear="onChange('emailAddress')"
|
||||
:label="lt('UserEmailAddress')"
|
||||
:error-messages="form().serverErrors(this, 'emailAddress')"
|
||||
ref="emailAddress"
|
||||
@change="onChange('emailAddress')"
|
||||
></v-text-field>
|
||||
</v-col>
|
||||
|
||||
<v-col cols="12" sm="6" lg="4" xl="3">
|
||||
<v-text-field
|
||||
v-model="obj.languageOverride"
|
||||
:placeholder="locale().getBrowserFirstLanguage()"
|
||||
:readonly="formState.readOnly"
|
||||
clearable
|
||||
@click:clear="onChange('languageOverride')"
|
||||
:label="lt('LanguageCode')"
|
||||
:error-messages="form().serverErrors(this, 'languageOverride')"
|
||||
ref="languageOverride"
|
||||
@change="onChange('languageOverride')"
|
||||
></v-text-field>
|
||||
</v-col>
|
||||
|
||||
<v-col cols="12" sm="6" lg="4" xl="3">
|
||||
<v-text-field
|
||||
v-model="obj.currencyName"
|
||||
hint="e.g. USD, EUR, GBP, AUD, CAD etc"
|
||||
:readonly="formState.readOnly"
|
||||
clearable
|
||||
@click:clear="onChange('currencyName')"
|
||||
:label="lt('CurrencyCode')"
|
||||
:rules="[form().required(this, 'currencyName')]"
|
||||
:error-messages="form().serverErrors(this, 'currencyName')"
|
||||
ref="currencyName"
|
||||
@change="onChange('currencyName')"
|
||||
></v-text-field>
|
||||
</v-col>
|
||||
|
||||
<v-col cols="12" sm="6" lg="4" xl="3">
|
||||
<v-text-field
|
||||
v-model="obj.timeZoneOverride"
|
||||
:placeholder="locale().getTimeZoneName()"
|
||||
:readonly="formState.readOnly"
|
||||
clearable
|
||||
@click:clear="onChange('timeZoneOverride')"
|
||||
:label="lt('TimeZone')"
|
||||
:error-messages="form().serverErrors(this, 'timeZoneOverride')"
|
||||
ref="timeZoneOverride"
|
||||
@change="onChange('timeZoneOverride')"
|
||||
></v-text-field>
|
||||
</v-col>
|
||||
|
||||
<v-col cols="12" sm="6" lg="4" xl="3">
|
||||
<!-- https://vuetifyjs.com/en/components/color-pickers -->
|
||||
<span class="v-label v-label--active theme--light">
|
||||
{{ lt("UserColor") }}
|
||||
</span>
|
||||
<v-color-picker
|
||||
v-model="obj.uiColor"
|
||||
:readonly="formState.readOnly"
|
||||
hide-mode-switch
|
||||
mode="hexa"
|
||||
:error-messages="form().serverErrors(this, 'uiColor')"
|
||||
ref="uiColor"
|
||||
@input="onChange('uiColor')"
|
||||
></v-color-picker>
|
||||
</v-col>
|
||||
|
||||
<v-col cols="12" sm="6" lg="4" xl="3">
|
||||
<v-checkbox
|
||||
v-model="obj.hour12"
|
||||
:readonly="formState.readOnly"
|
||||
:label="lt('Hour12')"
|
||||
ref="hour12"
|
||||
:error-messages="form().serverErrors(this, 'hour12')"
|
||||
@change="onChange('hour12')"
|
||||
></v-checkbox>
|
||||
</v-col>
|
||||
</v-row>
|
||||
</v-form>
|
||||
</v-col>
|
||||
</v-row>
|
||||
</v-container>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import UnderConstruction from "../components/underconstruction.vue";
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/* Xeslint-disable */
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
const FORM_KEY = "home-user-settings";
|
||||
const API_BASE_URL = "Useroptions/";
|
||||
const FORM_CUSTOM_TEMPLATE_KEY = "Useroptions";
|
||||
|
||||
export default {
|
||||
components: {
|
||||
UnderConstruction
|
||||
created() {
|
||||
var vm = this;
|
||||
initForm(vm)
|
||||
.then(() => {
|
||||
vm.rights = window.$gz.role.getRights(window.$gz.type.UserOptions);
|
||||
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 a new record don't load one but thats not applicable here
|
||||
|
||||
vm.getDataFromApi();
|
||||
})
|
||||
.catch(err => {
|
||||
vm.formState.ready = true;
|
||||
window.$gz.errorHandler.handleFormError(err, vm);
|
||||
});
|
||||
},
|
||||
beforeCreate() {
|
||||
window.$gz.eventBus.$emit("menu-change", {
|
||||
isMain: true,
|
||||
icon: "key",
|
||||
title: window.$gz.locale.get("SetLoginPassword"),
|
||||
helpUrl: "form-home-password"
|
||||
});
|
||||
beforeRouteLeave(to, from, next) {
|
||||
if (this.formState.dirty) {
|
||||
window.$gz.dialog.confirmLeaveUnsaved().then(dialogResult => {
|
||||
if (dialogResult == true) {
|
||||
next();
|
||||
} else {
|
||||
next(false);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
next();
|
||||
}
|
||||
},
|
||||
beforeDestroy() {
|
||||
window.$gz.eventBus.$off("menu-click", clickHandler);
|
||||
},
|
||||
components: {},
|
||||
data() {
|
||||
return {
|
||||
formCustomTemplateKey: FORM_CUSTOM_TEMPLATE_KEY,
|
||||
// pickLists: {
|
||||
// usertypes: []
|
||||
// },
|
||||
obj: {
|
||||
id: 0,
|
||||
concurrencyToken: 0,
|
||||
emailAddress: null,
|
||||
uiColor: null,
|
||||
languageOverride: null,
|
||||
timeZoneOverride: null,
|
||||
currencyName: null,
|
||||
hour12: null
|
||||
},
|
||||
formState: {
|
||||
ready: false,
|
||||
dirty: false,
|
||||
valid: true,
|
||||
readOnly: false,
|
||||
loading: true,
|
||||
errorBoxMessage: null,
|
||||
appError: null,
|
||||
serverError: {}
|
||||
},
|
||||
rights: window.$gz.role.defaultRightsObject()
|
||||
};
|
||||
},
|
||||
//WATCHERS
|
||||
watch: {
|
||||
formState: {
|
||||
handler: function(val) {
|
||||
//,oldval is available here too if necessary
|
||||
if (this.formState.loading) {
|
||||
return;
|
||||
}
|
||||
|
||||
//enable / disable save button
|
||||
var canSave = val.dirty && val.valid && !val.readOnly;
|
||||
if (canSave) {
|
||||
window.$gz.eventBus.$emit("menu-enable-item", FORM_KEY + ":save");
|
||||
} else {
|
||||
window.$gz.eventBus.$emit("menu-disable-item", FORM_KEY + ":save");
|
||||
}
|
||||
},
|
||||
deep: true
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
canSave: function() {
|
||||
return this.formState.valid && this.formState.dirty;
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
lt(ltKey) {
|
||||
return window.$gz.locale.get(ltKey);
|
||||
},
|
||||
locale() {
|
||||
return window.$gz.locale;
|
||||
},
|
||||
form() {
|
||||
return window.$gz.form;
|
||||
},
|
||||
onChange(ref) {
|
||||
if (!this.formState.loading && !this.formState.readOnly) {
|
||||
window.$gz.form.onChange(this, ref);
|
||||
}
|
||||
},
|
||||
getDataFromApi() {
|
||||
var vm = this;
|
||||
vm.formState.loading = true;
|
||||
//always fetch on this form for the current logged in user id
|
||||
var url = API_BASE_URL + vm.$store.state.userId;
|
||||
|
||||
window.$gz.form.deleteAllErrorBoxErrors(vm);
|
||||
|
||||
window.$gz.api
|
||||
.get(url)
|
||||
.then(res => {
|
||||
if (res.error != undefined) {
|
||||
//Not found?
|
||||
if (res.error.code == "2010") {
|
||||
//notify not found error then navigate backwards
|
||||
window.$gz.dialog
|
||||
.displayLTErrorMessage("ErrorAPI2010")
|
||||
.then(() => {
|
||||
// navigate backwards
|
||||
vm.$router.go(-1);
|
||||
});
|
||||
}
|
||||
vm.formState.serverError = res.error;
|
||||
window.$gz.form.setErrorBoxErrors(vm);
|
||||
} else {
|
||||
vm.obj = res.data;
|
||||
|
||||
//Update the form status
|
||||
window.$gz.form.setFormState({
|
||||
vm: vm,
|
||||
dirty: false,
|
||||
valid: true,
|
||||
loading: false,
|
||||
readOnly: res.readOnly ? true : false
|
||||
});
|
||||
//modify the menu as necessary
|
||||
generateMenu(vm, res.readOnly);
|
||||
}
|
||||
})
|
||||
.catch(function handleGetDataFromAPIError(error) {
|
||||
//Update the form status
|
||||
window.$gz.form.setFormState({
|
||||
vm: vm,
|
||||
loading: false
|
||||
});
|
||||
window.$gz.errorHandler.handleFormError(error, vm);
|
||||
});
|
||||
},
|
||||
submit() {
|
||||
var vm = this;
|
||||
if (vm.canSave) {
|
||||
vm.formState.loading = true;
|
||||
|
||||
//always submit from this form for the current logged in user id
|
||||
var url = API_BASE_URL + vm.$store.state.userId;
|
||||
|
||||
//clear any errors vm might be around from previous submit
|
||||
window.$gz.form.deleteAllErrorBoxErrors(vm);
|
||||
window.$gz.api
|
||||
.upsert(url, vm.obj)
|
||||
.then(res => {
|
||||
vm.formState.loading = false;
|
||||
if (res.error != undefined) {
|
||||
vm.formState.serverError = res.error;
|
||||
window.$gz.form.setErrorBoxErrors(vm);
|
||||
} else {
|
||||
//UserOptions is never a POST as it always exists and can't be deleted so always a PUT
|
||||
|
||||
//Handle "put" of an existing record (UPDATE)
|
||||
vm.obj.concurrencyToken = res.data.concurrencyToken;
|
||||
window.$gz.form.setFormState({
|
||||
vm: vm,
|
||||
dirty: false
|
||||
});
|
||||
}
|
||||
})
|
||||
.catch(function handleSubmitError(error) {
|
||||
vm.formState.loading = false;
|
||||
window.$gz.errorHandler.handleFormError(error, vm);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/////////////////////////////
|
||||
//
|
||||
//
|
||||
function clickHandler(menuItem) {
|
||||
if (!menuItem) {
|
||||
return;
|
||||
}
|
||||
var m = window.$gz.menu.parseMenuItem(menuItem);
|
||||
if (m.owner == FORM_KEY && !m.disabled) {
|
||||
switch (m.key) {
|
||||
case "save":
|
||||
m.vm.submit();
|
||||
break;
|
||||
|
||||
default:
|
||||
window.$gz.eventBus.$emit(
|
||||
"notify-warning",
|
||||
FORM_KEY + "::context click: [" + m.key + "]"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////
|
||||
//
|
||||
//
|
||||
function generateMenu(vm) {
|
||||
var menuOptions = {
|
||||
isMain: true,
|
||||
icon: "key",
|
||||
title: window.$gz.locale.get("SetLoginPassword"),
|
||||
helpUrl: "form-home-password",
|
||||
formData: {
|
||||
ayaType: window.$gz.type.UserOptions
|
||||
},
|
||||
menuItems: []
|
||||
};
|
||||
|
||||
/* isMain: true,
|
||||
icon: "key",
|
||||
title: window.$gz.locale.get("SetLoginPassword"),
|
||||
helpUrl: "form-home-password" */
|
||||
|
||||
if (vm.rights.change) {
|
||||
menuOptions.menuItems.push({
|
||||
title: window.$gz.locale.get("Save"),
|
||||
icon: "save",
|
||||
surface: true,
|
||||
key: FORM_KEY + ":save",
|
||||
vm: vm
|
||||
});
|
||||
}
|
||||
|
||||
//change password and login
|
||||
menuOptions.menuItems.push({
|
||||
title: window.$gz.locale.get("SetLoginPassword"),
|
||||
icon: "key",
|
||||
data: "home-password",
|
||||
key: "app:nav"
|
||||
});
|
||||
|
||||
window.$gz.eventBus.$emit("menu-change", menuOptions);
|
||||
}
|
||||
|
||||
/////////////////////////////////
|
||||
//
|
||||
//
|
||||
function initForm(vm) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
(async function() {
|
||||
try {
|
||||
await fetchUILocalizedText(vm);
|
||||
// await window.$gz.formCustomTemplate.get(FORM_CUSTOM_TEMPLATE_KEY);
|
||||
// await populatePickLists(vm);
|
||||
} catch (err) {
|
||||
reject(err);
|
||||
}
|
||||
resolve();
|
||||
})();
|
||||
});
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////
|
||||
//
|
||||
// Ensures UI localized text is available
|
||||
//
|
||||
function fetchUILocalizedText(vm) {
|
||||
return window.$gz.locale.fetch([
|
||||
"CurrencyCode",
|
||||
"LanguageCode",
|
||||
"TimeZone",
|
||||
"UserEmailAddress",
|
||||
"Hour12",
|
||||
"UserColor",
|
||||
"BrowserDefault"
|
||||
]);
|
||||
}
|
||||
|
||||
// //////////////////////
|
||||
// //
|
||||
// //
|
||||
// function populatePickLists(vm) {
|
||||
// //ensure the pick lists required are pre-fetched
|
||||
// return window.$gz.enums.fetchEnumList("usertype").then(() => {
|
||||
// vm.pickLists.usertypes = window.$gz.enums.getPickList("usertype");
|
||||
// });
|
||||
// }
|
||||
</script>
|
||||
|
||||
<style></style>
|
||||
|
||||
@@ -341,7 +341,6 @@ function generateMenu(vm) {
|
||||
title: window.$gz.locale.get("UserSettings"),
|
||||
helpUrl: "form-home-user-settings",
|
||||
formData: {
|
||||
formKey: FORM_KEY,
|
||||
ayaType: window.$gz.type.UserOptions
|
||||
},
|
||||
menuItems: []
|
||||
|
||||
@@ -588,7 +588,6 @@ function generateMenu(vm) {
|
||||
title: window.$gz.locale.get("Widget"),
|
||||
helpUrl: "form-widget",
|
||||
formData: {
|
||||
formKey: FORM_KEY,
|
||||
ayaType: window.$gz.type.Widget,
|
||||
recordId: vm.$route.params.recordid,
|
||||
formCustomTemplateKey: FORM_CUSTOM_TEMPLATE_KEY
|
||||
|
||||
Reference in New Issue
Block a user