This commit is contained in:
2020-06-11 14:08:40 +00:00
parent 3d4bf86518
commit f86207a33d
2 changed files with 64 additions and 40 deletions

View File

@@ -139,16 +139,19 @@ export default {
// //
required(vm, ref) { required(vm, ref) {
if (vm.formState.loading) { if (vm.formState.loading) {
// console.log("gzform:required rule - bailing due to loading", ref);
return true; return true;
} }
let ctrl = getControl(vm, ref); let ctrl = getControl(vm, ref);
if (typeof ctrl == "undefined") { if (typeof ctrl == "undefined") {
// console.log("gzform:required rule - bailing due to undefined", ref);
return true; return true;
} }
let value = getControlValue(ctrl); let value = getControlValue(ctrl);
if (!isEmpty(value)) { if (!isEmpty(value)) {
// console.log("gzform:required rule - PASSED!", ref);
return true; return true;
} }
@@ -158,6 +161,7 @@ export default {
err = window.$gz._.replace(err, "{0}", fieldName); err = window.$gz._.replace(err, "{0}", fieldName);
//lodash replace only replaces first instance so need to do it twice //lodash replace only replaces first instance so need to do it twice
err = window.$gz._.replace(err, "{0}", fieldName); err = window.$gz._.replace(err, "{0}", fieldName);
// console.log("gzform:required rule - failed, setting invalid", fieldName);
//Update the form status //Update the form status
this.setFormState({ this.setFormState({
vm: vm, vm: vm,
@@ -628,11 +632,17 @@ export default {
// This is required so that server errors can be cleared when input is changed // This is required so that server errors can be cleared when input is changed
// //
fieldValueChanged(vm, ref) { fieldValueChanged(vm, ref) {
let that = this;
//this is currently required to ensure that this method runs after all the broken rule checks have settled
Vue.nextTick(function() {
//-------------
if (triggeringChange || vm.formState.loading) { if (triggeringChange || vm.formState.loading) {
return; return;
} }
//If ref appears in the formState.serverErrors details collection, remove each one //If ref appears in the formState.serverErrors details collection, remove each one
let m = window.$gz._.remove(vm.formState.serverError.details, function(o) { let m = window.$gz._.remove(vm.formState.serverError.details, function(
o
) {
if (!o.target) { if (!o.target) {
return false; return false;
} }
@@ -646,7 +656,9 @@ export default {
) { ) {
if (vm.formState.serverError.code == "2200") { if (vm.formState.serverError.code == "2200") {
//clear all keys from server error //clear all keys from server error
window.$gz.util.removeAllPropertiesFromObject(vm.formState.serverError); window.$gz.util.removeAllPropertiesFromObject(
vm.formState.serverError
);
} }
} }
@@ -663,11 +675,18 @@ export default {
} }
//Update the form status //Update the form status
this.setFormState({ let formValid = vm.$refs.form.validate();
// console.log(
// "gzform:fieldValueChanged - form validity being set to ",
// formValid
// );
that.setFormState({
vm: vm, vm: vm,
dirty: true, dirty: true,
valid: vm.$refs.form.validate() valid: formValid
}); });
//---------------
}); //next tick end
}, },
//////////////////////////////////// ////////////////////////////////////
// set calling form Valid state // set calling form Valid state
@@ -678,6 +697,11 @@ export default {
// //
setFormState(newState) { setFormState(newState) {
//this returns a promise so any function that needs to wait for this can utilize that //this returns a promise so any function that needs to wait for this can utilize that
// if (newState.valid != null && newState.valid == false) {
// console.trace();
// console.log(newState);
// // debugger;
// }
return Vue.nextTick(function() { return Vue.nextTick(function() {
if (newState.valid != null) { if (newState.valid != null) {
newState.vm.formState.valid = newState.valid; newState.vm.formState.valid = newState.valid;

View File

@@ -107,7 +107,7 @@ export default {
readOnly: false readOnly: false
}); });
window.$gz.eventBus.$on("menu-click", clickHandler); window.$gz.eventBus.$on("menu-click", clickHandler);
//-------------
//Set known password warning if applicable //Set known password warning if applicable
//note: all code assumes only one known user the superuser //note: all code assumes only one known user the superuser
//if this changes then auth.js as well as store and here will need to be changed as well //if this changes then auth.js as well as store and here will need to be changed as well
@@ -116,10 +116,11 @@ export default {
(window.$gz.store.state.globalSettings.licenseStatus == 3 || //ActivePurchased = 3, (window.$gz.store.state.globalSettings.licenseStatus == 3 || //ActivePurchased = 3,
window.$gz.store.state.globalSettings.licenseStatus == 4) // ExpiredPurchased = 4 window.$gz.store.state.globalSettings.licenseStatus == 4) // ExpiredPurchased = 4
) { ) {
this.formState.errorBoxMessage = vm.$ay.t("KnownPasswordWarning"); // this.formState.errorBoxMessage = vm.$ay.t("KnownPasswordWarning");
this.obj.loginName = "superuser"; // this.obj.loginName = "superuser";
this.obj.oldPassword = "l3tm3in"; // this.obj.oldPassword = "l3tm3in";
} }
//------------------
}) })
.catch(err => { .catch(err => {
vm.formState.ready = true; vm.formState.ready = true;
@@ -198,7 +199,6 @@ export default {
return window.$gz.form; return window.$gz.form;
}, },
fieldValueChanged(ref) { fieldValueChanged(ref) {
debugger;
if (!this.formState.loading && !this.formState.readOnly) { if (!this.formState.loading && !this.formState.readOnly) {
window.$gz.form.fieldValueChanged(this, ref); window.$gz.form.fieldValueChanged(this, ref);
} }