@formio/js 5.0.0-dev.5543.afcff10 → 5.0.0-dev.5543.eaae5a6

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.
@@ -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;
126
+ var _a, _b;
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,6 +136,7 @@ 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
140
  });
140
141
  };
141
142
  this.options.hooks.renderComponents = (html, { components, self }) => {
@@ -486,6 +487,7 @@ class WebformBuilder extends Component_1.default {
486
487
  attach(element) {
487
488
  this.on('change', (form) => {
488
489
  this.populateRecaptchaSettings(form);
490
+ this.webform.setAlert(false);
489
491
  });
490
492
  return super.attach(element).then(() => {
491
493
  this.loadRefs(element, {
@@ -819,6 +821,20 @@ class WebformBuilder extends Component_1.default {
819
821
  return;
820
822
  }
821
823
  }
824
+ if (draggableComponent.uniqueComponent) {
825
+ let isCompAlreadyExists = false;
826
+ (0, formUtils_1.eachComponent)(this.webform.components, (component) => {
827
+ if (component.key === draggableComponent.schema.key) {
828
+ isCompAlreadyExists = true;
829
+ return;
830
+ }
831
+ }, true);
832
+ if (isCompAlreadyExists) {
833
+ this.webform.redraw();
834
+ this.webform.setAlert('danger', `You cannot add more than one ${draggableComponent.title} component to one page.`);
835
+ return;
836
+ }
837
+ }
822
838
  if (target !== source) {
823
839
  // Ensure the key remains unique in its new container.
824
840
  builder_1.default.uniquify(this.findNamespaceRoot(target.formioComponent), info);
@@ -851,7 +867,7 @@ class WebformBuilder extends Component_1.default {
851
867
  parent.addChildComponent(info, element, target, source, sibling);
852
868
  }
853
869
  const componentInDataGrid = parent.type === 'datagrid';
854
- if (isNew && !this.options.noNewEdit && !info.noNewEdit) {
870
+ if (isNew && !this.options.noNewEdit && !info.noNewEdit && !(this.options.design && info.type === 'reviewpage')) {
855
871
  this.editComponent(info, target, isNew, null, null, { inDataGrid: componentInDataGrid });
856
872
  }
857
873
  // Only rebuild the parts needing to be rebuilt.
@@ -198,7 +198,7 @@ class DataGridComponent extends NestedArrayComponent_1.default {
198
198
  return this.hasAddButton() && ['bottom', 'both'].includes(this.addAnotherPosition);
199
199
  }
200
200
  get canAddColumn() {
201
- return this.builderMode;
201
+ return this.builderMode && !this.options.design;
202
202
  }
203
203
  render() {
204
204
  const columns = this.getColumns();
@@ -115,6 +115,7 @@ 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
119
  });
119
120
  };
120
121
  this.options.hooks.renderComponents = (html, { components, self }) => {
@@ -472,6 +473,7 @@ export default class WebformBuilder extends Component {
472
473
  attach(element) {
473
474
  this.on('change', (form) => {
474
475
  this.populateRecaptchaSettings(form);
476
+ this.webform.setAlert(false);
475
477
  });
476
478
  return super.attach(element).then(() => {
477
479
  this.loadRefs(element, {
@@ -804,6 +806,20 @@ export default class WebformBuilder extends Component {
804
806
  return;
805
807
  }
806
808
  }
809
+ if (draggableComponent.uniqueComponent) {
810
+ let isCompAlreadyExists = false;
811
+ eachComponent(this.webform.components, (component) => {
812
+ if (component.key === draggableComponent.schema.key) {
813
+ isCompAlreadyExists = true;
814
+ return;
815
+ }
816
+ }, true);
817
+ if (isCompAlreadyExists) {
818
+ this.webform.redraw();
819
+ this.webform.setAlert('danger', `You cannot add more than one ${draggableComponent.title} component to one page.`);
820
+ return;
821
+ }
822
+ }
807
823
  if (target !== source) {
808
824
  // Ensure the key remains unique in its new container.
809
825
  BuilderUtils.uniquify(this.findNamespaceRoot(target.formioComponent), info);
@@ -836,7 +852,7 @@ export default class WebformBuilder extends Component {
836
852
  parent.addChildComponent(info, element, target, source, sibling);
837
853
  }
838
854
  const componentInDataGrid = parent.type === 'datagrid';
839
- if (isNew && !this.options.noNewEdit && !info.noNewEdit) {
855
+ if (isNew && !this.options.noNewEdit && !info.noNewEdit && !(this.options.design && info.type === 'reviewpage')) {
840
856
  this.editComponent(info, target, isNew, null, null, { inDataGrid: componentInDataGrid });
841
857
  }
842
858
  // Only rebuild the parts needing to be rebuilt.
@@ -195,7 +195,7 @@ export default class DataGridComponent extends NestedArrayComponent {
195
195
  return this.hasAddButton() && ['bottom', 'both'].includes(this.addAnotherPosition);
196
196
  }
197
197
  get canAddColumn() {
198
- return this.builderMode;
198
+ return this.builderMode && !this.options.design;
199
199
  }
200
200
  render() {
201
201
  const columns = this.getColumns();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@formio/js",
3
- "version": "5.0.0-dev.5543.afcff10",
3
+ "version": "5.0.0-dev.5543.eaae5a6",
4
4
  "description": "JavaScript powered Forms with JSON Form Builder",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/mjs/index.js",