Skip to content

Commit

Permalink
added dragula to this.root
Browse files Browse the repository at this point in the history
  • Loading branch information
ZenMasterJacob20011 committed Jul 9, 2024
1 parent d19792c commit 2fe896c
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/Webform.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
getArrayFromComponentPath,
} from "./utils/utils";
import { eachComponent } from "./utils/formUtils";
import dragula from "dragula";

// Initialize the available forms.
Formio.forms = {};
Expand Down Expand Up @@ -322,6 +323,8 @@ export default class Webform extends NestedDataComponent {
// Ensure the root is set to this component.
this.root = this;
this.localRoot = this;

this.root.dragulaLib = dragula;
}
/* eslint-enable max-statements */

Expand Down
8 changes: 8 additions & 0 deletions src/components/datagrid/DataGrid.unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
comp6,
comp7,
comp8,
comp9,
withDefValue,
withRowGroupsAndDefValue,
modalWithRequiredFields,
Expand Down Expand Up @@ -415,6 +416,13 @@ describe('DataGrid Component', () => {
assert.equal(component.childComponentsMap['dataGrid[0].radio'].element.querySelector('input').checked, false);
});
});

it('Should have dragula available when reorder flag is set to true', () => {
return Formio.createForm(document.createElement('div'), comp9, {}).then((form) => {
const dataGridComponent = form.getComponent('dataGrid');
assert(dataGridComponent.root.dragulaLib, 'could not find dragulaLib');
});
});
});

describe('DataGrid Panels', () => {
Expand Down
42 changes: 42 additions & 0 deletions src/components/datagrid/fixtures/comp9.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
export default {
"components": [
{
"label": "Data Grid",
"reorder": true,
"addAnotherPosition": "bottom",
"layoutFixed": false,
"enableRowGroups": false,
"initEmpty": false,
"tableView": false,
"defaultValue": [
{}
],
"key": "dataGrid",
"type": "datagrid",
"input": true,
"components": [
{
"label": "Text Field",
"applyMaskOn": "change",
"tableView": true,
"key": "textField",
"type": "textfield",
"input": true
},
{
"label": "Number",
"applyMaskOn": "change",
"mask": false,
"tableView": false,
"delimiter": false,
"requireDecimal": false,
"inputFormat": "plain",
"truncateMultipleSpaces": false,
"key": "number",
"type": "number",
"input": true
}
]
}
]
}
3 changes: 2 additions & 1 deletion src/components/datagrid/fixtures/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import comp5 from './comp5';
import comp6 from './comp6';
import comp7 from './comp7';
import comp8 from './comp8';
import comp9 from './comp9';
import withDefValue from './comp-with-def-value';
import withRowGroupsAndDefValue from './comp-row-groups-with-def-value';
import modalWithRequiredFields from './comp-modal-with-required-fields';
Expand All @@ -15,4 +16,4 @@ import withCollapsibleRowGroups from './comp-with-collapsible-groups';
import withAllowCalculateOverride from './comp-with-allow-calculate-override';
import twoWithAllowCalculatedOverride from './two-comp-with-allow-calculate-override';
import withCheckboxes from './comp-with-checkboxes';
export { comp1, comp2, comp3, comp4, comp5, comp6, comp7, comp8, withCollapsibleRowGroups, withConditionalFieldsAndValidations, withDefValue, withLogic, withRowGroupsAndDefValue, modalWithRequiredFields, withAllowCalculateOverride, twoWithAllowCalculatedOverride, withCheckboxes };
export { comp1, comp2, comp3, comp4, comp5, comp6, comp7, comp8, comp9, withCollapsibleRowGroups, withConditionalFieldsAndValidations, withDefValue, withLogic, withRowGroupsAndDefValue, modalWithRequiredFields, withAllowCalculateOverride, twoWithAllowCalculatedOverride, withCheckboxes };

0 comments on commit 2fe896c

Please sign in to comment.