UI: fixed initial value for targetDashboardId valueChanges pipe

This commit is contained in:
Dmitriymush 2023-12-19 13:44:28 +02:00
parent 45796d253f
commit 1fdbba6fc6

View File

@ -225,7 +225,7 @@ export class WidgetActionDialogComponent extends DialogComponent<WidgetActionDia
this.fb.control(action ? action.targetDashboardId : null, this.fb.control(action ? action.targetDashboardId : null,
[Validators.required]) [Validators.required])
); );
this.setupSelectedDashboardStateIds(action ? action.targetDashboardId : null); this.setupSelectedDashboardStateIds();
} else { } else {
if (type === WidgetActionType.openDashboardState) { if (type === WidgetActionType.openDashboardState) {
const displayType = this.getStateDisplayType(action); const displayType = this.getStateDisplayType(action);
@ -339,10 +339,12 @@ export class WidgetActionDialogComponent extends DialogComponent<WidgetActionDia
return res; return res;
} }
private setupSelectedDashboardStateIds(targetDashboardId?: string) { private setupSelectedDashboardStateIds() {
const dashboardControl = this.actionTypeFormGroup.get('targetDashboardId');
this.selectedDashboardStateIds = this.selectedDashboardStateIds =
this.actionTypeFormGroup.get('targetDashboardId').valueChanges.pipe( dashboardControl.valueChanges.pipe(
// startWith<string>(targetDashboardId), startWith(dashboardControl.value),
tap(() => { tap(() => {
this.targetDashboardStateSearchText = ''; this.targetDashboardStateSearchText = '';
}), }),