Skip to content

Commit

Permalink
FIO-8518 fixed adding checkbox with radio type to pdf design page
Browse files Browse the repository at this point in the history
  • Loading branch information
HannaKurban committed Nov 18, 2024
1 parent 854241f commit 81fbc1f
Showing 1 changed file with 6 additions and 18 deletions.
24 changes: 6 additions & 18 deletions src/WebformBuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -933,32 +933,20 @@ export default class WebformBuilder extends Component {
const compKey = (group === 'resource') ? `component-${key}` : key;
const draggableComponent = this.groups[group]?.components[compKey] || {};

if (draggableComponent.disableSiblings) {
if (draggableComponent.disableSiblings || draggableComponent.uniqueComponent) {
let isCompAlreadyExists = false;
eachComponent(this.webform.components, (component) => {
if (component.type === draggableComponent.schema.type) {
isCompAlreadyExists = true;
return;
}
}, true);
if (isCompAlreadyExists) {
this.webform.redraw();
this.webform.setAlert('danger', `You cannot add more than one ${draggableComponent.key} component to one page.`);
return;
}
}

if (draggableComponent.uniqueComponent) {
let isCompAlreadyExists = false;
eachComponent(this.webform.components, (component) => {
if (component.key === draggableComponent.schema.key) {
if (
(draggableComponent.disableSiblings && component.type === draggableComponent.schema.type) ||
(draggableComponent.uniqueComponent && component.component.key === draggableComponent.schema.key)
) {
isCompAlreadyExists = true;
return;
}
}, true);
if (isCompAlreadyExists) {
this.webform.redraw();
this.webform.setAlert('danger', `You cannot add more than one ${draggableComponent.title} component to one page.`);
this.webform.setAlert('danger', `You cannot add more than one ${_.get(draggableComponent, draggableComponent.uniqueComponent ? 'title' : 'key')} component to one page.`);
return;
}
}
Expand Down

0 comments on commit 81fbc1f

Please sign in to comment.