@stenajs-webui/redux 17.4.1 → 17.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/dist/common/ActionWithReducerId.d.ts +3 -3
- package/dist/common/EntityWithId.d.ts +3 -3
- package/dist/common/util/field-matcher.d.ts +1 -1
- package/dist/features/higher-order-reducers/entity-list-reducer/entity-list-action-creators.d.ts +17 -17
- package/dist/features/higher-order-reducers/entity-list-reducer/entity-list-actions.d.ts +52 -52
- package/dist/features/higher-order-reducers/entity-list-reducer/entity-list-reducer.d.ts +4 -4
- package/dist/features/higher-order-reducers/entity-list-reducer/entity-list-selectors.d.ts +6 -6
- package/dist/features/higher-order-reducers/record-object-reducer/record-object-action-creators.d.ts +7 -7
- package/dist/features/higher-order-reducers/record-object-reducer/record-object-actions.d.ts +17 -17
- package/dist/features/higher-order-reducers/record-object-reducer/record-object-reducer.d.ts +4 -4
- package/dist/features/higher-order-reducers/reducer-id-gate/reducer-id-action-wrapper.d.ts +12 -12
- package/dist/features/higher-order-reducers/reducer-id-gate/reducer-id-gate.d.ts +9 -9
- package/dist/features/reducer-factories/commit-reducer/commit-action-creators.d.ts +7 -7
- package/dist/features/reducer-factories/commit-reducer/commit-actions.d.ts +18 -18
- package/dist/features/reducer-factories/commit-reducer/commit-reducer.d.ts +3 -3
- package/dist/features/reducer-factories/commit-reducer/commit-selectors.d.ts +7 -7
- package/dist/features/reducer-factories/commit-reducer/commit-state.d.ts +4 -4
- package/dist/features/reducer-factories/editable-entity-reducer/editable-entity-action-creators.d.ts +11 -11
- package/dist/features/reducer-factories/editable-entity-reducer/editable-entity-actions.d.ts +27 -27
- package/dist/features/reducer-factories/editable-entity-reducer/editable-entity-reducer.d.ts +8 -8
- package/dist/features/reducer-factories/entity-by-id-reducer/entity-by-id-action-creators.d.ts +9 -9
- package/dist/features/reducer-factories/entity-by-id-reducer/entity-by-id-actions.d.ts +18 -18
- package/dist/features/reducer-factories/entity-by-id-reducer/entity-by-id-reducer.d.ts +11 -11
- package/dist/features/reducer-factories/entity-by-id-reducer/entity-by-id-selectors.d.ts +7 -7
- package/dist/features/reducer-factories/entity-crud-status-reducer/entity-crud-status-redux.d.ts +31 -31
- package/dist/features/reducer-factories/entity-reducer/entity-action-creators.d.ts +6 -6
- package/dist/features/reducer-factories/entity-reducer/entity-actions.d.ts +9 -9
- package/dist/features/reducer-factories/entity-reducer/entity-reducer.d.ts +4 -4
- package/dist/features/reducer-factories/entity-reducer/entity-selectors.d.ts +6 -6
- package/dist/features/reducer-factories/modified-field-reducer/modified-field-redux.d.ts +23 -23
- package/dist/features/reducer-factories/selected-ids-reducer/selected-ids-action-creators.d.ts +7 -7
- package/dist/features/reducer-factories/selected-ids-reducer/selected-ids-actions.d.ts +8 -8
- package/dist/features/reducer-factories/selected-ids-reducer/selected-ids-reducer.d.ts +9 -9
- package/dist/features/reducer-factories/selected-ids-reducer/selected-ids-selectors.d.ts +6 -6
- package/dist/features/reducer-factories/sort-order-by-id-reducer/hooks/use-sort-order-by-id.d.ts +3 -3
- package/dist/features/reducer-factories/sort-order-by-id-reducer/sort-order-by-id-action-creators.d.ts +7 -7
- package/dist/features/reducer-factories/sort-order-by-id-reducer/sort-order-by-id-actions.d.ts +8 -8
- package/dist/features/reducer-factories/sort-order-by-id-reducer/sort-order-by-id-reducer.d.ts +6 -6
- package/dist/features/reducer-factories/sort-order-by-id-reducer/sort-order-by-id-selectors.d.ts +8 -8
- package/dist/features/reducer-factories/sort-order-reducer/sort-order-action-creators.d.ts +6 -6
- package/dist/features/reducer-factories/sort-order-reducer/sort-order-actions.d.ts +9 -9
- package/dist/features/reducer-factories/sort-order-reducer/sort-order-reducer.d.ts +9 -9
- package/dist/features/reducer-factories/sort-order-reducer/sort-order-selectors.d.ts +6 -6
- package/dist/features/reducer-factories/value-by-id-reducer/value-by-id-action-creators.d.ts +7 -7
- package/dist/features/reducer-factories/value-by-id-reducer/value-by-id-actions.d.ts +13 -13
- package/dist/features/reducer-factories/value-by-id-reducer/value-by-id-reducer.d.ts +10 -10
- package/dist/features/reducer-factories/value-by-id-reducer/value-by-id-selectors.d.ts +6 -6
- package/dist/index.d.ts +44 -44
- package/dist/index.es.js +634 -656
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +1 -722
- package/dist/index.js.map +1 -1
- package/package.json +5 -6
- package/dist/common/util/__tests__/field-matcher.test.d.ts +0 -1
- package/dist/features/higher-order-reducers/entity-list-reducer/__tests__/entity-list-reducer.test.d.ts +0 -1
- package/dist/features/higher-order-reducers/record-object-reducer/__tests__/record-object-reducer.test.d.ts +0 -1
- package/dist/features/higher-order-reducers/reducer-id-gate/__tests__/reducer-id-gate.test.d.ts +0 -1
- package/dist/features/reducer-factories/entity-by-id-reducer/__tests__/entity-by-id-reducer.test.d.ts +0 -1
- package/dist/features/reducer-factories/entity-reducer/__tests__/entity-reducer.test.d.ts +0 -1
- package/dist/features/reducer-factories/selected-ids-reducer/__tests__/selected-ids-reducer.test.d.ts +0 -1
- package/dist/features/reducer-factories/sort-order-by-id-reducer/__tests__/sort-order-by-id-reducer.test.d.ts +0 -1
- package/dist/features/reducer-factories/sort-order-reducer/__tests__/sort-order-reducer.test.d.ts +0 -1
- package/dist/features/reducer-factories/value-by-id-reducer/__tests__/value-by-id-reducer.test.d.ts +0 -1
package/dist/index.es.js
CHANGED
|
@@ -1,675 +1,653 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
return t;
|
|
23
|
-
};
|
|
24
|
-
return __assign.apply(this, arguments);
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
function __spreadArray(to, from, pack) {
|
|
28
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
29
|
-
if (ar || !(i in from)) {
|
|
30
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
31
|
-
ar[i] = from[i];
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
var createRecordObjectReducer = function (reducer) {
|
|
38
|
-
return function (state, action) {
|
|
39
|
-
var _a;
|
|
40
|
-
if (state === void 0) { state = {}; }
|
|
41
|
-
switch (action.type) {
|
|
42
|
-
case "RECORD_OBJECT:CLEAR_RECORD": {
|
|
43
|
-
var recordId = action.recordId;
|
|
44
|
-
var newState = __assign({}, state);
|
|
45
|
-
delete newState[recordId];
|
|
46
|
-
return newState;
|
|
47
|
-
}
|
|
48
|
-
case "RECORD_OBJECT:CLEAR_ALL_RECORDS": {
|
|
49
|
-
return {};
|
|
50
|
-
}
|
|
51
|
-
case "RECORD_OBJECT:ACTION": {
|
|
52
|
-
var recordId = action.recordId, innerAction = action.action;
|
|
53
|
-
return __assign(__assign({}, state), (_a = {}, _a[recordId] = reducer(state[recordId], innerAction), _a));
|
|
54
|
-
}
|
|
55
|
-
default:
|
|
56
|
-
return state;
|
|
57
|
-
}
|
|
58
|
-
};
|
|
1
|
+
(function(){ try {var elementStyle = document.createElement('style'); elementStyle.appendChild(document.createTextNode("")); document.head.appendChild(elementStyle);} catch(e) {console.error('vite-plugin-css-injected-by-js', e);} })();const createRecordObjectReducer = (reducer) => (state = {}, action) => {
|
|
2
|
+
switch (action.type) {
|
|
3
|
+
case "RECORD_OBJECT:CLEAR_RECORD": {
|
|
4
|
+
const { recordId } = action;
|
|
5
|
+
const newState = { ...state };
|
|
6
|
+
delete newState[recordId];
|
|
7
|
+
return newState;
|
|
8
|
+
}
|
|
9
|
+
case "RECORD_OBJECT:CLEAR_ALL_RECORDS": {
|
|
10
|
+
return {};
|
|
11
|
+
}
|
|
12
|
+
case "RECORD_OBJECT:ACTION": {
|
|
13
|
+
const { recordId, action: innerAction } = action;
|
|
14
|
+
return {
|
|
15
|
+
...state,
|
|
16
|
+
[recordId]: reducer(state[recordId], innerAction)
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
default:
|
|
20
|
+
return state;
|
|
21
|
+
}
|
|
59
22
|
};
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
return
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
action.type !== "REDUCER_ID_GATE:ACTION") {
|
|
84
|
-
return newState;
|
|
85
|
-
}
|
|
86
|
-
return reducer(newState, action.action);
|
|
87
|
-
};
|
|
88
|
-
};
|
|
89
|
-
var reducerIdGateAction = function (reducerId, action) { return ({
|
|
90
|
-
type: "REDUCER_ID_GATE:ACTION",
|
|
91
|
-
action: action,
|
|
92
|
-
reducerId: reducerId,
|
|
93
|
-
}); };
|
|
94
|
-
var isValidReducerIdGateAction = function (action) {
|
|
95
|
-
return !!action.action &&
|
|
96
|
-
action.type === "REDUCER_ID_GATE:ACTION" &&
|
|
97
|
-
typeof action.reducerId === "string";
|
|
23
|
+
const createRecordObjectActions = () => ({
|
|
24
|
+
recordAction: (recordId, action) => ({
|
|
25
|
+
type: "RECORD_OBJECT:ACTION",
|
|
26
|
+
action,
|
|
27
|
+
recordId
|
|
28
|
+
}),
|
|
29
|
+
clearRecord: (recordId) => ({
|
|
30
|
+
type: "RECORD_OBJECT:CLEAR_RECORD",
|
|
31
|
+
recordId
|
|
32
|
+
}),
|
|
33
|
+
clearAllRecords: () => ({
|
|
34
|
+
type: "RECORD_OBJECT:CLEAR_ALL_RECORDS"
|
|
35
|
+
})
|
|
36
|
+
});
|
|
37
|
+
const reducerIdGate = (reducerId, reducer) => (state, action) => {
|
|
38
|
+
let newState = state == null ? reducer(void 0, {}) : state;
|
|
39
|
+
if (!isValidReducerIdGateAction(action)) {
|
|
40
|
+
return newState;
|
|
41
|
+
}
|
|
42
|
+
if (reducerId !== action.reducerId || action.type !== "REDUCER_ID_GATE:ACTION") {
|
|
43
|
+
return newState;
|
|
44
|
+
}
|
|
45
|
+
return reducer(newState, action.action);
|
|
98
46
|
};
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
};
|
|
112
|
-
};
|
|
113
|
-
var wrapActionsWithReducerIdGate = function (reducerId, actionCreators) {
|
|
114
|
-
var boundActionCreators = {};
|
|
115
|
-
for (var key in actionCreators) {
|
|
116
|
-
var actionCreator = actionCreators[key];
|
|
117
|
-
boundActionCreators[key] = wrapActionWithReducerIdGate(reducerId, actionCreator);
|
|
118
|
-
}
|
|
119
|
-
return boundActionCreators;
|
|
47
|
+
const reducerIdGateAction = (reducerId, action) => ({
|
|
48
|
+
type: "REDUCER_ID_GATE:ACTION",
|
|
49
|
+
action,
|
|
50
|
+
reducerId
|
|
51
|
+
});
|
|
52
|
+
const isValidReducerIdGateAction = (action) => !!action.action && action.type === "REDUCER_ID_GATE:ACTION" && typeof action.reducerId === "string";
|
|
53
|
+
const wrapActionWithReducerIdGate = (reducerId, actionCreator) => (...args) => {
|
|
54
|
+
return {
|
|
55
|
+
type: "REDUCER_ID_GATE:ACTION",
|
|
56
|
+
reducerId,
|
|
57
|
+
action: actionCreator(...args)
|
|
58
|
+
};
|
|
120
59
|
};
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
}); },
|
|
129
|
-
commitValues: function () { return ({
|
|
130
|
-
type: "COMMIT_REDUCER.COMMIT_VALUES",
|
|
131
|
-
id: id,
|
|
132
|
-
}); },
|
|
133
|
-
clearValues: function () { return ({
|
|
134
|
-
type: "COMMIT_REDUCER.CLEAR",
|
|
135
|
-
id: id,
|
|
136
|
-
}); },
|
|
137
|
-
};
|
|
60
|
+
const wrapActionsWithReducerIdGate = (reducerId, actionCreators) => {
|
|
61
|
+
const boundActionCreators = {};
|
|
62
|
+
for (const key in actionCreators) {
|
|
63
|
+
const actionCreator = actionCreators[key];
|
|
64
|
+
boundActionCreators[key] = wrapActionWithReducerIdGate(reducerId, actionCreator);
|
|
65
|
+
}
|
|
66
|
+
return boundActionCreators;
|
|
138
67
|
};
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
return __assign(__assign({}, state), { committed: __assign({}, state.workspace) });
|
|
156
|
-
}
|
|
157
|
-
default:
|
|
158
|
-
return state;
|
|
159
|
-
}
|
|
160
|
-
};
|
|
68
|
+
const createCommitReducerActions = (id) => {
|
|
69
|
+
return {
|
|
70
|
+
setValues: (values) => ({
|
|
71
|
+
type: "COMMIT_REDUCER.SET_VALUES",
|
|
72
|
+
id,
|
|
73
|
+
values
|
|
74
|
+
}),
|
|
75
|
+
commitValues: () => ({
|
|
76
|
+
type: "COMMIT_REDUCER.COMMIT_VALUES",
|
|
77
|
+
id
|
|
78
|
+
}),
|
|
79
|
+
clearValues: () => ({
|
|
80
|
+
type: "COMMIT_REDUCER.CLEAR",
|
|
81
|
+
id
|
|
82
|
+
})
|
|
83
|
+
};
|
|
161
84
|
};
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
return
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
85
|
+
const createCommitReducer = (id, initialState) => (state = initialState, action) => {
|
|
86
|
+
if (action.id !== id) {
|
|
87
|
+
return state;
|
|
88
|
+
}
|
|
89
|
+
switch (action.type) {
|
|
90
|
+
case `COMMIT_REDUCER.SET_VALUES`: {
|
|
91
|
+
const { values } = action;
|
|
92
|
+
return {
|
|
93
|
+
...state,
|
|
94
|
+
workspace: {
|
|
95
|
+
...state.workspace,
|
|
96
|
+
...values
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
case `COMMIT_REDUCER.CLEAR`: {
|
|
101
|
+
return {
|
|
102
|
+
...state,
|
|
103
|
+
workspace: {
|
|
104
|
+
...initialState.workspace
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
case `COMMIT_REDUCER.COMMIT_VALUES`: {
|
|
109
|
+
return {
|
|
110
|
+
...state,
|
|
111
|
+
committed: {
|
|
112
|
+
...state.workspace
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
default:
|
|
117
|
+
return state;
|
|
118
|
+
}
|
|
168
119
|
};
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
entity: entity,
|
|
175
|
-
type: "ENTITY_LIST:ADD_AT_START",
|
|
176
|
-
}); },
|
|
177
|
-
clearList: function () { return ({ type: "ENTITY_LIST:CLEAR_LIST" }); },
|
|
178
|
-
removeFirst: function () { return ({ type: "ENTITY_LIST:REMOVE_FIRST" }); },
|
|
179
|
-
removeLast: function () { return ({ type: "ENTITY_LIST:REMOVE_LAST" }); },
|
|
180
|
-
removeAtIndex: function (index) { return ({
|
|
181
|
-
type: "ENTITY_LIST:REMOVE_AT_INDEX",
|
|
182
|
-
index: index,
|
|
183
|
-
}); },
|
|
184
|
-
removeByFieldMatch: function (fields) { return ({
|
|
185
|
-
type: "ENTITY_LIST:REMOVE_BY_FIELD_MATCH",
|
|
186
|
-
fields: fields,
|
|
187
|
-
}); },
|
|
188
|
-
remove: function (entity) { return ({ type: "ENTITY_LIST:REMOVE", entity: entity }); },
|
|
189
|
-
setList: function (list) { return ({ type: "ENTITY_LIST:SET_LIST", list: list }); },
|
|
190
|
-
toggle: function (entity) { return ({ type: "ENTITY_LIST:TOGGLE", entity: entity }); },
|
|
191
|
-
actionByFieldsMatch: function (fields, action) { return ({
|
|
192
|
-
type: "ENTITY_LIST:ACTION_BY_FIELDS_MATCH",
|
|
193
|
-
fields: fields,
|
|
194
|
-
action: action,
|
|
195
|
-
}); },
|
|
196
|
-
actionByIndex: function (index, action) { return ({
|
|
197
|
-
type: "ENTITY_LIST:ACTION_BY_INDEX",
|
|
198
|
-
index: index,
|
|
199
|
-
action: action,
|
|
200
|
-
}); },
|
|
201
|
-
actionOnAll: function (action) { return ({
|
|
202
|
-
type: "ENTITY_LIST:ACTION_ON_ALL",
|
|
203
|
-
action: action,
|
|
204
|
-
}); },
|
|
205
|
-
};
|
|
120
|
+
const createCommitReducerSelectors = (id, stateSelector) => {
|
|
121
|
+
return {
|
|
122
|
+
getWorkspaceValues: (state) => stateSelector(state, id).workspace,
|
|
123
|
+
getCommittedValues: (state) => stateSelector(state, id).committed
|
|
124
|
+
};
|
|
206
125
|
};
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
126
|
+
const createEntityListActions = () => {
|
|
127
|
+
return {
|
|
128
|
+
addAtEnd: (entity) => ({ type: "ENTITY_LIST:ADD_AT_END", entity }),
|
|
129
|
+
addAtStart: (entity) => ({
|
|
130
|
+
entity,
|
|
131
|
+
type: "ENTITY_LIST:ADD_AT_START"
|
|
132
|
+
}),
|
|
133
|
+
clearList: () => ({ type: "ENTITY_LIST:CLEAR_LIST" }),
|
|
134
|
+
removeFirst: () => ({ type: "ENTITY_LIST:REMOVE_FIRST" }),
|
|
135
|
+
removeLast: () => ({ type: "ENTITY_LIST:REMOVE_LAST" }),
|
|
136
|
+
removeAtIndex: (index) => ({
|
|
137
|
+
type: "ENTITY_LIST:REMOVE_AT_INDEX",
|
|
138
|
+
index
|
|
139
|
+
}),
|
|
140
|
+
removeByFieldMatch: (fields) => ({
|
|
141
|
+
type: "ENTITY_LIST:REMOVE_BY_FIELD_MATCH",
|
|
142
|
+
fields
|
|
143
|
+
}),
|
|
144
|
+
remove: (entity) => ({ type: "ENTITY_LIST:REMOVE", entity }),
|
|
145
|
+
setList: (list) => ({ type: "ENTITY_LIST:SET_LIST", list }),
|
|
146
|
+
toggle: (entity) => ({ type: "ENTITY_LIST:TOGGLE", entity }),
|
|
147
|
+
actionByFieldsMatch: (fields, action) => ({
|
|
148
|
+
type: "ENTITY_LIST:ACTION_BY_FIELDS_MATCH",
|
|
149
|
+
fields,
|
|
150
|
+
action
|
|
151
|
+
}),
|
|
152
|
+
actionByIndex: (index, action) => ({
|
|
153
|
+
type: "ENTITY_LIST:ACTION_BY_INDEX",
|
|
154
|
+
index,
|
|
155
|
+
action
|
|
156
|
+
}),
|
|
157
|
+
actionOnAll: (action) => ({
|
|
158
|
+
type: "ENTITY_LIST:ACTION_ON_ALL",
|
|
159
|
+
action
|
|
160
|
+
})
|
|
161
|
+
};
|
|
220
162
|
};
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
case "ENTITY_LIST:ADD_AT_END": {
|
|
234
|
-
var entity = action.entity;
|
|
235
|
-
return __spreadArray(__spreadArray([], state, true), [entity], false);
|
|
236
|
-
}
|
|
237
|
-
case "ENTITY_LIST:ADD_AT_START": {
|
|
238
|
-
var entity = action.entity;
|
|
239
|
-
return __spreadArray([entity], state, true);
|
|
240
|
-
}
|
|
241
|
-
case "ENTITY_LIST:REMOVE_FIRST": {
|
|
242
|
-
if (state.length === 0) {
|
|
243
|
-
throw new Error("Cannot remove, list is empty.");
|
|
244
|
-
}
|
|
245
|
-
var list = state.slice(1);
|
|
246
|
-
return list;
|
|
247
|
-
}
|
|
248
|
-
case "ENTITY_LIST:REMOVE_LAST": {
|
|
249
|
-
if (state.length === 0) {
|
|
250
|
-
throw new Error("Cannot remove, list is empty.");
|
|
251
|
-
}
|
|
252
|
-
var list = __spreadArray([], state, true);
|
|
253
|
-
list.pop();
|
|
254
|
-
return list;
|
|
255
|
-
}
|
|
256
|
-
case "ENTITY_LIST:REMOVE_AT_INDEX": {
|
|
257
|
-
var index = action.index;
|
|
258
|
-
if (index < 0) {
|
|
259
|
-
throw new Error("Index is lower than 0.");
|
|
260
|
-
}
|
|
261
|
-
if (index >= state.length) {
|
|
262
|
-
throw new Error("Index is outside of list bounds.");
|
|
263
|
-
}
|
|
264
|
-
var list = __spreadArray([], state, true);
|
|
265
|
-
list.splice(index, 1);
|
|
266
|
-
return list;
|
|
267
|
-
}
|
|
268
|
-
case "ENTITY_LIST:REMOVE_BY_FIELD_MATCH": {
|
|
269
|
-
var fields_1 = action.fields;
|
|
270
|
-
return state.filter(function (item) { return !fieldsMatch(item, fields_1); });
|
|
271
|
-
}
|
|
272
|
-
case "ENTITY_LIST:REMOVE": {
|
|
273
|
-
var entity_1 = action.entity;
|
|
274
|
-
return state.filter(function (item) { return item !== entity_1; });
|
|
275
|
-
}
|
|
276
|
-
case "ENTITY_LIST:TOGGLE": {
|
|
277
|
-
var entity_2 = action.entity;
|
|
278
|
-
var index = state.findIndex(function (item) { return item === entity_2 || fieldsMatch(item, entity_2); });
|
|
279
|
-
if (index >= 0) {
|
|
280
|
-
var list = __spreadArray([], state, true);
|
|
281
|
-
list.splice(index, index);
|
|
282
|
-
return list;
|
|
283
|
-
}
|
|
284
|
-
else {
|
|
285
|
-
return __spreadArray(__spreadArray([], state, true), [entity_2], false);
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
case "ENTITY_LIST:ACTION_BY_FIELDS_MATCH": {
|
|
289
|
-
var fields_2 = action.fields, innerAction_1 = action.action;
|
|
290
|
-
if (!reducer) {
|
|
291
|
-
throw new Error("No reducer specified, unable to handle 'actionByFieldsMatch'.");
|
|
292
|
-
}
|
|
293
|
-
return state.map(function (item) {
|
|
294
|
-
return fieldsMatch(item, fields_2) ? reducer(item, innerAction_1) : item;
|
|
295
|
-
});
|
|
296
|
-
}
|
|
297
|
-
case "ENTITY_LIST:ACTION_BY_INDEX": {
|
|
298
|
-
var index_1 = action.index, innerAction_2 = action.action;
|
|
299
|
-
if (!reducer) {
|
|
300
|
-
throw new Error("No reducer specified, unable to handle 'actionByIndex'.");
|
|
301
|
-
}
|
|
302
|
-
return state.map(function (item, i) {
|
|
303
|
-
return index_1 === i ? reducer(item, innerAction_2) : item;
|
|
304
|
-
});
|
|
305
|
-
}
|
|
306
|
-
case "ENTITY_LIST:ACTION_ON_ALL": {
|
|
307
|
-
var innerAction_3 = action.action;
|
|
308
|
-
if (!reducer) {
|
|
309
|
-
throw new Error("No reducer specified, unable to handle 'actionByIndex'.");
|
|
310
|
-
}
|
|
311
|
-
return state.map(function (item) { return reducer(item, innerAction_3); });
|
|
312
|
-
}
|
|
313
|
-
default:
|
|
314
|
-
return state;
|
|
315
|
-
}
|
|
316
|
-
};
|
|
163
|
+
const fieldsMatch = (entity, fields) => {
|
|
164
|
+
const keys = Object.keys(fields);
|
|
165
|
+
if (keys.length === 0) {
|
|
166
|
+
return false;
|
|
167
|
+
}
|
|
168
|
+
for (let i = 0; i < keys.length; i++) {
|
|
169
|
+
const key = keys[i];
|
|
170
|
+
if (entity[key] !== fields[key]) {
|
|
171
|
+
return false;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
return true;
|
|
317
175
|
};
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
}
|
|
176
|
+
const createEntityListReducer = (reducer) => (state = [], action) => {
|
|
177
|
+
switch (action.type) {
|
|
178
|
+
case "ENTITY_LIST:SET_LIST": {
|
|
179
|
+
const { list } = action;
|
|
180
|
+
return list;
|
|
181
|
+
}
|
|
182
|
+
case "ENTITY_LIST:CLEAR_LIST": {
|
|
183
|
+
return [];
|
|
184
|
+
}
|
|
185
|
+
case "ENTITY_LIST:ADD_AT_END": {
|
|
186
|
+
const { entity } = action;
|
|
187
|
+
return [...state, entity];
|
|
188
|
+
}
|
|
189
|
+
case "ENTITY_LIST:ADD_AT_START": {
|
|
190
|
+
const { entity } = action;
|
|
191
|
+
return [entity, ...state];
|
|
192
|
+
}
|
|
193
|
+
case "ENTITY_LIST:REMOVE_FIRST": {
|
|
194
|
+
if (state.length === 0) {
|
|
195
|
+
throw new Error("Cannot remove, list is empty.");
|
|
196
|
+
}
|
|
197
|
+
const [, ...list] = state;
|
|
198
|
+
return list;
|
|
199
|
+
}
|
|
200
|
+
case "ENTITY_LIST:REMOVE_LAST": {
|
|
201
|
+
if (state.length === 0) {
|
|
202
|
+
throw new Error("Cannot remove, list is empty.");
|
|
203
|
+
}
|
|
204
|
+
const list = [...state];
|
|
205
|
+
list.pop();
|
|
206
|
+
return list;
|
|
207
|
+
}
|
|
208
|
+
case "ENTITY_LIST:REMOVE_AT_INDEX": {
|
|
209
|
+
const { index } = action;
|
|
210
|
+
if (index < 0) {
|
|
211
|
+
throw new Error("Index is lower than 0.");
|
|
212
|
+
}
|
|
213
|
+
if (index >= state.length) {
|
|
214
|
+
throw new Error("Index is outside of list bounds.");
|
|
215
|
+
}
|
|
216
|
+
const list = [...state];
|
|
217
|
+
list.splice(index, 1);
|
|
218
|
+
return list;
|
|
219
|
+
}
|
|
220
|
+
case "ENTITY_LIST:REMOVE_BY_FIELD_MATCH": {
|
|
221
|
+
const { fields } = action;
|
|
222
|
+
return state.filter((item) => !fieldsMatch(item, fields));
|
|
223
|
+
}
|
|
224
|
+
case "ENTITY_LIST:REMOVE": {
|
|
225
|
+
const { entity } = action;
|
|
226
|
+
return state.filter((item) => item !== entity);
|
|
227
|
+
}
|
|
228
|
+
case "ENTITY_LIST:TOGGLE": {
|
|
229
|
+
const { entity } = action;
|
|
230
|
+
const index = state.findIndex((item) => item === entity || fieldsMatch(item, entity));
|
|
231
|
+
if (index >= 0) {
|
|
232
|
+
const list = [...state];
|
|
233
|
+
list.splice(index, index);
|
|
234
|
+
return list;
|
|
235
|
+
} else {
|
|
236
|
+
return [...state, entity];
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
case "ENTITY_LIST:ACTION_BY_FIELDS_MATCH": {
|
|
240
|
+
const { fields, action: innerAction } = action;
|
|
241
|
+
if (!reducer) {
|
|
242
|
+
throw new Error("No reducer specified, unable to handle 'actionByFieldsMatch'.");
|
|
243
|
+
}
|
|
244
|
+
return state.map((item) => fieldsMatch(item, fields) ? reducer(item, innerAction) : item);
|
|
245
|
+
}
|
|
246
|
+
case "ENTITY_LIST:ACTION_BY_INDEX": {
|
|
247
|
+
const { index, action: innerAction } = action;
|
|
248
|
+
if (!reducer) {
|
|
249
|
+
throw new Error("No reducer specified, unable to handle 'actionByIndex'.");
|
|
250
|
+
}
|
|
251
|
+
return state.map((item, i) => index === i ? reducer(item, innerAction) : item);
|
|
252
|
+
}
|
|
253
|
+
case "ENTITY_LIST:ACTION_ON_ALL": {
|
|
254
|
+
const { action: innerAction } = action;
|
|
255
|
+
if (!reducer) {
|
|
256
|
+
throw new Error("No reducer specified, unable to handle 'actionByIndex'.");
|
|
257
|
+
}
|
|
258
|
+
return state.map((item) => reducer(item, innerAction));
|
|
259
|
+
}
|
|
260
|
+
default:
|
|
261
|
+
return state;
|
|
262
|
+
}
|
|
350
263
|
};
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
}
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
264
|
+
const createEntityListSelectors = (stateSelector) => ({
|
|
265
|
+
getList: (store) => stateSelector(store)
|
|
266
|
+
});
|
|
267
|
+
const entityByIdInitialState = { entities: {} };
|
|
268
|
+
const createEntityByIdReducer = () => {
|
|
269
|
+
return (state = entityByIdInitialState, action) => {
|
|
270
|
+
switch (action.type) {
|
|
271
|
+
case "ENTITY_BY_ID:SET_ENTITY": {
|
|
272
|
+
const { entity } = action;
|
|
273
|
+
return {
|
|
274
|
+
...state,
|
|
275
|
+
entities: {
|
|
276
|
+
...state.entities,
|
|
277
|
+
[entity.id]: entity
|
|
278
|
+
}
|
|
279
|
+
};
|
|
280
|
+
}
|
|
281
|
+
case "ENTITY_BY_ID:SET_ENTITY_FIELDS": {
|
|
282
|
+
const { id, fields } = action;
|
|
283
|
+
return {
|
|
284
|
+
...state,
|
|
285
|
+
entities: {
|
|
286
|
+
...state.entities,
|
|
287
|
+
[id]: {
|
|
288
|
+
...state.entities[id],
|
|
289
|
+
...fields
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
};
|
|
293
|
+
}
|
|
294
|
+
case "ENTITY_BY_ID:CLEAR_ALL_ENTITIES": {
|
|
295
|
+
return {
|
|
296
|
+
...state,
|
|
297
|
+
entities: {}
|
|
298
|
+
};
|
|
299
|
+
}
|
|
300
|
+
case "ENTITY_BY_ID:CLEAR_ENTITY": {
|
|
301
|
+
const { id } = action;
|
|
302
|
+
const entities = {
|
|
303
|
+
...state.entities
|
|
304
|
+
};
|
|
305
|
+
delete entities[id];
|
|
306
|
+
return {
|
|
307
|
+
...state,
|
|
308
|
+
entities
|
|
309
|
+
};
|
|
310
|
+
}
|
|
311
|
+
default:
|
|
312
|
+
return state;
|
|
313
|
+
}
|
|
314
|
+
};
|
|
392
315
|
};
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
316
|
+
const createEntityByIdActions = () => ({
|
|
317
|
+
setEntity: (entity) => ({
|
|
318
|
+
type: "ENTITY_BY_ID:SET_ENTITY",
|
|
319
|
+
entity
|
|
320
|
+
}),
|
|
321
|
+
setEntityFields: (id, fields) => ({
|
|
322
|
+
type: "ENTITY_BY_ID:SET_ENTITY_FIELDS",
|
|
323
|
+
id,
|
|
324
|
+
fields
|
|
325
|
+
}),
|
|
326
|
+
clearEntity: (id) => ({
|
|
327
|
+
type: "ENTITY_BY_ID:CLEAR_ENTITY",
|
|
328
|
+
id
|
|
329
|
+
}),
|
|
330
|
+
clearAllEntities: () => ({
|
|
331
|
+
type: "ENTITY_BY_ID:CLEAR_ALL_ENTITIES"
|
|
332
|
+
})
|
|
333
|
+
});
|
|
334
|
+
const createEntityByIdSelectors = (stateSelector) => ({
|
|
335
|
+
getState: stateSelector
|
|
336
|
+
});
|
|
337
|
+
const createEntityReducer = (initialEntity) => {
|
|
338
|
+
const INITIAL_STATE2 = initialEntity;
|
|
339
|
+
return (state = INITIAL_STATE2, action) => {
|
|
340
|
+
switch (action.type) {
|
|
341
|
+
case "ENTITY:SET_ENTITY": {
|
|
342
|
+
const { entity } = action;
|
|
343
|
+
return entity;
|
|
344
|
+
}
|
|
345
|
+
case "ENTITY:SET_ENTITY_FIELDS": {
|
|
346
|
+
const { fields } = action;
|
|
347
|
+
return {
|
|
348
|
+
...state,
|
|
349
|
+
...fields
|
|
350
|
+
};
|
|
351
|
+
}
|
|
352
|
+
default:
|
|
353
|
+
return state;
|
|
354
|
+
}
|
|
355
|
+
};
|
|
425
356
|
};
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
357
|
+
const createEntityActions = () => ({
|
|
358
|
+
setEntity: (entity) => ({
|
|
359
|
+
type: "ENTITY:SET_ENTITY",
|
|
360
|
+
entity
|
|
361
|
+
}),
|
|
362
|
+
setEntityFields: (fields) => ({
|
|
363
|
+
type: "ENTITY:SET_ENTITY_FIELDS",
|
|
364
|
+
fields
|
|
365
|
+
})
|
|
366
|
+
});
|
|
367
|
+
const createEntitySelectors = (stateSelector) => ({
|
|
368
|
+
getEntity: (state) => stateSelector(state)
|
|
369
|
+
});
|
|
370
|
+
const createEntityCrudStatusReducer = () => createEntityByIdReducer();
|
|
371
|
+
const createEntityCrudStatusActions = () => createEntityByIdActions();
|
|
372
|
+
const createEntityCrudStatusSelectors = (stateSelector) => createEntityByIdSelectors(stateSelector);
|
|
373
|
+
const createEntityCrudStatusRedux = (stateSelector) => {
|
|
374
|
+
const reducer = createEntityCrudStatusReducer();
|
|
375
|
+
const actions = createEntityCrudStatusActions();
|
|
376
|
+
const selectors = createEntityCrudStatusSelectors(stateSelector);
|
|
377
|
+
return {
|
|
378
|
+
reducer,
|
|
379
|
+
actions,
|
|
380
|
+
selectors
|
|
381
|
+
};
|
|
436
382
|
};
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
switch (action.type) {
|
|
447
|
-
case "EDITABLE_ENTITY:SET_ENTITY_ID": {
|
|
448
|
-
var id = action.id;
|
|
449
|
-
return __assign(__assign({}, state), { id: id });
|
|
450
|
-
}
|
|
451
|
-
case "EDITABLE_ENTITY:SET_ENTITY": {
|
|
452
|
-
var entity = action.entity;
|
|
453
|
-
return __assign(__assign({}, state), { persisted: entity, editable: entity });
|
|
454
|
-
}
|
|
455
|
-
case "EDITABLE_ENTITY:SET_PERSISTED_ENTITY": {
|
|
456
|
-
var entity = action.entity;
|
|
457
|
-
return __assign(__assign({}, state), { persisted: entity });
|
|
458
|
-
}
|
|
459
|
-
case "EDITABLE_ENTITY:SET_EDITABLE_ENTITY": {
|
|
460
|
-
var entity = action.entity;
|
|
461
|
-
return __assign(__assign({}, state), { editable: entity });
|
|
462
|
-
}
|
|
463
|
-
case "EDITABLE_ENTITY:SET_EDITABLE_ENTITY_FIELDS": {
|
|
464
|
-
var fields = action.fields;
|
|
465
|
-
return __assign(__assign({}, state), { editable: __assign(__assign({}, state.editable), fields) });
|
|
466
|
-
}
|
|
467
|
-
case "EDITABLE_ENTITY:REVERT_EDITABLE_ENTITY": {
|
|
468
|
-
return __assign(__assign({}, state), { editable: state.persisted });
|
|
469
|
-
}
|
|
470
|
-
case "EDITABLE_ENTITY:COMMIT_EDITABLE_ENTITY_TO_PERSISTED": {
|
|
471
|
-
return __assign(__assign({}, state), { persisted: state.editable });
|
|
472
|
-
}
|
|
473
|
-
default:
|
|
474
|
-
return state;
|
|
475
|
-
}
|
|
476
|
-
};
|
|
383
|
+
const createModifiedFieldRedux = (stateSelector) => {
|
|
384
|
+
const reducer = createEntityByIdReducer();
|
|
385
|
+
const selectors = createEntityByIdSelectors(stateSelector);
|
|
386
|
+
const actions = createEntityByIdActions();
|
|
387
|
+
return {
|
|
388
|
+
reducer,
|
|
389
|
+
selectors,
|
|
390
|
+
actions
|
|
391
|
+
};
|
|
477
392
|
};
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
}
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
var createSelectedIdsSelectors = function (stateSelector) { return ({
|
|
543
|
-
getState: stateSelector,
|
|
544
|
-
}); };
|
|
545
|
-
|
|
546
|
-
var INITIAL_STATE = {
|
|
547
|
-
ids: undefined,
|
|
548
|
-
};
|
|
549
|
-
var createSortOrderByIdReducer = function () {
|
|
550
|
-
return function (state, action) {
|
|
551
|
-
if (state === void 0) { state = INITIAL_STATE; }
|
|
552
|
-
switch (action.type) {
|
|
553
|
-
case "SORT_ORDER_BY_ID:SET_SORT_ORDER":
|
|
554
|
-
return __assign(__assign({}, state), { ids: action.ids });
|
|
555
|
-
case "SORT_ORDER_BY_ID:CLEAR_SORT_ORDER":
|
|
556
|
-
return __assign(__assign({}, state), { ids: undefined });
|
|
557
|
-
default:
|
|
558
|
-
return state;
|
|
559
|
-
}
|
|
560
|
-
};
|
|
561
|
-
};
|
|
562
|
-
var sortOrderByIdReducer = createSortOrderByIdReducer();
|
|
563
|
-
|
|
564
|
-
var createSortOrderByIdActions = function () {
|
|
565
|
-
return {
|
|
566
|
-
setSortOrder: function (ids) { return ({
|
|
567
|
-
ids: ids,
|
|
568
|
-
type: "SORT_ORDER_BY_ID:SET_SORT_ORDER",
|
|
569
|
-
}); },
|
|
570
|
-
clearSortOrder: function () { return ({
|
|
571
|
-
type: "SORT_ORDER_BY_ID:CLEAR_SORT_ORDER",
|
|
572
|
-
}); },
|
|
573
|
-
};
|
|
574
|
-
};
|
|
575
|
-
var sortOrderByIdActions = createSortOrderByIdActions();
|
|
576
|
-
|
|
577
|
-
var createSortOrderByIdSelectors = function (rootStateProvider) {
|
|
578
|
-
return {
|
|
579
|
-
getSortOrderByIdState: function (state) {
|
|
580
|
-
return rootStateProvider(state);
|
|
581
|
-
},
|
|
582
|
-
getSortOrder: function (state) {
|
|
583
|
-
return rootStateProvider(state).ids;
|
|
584
|
-
},
|
|
585
|
-
};
|
|
393
|
+
const createEditableEntityReducer = (initialEntity, initialId) => {
|
|
394
|
+
const initialState = {
|
|
395
|
+
id: initialId,
|
|
396
|
+
editable: initialEntity,
|
|
397
|
+
persisted: initialEntity
|
|
398
|
+
};
|
|
399
|
+
return (state = initialState, action) => {
|
|
400
|
+
switch (action.type) {
|
|
401
|
+
case "EDITABLE_ENTITY:SET_ENTITY_ID": {
|
|
402
|
+
const { id } = action;
|
|
403
|
+
return {
|
|
404
|
+
...state,
|
|
405
|
+
id
|
|
406
|
+
};
|
|
407
|
+
}
|
|
408
|
+
case "EDITABLE_ENTITY:SET_ENTITY": {
|
|
409
|
+
const { entity } = action;
|
|
410
|
+
return {
|
|
411
|
+
...state,
|
|
412
|
+
persisted: entity,
|
|
413
|
+
editable: entity
|
|
414
|
+
};
|
|
415
|
+
}
|
|
416
|
+
case "EDITABLE_ENTITY:SET_PERSISTED_ENTITY": {
|
|
417
|
+
const { entity } = action;
|
|
418
|
+
return {
|
|
419
|
+
...state,
|
|
420
|
+
persisted: entity
|
|
421
|
+
};
|
|
422
|
+
}
|
|
423
|
+
case "EDITABLE_ENTITY:SET_EDITABLE_ENTITY": {
|
|
424
|
+
const { entity } = action;
|
|
425
|
+
return {
|
|
426
|
+
...state,
|
|
427
|
+
editable: entity
|
|
428
|
+
};
|
|
429
|
+
}
|
|
430
|
+
case "EDITABLE_ENTITY:SET_EDITABLE_ENTITY_FIELDS": {
|
|
431
|
+
const { fields } = action;
|
|
432
|
+
return {
|
|
433
|
+
...state,
|
|
434
|
+
editable: {
|
|
435
|
+
...state.editable,
|
|
436
|
+
...fields
|
|
437
|
+
}
|
|
438
|
+
};
|
|
439
|
+
}
|
|
440
|
+
case "EDITABLE_ENTITY:REVERT_EDITABLE_ENTITY": {
|
|
441
|
+
return {
|
|
442
|
+
...state,
|
|
443
|
+
editable: state.persisted
|
|
444
|
+
};
|
|
445
|
+
}
|
|
446
|
+
case "EDITABLE_ENTITY:COMMIT_EDITABLE_ENTITY_TO_PERSISTED": {
|
|
447
|
+
return {
|
|
448
|
+
...state,
|
|
449
|
+
persisted: state.editable
|
|
450
|
+
};
|
|
451
|
+
}
|
|
452
|
+
default:
|
|
453
|
+
return state;
|
|
454
|
+
}
|
|
455
|
+
};
|
|
586
456
|
};
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
457
|
+
const createEditableEntityActions = () => ({
|
|
458
|
+
setEntityId: (id) => ({
|
|
459
|
+
type: "EDITABLE_ENTITY:SET_ENTITY_ID",
|
|
460
|
+
id
|
|
461
|
+
}),
|
|
462
|
+
setEntity: (entity) => ({ type: "EDITABLE_ENTITY:SET_ENTITY", entity }),
|
|
463
|
+
setPersistedEntity: (entity) => ({
|
|
464
|
+
type: "EDITABLE_ENTITY:SET_PERSISTED_ENTITY",
|
|
465
|
+
entity
|
|
466
|
+
}),
|
|
467
|
+
setEditableEntity: (entity) => ({
|
|
468
|
+
type: "EDITABLE_ENTITY:SET_EDITABLE_ENTITY",
|
|
469
|
+
entity
|
|
470
|
+
}),
|
|
471
|
+
setEditableEntityFields: (fields) => ({
|
|
472
|
+
type: "EDITABLE_ENTITY:SET_EDITABLE_ENTITY_FIELDS",
|
|
473
|
+
fields
|
|
474
|
+
}),
|
|
475
|
+
revertEditableEntity: () => ({
|
|
476
|
+
type: "EDITABLE_ENTITY:REVERT_EDITABLE_ENTITY"
|
|
477
|
+
}),
|
|
478
|
+
commitEditableEntityToPersisted: () => ({
|
|
479
|
+
type: "EDITABLE_ENTITY:COMMIT_EDITABLE_ENTITY_TO_PERSISTED"
|
|
480
|
+
})
|
|
481
|
+
});
|
|
482
|
+
const createSelectedIdsReducerInitialState = (initialSelection = []) => ({
|
|
483
|
+
selectedIds: initialSelection
|
|
484
|
+
});
|
|
485
|
+
const INITIAL_STATE$1 = createSelectedIdsReducerInitialState();
|
|
486
|
+
const createSelectedIdsReducer = (initialState = INITIAL_STATE$1) => (state = initialState, action) => {
|
|
487
|
+
switch (action.type) {
|
|
488
|
+
case "SELECTED_IDS:SET_SELECTED_IDS": {
|
|
489
|
+
const { selectedIds } = action;
|
|
490
|
+
return {
|
|
491
|
+
...state,
|
|
492
|
+
selectedIds
|
|
493
|
+
};
|
|
494
|
+
}
|
|
495
|
+
case "SELECTED_IDS:CLEAR_SELECTED_IDS": {
|
|
496
|
+
return {
|
|
497
|
+
...state,
|
|
498
|
+
selectedIds: []
|
|
499
|
+
};
|
|
500
|
+
}
|
|
501
|
+
default:
|
|
502
|
+
return state;
|
|
503
|
+
}
|
|
612
504
|
};
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
var valueByIdInitialState = { values: {} };
|
|
630
|
-
var createValueByIdReducer = function (initialValue) {
|
|
631
|
-
if (initialValue === void 0) { initialValue = valueByIdInitialState; }
|
|
632
|
-
return function (state, action) {
|
|
633
|
-
var _a;
|
|
634
|
-
if (state === void 0) { state = initialValue; }
|
|
635
|
-
switch (action.type) {
|
|
636
|
-
case "VALUE_BY_ID:SET_VALUE": {
|
|
637
|
-
var id = action.id, value = action.value;
|
|
638
|
-
return __assign(__assign({}, state), { values: __assign(__assign({}, state.values), (_a = {}, _a[id] = value, _a)) });
|
|
639
|
-
}
|
|
640
|
-
case "VALUE_BY_ID:CLEAR_ALL_VALUES": {
|
|
641
|
-
return __assign(__assign({}, state), { values: {} });
|
|
642
|
-
}
|
|
643
|
-
case "VALUE_BY_ID:CLEAR_VALUE": {
|
|
644
|
-
var id = action.id;
|
|
645
|
-
var values = __assign({}, state.values);
|
|
646
|
-
delete values[id];
|
|
647
|
-
return __assign(__assign({}, state), { values: values });
|
|
648
|
-
}
|
|
649
|
-
default:
|
|
650
|
-
return state;
|
|
651
|
-
}
|
|
652
|
-
};
|
|
505
|
+
const selectedIdsReducer = createSelectedIdsReducer();
|
|
506
|
+
const createSelectedIdsActions = () => ({
|
|
507
|
+
setSelectedIds: (selectedIds) => ({
|
|
508
|
+
selectedIds,
|
|
509
|
+
type: "SELECTED_IDS:SET_SELECTED_IDS"
|
|
510
|
+
}),
|
|
511
|
+
clearSelectedIds: () => ({
|
|
512
|
+
type: "SELECTED_IDS:CLEAR_SELECTED_IDS"
|
|
513
|
+
})
|
|
514
|
+
});
|
|
515
|
+
const selectedIdsActions = createSelectedIdsActions();
|
|
516
|
+
const createSelectedIdsSelectors = (stateSelector) => ({
|
|
517
|
+
getState: stateSelector
|
|
518
|
+
});
|
|
519
|
+
const INITIAL_STATE = {
|
|
520
|
+
ids: void 0
|
|
653
521
|
};
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
}
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
522
|
+
const createSortOrderByIdReducer = () => (state = INITIAL_STATE, action) => {
|
|
523
|
+
switch (action.type) {
|
|
524
|
+
case "SORT_ORDER_BY_ID:SET_SORT_ORDER":
|
|
525
|
+
return {
|
|
526
|
+
...state,
|
|
527
|
+
ids: action.ids
|
|
528
|
+
};
|
|
529
|
+
case "SORT_ORDER_BY_ID:CLEAR_SORT_ORDER":
|
|
530
|
+
return {
|
|
531
|
+
...state,
|
|
532
|
+
ids: void 0
|
|
533
|
+
};
|
|
534
|
+
default:
|
|
535
|
+
return state;
|
|
536
|
+
}
|
|
537
|
+
};
|
|
538
|
+
const sortOrderByIdReducer = createSortOrderByIdReducer();
|
|
539
|
+
const createSortOrderByIdActions = () => {
|
|
540
|
+
return {
|
|
541
|
+
setSortOrder: (ids) => ({
|
|
542
|
+
ids,
|
|
543
|
+
type: "SORT_ORDER_BY_ID:SET_SORT_ORDER"
|
|
544
|
+
}),
|
|
545
|
+
clearSortOrder: () => ({
|
|
546
|
+
type: "SORT_ORDER_BY_ID:CLEAR_SORT_ORDER"
|
|
547
|
+
})
|
|
548
|
+
};
|
|
549
|
+
};
|
|
550
|
+
const sortOrderByIdActions = createSortOrderByIdActions();
|
|
551
|
+
const createSortOrderByIdSelectors = (rootStateProvider) => {
|
|
552
|
+
return {
|
|
553
|
+
getSortOrderByIdState: (state) => {
|
|
554
|
+
return rootStateProvider(state);
|
|
555
|
+
},
|
|
556
|
+
getSortOrder: (state) => {
|
|
557
|
+
return rootStateProvider(state).ids;
|
|
558
|
+
}
|
|
559
|
+
};
|
|
560
|
+
};
|
|
561
|
+
const createSortOrderReducerInitialState = (sortBy = void 0, desc = false) => ({
|
|
562
|
+
sortBy,
|
|
563
|
+
desc
|
|
564
|
+
});
|
|
565
|
+
const createSortOrderReducer = (initialState = { sortBy: void 0, desc: false }) => (state = initialState, action) => {
|
|
566
|
+
switch (action.type) {
|
|
567
|
+
case "SORT_ORDER:SET_SORT_BY": {
|
|
568
|
+
const { sortBy, desc } = action;
|
|
569
|
+
return {
|
|
570
|
+
...state,
|
|
571
|
+
sortBy,
|
|
572
|
+
desc
|
|
573
|
+
};
|
|
574
|
+
}
|
|
575
|
+
case "SORT_ORDER:CLEAR_SORT_ORDER": {
|
|
576
|
+
return {
|
|
577
|
+
...state,
|
|
578
|
+
sortBy: void 0,
|
|
579
|
+
desc: false
|
|
580
|
+
};
|
|
581
|
+
}
|
|
582
|
+
default:
|
|
583
|
+
return state;
|
|
584
|
+
}
|
|
585
|
+
};
|
|
586
|
+
const createSortOrderActions = () => ({
|
|
587
|
+
sortBy: (sortBy, desc) => ({
|
|
588
|
+
desc,
|
|
589
|
+
sortBy,
|
|
590
|
+
type: "SORT_ORDER:SET_SORT_BY"
|
|
591
|
+
}),
|
|
592
|
+
clearSortOrder: () => ({
|
|
593
|
+
type: "SORT_ORDER:CLEAR_SORT_ORDER"
|
|
594
|
+
})
|
|
595
|
+
});
|
|
596
|
+
const createSortOrderSelectors = (stateProvider) => ({
|
|
597
|
+
getState: stateProvider
|
|
598
|
+
});
|
|
599
|
+
const valueByIdInitialState = { values: {} };
|
|
600
|
+
const createValueByIdReducer = (initialValue = valueByIdInitialState) => {
|
|
601
|
+
return (state = initialValue, action) => {
|
|
602
|
+
switch (action.type) {
|
|
603
|
+
case "VALUE_BY_ID:SET_VALUE": {
|
|
604
|
+
const { id, value } = action;
|
|
605
|
+
return {
|
|
606
|
+
...state,
|
|
607
|
+
values: {
|
|
608
|
+
...state.values,
|
|
609
|
+
[id]: value
|
|
610
|
+
}
|
|
611
|
+
};
|
|
612
|
+
}
|
|
613
|
+
case "VALUE_BY_ID:CLEAR_ALL_VALUES": {
|
|
614
|
+
return {
|
|
615
|
+
...state,
|
|
616
|
+
values: {}
|
|
617
|
+
};
|
|
618
|
+
}
|
|
619
|
+
case "VALUE_BY_ID:CLEAR_VALUE": {
|
|
620
|
+
const { id } = action;
|
|
621
|
+
const values = {
|
|
622
|
+
...state.values
|
|
623
|
+
};
|
|
624
|
+
delete values[id];
|
|
625
|
+
return {
|
|
626
|
+
...state,
|
|
627
|
+
values
|
|
628
|
+
};
|
|
629
|
+
}
|
|
630
|
+
default:
|
|
631
|
+
return state;
|
|
632
|
+
}
|
|
633
|
+
};
|
|
634
|
+
};
|
|
635
|
+
const createValueByIdActions = () => ({
|
|
636
|
+
setValue: (id, value) => ({
|
|
637
|
+
type: "VALUE_BY_ID:SET_VALUE",
|
|
638
|
+
id,
|
|
639
|
+
value
|
|
640
|
+
}),
|
|
641
|
+
clearValue: (id) => ({
|
|
642
|
+
type: "VALUE_BY_ID:CLEAR_VALUE",
|
|
643
|
+
id
|
|
644
|
+
}),
|
|
645
|
+
clearAllValues: () => ({
|
|
646
|
+
type: "VALUE_BY_ID:CLEAR_ALL_VALUES"
|
|
647
|
+
})
|
|
648
|
+
});
|
|
649
|
+
const createValueByIdSelectors = (stateSelector) => ({
|
|
650
|
+
getState: stateSelector
|
|
651
|
+
});
|
|
674
652
|
export { createCommitReducer, createCommitReducerActions, createCommitReducerSelectors, createEditableEntityActions, createEditableEntityReducer, createEntityActions, createEntityByIdActions, createEntityByIdReducer, createEntityByIdSelectors, createEntityCrudStatusActions, createEntityCrudStatusReducer, createEntityCrudStatusRedux, createEntityCrudStatusSelectors, createEntityListActions, createEntityListReducer, createEntityListSelectors, createEntityReducer, createEntitySelectors, createModifiedFieldRedux, createRecordObjectActions, createRecordObjectReducer, createSelectedIdsActions, createSelectedIdsReducer, createSelectedIdsReducerInitialState, createSelectedIdsSelectors, createSortOrderActions, createSortOrderByIdActions, createSortOrderByIdReducer, createSortOrderByIdSelectors, createSortOrderReducer, createSortOrderReducerInitialState, createSortOrderSelectors, createValueByIdActions, createValueByIdReducer, createValueByIdSelectors, entityByIdInitialState, reducerIdGate, reducerIdGateAction, selectedIdsActions, selectedIdsReducer, sortOrderByIdActions, sortOrderByIdReducer, valueByIdInitialState, wrapActionWithReducerIdGate, wrapActionsWithReducerIdGate };
|
|
675
653
|
//# sourceMappingURL=index.es.js.map
|