summaryrefslogtreecommitdiffstats
path: root/sdnr/wt/odlux/apps/maintenanceApp/src/handlers
diff options
context:
space:
mode:
authorHerbert Eiselt <herbert.eiselt@highstreet-technologies.com>2019-02-28 15:23:42 +0100
committerHerbert Eiselt <herbert.eiselt@highstreet-technologies.com>2019-02-28 15:24:28 +0100
commit7446f23b3abc30d7c53f2eaa951742371c071171 (patch)
treeb76a8d2e64c7aa850c09f8e69f01e7a262ab5cd5 /sdnr/wt/odlux/apps/maintenanceApp/src/handlers
parent49b155ec687cdf58fb51fe8245a2f5f4582b68f0 (diff)
UX extensions
UX Maintenance client and further changes Change-Id: I7643661d17db5fc3d3f94b58cb42ed0be558c64f Issue-ID: SDNC-583 Signed-off-by: Herbert Eiselt <herbert.eiselt@highstreet-technologies.com>
Diffstat (limited to 'sdnr/wt/odlux/apps/maintenanceApp/src/handlers')
-rw-r--r--sdnr/wt/odlux/apps/maintenanceApp/src/handlers/maintenanceAppRootHandler.ts27
-rw-r--r--sdnr/wt/odlux/apps/maintenanceApp/src/handlers/maintenenceEntriesHandler.ts40
2 files changed, 67 insertions, 0 deletions
diff --git a/sdnr/wt/odlux/apps/maintenanceApp/src/handlers/maintenanceAppRootHandler.ts b/sdnr/wt/odlux/apps/maintenanceApp/src/handlers/maintenanceAppRootHandler.ts
new file mode 100644
index 000000000..956d05843
--- /dev/null
+++ b/sdnr/wt/odlux/apps/maintenanceApp/src/handlers/maintenanceAppRootHandler.ts
@@ -0,0 +1,27 @@
+// main state handler
+
+import { combineActionHandler } from '../../../../framework/src/flux/middleware';
+
+import { IApplicationStoreState } from '../../../../framework/src/store/applicationStore';
+
+import { IConnectAppStoreState } from '../../../connectApp/src/handlers/connectAppRootHandler';
+
+import { IMaintenenceEntriesState, maintenenceEntriesActionHandler } from './maintenenceEntriesHandler';
+
+export interface IMaintenanceAppStoreState {
+ maintenenceEntries : IMaintenenceEntriesState
+}
+
+declare module '../../../../framework/src/store/applicationStore' {
+ interface IApplicationStoreState {
+ maintenanceApp: IMaintenanceAppStoreState,
+ connectApp: IConnectAppStoreState
+ }
+}
+
+const actionHandlers = {
+ maintenenceEntries: maintenenceEntriesActionHandler
+};
+
+export const maintenanceAppRootHandler = combineActionHandler<IMaintenanceAppStoreState>(actionHandlers);
+export default maintenanceAppRootHandler;
diff --git a/sdnr/wt/odlux/apps/maintenanceApp/src/handlers/maintenenceEntriesHandler.ts b/sdnr/wt/odlux/apps/maintenanceApp/src/handlers/maintenenceEntriesHandler.ts
new file mode 100644
index 000000000..13f4a3b6d
--- /dev/null
+++ b/sdnr/wt/odlux/apps/maintenanceApp/src/handlers/maintenenceEntriesHandler.ts
@@ -0,0 +1,40 @@
+import { IActionHandler } from '../../../../framework/src/flux/action';
+
+import { MaintenenceEntry } from '../models/maintenenceEntryType';
+import { LoadAllMainteneceEntriesAction, AllMainteneceEntriesLoadedAction, UpdateMaintenanceEntry } from '../actions/maintenenceActions';
+
+export interface IMaintenenceEntriesState {
+ entries: MaintenenceEntry[];
+ busy: boolean;
+}
+
+const maintenanceEntriesStateInit: IMaintenenceEntriesState = {
+ entries: [],
+ busy: false
+};
+
+export const maintenenceEntriesActionHandler: IActionHandler<IMaintenenceEntriesState> = (state = maintenanceEntriesStateInit, action) => {
+ if (action instanceof LoadAllMainteneceEntriesAction){
+ state = {
+ ...state,
+ busy: true,
+ }
+ } else if (action instanceof AllMainteneceEntriesLoadedAction){
+ state = {
+ ...state,
+ entries: action.maintenenceEntries || [],
+ busy: false,
+ }
+ } else if (action instanceof UpdateMaintenanceEntry) {
+ const index = state.entries.findIndex(e => action.maintenenceEntry.mountId === e.mountId);
+ state = {
+ ...state,
+ entries: index > -1 ? [
+ ...state.entries.slice(0, index),
+ action.maintenenceEntry,
+ ...state.entries.slice(index+1),
+ ] : [...state.entries, action.maintenenceEntry]
+ }
+ }
+ return state;
+} \ No newline at end of file