-
Type: Improvement
-
Status: Resolved
-
Priority: Major
-
Resolution: Fixed
-
Affects Version/s: None
-
Component/s: Web UI
-
Epic Link:
-
Tags:
-
Upgrade notes:
-
Team:GANG
-
Sprint:nxGang Sprint 11.1.19, nxGang Sprint 11.1.20, nxGang Sprint 11.1.21
-
Story Points:5
`validate` hook in WebUI is important to give feedback on invalid fields, but we need to add a same hook for asynchronous call (like external call, or operation call).
why not call it `$validate` or `validateAsync` :
// Trigger the layout ASYNC validation if it exists. $validate() { return this.$.myOp.execute() .then((ret) => { if (!ret || !ret.value) { const element = this._getValidatableElement(); element.invalid = true; element.errorMessage = "we have a pb here"; return Promise.reject('Pre validation service problem.'); } }); },
As example, the new _create we implement in our project now looks like :
_create() { const elementsToValidate = this._getValidatableElements(); let valid = true; let validations = []; elementsToValidate.forEach(el => { if (valid && el.validate) { valid = el.validate(); } if (valid && el.$validate) { validations.push(el.$validate()); } }); if (!valid) { return; } Promise.all(validations) .then(() => { this.document.name = this.document.name || this._sanitizeName(this.document.properties['dc:title']); this.set('creating', true); return this.$.docRequest.post(); }) .then((response) => { this.$.creationStats.storeType(this.selectedDocType.id); this._clear(); this.navigateTo('browse', response.path); this._notify(response); this.set('creating', false); }) .catch((err) => { this.set('creating', false); this.fire('notify', {message: this.i18n('documentCreationForm.createError')}); console.error(err); }); },
- causes
-
NXP-29680 Revert DocumentValidationException#getMessage behaviour change
- Resolved
- depends on
-
ELEMENTS-1091 nuxeo-layout should proceed to native validation first
- Resolved
- is duplicated by
-
NXP-26878 While creating documents, catch validation errors returned by the server-side validation process with HTTP code 400
- Resolved
- is related to
-
NXP-29129 Web UI Upload Issues
- Resolved
-
ELEMENTS-1077 Add helper to retrieve elements bound to document property
- Resolved