From 567d034c247435e5face5912abfde5d91141879e Mon Sep 17 00:00:00 2001 From: Clemente Raposo Date: Thu, 5 Dec 2024 00:44:11 +0000 Subject: [PATCH] Fix bottom-widget display/hide logic --- .../store/create-view/create-view.store.ts | 1 + .../record/adapters/bottom-widget.adapter.ts | 2 +- .../store/record-view/record-view.store.model.ts | 1 + .../store/record-view/record-view.store.ts | 16 ++++++++++++++++ 4 files changed, 19 insertions(+), 1 deletion(-) diff --git a/core/app/core/src/lib/views/create/store/create-view/create-view.store.ts b/core/app/core/src/lib/views/create/store/create-view/create-view.store.ts index e4d31d44b..5c48bb498 100644 --- a/core/app/core/src/lib/views/create/store/create-view/create-view.store.ts +++ b/core/app/core/src/lib/views/create/store/create-view/create-view.store.ts @@ -108,6 +108,7 @@ export class CreateViewStore extends RecordViewStore { this.parseParams(params); this.calculateShowWidgets(); this.showTopWidget = false; + this.showBottomWidgets = false; this.showSubpanels = false; const isDuplicate = this.params.isDuplicate ?? false; diff --git a/core/app/core/src/lib/views/record/adapters/bottom-widget.adapter.ts b/core/app/core/src/lib/views/record/adapters/bottom-widget.adapter.ts index 9be94854e..6a6b76cb3 100644 --- a/core/app/core/src/lib/views/record/adapters/bottom-widget.adapter.ts +++ b/core/app/core/src/lib/views/record/adapters/bottom-widget.adapter.ts @@ -34,7 +34,7 @@ import {RecordViewStore} from '../store/record-view/record-view.store'; export class BottomWidgetAdapter { config$ = this.metadata.recordViewMetadata$.pipe( - combineLatestWith(this.store.widgets$), + combineLatestWith(this.store.showBottomWidgets$), map(([metadata, show]: [RecordViewMetadata, boolean]) => { if (metadata.bottomWidgets && metadata.bottomWidgets.length) { diff --git a/core/app/core/src/lib/views/record/store/record-view/record-view.store.model.ts b/core/app/core/src/lib/views/record/store/record-view/record-view.store.model.ts index c5ef93cc5..c7de37575 100644 --- a/core/app/core/src/lib/views/record/store/record-view/record-view.store.model.ts +++ b/core/app/core/src/lib/views/record/store/record-view/record-view.store.model.ts @@ -49,6 +49,7 @@ export interface RecordViewState { loading: boolean; widgets: boolean; showSidebarWidgets: boolean; + showBottomWidgets: boolean; showTopWidget: boolean; showSubpanels: boolean; mode: ViewMode; diff --git a/core/app/core/src/lib/views/record/store/record-view/record-view.store.ts b/core/app/core/src/lib/views/record/store/record-view/record-view.store.ts index d2af27fe5..72b2c5396 100644 --- a/core/app/core/src/lib/views/record/store/record-view/record-view.store.ts +++ b/core/app/core/src/lib/views/record/store/record-view/record-view.store.ts @@ -75,6 +75,7 @@ const initialState: RecordViewState = { loading: false, widgets: false, showSidebarWidgets: false, + showBottomWidgets: false, showTopWidget: false, showSubpanels: false, mode: 'detail', @@ -96,6 +97,7 @@ export class RecordViewStore extends ViewStore implements StateStore { loading$: Observable; widgets$: Observable; showSidebarWidgets$: Observable; + showBottomWidgets$: Observable; showTopWidget$: Observable; showSubpanels$: Observable; mode$: Observable; @@ -161,6 +163,7 @@ export class RecordViewStore extends ViewStore implements StateStore { this.loading$ = this.state$.pipe(map(state => state.loading)); this.widgets$ = this.state$.pipe(map(state => state.widgets)); this.showSidebarWidgets$ = this.state$.pipe(map(state => state.showSidebarWidgets)); + this.showBottomWidgets$ = this.state$.pipe(map(state => state.showBottomWidgets)); this.showTopWidget$ = this.state$.pipe(map(state => state.showTopWidget)); this.showSubpanels$ = this.state$.pipe(map(state => state.showSubpanels)); this.mode$ = this.state$.pipe(map(state => state.mode)); @@ -214,6 +217,17 @@ export class RecordViewStore extends ViewStore implements StateStore { }); } + get showBottomWidgets(): boolean { + return this.internalState.showBottomWidgets; + } + + set showBottomWidgets(show: boolean) { + this.updateState({ + ...this.internalState, + showBottomWidgets: show + }); + } + get showTopWidget(): boolean { return this.internalState.showTopWidget; } @@ -664,6 +678,8 @@ export class RecordViewStore extends ViewStore implements StateStore { this.showSidebarWidgets = show; } + this.showBottomWidgets = true; + this.widgets = show; }