Sha256: c32f8cefcb675435358ab6387059132461711e0a35559965d094791136915339
Contents?: true
Size: 1.61 KB
Versions: 6
Compression:
Stored size: 1.61 KB
Contents
import Immutable from 'seamless-immutable'; import { combineReducers } from 'redux'; import { union } from 'lodash'; import { createTableReducer } from 'foremanReact/components/common/table'; import createTableActionTypes from 'foremanReact/components/common/table/actionsHelpers/actionTypeCreator'; import { TASKS_TABLE_ID, SELECT_ROWS, UNSELECT_ROWS, UNSELECT_ALL_ROWS, TASKS_TABLE_SELECTED_MODAL, CLOSED, } from './TasksTableConstants'; const initialState = Immutable({ selectedRows: [], modalStatus: CLOSED, }); export const TasksTableQueryReducer = (state = initialState, action) => { const { type, payload } = action; const { subtotal, page, per_page: perPageString, action_name: actionName } = payload || {}; const ACTION_TYPES = createTableActionTypes(TASKS_TABLE_ID); switch (type) { case ACTION_TYPES.SUCCESS: return Immutable.merge(state, { itemCount: subtotal, actionName, pagination: { page: Number(page), perPage: Number(perPageString), }, selectedRows: [], }); case SELECT_ROWS: return state.set('selectedRows', union(payload, state.selectedRows)); case UNSELECT_ROWS: return state.set( 'selectedRows', state.selectedRows.filter(row => row !== payload) ); case UNSELECT_ALL_ROWS: return state.set('selectedRows', []); case TASKS_TABLE_SELECTED_MODAL: return state.set('modalStatus', payload); default: return state; } }; export default combineReducers({ tasksTableContent: createTableReducer(TASKS_TABLE_ID), tasksTableQuery: TasksTableQueryReducer, });
Version data entries
6 entries across 6 versions & 1 rubygems