Total Complexity | 7 |
Complexity/F | 1.4 |
Lines of Code | 56 |
Function Count | 5 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
1 | import { fromJS } from 'immutable'; |
||
2 | import { generateLastUpdate } from './../../util/lastUpdate'; |
||
3 | |||
4 | import |
||
5 | localStorageManager |
||
6 | from './../../components/core/LocalStorageManager'; |
||
7 | |||
8 | const debouncedColumnSetter = localStorageManager.debouncedSetStateItem(); |
||
9 | |||
10 | export const hideHeader = (state, { stateKey, headerHidden }) => |
||
11 | state.mergeIn([stateKey], fromJS({ |
||
12 | headerHidden: headerHidden, |
||
13 | lastUpdate: generateLastUpdate() |
||
14 | })); |
||
15 | |||
16 | export const setColumns = (state, { columns, stateKey, stateful }) => { |
||
17 | if (stateful) { |
||
18 | setColumnsInStorage({ |
||
19 | stateKey: stateKey, |
||
20 | columns: columns |
||
21 | }); |
||
22 | } |
||
23 | |||
24 | return state.mergeIn([stateKey], fromJS({ |
||
25 | columns: columns, |
||
26 | lastUpdate: generateLastUpdate() |
||
27 | })); |
||
28 | }; |
||
29 | |||
30 | export const setSortDirection = (state, { stateKey, columns }) => |
||
31 | state.mergeIn([stateKey], fromJS({ |
||
32 | columns: columns, |
||
33 | lastUpdate: generateLastUpdate() |
||
34 | })); |
||
35 | |||
36 | export const resizeColumns = (state, { stateful, stateKey, columns }) => { |
||
37 | if (stateful) { |
||
38 | setColumnsInStorage({ |
||
39 | stateKey: stateKey, |
||
40 | columns: columns |
||
41 | }); |
||
42 | } |
||
43 | |||
44 | return state.mergeIn([stateKey], fromJS({ |
||
45 | columns: columns, |
||
46 | lastUpdate: generateLastUpdate() |
||
47 | })); |
||
48 | }; |
||
49 | |||
50 | export const setColumnsInStorage = ({ columns, stateKey }) => { |
||
51 | debouncedColumnSetter({ |
||
52 | stateKey: stateKey, |
||
53 | property: 'columns', |
||
54 | value: columns |
||
55 | }); |
||
56 | }; |
||
57 |