This commit is contained in:
@@ -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,46 +632,61 @@ 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) {
|
||||||
if (triggeringChange || vm.formState.loading) {
|
let that = this;
|
||||||
return;
|
//this is currently required to ensure that this method runs after all the broken rule checks have settled
|
||||||
}
|
Vue.nextTick(function() {
|
||||||
//If ref appears in the formState.serverErrors details collection, remove each one
|
//-------------
|
||||||
let m = window.$gz._.remove(vm.formState.serverError.details, function(o) {
|
if (triggeringChange || vm.formState.loading) {
|
||||||
if (!o.target) {
|
return;
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
return o.target.toLowerCase() == ref;
|
//If ref appears in the formState.serverErrors details collection, remove each one
|
||||||
});
|
let m = window.$gz._.remove(vm.formState.serverError.details, function(
|
||||||
|
o
|
||||||
|
) {
|
||||||
|
if (!o.target) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return o.target.toLowerCase() == ref;
|
||||||
|
});
|
||||||
|
|
||||||
//If there are no more errors in details then remove the whole thing as it's no longer required
|
//If there are no more errors in details then remove the whole thing as it's no longer required
|
||||||
if (
|
if (
|
||||||
vm.formState.serverError.details &&
|
vm.formState.serverError.details &&
|
||||||
vm.formState.serverError.details.length < 1
|
vm.formState.serverError.details.length < 1
|
||||||
) {
|
) {
|
||||||
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
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
//Clear out old validation display in form by forcing the control's data to change
|
//Clear out old validation display in form by forcing the control's data to change
|
||||||
//I tried calling form validate and reset and all that bullshit but it did nothing
|
//I tried calling form validate and reset and all that bullshit but it did nothing
|
||||||
//probably because it has safeguards to prevent excess validation, this works though so far
|
//probably because it has safeguards to prevent excess validation, this works though so far
|
||||||
//I added the triggering change guard but it actually doesn't seem to be required here, more investigation is required
|
//I added the triggering change guard but it actually doesn't seem to be required here, more investigation is required
|
||||||
if (m.length > 0) {
|
if (m.length > 0) {
|
||||||
triggeringChange = true;
|
triggeringChange = true;
|
||||||
let val = vm.obj[ref];
|
let val = vm.obj[ref];
|
||||||
vm.obj[ref] = null;
|
vm.obj[ref] = null;
|
||||||
vm.obj[ref] = val;
|
vm.obj[ref] = val;
|
||||||
triggeringChange = false;
|
triggeringChange = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Update the form status
|
//Update the form status
|
||||||
this.setFormState({
|
let formValid = vm.$refs.form.validate();
|
||||||
vm: vm,
|
// console.log(
|
||||||
dirty: true,
|
// "gzform:fieldValueChanged - form validity being set to ",
|
||||||
valid: vm.$refs.form.validate()
|
// formValid
|
||||||
});
|
// );
|
||||||
|
that.setFormState({
|
||||||
|
vm: vm,
|
||||||
|
dirty: true,
|
||||||
|
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;
|
||||||
|
|||||||
@@ -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);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user