This commit is contained in:
2020-03-05 18:23:37 +00:00
parent d649875e3a
commit 59e6b971e2
4 changed files with 115 additions and 174 deletions

View File

@@ -74,6 +74,17 @@ export default {
delete: false delete: false
}; };
}, },
///////////////////////////////////////////////////////////////////////
// Get a default FULL rights object for forms that don't really need
// to check rights but fits into system for forms in place (e.g. change password)
//
fullRightsObject() {
return {
change: true,
read: true,
delete: true
};
},
///////////////////////////////// /////////////////////////////////
// oType is the name of the object type as defined in ayatype.js // oType is the name of the object type as defined in ayatype.js
// //

View File

@@ -17,88 +17,67 @@
> >
</v-col> </v-col>
<v-col cols="12" sm="6" lg="4" xl="3"> <v-col cols="12">
<v-text-field <v-text-field
v-model="obj.emailAddress" v-model="obj.loginName"
:readonly="formState.readOnly" :readonly="formState.readOnly"
clearable prepend-icon="fa-user"
@click:clear="onChange('emailAddress')" autocomplete="off"
:label="lt('UserEmailAddress')" autocorrect="off"
:error-messages="form().serverErrors(this, 'emailAddress')" autocapitalize="off"
ref="emailAddress" spellcheck="false"
@change="onChange('emailAddress')" v-focus
:label="lt('UserLogin')"
:error-messages="form().serverErrors(this, 'loginName')"
ref="loginName"
@change="onChange('loginName')"
></v-text-field> ></v-text-field>
</v-col> </v-col>
<v-col cols="12" sm="6" lg="4" xl="3"> <v-col cols="12">
<v-text-field <v-text-field
v-model="obj.languageOverride" v-model="obj.oldPassword"
:placeholder="locale().getBrowserFirstLanguage()"
:readonly="formState.readOnly" :readonly="formState.readOnly"
clearable :append-outer-icon="reveal ? 'fa-eye' : 'fa-eye-slash'"
@click:clear="onChange('languageOverride')" prepend-icon="fa-key"
:label="lt('LanguageCode')" :label="lt('OldPassword')"
:error-messages="form().serverErrors(this, 'languageOverride')" :type="reveal ? 'text' : 'password'"
ref="languageOverride" :error-messages="form().serverErrors(this, 'oldPassword')"
@change="onChange('languageOverride')" ref="oldPassword"
@change="onChange('oldPassword')"
@click:append-outer="reveal = !reveal"
></v-text-field> ></v-text-field>
</v-col> </v-col>
<v-col cols="12" sm="6" lg="4" xl="3"> <v-col cols="12">
<v-text-field <v-text-field
v-model="obj.currencyName" v-model="obj.newPassword"
hint="e.g. USD, EUR, GBP, AUD, CAD etc"
:readonly="formState.readOnly" :readonly="formState.readOnly"
clearable :append-outer-icon="reveal ? 'fa-eye' : 'fa-eye-slash'"
@click:clear="onChange('currencyName')" prepend-icon="fa-key"
:label="lt('CurrencyCode')" :label="lt('NewPassword')"
:rules="[form().required(this, 'currencyName')]" :type="reveal ? 'text' : 'password'"
:error-messages="form().serverErrors(this, 'currencyName')" :error-messages="form().serverErrors(this, 'newPassword')"
ref="currencyName" ref="newPassword"
@change="onChange('currencyName')" @change="onChange('newPassword')"
@click:append-outer="reveal = !reveal"
></v-text-field> ></v-text-field>
</v-col> </v-col>
<v-col cols="12" sm="6" lg="4" xl="3"> <v-col cols="12">
<v-text-field <v-text-field
v-model="obj.timeZoneOverride" v-model="obj.confirmPassword"
:placeholder="locale().getTimeZoneName()"
:readonly="formState.readOnly" :readonly="formState.readOnly"
clearable :append-outer-icon="reveal ? 'fa-eye' : 'fa-eye-slash'"
@click:clear="onChange('timeZoneOverride')" prepend-icon="fa-key"
:label="lt('TimeZone')" :label="lt('ConfirmPassword')"
:error-messages="form().serverErrors(this, 'timeZoneOverride')" :type="reveal ? 'text' : 'password'"
ref="timeZoneOverride" :error-messages="form().serverErrors(this, 'confirmPassword')"
@change="onChange('timeZoneOverride')" ref="confirmPassword"
@change="onChange('confirmPassword')"
@click:append-outer="reveal = !reveal"
></v-text-field> ></v-text-field>
</v-col> </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-row>
</v-form> </v-form>
</v-col> </v-col>
@@ -111,26 +90,18 @@
/* Xeslint-disable */ /* Xeslint-disable */
//////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////
const FORM_KEY = "home-user-settings"; const FORM_KEY = "home-password";
const API_BASE_URL = "Useroptions/"; const API_BASE_URL = "Auth/";
const FORM_CUSTOM_TEMPLATE_KEY = "Useroptions";
export default { export default {
created() { created() {
var vm = this; var vm = this;
initForm(vm) initForm(vm)
.then(() => { .then(() => {
vm.rights = window.$gz.role.getRights(window.$gz.type.UserOptions); vm.rights = window.$gz.role.fullRightsObject();
generateMenu(vm);
vm.formState.ready = true; vm.formState.ready = true;
window.$gz.eventBus.$on("menu-click", clickHandler); 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 => { .catch(err => {
vm.formState.ready = true; vm.formState.ready = true;
@@ -156,20 +127,13 @@ export default {
components: {}, components: {},
data() { data() {
return { return {
formCustomTemplateKey: FORM_CUSTOM_TEMPLATE_KEY,
// pickLists: {
// usertypes: []
// },
obj: { obj: {
id: 0, loginName: null,
concurrencyToken: 0, oldPassword: null,
emailAddress: null, newPassword: null,
uiColor: null, confirmPassword: null
languageOverride: null,
timeZoneOverride: null,
currencyName: null,
hour12: null
}, },
reveal: false,
formState: { formState: {
ready: false, ready: false,
dirty: false, dirty: false,
@@ -180,7 +144,7 @@ export default {
appError: null, appError: null,
serverError: {} serverError: {}
}, },
rights: window.$gz.role.defaultRightsObject() rights: window.$gz.role.fullRightsObject()
}; };
}, },
//WATCHERS //WATCHERS
@@ -223,54 +187,54 @@ export default {
window.$gz.form.onChange(this, ref); window.$gz.form.onChange(this, ref);
} }
}, },
getDataFromApi() { // getDataFromApi() {
var vm = this; // var vm = this;
vm.formState.loading = true; // vm.formState.loading = true;
//always fetch on this form for the current logged in user id // //always fetch on this form for the current logged in user id
var url = API_BASE_URL + vm.$store.state.userId; // var url = API_BASE_URL + vm.$store.state.userId;
window.$gz.form.deleteAllErrorBoxErrors(vm); // window.$gz.form.deleteAllErrorBoxErrors(vm);
window.$gz.api // window.$gz.api
.get(url) // .get(url)
.then(res => { // .then(res => {
if (res.error != undefined) { // if (res.error != undefined) {
//Not found? // //Not found?
if (res.error.code == "2010") { // if (res.error.code == "2010") {
//notify not found error then navigate backwards // //notify not found error then navigate backwards
window.$gz.dialog // window.$gz.dialog
.displayLTErrorMessage("ErrorAPI2010") // .displayLTErrorMessage("ErrorAPI2010")
.then(() => { // .then(() => {
// navigate backwards // // navigate backwards
vm.$router.go(-1); // vm.$router.go(-1);
}); // });
} // }
vm.formState.serverError = res.error; // vm.formState.serverError = res.error;
window.$gz.form.setErrorBoxErrors(vm); // window.$gz.form.setErrorBoxErrors(vm);
} else { // } else {
vm.obj = res.data; // vm.obj = res.data;
//Update the form status // //Update the form status
window.$gz.form.setFormState({ // window.$gz.form.setFormState({
vm: vm, // vm: vm,
dirty: false, // dirty: false,
valid: true, // valid: true,
loading: false, // loading: false,
readOnly: res.readOnly ? true : false // readOnly: res.readOnly ? true : false
}); // });
//modify the menu as necessary // //modify the menu as necessary
generateMenu(vm, res.readOnly); // generateMenu(vm);
} // }
}) // })
.catch(function handleGetDataFromAPIError(error) { // .catch(function handleGetDataFromAPIError(error) {
//Update the form status // //Update the form status
window.$gz.form.setFormState({ // window.$gz.form.setFormState({
vm: vm, // vm: vm,
loading: false // loading: false
}); // });
window.$gz.errorHandler.handleFormError(error, vm); // window.$gz.errorHandler.handleFormError(error, vm);
}); // });
}, // },
submit() { submit() {
var vm = this; var vm = this;
if (vm.canSave) { if (vm.canSave) {
@@ -340,17 +304,9 @@ function generateMenu(vm) {
icon: "key", icon: "key",
title: window.$gz.locale.get("SetLoginPassword"), title: window.$gz.locale.get("SetLoginPassword"),
helpUrl: "form-home-password", helpUrl: "form-home-password",
formData: {
ayaType: window.$gz.type.UserOptions
},
menuItems: [] menuItems: []
}; };
/* isMain: true,
icon: "key",
title: window.$gz.locale.get("SetLoginPassword"),
helpUrl: "form-home-password" */
if (vm.rights.change) { if (vm.rights.change) {
menuOptions.menuItems.push({ menuOptions.menuItems.push({
title: window.$gz.locale.get("Save"), title: window.$gz.locale.get("Save"),
@@ -361,14 +317,6 @@ function generateMenu(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); window.$gz.eventBus.$emit("menu-change", menuOptions);
} }
@@ -380,8 +328,6 @@ function initForm(vm) {
(async function() { (async function() {
try { try {
await fetchUILocalizedText(vm); await fetchUILocalizedText(vm);
// await window.$gz.formCustomTemplate.get(FORM_CUSTOM_TEMPLATE_KEY);
// await populatePickLists(vm);
} catch (err) { } catch (err) {
reject(err); reject(err);
} }
@@ -396,25 +342,10 @@ function initForm(vm) {
// //
function fetchUILocalizedText(vm) { function fetchUILocalizedText(vm) {
return window.$gz.locale.fetch([ return window.$gz.locale.fetch([
"CurrencyCode", "UserLogin",
"LanguageCode", "OldPassword",
"TimeZone", "NewPassword",
"UserEmailAddress", "ConfirmPassword"
"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> </script>
<style></style>

View File

@@ -259,7 +259,7 @@ export default {
readOnly: res.readOnly ? true : false readOnly: res.readOnly ? true : false
}); });
//modify the menu as necessary //modify the menu as necessary
generateMenu(vm, res.readOnly); generateMenu(vm);
} }
}) })
.catch(function handleGetDataFromAPIError(error) { .catch(function handleGetDataFromAPIError(error) {
@@ -396,8 +396,7 @@ function fetchUILocalizedText(vm) {
"TimeZone", "TimeZone",
"UserEmailAddress", "UserEmailAddress",
"Hour12", "Hour12",
"UserColor", "UserColor"
"BrowserDefault"
]); ]);
} }

View File

@@ -399,7 +399,7 @@ export default {
readOnly: res.readOnly ? true : false readOnly: res.readOnly ? true : false
}); });
//modify the menu as necessary //modify the menu as necessary
generateMenu(vm, res.readOnly); generateMenu(vm);
} }
}) })
.catch(function handleGetDataFromAPIError(error) { .catch(function handleGetDataFromAPIError(error) {