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