Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import { ContentActionBarMainItem, ViewType } from '@siemens/element-ng/content-
import { SiDashboardCardComponent } from '@siemens/element-ng/dashboard';
import { MenuItem } from '@siemens/element-ng/menu';
import { t } from '@siemens/element-translate-ng/translate';
import { tap } from 'rxjs';

import { WidgetConfig, WidgetConfigEvent, WidgetInstance } from '../../model/widgets.model';
import { SiGridService } from '../../services/si-grid.service';
Expand Down Expand Up @@ -86,7 +87,9 @@ export class SiWidgetHostComponent implements OnInit, OnChanges {
secondaryActions: (MenuItemLegacy | MenuItem)[] = [];
/** @defaultValue 'expanded' */
actionBarViewType: ViewType = 'expanded';
editable$ = this.gridService.editable$;
protected editable$ = this.gridService.editable$.pipe(
tap(editable => this.setupEditable(editable))
);
Comment on lines +90 to +92
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about using fromObservable here? And then making all the things calculated in setupEditable computed or linkedSignals?

I don't like that this depends on the async pipe in the template. What happens if someone later uses this a second time in the template? Then we have duplicated execution of setupEditable. So in that regard the current approach is better. But using `fromObservable might be even nicer...


/** @defaultValue [] */
editablePrimaryActions: (MenuItemLegacy | ContentActionBarMainItem)[] = [];
Expand Down Expand Up @@ -152,9 +155,6 @@ export class SiWidgetHostComponent implements OnInit, OnChanges {

ngOnInit(): void {
this.attachWidgetInstance();
this.editable$
.pipe<boolean>(takeUntilDestroyed(this.destroyRef))
.subscribe(editable => this.setupEditable(editable));
}

private attachWidgetInstance(): void {
Expand All @@ -176,7 +176,7 @@ export class SiWidgetHostComponent implements OnInit, OnChanges {
this.widgetInstance.configChange
.pipe(takeUntilDestroyed(this.destroyRef))
.subscribe(event =>
setTimeout(() => this.setupEditable(this.editable$.value, event))
setTimeout(() => this.setupEditable(this.gridService.editable$.value, event))
);
Comment thread
chintankavathia marked this conversation as resolved.
}
if (isSignal(this.widgetInstance.config)) {
Expand Down
Loading