From e9d273c5a2a251b29a37a08aeffb3c0263f6fdf6 Mon Sep 17 00:00:00 2001 From: Tykayn Date: Thu, 25 Sep 2025 17:43:02 +0200 Subject: [PATCH] linking lists with reducer --- airwatch/src/app/reducers/index.ts | 20 ++++++++ .../filters/filters-group/filters-group.html | 18 +++---- .../filters/filters-group/filters-group.scss | 1 + .../filters/filters-group/filters-group.ts | 6 ++- .../inputs/multi-selector/multi-selector.html | 1 + sae-csc/src/app/redux/initialState.ts | 33 +++++++------ sae-csc/src/app/redux/reducers/index.ts | 49 +++++++++++++++++++ 7 files changed, 101 insertions(+), 27 deletions(-) diff --git a/airwatch/src/app/reducers/index.ts b/airwatch/src/app/reducers/index.ts index 0c56b23..bf64da7 100644 --- a/airwatch/src/app/reducers/index.ts +++ b/airwatch/src/app/reducers/index.ts @@ -9,6 +9,7 @@ import {ChatbotMessage} from '../services/chatbot.message.type'; export enum ActionTypes { UPDATE_USER = '[User] Update User', UPDATE_APP = '[App] Update App', + UPDATE_FILTER = '[App] Update Filter', UPDATE_CONVERSATIONS_LIST = '[Conversations] Update Conversations List', UPDATE_ACTIVE_CONVERSATION = '[Conversations] Update Active Conversation', POST_MESSAGE_TO_ACTIVE_CONVERSATION = '[Conversations] Post message to Active Conversation', @@ -58,6 +59,14 @@ export interface UpdateAppAction { }; } +export interface UpdateFilterAction { + type: ActionTypes.UPDATE_FILTER; + payload: { + name: string; + enabled?: boolean; + }; +} + export interface UpdateConversationsListAction { type: ActionTypes.UPDATE_CONVERSATIONS_LIST; payload: Array; @@ -103,6 +112,7 @@ export interface SwitchToNextLanguageAction { export type AppActions = | UpdateUserAction | UpdateAppAction + | UpdateFilterAction | UpdateConversationsListAction | UpdateActiveConversationAction | UpdateConversationPanelAction @@ -168,6 +178,16 @@ function appReducer(state = initialState.app, action: AppActions) { ...state, ...action.payload }; + case ActionTypes.UPDATE_FILTER: + return { + ...state, + filters: state.filters.map(f => { + if (f.name !== action.payload.name) return f; + const nextEnabled = + typeof action.payload.enabled === 'boolean' ? action.payload.enabled : !f.enabled; + return { ...f, enabled: nextEnabled }; + }) + }; case ActionTypes.SWITCH_TO_NEXT_THEME: // Find the main-button of the current active theme const currentThemeIndex = state.themesList.indexOf(state.activeTheme); diff --git a/my-workspace/projects/sae-lib/filters/filters-group/filters-group.html b/my-workspace/projects/sae-lib/filters/filters-group/filters-group.html index 8cb38ae..14b5c42 100644 --- a/my-workspace/projects/sae-lib/filters/filters-group/filters-group.html +++ b/my-workspace/projects/sae-lib/filters/filters-group/filters-group.html @@ -50,12 +50,12 @@ [store]="store" > @@ -78,7 +78,7 @@
@for (elem of appState.filters.findings.selectedList; track elem.label) { -
@for (elem of appState.filters.ata.selectedList; track elem.label) { -
@for (elem of appState.filters.partNumber.selectedList; track elem.label) { -
@for (elem of appState.filters.technicalManual.selectedList; track elem.label) { -
@for (elem of appState.filters.onOffWing.selectedList; track elem.label) { -