redux-clerk2 2.0.9 → 2.0.14
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/lib/actions/Fetch.js +5 -5
- package/lib/reducers/fetch.js +7 -3
- package/lib/reducers/perform.js +7 -1
- package/package.json +1 -1
- package/src/actions/Fetch.js +5 -5
- package/src/reducers/fetch.js +6 -2
- package/src/reducers/perform.js +7 -1
- package/CHANGELOG.md +0 -79
package/lib/actions/Fetch.js
CHANGED
|
@@ -76,7 +76,7 @@ var Fetch = exports.Fetch = function (_BaseAction) {
|
|
|
76
76
|
normalizationSettings = _this$config.normalizationSettings;
|
|
77
77
|
|
|
78
78
|
|
|
79
|
-
var data = { instance: instance, uidField: uidField, options: options, normalizationSettings: normalizationSettings };
|
|
79
|
+
var data = { instance: instance, uidField: uidField, options: options, normalizationSettings: normalizationSettings, params: params };
|
|
80
80
|
var msguid = uuidv1();
|
|
81
81
|
|
|
82
82
|
// Call BaseAction.start with dispatch
|
|
@@ -147,11 +147,11 @@ var Fetch = exports.Fetch = function (_BaseAction) {
|
|
|
147
147
|
}
|
|
148
148
|
|
|
149
149
|
var parameters = _extends({
|
|
150
|
-
page: params.page || 1,
|
|
151
|
-
query: params.query || undefined,
|
|
152
|
-
order: params.order || undefined,
|
|
150
|
+
page: params && params.page || 1,
|
|
151
|
+
query: params && params.query || undefined,
|
|
152
|
+
order: params && params.order || undefined,
|
|
153
153
|
sort: sort_order || undefined,
|
|
154
|
-
limit: params.limit || 10
|
|
154
|
+
limit: params && params.limit || 10
|
|
155
155
|
}, additionalData.filters);
|
|
156
156
|
apiparams = _pickBy(parameters, _identity);
|
|
157
157
|
|
package/lib/reducers/fetch.js
CHANGED
|
@@ -33,6 +33,7 @@ var uniqEs6 = function uniqEs6(arrArg) {
|
|
|
33
33
|
* @return {Immutable.Map} - updated state
|
|
34
34
|
*/
|
|
35
35
|
var start = exports.start = function start(state, action) {
|
|
36
|
+
var params = action.params;
|
|
36
37
|
return state.withMutations(function (map) {
|
|
37
38
|
|
|
38
39
|
// Add additional data if provided
|
|
@@ -41,7 +42,8 @@ var start = exports.start = function start(state, action) {
|
|
|
41
42
|
map.mergeIn(['instances', action.instance, 'additionalData'], _immutable2.default.fromJS(_extends({}, action.additionalData, {
|
|
42
43
|
error: false,
|
|
43
44
|
errorMessage: null,
|
|
44
|
-
isFetching: true
|
|
45
|
+
isFetching: !params || params._id === undefined ? true : false,
|
|
46
|
+
isFetchingSingle: params && params._id !== undefined ? true : false
|
|
45
47
|
})));
|
|
46
48
|
//}
|
|
47
49
|
});
|
|
@@ -103,7 +105,8 @@ var success = exports.success = function success(state, action) {
|
|
|
103
105
|
map.mergeIn(['instances', action.instance, 'additionalData'], _immutable2.default.fromJS(_extends({}, action.additionalData, {
|
|
104
106
|
error: false,
|
|
105
107
|
errorMessage: null,
|
|
106
|
-
isFetching: false
|
|
108
|
+
isFetching: false,
|
|
109
|
+
isFetchingSingle: false
|
|
107
110
|
//...(action.options && action.options.recalcTotal) && { total: instanceTotal.size },
|
|
108
111
|
})));
|
|
109
112
|
//}
|
|
@@ -126,7 +129,8 @@ var error = exports.error = function error(state, action) {
|
|
|
126
129
|
map.mergeIn(['instances', action.instance, 'additionalData'], _immutable2.default.fromJS(_extends({}, action.additionalData, {
|
|
127
130
|
error: true,
|
|
128
131
|
errorMessage: action.responseData,
|
|
129
|
-
isFetching: false
|
|
132
|
+
isFetching: false,
|
|
133
|
+
isFetchingSingle: false
|
|
130
134
|
})));
|
|
131
135
|
//}
|
|
132
136
|
});
|
package/lib/reducers/perform.js
CHANGED
|
@@ -86,7 +86,13 @@ var success = exports.success = function success(state, action) {
|
|
|
86
86
|
map.set('raw', state.get('raw').merge(newRecord));
|
|
87
87
|
|
|
88
88
|
// Add new record to instance array using permanent uid
|
|
89
|
-
map.
|
|
89
|
+
var instanceData = map.getIn(['instances', action.instance, 'data'], (0, _immutable.List)());
|
|
90
|
+
// Check if key already present in instance
|
|
91
|
+
if (!(instanceData.indexOf(uid) !== -1)) {
|
|
92
|
+
map.setIn(['instances', action.instance, 'data'], instanceData.push(uid));
|
|
93
|
+
}
|
|
94
|
+
// OLD method
|
|
95
|
+
//map.setIn(['instances', action.instance, 'data'], map.getIn(['instances', action.instance, 'data']).push(uid));
|
|
90
96
|
|
|
91
97
|
// UPDATE TOTAL COUNT FOR THIS INSTANCE
|
|
92
98
|
map.setIn(['instances', action.instance, 'additionalData', 'total'], map.getIn(['instances', action.instance, 'additionalData', 'total']) + 1);
|
package/package.json
CHANGED
package/src/actions/Fetch.js
CHANGED
|
@@ -55,7 +55,7 @@ export class Fetch extends BaseAction {
|
|
|
55
55
|
// Create data object to be dispatched with actions
|
|
56
56
|
const { uidField, actionSettings, api, notificationActions, normalizationSettings } = this.config;
|
|
57
57
|
|
|
58
|
-
const data = { instance, uidField, options, normalizationSettings };
|
|
58
|
+
const data = { instance, uidField, options, normalizationSettings, params };
|
|
59
59
|
const msguid = uuidv1();
|
|
60
60
|
|
|
61
61
|
// Call BaseAction.start with dispatch
|
|
@@ -124,11 +124,11 @@ export class Fetch extends BaseAction {
|
|
|
124
124
|
}
|
|
125
125
|
|
|
126
126
|
const parameters = {
|
|
127
|
-
page: params.page || 1
|
|
128
|
-
,query: params.query || undefined
|
|
129
|
-
,order: params.order || undefined
|
|
127
|
+
page: params && params.page || 1
|
|
128
|
+
,query: params && params.query || undefined
|
|
129
|
+
,order: params && params.order || undefined
|
|
130
130
|
,sort: sort_order || undefined
|
|
131
|
-
,limit: params.limit || 10
|
|
131
|
+
,limit: params && params.limit || 10
|
|
132
132
|
,...additionalData.filters
|
|
133
133
|
}
|
|
134
134
|
apiparams = _pickBy(parameters, _identity);
|
package/src/reducers/fetch.js
CHANGED
|
@@ -16,6 +16,7 @@ const uniqEs6 = (arrArg) => {
|
|
|
16
16
|
* @return {Immutable.Map} - updated state
|
|
17
17
|
*/
|
|
18
18
|
export const start = (state, action) => {
|
|
19
|
+
const params = action.params;
|
|
19
20
|
return state.withMutations(map => {
|
|
20
21
|
|
|
21
22
|
// Add additional data if provided
|
|
@@ -24,7 +25,8 @@ export const start = (state, action) => {
|
|
|
24
25
|
map.mergeIn(['instances', action.instance, 'additionalData'], Immutable.fromJS(Object.assign({}, action.additionalData, {
|
|
25
26
|
error: false,
|
|
26
27
|
errorMessage: null,
|
|
27
|
-
isFetching: true
|
|
28
|
+
isFetching: !params || params._id === undefined ? true : false,
|
|
29
|
+
isFetchingSingle: params && params._id !== undefined ? true : false,
|
|
28
30
|
})));
|
|
29
31
|
//}
|
|
30
32
|
})
|
|
@@ -85,6 +87,7 @@ export const success = (state, action) => {
|
|
|
85
87
|
error: false,
|
|
86
88
|
errorMessage: null,
|
|
87
89
|
isFetching: false,
|
|
90
|
+
isFetchingSingle: false,
|
|
88
91
|
//...(action.options && action.options.recalcTotal) && { total: instanceTotal.size },
|
|
89
92
|
})));
|
|
90
93
|
//}
|
|
@@ -107,7 +110,8 @@ export const error = (state, action) => {
|
|
|
107
110
|
map.mergeIn(['instances', action.instance, 'additionalData'], Immutable.fromJS(Object.assign({}, action.additionalData, {
|
|
108
111
|
error: true,
|
|
109
112
|
errorMessage: action.responseData,
|
|
110
|
-
isFetching: false
|
|
113
|
+
isFetching: false,
|
|
114
|
+
isFetchingSingle: false,
|
|
111
115
|
})));
|
|
112
116
|
//}
|
|
113
117
|
})
|
package/src/reducers/perform.js
CHANGED
|
@@ -73,7 +73,13 @@ export const start = (state, action) => {
|
|
|
73
73
|
map.set('raw', state.get('raw').merge(newRecord))
|
|
74
74
|
|
|
75
75
|
// Add new record to instance array using permanent uid
|
|
76
|
-
|
|
76
|
+
const instanceData = map.getIn(['instances', action.instance, 'data'], List());
|
|
77
|
+
// Check if key already present in instance
|
|
78
|
+
if(!instanceData.includes(uid)){
|
|
79
|
+
map.setIn(['instances', action.instance, 'data'], instanceData.push(uid));
|
|
80
|
+
}
|
|
81
|
+
// OLD method
|
|
82
|
+
//map.setIn(['instances', action.instance, 'data'], map.getIn(['instances', action.instance, 'data']).push(uid));
|
|
77
83
|
|
|
78
84
|
// UPDATE TOTAL COUNT FOR THIS INSTANCE
|
|
79
85
|
map.setIn(['instances', action.instance, 'additionalData', 'total'], map.getIn(['instances', action.instance, 'additionalData', 'total']) + 1 );
|
package/CHANGELOG.md
DELETED
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
## 1.0.0
|
|
2
|
-
###### _August 10, 2017_
|
|
3
|
-
|
|
4
|
-
- Convert responseData to Immutable data structure before adding to store ([#51](https://github.com/GetAmbassador/redux-clerk/pull/51))
|
|
5
|
-
|
|
6
|
-
## 1.0.0-rc.4
|
|
7
|
-
###### _May 2, 2017_
|
|
8
|
-
|
|
9
|
-
- Accept responseData in handleSuccess for the update action ([#48](https://github.com/GetAmbassador/redux-clerk/pull/48))
|
|
10
|
-
- Update docs to reflect optional optimism ([#47](https://github.com/GetAmbassador/redux-clerk/pull/47))
|
|
11
|
-
|
|
12
|
-
## 1.0.0-rc.3
|
|
13
|
-
###### _April 10, 2017_
|
|
14
|
-
|
|
15
|
-
- Cast all raw ids to strings ([#44](https://github.com/GetAmbassador/redux-clerk/pull/44))
|
|
16
|
-
- Update selectors to handle optional optimism ([#43](https://github.com/GetAmbassador/redux-clerk/pull/43))
|
|
17
|
-
- Make optimistic updates optional ([#41](https://github.com/GetAmbassador/redux-clerk/pull/41))
|
|
18
|
-
|
|
19
|
-
## 1.0.0-rc.2
|
|
20
|
-
###### _March 23, 2017_
|
|
21
|
-
|
|
22
|
-
- Added pre action hooks ([#38](https://github.com/GetAmbassador/redux-clerk/pull/38))
|
|
23
|
-
|
|
24
|
-
## 1.0.0-rc.1
|
|
25
|
-
###### _March 22, 2017_
|
|
26
|
-
|
|
27
|
-
- Added post action hooks ([#36](https://github.com/GetAmbassador/redux-clerk/pull/36))
|
|
28
|
-
- Rename delete action to remove to avoid reserved word conflicts ([#35](https://github.com/GetAmbassador/redux-clerk/pull/35))
|
|
29
|
-
|
|
30
|
-
## 0.3.0
|
|
31
|
-
###### _March 15, 2017_
|
|
32
|
-
|
|
33
|
-
- Fetch response will now deep merge response data into raw data ([#33](https://github.com/GetAmbassador/redux-clerk/pull/33))
|
|
34
|
-
|
|
35
|
-
## 0.2.8
|
|
36
|
-
###### _February 21, 2017_
|
|
37
|
-
|
|
38
|
-
- Cast uid to int in record selector ([#31](https://github.com/GetAmbassador/redux-clerk/pull/31))
|
|
39
|
-
|
|
40
|
-
## 0.2.7
|
|
41
|
-
###### _February 16, 2017_
|
|
42
|
-
|
|
43
|
-
- Added the get selector ([#29](https://github.com/GetAmbassador/redux-clerk/pull/29))
|
|
44
|
-
|
|
45
|
-
## 0.2.6
|
|
46
|
-
###### _January 11, 2017_
|
|
47
|
-
|
|
48
|
-
- Added the datasetProperty selector ([#27](https://github.com/GetAmbassador/redux-clerk/pull/27))
|
|
49
|
-
|
|
50
|
-
## 0.2.5
|
|
51
|
-
###### _January 3, 2017_
|
|
52
|
-
|
|
53
|
-
- Return Map instead of List for empty dataset ([#25](https://github.com/GetAmbassador/redux-clerk/pull/25))
|
|
54
|
-
- Ensure data is properly converted between actions and reducers ([#24](https://github.com/GetAmbassador/redux-clerk/pull/24))
|
|
55
|
-
|
|
56
|
-
## 0.2.4
|
|
57
|
-
###### _December 15, 2016_
|
|
58
|
-
|
|
59
|
-
- uidField option has been removed for the reducer (it is not longer needed) ([#22](https://github.com/GetAmbassador/redux-clerk/pull/22))
|
|
60
|
-
|
|
61
|
-
## 0.2.3
|
|
62
|
-
###### _December 14, 2016_
|
|
63
|
-
|
|
64
|
-
- Records are now added while updating if not already in state ([#20](https://github.com/GetAmbassador/redux-clerk/pull/20))
|
|
65
|
-
|
|
66
|
-
## 0.2.2
|
|
67
|
-
###### _December 13, 2016_
|
|
68
|
-
|
|
69
|
-
- Added the ability to return fetch response as an object or array ([#18](https://github.com/GetAmbassador/redux-clerk/pull/18))
|
|
70
|
-
|
|
71
|
-
## 0.2.1
|
|
72
|
-
###### _December 7, 2016_
|
|
73
|
-
|
|
74
|
-
- Added the ability to pass additional data with fetch, create and delete actions ([#16](https://github.com/GetAmbassador/redux-clerk/pull/16))
|
|
75
|
-
|
|
76
|
-
## 0.2.0
|
|
77
|
-
###### _December 5, 2016_
|
|
78
|
-
|
|
79
|
-
- Initial Release
|