Skip to content

Commit

Permalink
Merge pull request #23 from bcgov/medis-imp-export-api-fe-valid
Browse files Browse the repository at this point in the history
Medis imp export api fe valid
  • Loading branch information
evgeny-pluzhnikov authored Aug 2, 2023
2 parents 282b813 + 47a1a90 commit d1e02db
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion app/frontend/src/components/designer/FormViewerMultiUpload.vue
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@
import { mapActions } from 'vuex';
import { Formio, Utils } from 'vue-formio';
// import { nextTick } from 'process';
import _ from 'lodash';
export default {
name: 'FormViewerDownloadButton',
components: {},
Expand Down Expand Up @@ -432,6 +433,22 @@ export default {
}
return time;
},
convertEmptyArraysToNull(obj) {
/*
* This function is purely made to solve this https://github.com/formio/formio.js/issues/4515 formio bug
* where setSubmission mislead payload for submission. In our case if setSubmission got triggered multiple
* time it cache submission key's with old values that leads to trigger false validation errors.
* This function clear object with some empty arrays to null. Main problem was occured to columns and grids components.
*/
if (_.isArray(obj)) {
return obj.length === 0 ? null : obj.map(this.convertEmptyArraysToNull);
} else if (_.isObject(obj)) {
return _.mapValues(obj, this.convertEmptyArraysToNull);
} else {
return obj;
}
},
async validate(element, errors) {
await this.delay(500);
//this.checkMemoryUsage();
Expand Down Expand Up @@ -485,7 +502,7 @@ export default {
async formIOValidation(element) {
return new Promise((resolve) => {
this.vForm.setSubmission({
data: element,
data: this.convertEmptyArraysToNull(element),
});
this.vForm
.submit()
Expand Down

0 comments on commit d1e02db

Please sign in to comment.