-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
101 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
export const tableVisibleColumnsUpdate = 'tables/visibleColumnsUpdate' | ||
export const tableMaxRowsUpdate = 'tables/maxRowsUpdate' | ||
|
||
export const updateVisibleColumns = | ||
({ module, visibleColumns }) => | ||
(dispatch) => | ||
dispatch({ type: tableVisibleColumnsUpdate, module, visibleColumns }) | ||
|
||
export const updateMaxRows = | ||
({ module, maxRows }) => | ||
(dispatch) => | ||
dispatch({ type: tableMaxRowsUpdate, module, maxRows }) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { useSelector } from 'react-redux' | ||
import * as TablesState from './state' | ||
|
||
export const useTableMaxRows = (module) => useSelector(TablesState.getMaxRows(module)) | ||
|
||
export const useTableVisibleColumns = (module) => useSelector(TablesState.getVisibleColumns(module)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import * as TablesActions from './actions' | ||
import TablesReducer from './reducer' | ||
import * as TablesState from './state' | ||
|
||
export { TablesActions, TablesReducer, TablesState } | ||
export { useTableMaxRows, useTableVisibleColumns } from './hooks' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { exportReducer } from '@webapp/utils/reduxUtils' | ||
|
||
import { SystemActions } from '@webapp/store/system' | ||
|
||
import * as TablesActions from './actions' | ||
import * as TablesState from './state' | ||
|
||
const actionHandlers = { | ||
// Reset form | ||
[SystemActions.SYSTEM_RESET]: () => ({}), | ||
|
||
// Tables | ||
[TablesActions.tableVisibleColumnsUpdate]: (state, { module, visibleColumns }) => | ||
TablesState.assocVisibleColumns({ module, visibleColumns })(state), | ||
|
||
[TablesActions.tableMaxRowsUpdate]: (state, { module, maxRows }) => | ||
TablesState.assocMaxRows({ module, maxRows })(state), | ||
} | ||
|
||
export default exportReducer(actionHandlers) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import * as A from '@core/arena' | ||
|
||
import * as UiState from '../state' | ||
import { Objects } from '@openforis/arena-core' | ||
|
||
export const stateKey = 'tables' | ||
|
||
const getState = A.pipe(UiState.getState, A.propOr({}, stateKey)) | ||
|
||
const keys = { | ||
visibleColumnKeysByModule: 'visibleColumnKeysByModule', | ||
maxRowsByModule: 'maxRowsByModule', | ||
} | ||
|
||
export const getVisibleColumns = (module) => A.pipe(getState, Objects.path([keys.visibleColumnKeysByModule, module])) | ||
|
||
export const getMaxRows = (module) => A.pipe(getState, Objects.path([keys.maxRowsByModule, module])) | ||
|
||
export const assocVisibleColumns = | ||
({ module, visibleColumns }) => | ||
(state) => | ||
Objects.assocPath({ obj: state, path: [keys.visibleColumnKeysByModule, module], value: visibleColumns }) | ||
|
||
export const assocMaxRows = | ||
({ module, maxRows }) => | ||
(state) => | ||
Objects.assocPath({ obj: state, path: [keys.maxRowsByModule, module], value: maxRows }) |