@formio/js 5.1.0-dev.6021.879d00c → 5.1.0-dev.6024.3b197fc

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -300,7 +300,7 @@ class PDFBuilder extends WebformBuilder_1.default {
300
300
  height: schema.height,
301
301
  width: schema.width
302
302
  };
303
- if (!this.options.noNewEdit && !component.component.noNewEdit) {
303
+ if (!this.options.noNewEdit && !component.component.noNewEdit && this.hasEditTabs(component.type)) {
304
304
  this.editComponent(component.component, this.getParentContainer(component), isNew);
305
305
  }
306
306
  this.emit('updateComponent', component.component);
@@ -324,7 +324,7 @@ class PDFBuilder extends WebformBuilder_1.default {
324
324
  });
325
325
  this.webform.on('iframe-componentClick', schema => {
326
326
  const component = this.webform.getComponentById(schema.id);
327
- if (component) {
327
+ if (component && this.hasEditTabs(component.type)) {
328
328
  this.editComponent(component.component, this.getParentContainer(component));
329
329
  }
330
330
  }, true);
@@ -123,6 +123,7 @@ export default class WebformBuilder extends Component {
123
123
  addBuilderGroup(name: any, group: any): void;
124
124
  updateBuilderGroup(name: any, group: any): void;
125
125
  generateKey(info: any): any;
126
+ hasEditTabs(type: any): boolean;
126
127
  }
127
128
  import Component from './components/_classes/component/Component';
128
129
  import Webform from './Webform';
@@ -123,7 +123,7 @@ class WebformBuilder extends Component_1.default {
123
123
  }
124
124
  this.options.hooks = this.options.hooks || {};
125
125
  this.options.hooks.renderComponent = (html, { component, self }) => {
126
- var _a, _b;
126
+ var _a, _b, _c;
127
127
  if (self.type === 'form' && !self.key) {
128
128
  const template = this.hook('renderComponentFormTemplate', html.replace('formio-component-form', ''));
129
129
  // The main webform shouldn't have this class as it adds extra styles.
@@ -136,7 +136,9 @@ class WebformBuilder extends Component_1.default {
136
136
  html,
137
137
  disableBuilderActions: (_a = self === null || self === void 0 ? void 0 : self.component) === null || _a === void 0 ? void 0 : _a.disableBuilderActions,
138
138
  childComponent: component,
139
- design: (_b = self === null || self === void 0 ? void 0 : self.options) === null || _b === void 0 ? void 0 : _b.design
139
+ design: (_b = self === null || self === void 0 ? void 0 : self.options) === null || _b === void 0 ? void 0 : _b.design,
140
+ editJson: (_c = self === null || self === void 0 ? void 0 : self.options) === null || _c === void 0 ? void 0 : _c.editJson,
141
+ editComponent: this.hasEditTabs(component.type)
140
142
  });
141
143
  };
142
144
  this.options.hooks.renderComponents = (html, { components, self }) => {
@@ -855,7 +857,11 @@ class WebformBuilder extends Component_1.default {
855
857
  parent.addChildComponent(info, element, target, source, sibling);
856
858
  }
857
859
  const componentInDataGrid = parent.type === 'datagrid';
858
- if (isNew && !this.options.noNewEdit && !info.noNewEdit && !(this.options.design && info.type === 'reviewpage')) {
860
+ if (isNew
861
+ && !this.options.noNewEdit
862
+ && !info.noNewEdit
863
+ && this.hasEditTabs(info.type)
864
+ && !(this.options.design && info.type === 'reviewpage')) {
859
865
  this.editComponent(info, target, isNew, null, null, { inDataGrid: componentInDataGrid });
860
866
  }
861
867
  // Only rebuild the parts needing to be rebuilt.
@@ -1616,5 +1622,10 @@ class WebformBuilder extends Component_1.default {
1616
1622
  info.placeholder ||
1617
1623
  info.type);
1618
1624
  }
1625
+ hasEditTabs(type) {
1626
+ const editTabs = (0, formUtils_1.getComponent)(Components_1.default.components[type].editForm().components, 'tabs', true).components;
1627
+ const hiddenEditTabs = lodash_1.default.filter(lodash_1.default.get(this.options, `editForm.${type}`, []), 'ignore');
1628
+ return lodash_1.default.intersectionBy(editTabs, hiddenEditTabs, 'key').length !== editTabs.length;
1629
+ }
1619
1630
  }
1620
1631
  exports.default = WebformBuilder;
@@ -45,18 +45,16 @@ export default class FormComponent extends Component {
45
45
  /**
46
46
  * Create a subform instance.
47
47
  * @param {boolean} [fromAttach] - This function is being called from an `attach` method.
48
- * @param {boolean} [beforeSubmit] - This function is being called from a `beforeSubmit` method.
49
48
  * @returns {*} - The subform instance.
50
49
  */
51
- createSubForm(fromAttach?: boolean | undefined, beforeSubmit?: boolean | undefined): any;
50
+ createSubForm(fromAttach?: boolean | undefined): any;
52
51
  hideSubmitButton(component: any): void;
53
52
  /**
54
53
  * Load the subform.
55
54
  * @param {boolean} fromAttach - This function is being called from an `attach` method.
56
- * @param {boolean} beforeSubmit - This function is being called from a `beforeSubmit` method.
57
55
  * @returns {Promise} - The promise that resolves when the subform is loaded.
58
56
  */
59
- loadSubForm(fromAttach: boolean, beforeSubmit: boolean): Promise<any>;
57
+ loadSubForm(fromAttach: boolean): Promise<any>;
60
58
  subFormLoading: boolean | undefined;
61
59
  checkComponentConditions(data: any, flags: any, row: any): any;
62
60
  calculateValue(data: any, flags: any, row: any): any;
@@ -380,11 +380,10 @@ class FormComponent extends Component_1.default {
380
380
  /**
381
381
  * Create a subform instance.
382
382
  * @param {boolean} [fromAttach] - This function is being called from an `attach` method.
383
- * @param {boolean} [beforeSubmit] - This function is being called from a `beforeSubmit` method.
384
383
  * @returns {*} - The subform instance.
385
384
  */
386
- createSubForm(fromAttach, beforeSubmit) {
387
- this.subFormReady = this.loadSubForm(fromAttach, beforeSubmit).then((form) => {
385
+ createSubForm(fromAttach) {
386
+ this.subFormReady = this.loadSubForm(fromAttach).then((form) => {
388
387
  if (!form) {
389
388
  return;
390
389
  }
@@ -441,13 +440,11 @@ class FormComponent extends Component_1.default {
441
440
  /**
442
441
  * Load the subform.
443
442
  * @param {boolean} fromAttach - This function is being called from an `attach` method.
444
- * @param {boolean} beforeSubmit - This function is being called from a `beforeSubmit` method.
445
443
  * @returns {Promise} - The promise that resolves when the subform is loaded.
446
444
  */
447
- loadSubForm(fromAttach, beforeSubmit) {
445
+ loadSubForm(fromAttach) {
448
446
  var _a, _b, _c, _d, _e;
449
- const loadHiddenForm = beforeSubmit && !this.component.clearOnHide;
450
- if (this.builderMode || (this.conditionallyHidden && !loadHiddenForm) || (this.isSubFormLazyLoad() && !fromAttach)) {
447
+ if (this.builderMode || this.conditionallyHidden || (this.isSubFormLazyLoad() && !fromAttach)) {
451
448
  return Promise.resolve();
452
449
  }
453
450
  if (this.hasLoadedForm && !this.isRevisionChanged &&
@@ -519,7 +516,7 @@ class FormComponent extends Component_1.default {
519
516
  * @returns {*|boolean} - TRUE if the subform should be submitted, FALSE if it should not.
520
517
  */
521
518
  get shouldSubmit() {
522
- return this.subFormReady && (!this.component.hasOwnProperty('reference') || this.component.reference) && (!this.conditionallyHidden || !this.component.clearOnHide);
519
+ return this.subFormReady && (!this.component.hasOwnProperty('reference') || this.component.reference) && !this.conditionallyHidden;
523
520
  }
524
521
  /**
525
522
  * Returns the data for the subform.
@@ -590,10 +587,8 @@ class FormComponent extends Component_1.default {
590
587
  this.dataValue = submission;
591
588
  return Promise.resolve(this.dataValue);
592
589
  }
593
- // we need to load a hidden form (when clearOnHide is disabled) in order to get and submit (if needed) its data
594
- const loadHiddenForm = !this.subForm && !this.component.clearOnHide;
595
- if ((this.isSubFormLazyLoad() || loadHiddenForm) && !this.subFormLoading) {
596
- return this.createSubForm(true, true)
590
+ if (this.isSubFormLazyLoad() && !this.subFormLoading) {
591
+ return this.createSubForm(true)
597
592
  .then(this.submitSubForm(false))
598
593
  .then(() => {
599
594
  return this.dataValue;
@@ -294,7 +294,7 @@ export default class PDFBuilder extends WebformBuilder {
294
294
  height: schema.height,
295
295
  width: schema.width
296
296
  };
297
- if (!this.options.noNewEdit && !component.component.noNewEdit) {
297
+ if (!this.options.noNewEdit && !component.component.noNewEdit && this.hasEditTabs(component.type)) {
298
298
  this.editComponent(component.component, this.getParentContainer(component), isNew);
299
299
  }
300
300
  this.emit('updateComponent', component.component);
@@ -318,7 +318,7 @@ export default class PDFBuilder extends WebformBuilder {
318
318
  });
319
319
  this.webform.on('iframe-componentClick', schema => {
320
320
  const component = this.webform.getComponentById(schema.id);
321
- if (component) {
321
+ if (component && this.hasEditTabs(component.type)) {
322
322
  this.editComponent(component.component, this.getParentContainer(component));
323
323
  }
324
324
  }, true);
@@ -123,6 +123,7 @@ export default class WebformBuilder extends Component {
123
123
  addBuilderGroup(name: any, group: any): void;
124
124
  updateBuilderGroup(name: any, group: any): void;
125
125
  generateKey(info: any): any;
126
+ hasEditTabs(type: any): boolean;
126
127
  }
127
128
  import Component from './components/_classes/component/Component';
128
129
  import Webform from './Webform';
@@ -115,7 +115,9 @@ export default class WebformBuilder extends Component {
115
115
  html,
116
116
  disableBuilderActions: self?.component?.disableBuilderActions,
117
117
  childComponent: component,
118
- design: self?.options?.design
118
+ design: self?.options?.design,
119
+ editJson: self?.options?.editJson,
120
+ editComponent: this.hasEditTabs(component.type)
119
121
  });
120
122
  };
121
123
  this.options.hooks.renderComponents = (html, { components, self }) => {
@@ -840,7 +842,11 @@ export default class WebformBuilder extends Component {
840
842
  parent.addChildComponent(info, element, target, source, sibling);
841
843
  }
842
844
  const componentInDataGrid = parent.type === 'datagrid';
843
- if (isNew && !this.options.noNewEdit && !info.noNewEdit && !(this.options.design && info.type === 'reviewpage')) {
845
+ if (isNew
846
+ && !this.options.noNewEdit
847
+ && !info.noNewEdit
848
+ && this.hasEditTabs(info.type)
849
+ && !(this.options.design && info.type === 'reviewpage')) {
844
850
  this.editComponent(info, target, isNew, null, null, { inDataGrid: componentInDataGrid });
845
851
  }
846
852
  // Only rebuild the parts needing to be rebuilt.
@@ -1619,4 +1625,9 @@ export default class WebformBuilder extends Component {
1619
1625
  info.placeholder ||
1620
1626
  info.type);
1621
1627
  }
1628
+ hasEditTabs(type) {
1629
+ const editTabs = getComponent(Components.components[type].editForm().components, 'tabs', true).components;
1630
+ const hiddenEditTabs = _.filter(_.get(this.options, `editForm.${type}`, []), 'ignore');
1631
+ return _.intersectionBy(editTabs, hiddenEditTabs, 'key').length !== editTabs.length;
1632
+ }
1622
1633
  }
@@ -45,18 +45,16 @@ export default class FormComponent extends Component {
45
45
  /**
46
46
  * Create a subform instance.
47
47
  * @param {boolean} [fromAttach] - This function is being called from an `attach` method.
48
- * @param {boolean} [beforeSubmit] - This function is being called from a `beforeSubmit` method.
49
48
  * @returns {*} - The subform instance.
50
49
  */
51
- createSubForm(fromAttach?: boolean | undefined, beforeSubmit?: boolean | undefined): any;
50
+ createSubForm(fromAttach?: boolean | undefined): any;
52
51
  hideSubmitButton(component: any): void;
53
52
  /**
54
53
  * Load the subform.
55
54
  * @param {boolean} fromAttach - This function is being called from an `attach` method.
56
- * @param {boolean} beforeSubmit - This function is being called from a `beforeSubmit` method.
57
55
  * @returns {Promise} - The promise that resolves when the subform is loaded.
58
56
  */
59
- loadSubForm(fromAttach: boolean, beforeSubmit: boolean): Promise<any>;
57
+ loadSubForm(fromAttach: boolean): Promise<any>;
60
58
  subFormLoading: boolean | undefined;
61
59
  checkComponentConditions(data: any, flags: any, row: any): any;
62
60
  calculateValue(data: any, flags: any, row: any): any;
@@ -375,11 +375,10 @@ export default class FormComponent extends Component {
375
375
  /**
376
376
  * Create a subform instance.
377
377
  * @param {boolean} [fromAttach] - This function is being called from an `attach` method.
378
- * @param {boolean} [beforeSubmit] - This function is being called from a `beforeSubmit` method.
379
378
  * @returns {*} - The subform instance.
380
379
  */
381
- createSubForm(fromAttach, beforeSubmit) {
382
- this.subFormReady = this.loadSubForm(fromAttach, beforeSubmit).then((form) => {
380
+ createSubForm(fromAttach) {
381
+ this.subFormReady = this.loadSubForm(fromAttach).then((form) => {
383
382
  if (!form) {
384
383
  return;
385
384
  }
@@ -436,12 +435,10 @@ export default class FormComponent extends Component {
436
435
  /**
437
436
  * Load the subform.
438
437
  * @param {boolean} fromAttach - This function is being called from an `attach` method.
439
- * @param {boolean} beforeSubmit - This function is being called from a `beforeSubmit` method.
440
438
  * @returns {Promise} - The promise that resolves when the subform is loaded.
441
439
  */
442
- loadSubForm(fromAttach, beforeSubmit) {
443
- const loadHiddenForm = beforeSubmit && !this.component.clearOnHide;
444
- if (this.builderMode || (this.conditionallyHidden && !loadHiddenForm) || (this.isSubFormLazyLoad() && !fromAttach)) {
440
+ loadSubForm(fromAttach) {
441
+ if (this.builderMode || this.conditionallyHidden || (this.isSubFormLazyLoad() && !fromAttach)) {
445
442
  return Promise.resolve();
446
443
  }
447
444
  if (this.hasLoadedForm && !this.isRevisionChanged &&
@@ -513,7 +510,7 @@ export default class FormComponent extends Component {
513
510
  * @returns {*|boolean} - TRUE if the subform should be submitted, FALSE if it should not.
514
511
  */
515
512
  get shouldSubmit() {
516
- return this.subFormReady && (!this.component.hasOwnProperty('reference') || this.component.reference) && (!this.conditionallyHidden || !this.component.clearOnHide);
513
+ return this.subFormReady && (!this.component.hasOwnProperty('reference') || this.component.reference) && !this.conditionallyHidden;
517
514
  }
518
515
  /**
519
516
  * Returns the data for the subform.
@@ -583,10 +580,8 @@ export default class FormComponent extends Component {
583
580
  this.dataValue = submission;
584
581
  return Promise.resolve(this.dataValue);
585
582
  }
586
- // we need to load a hidden form (when clearOnHide is disabled) in order to get and submit (if needed) its data
587
- const loadHiddenForm = !this.subForm && !this.component.clearOnHide;
588
- if ((this.isSubFormLazyLoad() || loadHiddenForm) && !this.subFormLoading) {
589
- return this.createSubForm(true, true)
583
+ if (this.isSubFormLazyLoad() && !this.subFormLoading) {
584
+ return this.createSubForm(true)
590
585
  .then(this.submitSubForm(false))
591
586
  .then(() => {
592
587
  return this.dataValue;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@formio/js",
3
- "version": "5.1.0-dev.6021.879d00c",
3
+ "version": "5.1.0-dev.6024.3b197fc",
4
4
  "description": "JavaScript powered Forms with JSON Form Builder",
5
5
  "main": "lib/cjs/index.js",
6
6
  "exports": {