Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into feat/FIO-8690_migra…
Browse files Browse the repository at this point in the history
…te_conditional_core_flow_into_formiojs
  • Loading branch information
mikekotikov committed Nov 4, 2024
2 parents 8d76627 + d8f94f4 commit d93d01d
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 2 deletions.
1 change: 1 addition & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ Formio.createForm(document.getElementById('formio'), 'https://examples.form.io/e
```

### Breaking Changes
- Sketchpad imageType is being removed. All image types are now treated the same. You no longer need the imageType property in your form json
- Bootstrap 5 Default Template - With the 5.x version of the renderer, the default template is now **Bootstrap 5** and is found @ https://github.com/formio/bootstrap repo.
- Bootstrap Icons - Now, instead of Font Awesome being the default icon set for our renderer, we are using Bootstrap Icons as the default icon set which is compatible with Bootstrap 5. Of course, you can always change out icon sets, but this is now the default.
- This version implements a new validation system. Within this, there are some changes that you should be aware of.
Expand Down
2 changes: 1 addition & 1 deletion src/Webform.js
Original file line number Diff line number Diff line change
Expand Up @@ -838,7 +838,7 @@ export default class Webform extends NestedDataComponent {
}

saveDraft() {
if (!this.draftEnabled) {
if (!this.draftEnabled || this.parent?.component.reference === false) {
return;
}
if (!this.formio) {
Expand Down
5 changes: 5 additions & 0 deletions src/components/_classes/nested/NestedComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -773,6 +773,11 @@ export default class NestedComponent extends Field {
if (!instance) {
return;
}

if(!instance.component.path) {
instance.component.path = component.path;
}

instance.checkComponentValidity(data, dirty, row, flags, scope.errors);
if (instance.processOwnValidation) {
scope.noRecurse = true;
Expand Down
2 changes: 2 additions & 0 deletions src/components/editgrid/EditGrid.unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -1585,6 +1585,8 @@ describe('EditGrid Open when Empty', () => {
assert.equal(editRow.errors.length, 1, 'Should show error on row');
const textField = editRow.components[0];
assert(textField.element.className.includes('formio-error-wrapper'), 'Should add error class to component');
const error = editRow.errors[0];
assert.equal(error.formattedKeyOrPath, 'editGrid[0].textField');
done();
}, 450);
}, 100);
Expand Down
2 changes: 1 addition & 1 deletion src/components/select/Select.js
Original file line number Diff line number Diff line change
Expand Up @@ -1465,7 +1465,7 @@ export default class SelectComponent extends ListComponent {
}
// Check to see if we need to save off the template data into our metadata.
const templateValue = this.component.reference && value?._id ? value._id.toString() : value;
const shouldSaveData = !valueIsObject || this.component.reference;
const shouldSaveData = (!valueIsObject || this.component.reference) && !this.inDataTable;
if (!_.isNil(templateValue) && shouldSaveData && this.templateData && this.templateData[templateValue] && this.root?.submission) {
const submission = this.root.submission;
if (!submission.metadata) {
Expand Down
25 changes: 25 additions & 0 deletions test/unit/Form.unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,31 @@ describe('SaveDraft functionality for Nested Form', () => {
}).catch((err) => done(err));
});

it('Should not create a draft submission for nested form if Save as reference is set to false', function(done) {
_.set(comp7.components[1], 'reference', false);
const formElement = document.createElement('div');
Formio.createForm(
formElement,
'http://localhost:3000/idwqwhclwioyqbw/testdraftparent',
{
saveDraft: true
}
).then((form)=>{
setTimeout(() => {
const tfNestedInput = form.getComponent('form.nested').refs.input[0];
tfNestedInput.value = 'test Nested Input';
const inputEvent = new Event('input');
tfNestedInput.dispatchEvent(inputEvent);
setTimeout(() => {
assert.equal(saveDraftCalls, 1);
assert.equal(state, 'draft');
_.unset(comp7.components[1], 'reference');
done();
}, 1000);
}, 200);
}).catch((err) => done(err));
});

it('Should pass all the required options to the nested form properly', function(done) {
const formElement = document.createElement('div');
Formio.createForm(
Expand Down

0 comments on commit d93d01d

Please sign in to comment.