LT-67: Re-validating fields on change only if the form validation has already been called
This commit is contained in:
parent
c6690781f8
commit
92728c4100
@ -17,6 +17,9 @@ OHIF.mixins.form = new OHIF.Mixin({
|
|||||||
// Set the form identifier flag
|
// Set the form identifier flag
|
||||||
component.isForm = true;
|
component.isForm = true;
|
||||||
|
|
||||||
|
// Set the form validated flag
|
||||||
|
component.isValidatedAlready = false;
|
||||||
|
|
||||||
component.validationObserver = new Tracker.Dependency();
|
component.validationObserver = new Tracker.Dependency();
|
||||||
|
|
||||||
// Reset the pathKey
|
// Reset the pathKey
|
||||||
@ -34,6 +37,9 @@ OHIF.mixins.form = new OHIF.Mixin({
|
|||||||
// Call the original validation function
|
// Call the original validation function
|
||||||
validateSelf();
|
validateSelf();
|
||||||
|
|
||||||
|
// Change the form validated flag to true
|
||||||
|
component.isValidatedAlready = true;
|
||||||
|
|
||||||
// Focus the first error field if some validation failed
|
// Focus the first error field if some validation failed
|
||||||
if (component.schema && component.schema._invalidKeys.length) {
|
if (component.schema && component.schema._invalidKeys.length) {
|
||||||
instance.$('.state-error :input:first').focus();
|
instance.$('.state-error :input:first').focus();
|
||||||
|
|||||||
@ -235,8 +235,11 @@ OHIF.mixins.formItem = new OHIF.Mixin({
|
|||||||
// Enable reactivity by changing a Tracker.Dependency observer
|
// Enable reactivity by changing a Tracker.Dependency observer
|
||||||
component.changeObserver.changed();
|
component.changeObserver.changed();
|
||||||
|
|
||||||
// Revalidate the component
|
const form = component.getForm();
|
||||||
component.validate();
|
if (form && form.isValidatedAlready) {
|
||||||
|
// Revalidate the component if form is already validated
|
||||||
|
component.validate();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user