UNPKG

@adaptabletools/adaptable-cjs

Version:

Powerful data-agnostic HTML5 AG Grid extension which provides advanced, cutting-edge functionality to meet all DataGrid requirements

67 lines (66 loc) 3.1 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ApplicationReducer = exports.ApplicationDataEntryDelete = exports.ApplicationDataEntryEdit = exports.ApplicationDataEntryAdd = exports.APPLICATION_DATA_ENTRY_DELETE = exports.APPLICATION_DATA_ENTRY_EDIT = exports.APPLICATION_DATA_ENTRY_ADD = void 0; const GeneralConstants_1 = require("../../Utilities/Constants/GeneralConstants"); /** * @ReduxAction An Application Data Entry has been added */ exports.APPLICATION_DATA_ENTRY_ADD = 'APPLICATION_DATA_ENTRY_ADD'; /** * @ReduxAction An Application Data Entry has been edited */ exports.APPLICATION_DATA_ENTRY_EDIT = 'APPLICATION_DATA_ENTRY_EDIT'; /** * @ReduxAction An Application Data Entry has been deleted */ exports.APPLICATION_DATA_ENTRY_DELETE = 'APPLICATION_DATA_ENTRY_DELETE'; const ApplicationDataEntryAdd = (applicationDataEntry) => ({ type: exports.APPLICATION_DATA_ENTRY_ADD, applicationDataEntry, }); exports.ApplicationDataEntryAdd = ApplicationDataEntryAdd; const ApplicationDataEntryEdit = (applicationDataEntry) => ({ type: exports.APPLICATION_DATA_ENTRY_EDIT, applicationDataEntry, }); exports.ApplicationDataEntryEdit = ApplicationDataEntryEdit; const ApplicationDataEntryDelete = (applicationDataEntry) => ({ type: exports.APPLICATION_DATA_ENTRY_DELETE, applicationDataEntry, }); exports.ApplicationDataEntryDelete = ApplicationDataEntryDelete; const initialState = { ApplicationDataEntries: GeneralConstants_1.EMPTY_ARRAY, }; const ApplicationReducer = (state = initialState, action) => { let applicationDataEntries; let index; switch (action.type) { case exports.APPLICATION_DATA_ENTRY_ADD: const actionTypedAdd = action; applicationDataEntries = [].concat(state.ApplicationDataEntries); applicationDataEntries.push(actionTypedAdd.applicationDataEntry); return Object.assign({}, state, { ApplicationDataEntries: applicationDataEntries, }); case exports.APPLICATION_DATA_ENTRY_EDIT: const actionTypedUpdate = action; applicationDataEntries = [].concat(state.ApplicationDataEntries); index = applicationDataEntries.findIndex((fe) => fe.Key == actionTypedUpdate.applicationDataEntry.Key); applicationDataEntries[index] = actionTypedUpdate.applicationDataEntry; return Object.assign({}, state, { ApplicationDataEntries: applicationDataEntries, }); case exports.APPLICATION_DATA_ENTRY_DELETE: const actionTypedDelete = action; applicationDataEntries = [].concat(state.ApplicationDataEntries); index = applicationDataEntries.findIndex((a) => a.Key == actionTypedDelete.applicationDataEntry.Key); applicationDataEntries.splice(index, 1); return Object.assign({}, state, { ApplicationDataEntries: applicationDataEntries, }); default: return state; } }; exports.ApplicationReducer = ApplicationReducer;