Update widgets-bundle-widgets.component.ts

This commit is contained in:
Igor Kulikov 2023-10-23 17:17:13 +03:00 committed by GitHub
parent d23c6c1047
commit 7b33629019
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -205,14 +205,16 @@ export class WidgetsBundleWidgetsComponent extends PageComponent implements OnIn
const isExistWidget = this.widgets.some(widget => widget.id.id === widgetType.id.id);
if (isExistWidget) {
this.widgets = this.widgets.map(widget => widget.id.id !== widgetType.id.id ? widget : widgetType);
} else {
this.widgets.push(widgetType);
}
if (this.editMode) {
this.widgets.push(widgetType);
this.isDirty = true;
this.cd.markForCheck();
} else if (!isExistWidget) {
this.widgetsService.addWidgetFqnToWidgetBundle(this.widgetsBundle.id.id, widgetType.fqn).subscribe(() => {});
this.widgetsService.addWidgetFqnToWidgetBundle(this.widgetsBundle.id.id, widgetType.fqn).subscribe(() => {
this.widgets.push(widgetType);
this.cd.markForCheck();
});
}
}
}