redux-clerk2 2.0.12 → 2.0.17
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/Create.js +13 -13
- package/lib/actions/Fetch.js +4 -4
- package/lib/actions/Perform.js +202 -200
- package/lib/reducers/bulk.js +6 -2
- package/lib/reducers/create.js +6 -2
- package/lib/reducers/perform.js +10 -2
- package/lib/reducers/remove.js +3 -1
- package/lib/reducers/update.js +6 -2
- package/package.json +1 -1
- package/src/actions/Create.js +34 -80
- package/src/actions/Fetch.js +4 -4
- package/src/actions/Perform.js +22 -20
- package/src/actions/Update.js +1 -1
- package/src/reducers/bulk.js +4 -0
- package/src/reducers/create.js +5 -1
- package/src/reducers/perform.js +9 -1
- package/src/reducers/remove.js +3 -1
- package/src/reducers/update.js +6 -2
- package/CHANGELOG.md +0 -79
package/lib/actions/Create.js
CHANGED
|
@@ -137,21 +137,20 @@ var Create = exports.Create = function (_BaseAction) {
|
|
|
137
137
|
|
|
138
138
|
if (response.data.success) {
|
|
139
139
|
successHandler(response.data.data || [], null, response.data.updates || []);
|
|
140
|
-
|
|
141
140
|
message = response.data.message;
|
|
142
141
|
|
|
143
142
|
if (settings.notification !== undefined) {
|
|
144
|
-
if (settings.notification.type !== undefined && settings.notification.type ===
|
|
143
|
+
if (settings.notification.type !== undefined && settings.notification.type === 'notification') {
|
|
145
144
|
dispatch(notify({
|
|
146
145
|
title: settings.notification.title,
|
|
147
146
|
message: settings.notification.message !== undefined ? settings.notification.message : message,
|
|
148
|
-
type:
|
|
149
|
-
kind: settings.notification.kind !== undefined ? settings.notification.kind :
|
|
147
|
+
type: 'notification',
|
|
148
|
+
kind: settings.notification.kind !== undefined ? settings.notification.kind : 'success'
|
|
150
149
|
}));
|
|
151
150
|
} else {
|
|
152
151
|
dispatch(notify({
|
|
153
152
|
title: settings.notification.title !== undefined ? settings.notification.title : message, //response.data.message,
|
|
154
|
-
kind: settings.notification.kind !== undefined ? settings.notification.kind :
|
|
153
|
+
kind: settings.notification.kind !== undefined ? settings.notification.kind : 'success'
|
|
155
154
|
}));
|
|
156
155
|
}
|
|
157
156
|
}
|
|
@@ -162,8 +161,8 @@ var Create = exports.Create = function (_BaseAction) {
|
|
|
162
161
|
dispatch(notify({
|
|
163
162
|
title: settings.error.title,
|
|
164
163
|
message: message || settings.error.message,
|
|
165
|
-
type:
|
|
166
|
-
kind: settings.error.kind !== undefined ? settings.error.kind :
|
|
164
|
+
type: 'notification',
|
|
165
|
+
kind: settings.error.kind !== undefined ? settings.error.kind : 'error'
|
|
167
166
|
}));
|
|
168
167
|
}
|
|
169
168
|
return response.data;
|
|
@@ -174,17 +173,18 @@ var Create = exports.Create = function (_BaseAction) {
|
|
|
174
173
|
errorHandler(error);
|
|
175
174
|
|
|
176
175
|
if (error && error.response && error.response.status && error.response.status !== 401) {
|
|
177
|
-
|
|
176
|
+
|
|
177
|
+
if (settings.error.type !== undefined && settings.error.type === 'notification') {
|
|
178
178
|
dispatch(notify({
|
|
179
179
|
title: settings.error.title,
|
|
180
|
-
message: settings.error.message !== undefined ? settings.error.message :
|
|
181
|
-
type:
|
|
182
|
-
kind: settings.error.kind !== undefined ? settings.error.kind :
|
|
180
|
+
message: error.response.data.message ? error.response.data.message : settings.error.message !== undefined ? settings.error.message : '',
|
|
181
|
+
type: 'notification',
|
|
182
|
+
kind: settings.error.kind !== undefined ? settings.error.kind : 'error'
|
|
183
183
|
}));
|
|
184
184
|
} else {
|
|
185
185
|
dispatch(notify({
|
|
186
|
-
title: settings.error.title !== undefined ? settings.error.title :
|
|
187
|
-
kind: settings.error.kind !== undefined ? settings.error.kind :
|
|
186
|
+
title: error.response.data.message ? error.response.data.message : settings.error.title !== undefined ? settings.error.title : '',
|
|
187
|
+
kind: settings.error.kind !== undefined ? settings.error.kind : 'error'
|
|
188
188
|
}));
|
|
189
189
|
}
|
|
190
190
|
}
|
package/lib/actions/Fetch.js
CHANGED
|
@@ -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/actions/Perform.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
|
|
4
|
+
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.Perform = undefined;
|
|
7
7
|
|
|
@@ -31,205 +31,207 @@ var uuidv1 = require('uuid/v1');
|
|
|
31
31
|
*/
|
|
32
32
|
|
|
33
33
|
var Perform = exports.Perform = function (_BaseAction) {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
34
|
+
_inherits(Perform, _BaseAction);
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Create an instance of the bulk action.
|
|
38
|
+
* @param {Object} config - The configuration for the action.
|
|
39
|
+
*/
|
|
40
|
+
function Perform(config) {
|
|
41
|
+
_classCallCheck(this, Perform);
|
|
42
|
+
|
|
43
|
+
var _this = _possibleConstructorReturn(this, (Perform.__proto__ || Object.getPrototypeOf(Perform)).call(this, 'perform', config));
|
|
44
|
+
|
|
45
|
+
_this.do = function (instance, record) {
|
|
46
|
+
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
47
|
+
var _this$config = _this.config,
|
|
48
|
+
uidField = _this$config.uidField,
|
|
49
|
+
performer = _this$config.performer,
|
|
50
|
+
actionSettings = _this$config.actionSettings,
|
|
51
|
+
api = _this$config.api,
|
|
52
|
+
notificationActions = _this$config.notificationActions,
|
|
53
|
+
normalizationSettings = _this$config.normalizationSettings;
|
|
54
|
+
|
|
55
|
+
//console.log('actionSettings', actionSettings);
|
|
56
|
+
//console.log('api', api);
|
|
57
|
+
//console.log('notificationAction', notificationAction);
|
|
58
|
+
|
|
59
|
+
// Extend fetch options
|
|
60
|
+
|
|
61
|
+
options = _extends({}, _this.defaultOptions, options);
|
|
62
|
+
|
|
63
|
+
// Make sure record is an immutable map
|
|
64
|
+
record = _immutable2.default.Iterable.isIterable(record) ? record : _immutable2.default.fromJS(record);
|
|
65
|
+
|
|
66
|
+
// Validate instance key
|
|
67
|
+
_this.validateInstance(instance);
|
|
68
|
+
|
|
69
|
+
/*if(List.isList(record)){
|
|
70
|
+
// ADD uids to new items
|
|
71
|
+
record = record.map(item =>
|
|
72
|
+
item.get(uidField) === undefined ? item.set("tmpid", uuidv1()) : item
|
|
73
|
+
);
|
|
74
|
+
}else{
|
|
75
|
+
record.get(uidField) === undefined ? record.set("tmpid", uuidv1()) : record
|
|
76
|
+
}*/
|
|
77
|
+
|
|
78
|
+
return function (dispatch) {
|
|
79
|
+
|
|
80
|
+
// Create data object to be dispatched with actions
|
|
81
|
+
var isAsync = options.isAsync !== undefined ? options.isAsync : typeof performer === 'function' || actionSettings !== undefined;
|
|
82
|
+
var data = { instance: instance, record: record, uidField: uidField, isAsync: isAsync, options: options, normalizationSettings: normalizationSettings };
|
|
83
|
+
var msguid = uuidv1();
|
|
84
|
+
|
|
85
|
+
// Call BaseAction.start with dispatch and the action data
|
|
86
|
+
_this.start(dispatch, data);
|
|
87
|
+
|
|
88
|
+
//console.log('action bulk:', data);
|
|
89
|
+
|
|
90
|
+
if (actionSettings !== undefined && isAsync) {
|
|
91
|
+
var notify = notificationActions.notify,
|
|
92
|
+
notifyDismiss = notificationActions.notifyDismiss;
|
|
93
|
+
// Extend config options
|
|
94
|
+
|
|
95
|
+
var settings = _extends({}, actionSettings.default, actionSettings.performer);
|
|
96
|
+
//console.log(settings);
|
|
97
|
+
var displayLoading = settings.loading !== undefined && settings.loading !== '' ? true : false;
|
|
98
|
+
var displayNotification = settings.notification !== undefined && settings.notification.type === 'notification' ? true : false;
|
|
99
|
+
var displayMessage = settings.notification !== undefined && !displayNotification ? true : false;
|
|
100
|
+
|
|
101
|
+
if (displayLoading) {
|
|
102
|
+
dispatch(notify({
|
|
103
|
+
id: msguid,
|
|
104
|
+
title: settings.loading !== undefined ? settings.loading : 'Please wait',
|
|
105
|
+
kind: 'loading'
|
|
106
|
+
}));
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
//console.log('auto performer action');
|
|
110
|
+
var successHandler = _this.success.bind(_this, dispatch, data);
|
|
111
|
+
var errorHandler = _this.error.bind(_this, dispatch, data);
|
|
112
|
+
|
|
113
|
+
var url = settings.url;
|
|
114
|
+
|
|
115
|
+
var activeProperty = localStorage.activeProperty !== undefined && localStorage.activeProperty !== 'undefined' ? JSON.parse(localStorage.activeProperty) : null;
|
|
116
|
+
var propertycode = activeProperty !== null ? activeProperty.propertycode : null;
|
|
117
|
+
|
|
118
|
+
if (options && options.property_id) {
|
|
119
|
+
var properties = localStorage.properties !== undefined && localStorage.properties !== 'undefined' ? JSON.parse(localStorage.properties) : [];
|
|
120
|
+
var overrideProperty = properties.find(function (property) {
|
|
121
|
+
return property.id === options.property_id;
|
|
122
|
+
});
|
|
123
|
+
if (overrideProperty && overrideProperty.propertycode) {
|
|
124
|
+
propertycode = overrideProperty.propertycode;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
if (propertycode !== null) {
|
|
129
|
+
url = settings.url.replace(/#@propertycode@#/i, propertycode);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
//console.log(`options`, options);
|
|
133
|
+
|
|
134
|
+
if (options.url) {
|
|
135
|
+
url = url + '/' + options.url;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
//return api.put(url, record.toJSON())
|
|
139
|
+
return api({ method: options.method || 'get', url: url, data: record.toJSON() }).then(function (response) {
|
|
140
|
+
if (displayLoading) {
|
|
141
|
+
dispatch(notifyDismiss(msguid));
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
var message = '';
|
|
145
|
+
|
|
146
|
+
if (response.data.success) {
|
|
147
|
+
successHandler(response.data.data || [], null, response.data.updates || []);
|
|
148
|
+
message = response.data.message;
|
|
149
|
+
|
|
150
|
+
if (settings.notification !== undefined) {
|
|
151
|
+
if (settings.notification.type !== undefined && settings.notification.type === 'notification') {
|
|
152
|
+
dispatch(notify({
|
|
153
|
+
title: settings.notification.title,
|
|
154
|
+
message: settings.notification.message !== undefined ? settings.notification.message : message,
|
|
155
|
+
type: 'notification',
|
|
156
|
+
kind: settings.notification.kind !== undefined ? settings.notification.kind : 'success'
|
|
157
|
+
}));
|
|
158
|
+
} else {
|
|
159
|
+
dispatch(notify({
|
|
160
|
+
title: settings.notification.title !== undefined ? settings.notification.title : message, //response.data.message,
|
|
161
|
+
kind: settings.notification.kind !== undefined ? settings.notification.kind : 'success'
|
|
162
|
+
}));
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
} else {
|
|
166
|
+
errorHandler(response.data.error);
|
|
167
|
+
message = response.data.error.message !== undefined ? response.data.error.message : response.data.error;
|
|
168
|
+
|
|
169
|
+
dispatch(notify({
|
|
170
|
+
title: settings.error.title,
|
|
171
|
+
message: message || settings.error.message,
|
|
172
|
+
type: 'notification',
|
|
173
|
+
kind: settings.error.kind !== undefined ? settings.error.kind : 'error'
|
|
174
|
+
}));
|
|
175
|
+
}
|
|
176
|
+
return response.data;
|
|
177
|
+
}).catch(function (error) {
|
|
178
|
+
if (displayLoading) {
|
|
179
|
+
dispatch(notifyDismiss(msguid));
|
|
180
|
+
}
|
|
181
|
+
errorHandler(error);
|
|
182
|
+
|
|
183
|
+
if (error && error.response && error.response.status && error.response.status !== 401) {
|
|
184
|
+
|
|
185
|
+
if (settings.error.type !== undefined && settings.error.type === 'notification') {
|
|
186
|
+
dispatch(notify({
|
|
187
|
+
title: settings.error.title,
|
|
188
|
+
message: error.response.data.message ? error.response.data.message : settings.error.message !== undefined ? settings.error.message : '',
|
|
189
|
+
type: 'notification',
|
|
190
|
+
kind: settings.error.kind !== undefined ? settings.error.kind : 'error'
|
|
191
|
+
}));
|
|
192
|
+
} else {
|
|
193
|
+
dispatch(notify({
|
|
194
|
+
title: error.response.data.message ? error.response.data.message : settings.error.title !== undefined ? settings.error.title : '',
|
|
195
|
+
kind: settings.error.kind !== undefined ? settings.error.kind : 'error'
|
|
196
|
+
}));
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
} else {
|
|
201
|
+
// If config.performer is provided, call it
|
|
202
|
+
//if(isAsync) {
|
|
203
|
+
// Prepare BaseAction.success and BaseAction.error handlers
|
|
204
|
+
// by currying with dispatch
|
|
205
|
+
var success = _this.success.bind(_this, dispatch, data);
|
|
206
|
+
var error = _this.error.bind(_this, dispatch, data);
|
|
207
|
+
return success(record || []);
|
|
208
|
+
// Call performer
|
|
209
|
+
//return performer(record, success, error);
|
|
210
|
+
//}
|
|
211
|
+
}
|
|
212
|
+
};
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
return _this;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* Default options for the fetch action.
|
|
220
|
+
*/
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* Generate an action creator with the provided data.
|
|
225
|
+
* @param {Object} record - item being updated.
|
|
226
|
+
*
|
|
227
|
+
* @returns {Function} - Returns the perform action thunk.
|
|
228
|
+
*/
|
|
229
|
+
|
|
230
|
+
|
|
231
|
+
return Perform;
|
|
230
232
|
}(_BaseAction3.default);
|
|
231
233
|
|
|
232
234
|
Perform.defaultOptions = {
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
235
|
+
appendResponse: true,
|
|
236
|
+
normalizeResponse: false,
|
|
237
|
+
property_id: null };
|
package/lib/reducers/bulk.js
CHANGED
|
@@ -95,7 +95,9 @@ var start = exports.start = function start(state, action) {
|
|
|
95
95
|
state = state.mergeIn(['instances', action.instance, 'additionalData'], _immutable2.default.fromJS(_extends({}, action.additionalData, {
|
|
96
96
|
error: false,
|
|
97
97
|
errorMessage: null,
|
|
98
|
-
isSaving: true
|
|
98
|
+
isSaving: true,
|
|
99
|
+
isFetching: false,
|
|
100
|
+
isFetchingSingle: false
|
|
99
101
|
})));
|
|
100
102
|
//}
|
|
101
103
|
return state;
|
|
@@ -125,7 +127,9 @@ var start = exports.start = function start(state, action) {
|
|
|
125
127
|
map.mergeIn(['instances', action.instance, 'additionalData'], _immutable2.default.fromJS(_extends({}, action.additionalData, {
|
|
126
128
|
error: false,
|
|
127
129
|
errorMessage: null,
|
|
128
|
-
isSaving: true
|
|
130
|
+
isSaving: true,
|
|
131
|
+
isFetching: false,
|
|
132
|
+
isFetchingSingle: false
|
|
129
133
|
})));
|
|
130
134
|
} else {
|
|
131
135
|
// Optimistically update the record
|
package/lib/reducers/create.js
CHANGED
|
@@ -62,7 +62,9 @@ var start = exports.start = function start(state, action) {
|
|
|
62
62
|
state = state.mergeIn(['instances', action.instance, 'additionalData'], _immutable2.default.fromJS(_extends({}, action.additionalData, {
|
|
63
63
|
error: false,
|
|
64
64
|
errorMessage: null,
|
|
65
|
-
isSaving: true
|
|
65
|
+
isSaving: true,
|
|
66
|
+
isFetching: false,
|
|
67
|
+
isFetchingSingle: false
|
|
66
68
|
})));
|
|
67
69
|
|
|
68
70
|
return state;
|
|
@@ -102,7 +104,9 @@ var start = exports.start = function start(state, action) {
|
|
|
102
104
|
map.mergeIn(['instances', action.instance, 'additionalData'], _immutable2.default.fromJS(_extends({}, action.additionalData, {
|
|
103
105
|
error: false,
|
|
104
106
|
errorMessage: null,
|
|
105
|
-
isSaving: true
|
|
107
|
+
isSaving: true,
|
|
108
|
+
isFetching: false,
|
|
109
|
+
isFetchingSingle: false
|
|
106
110
|
})));
|
|
107
111
|
});
|
|
108
112
|
}
|
package/lib/reducers/perform.js
CHANGED
|
@@ -29,7 +29,9 @@ var start = exports.start = function start(state, action) {
|
|
|
29
29
|
map.mergeIn(['instances', action.instance, 'additionalData'], _immutable2.default.fromJS(_extends({}, action.additionalData, {
|
|
30
30
|
error: false,
|
|
31
31
|
errorMessage: null,
|
|
32
|
-
isSaving: true
|
|
32
|
+
isSaving: true,
|
|
33
|
+
isFetching: false,
|
|
34
|
+
isFetchingSingle: false
|
|
33
35
|
})));
|
|
34
36
|
}
|
|
35
37
|
});
|
|
@@ -86,7 +88,13 @@ var success = exports.success = function success(state, action) {
|
|
|
86
88
|
map.set('raw', state.get('raw').merge(newRecord));
|
|
87
89
|
|
|
88
90
|
// Add new record to instance array using permanent uid
|
|
89
|
-
map.
|
|
91
|
+
var instanceData = map.getIn(['instances', action.instance, 'data'], (0, _immutable.List)());
|
|
92
|
+
// Check if key already present in instance
|
|
93
|
+
if (!(instanceData.indexOf(uid) !== -1)) {
|
|
94
|
+
map.setIn(['instances', action.instance, 'data'], instanceData.push(uid));
|
|
95
|
+
}
|
|
96
|
+
// OLD method
|
|
97
|
+
//map.setIn(['instances', action.instance, 'data'], map.getIn(['instances', action.instance, 'data']).push(uid));
|
|
90
98
|
|
|
91
99
|
// UPDATE TOTAL COUNT FOR THIS INSTANCE
|
|
92
100
|
map.setIn(['instances', action.instance, 'additionalData', 'total'], map.getIn(['instances', action.instance, 'additionalData', 'total']) + 1);
|
package/lib/reducers/remove.js
CHANGED
|
@@ -63,7 +63,9 @@ var start = exports.start = function start(state, action) {
|
|
|
63
63
|
state = state.mergeIn(['instances', action.instance, 'additionalData'], _immutable2.default.fromJS(_extends({}, action.additionalData, {
|
|
64
64
|
error: false,
|
|
65
65
|
errorMessage: null,
|
|
66
|
-
isDeleting: true
|
|
66
|
+
isDeleting: true,
|
|
67
|
+
isFetching: false,
|
|
68
|
+
isFetchingSingle: false
|
|
67
69
|
})));
|
|
68
70
|
|
|
69
71
|
return state;
|
package/lib/reducers/update.js
CHANGED
|
@@ -64,7 +64,9 @@ var start = exports.start = function start(state, action) {
|
|
|
64
64
|
state = state.mergeIn(['instances', action.instance, 'additionalData'], _immutable2.default.fromJS(_extends({}, action.additionalData, {
|
|
65
65
|
error: false,
|
|
66
66
|
errorMessage: null,
|
|
67
|
-
isSaving: true
|
|
67
|
+
isSaving: true,
|
|
68
|
+
isFetching: false,
|
|
69
|
+
isFetchingSingle: false
|
|
68
70
|
})));
|
|
69
71
|
|
|
70
72
|
return state;
|
|
@@ -100,7 +102,9 @@ var start = exports.start = function start(state, action) {
|
|
|
100
102
|
map.mergeIn(['instances', action.instance, 'additionalData'], _immutable2.default.fromJS(_extends({}, action.additionalData, {
|
|
101
103
|
error: false,
|
|
102
104
|
errorMessage: null,
|
|
103
|
-
isSaving: true
|
|
105
|
+
isSaving: true,
|
|
106
|
+
isFetching: false,
|
|
107
|
+
isFetchingSingle: false
|
|
104
108
|
})));
|
|
105
109
|
});
|
|
106
110
|
}
|
package/package.json
CHANGED
package/src/actions/Create.js
CHANGED
|
@@ -143,61 +143,33 @@ export class Create extends BaseAction {
|
|
|
143
143
|
|
|
144
144
|
if (response.data.success) {
|
|
145
145
|
successHandler(response.data.data || [], null, response.data.updates || []);
|
|
146
|
-
|
|
147
146
|
message = response.data.message;
|
|
148
|
-
|
|
149
|
-
if
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
:
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
settings.notification.kind !== undefined
|
|
164
|
-
? settings.notification.kind
|
|
165
|
-
: "success"
|
|
166
|
-
})
|
|
167
|
-
);
|
|
168
|
-
} else {
|
|
169
|
-
dispatch(
|
|
170
|
-
notify({
|
|
171
|
-
title:
|
|
172
|
-
settings.notification.title !== undefined
|
|
173
|
-
? settings.notification.title
|
|
174
|
-
: message, //response.data.message,
|
|
175
|
-
kind:
|
|
176
|
-
settings.notification.kind !== undefined
|
|
177
|
-
? settings.notification.kind
|
|
178
|
-
: "success"
|
|
179
|
-
})
|
|
180
|
-
);
|
|
181
|
-
}
|
|
147
|
+
|
|
148
|
+
if(settings.notification !== undefined ){
|
|
149
|
+
if(settings.notification.type !== undefined && settings.notification.type === 'notification'){
|
|
150
|
+
dispatch(notify({
|
|
151
|
+
title: settings.notification.title,
|
|
152
|
+
message: (settings.notification.message !== undefined)?settings.notification.message:message,
|
|
153
|
+
type: 'notification',
|
|
154
|
+
kind: (settings.notification.kind !== undefined)?settings.notification.kind:'success'
|
|
155
|
+
}));
|
|
156
|
+
}else{
|
|
157
|
+
dispatch(notify({
|
|
158
|
+
title: (settings.notification.title !== undefined)?settings.notification.title:message,//response.data.message,
|
|
159
|
+
kind: (settings.notification.kind !== undefined)?settings.notification.kind:'success'
|
|
160
|
+
}));
|
|
161
|
+
}
|
|
182
162
|
}
|
|
183
163
|
} else {
|
|
184
164
|
errorHandler(response.data.error);
|
|
185
|
-
message =
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
: response.data.error;
|
|
189
|
-
|
|
190
|
-
dispatch(
|
|
191
|
-
notify({
|
|
165
|
+
message = (response.data.error.message !== undefined) ? response.data.error.message : response.data.error;
|
|
166
|
+
|
|
167
|
+
dispatch(notify({
|
|
192
168
|
title: settings.error.title,
|
|
193
169
|
message: message || settings.error.message,
|
|
194
|
-
type:
|
|
195
|
-
kind:
|
|
196
|
-
|
|
197
|
-
? settings.error.kind
|
|
198
|
-
: "error"
|
|
199
|
-
})
|
|
200
|
-
);
|
|
170
|
+
type: 'notification',
|
|
171
|
+
kind: (settings.error.kind !== undefined)?settings.error.kind:'error'
|
|
172
|
+
}));
|
|
201
173
|
}
|
|
202
174
|
return response.data;
|
|
203
175
|
})
|
|
@@ -208,39 +180,21 @@ export class Create extends BaseAction {
|
|
|
208
180
|
errorHandler(error);
|
|
209
181
|
|
|
210
182
|
if(error && error.response && error.response.status && error.response.status !== 401 ){
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
) {
|
|
215
|
-
dispatch(
|
|
216
|
-
notify({
|
|
183
|
+
|
|
184
|
+
if(settings.error.type !== undefined && settings.error.type === 'notification'){
|
|
185
|
+
dispatch(notify({
|
|
217
186
|
title: settings.error.title,
|
|
218
|
-
message:
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
settings.error.
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
})
|
|
228
|
-
);
|
|
229
|
-
} else {
|
|
230
|
-
dispatch(
|
|
231
|
-
notify({
|
|
232
|
-
title:
|
|
233
|
-
settings.error.title !== undefined
|
|
234
|
-
? settings.error.title
|
|
235
|
-
: error.response.data.message,
|
|
236
|
-
kind:
|
|
237
|
-
settings.error.kind !== undefined
|
|
238
|
-
? settings.error.kind
|
|
239
|
-
: "error"
|
|
240
|
-
})
|
|
241
|
-
);
|
|
242
|
-
}
|
|
187
|
+
message: error.response.data.message ? error.response.data.message : (settings.error.message !== undefined)?settings.error.message:'',
|
|
188
|
+
type: 'notification',
|
|
189
|
+
kind: (settings.error.kind !== undefined)?settings.error.kind:'error'
|
|
190
|
+
}));
|
|
191
|
+
}else{
|
|
192
|
+
dispatch(notify({
|
|
193
|
+
title: error.response.data.message ? error.response.data.message : (settings.error.title !== undefined)?settings.error.title:'',
|
|
194
|
+
kind: (settings.error.kind !== undefined)?settings.error.kind:'error'
|
|
195
|
+
}));
|
|
243
196
|
}
|
|
197
|
+
}
|
|
244
198
|
})
|
|
245
199
|
);
|
|
246
200
|
} else {
|
package/src/actions/Fetch.js
CHANGED
|
@@ -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/actions/Perform.js
CHANGED
|
@@ -126,30 +126,32 @@ export class Perform extends BaseAction {
|
|
|
126
126
|
successHandler(response.data.data || [], null, response.data.updates || []);
|
|
127
127
|
message = response.data.message;
|
|
128
128
|
|
|
129
|
-
if(
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
129
|
+
if(settings.notification !== undefined ){
|
|
130
|
+
if(settings.notification.type !== undefined && settings.notification.type === 'notification'){
|
|
131
|
+
dispatch(notify({
|
|
132
|
+
title: settings.notification.title,
|
|
133
|
+
message: (settings.notification.message !== undefined)?settings.notification.message:message,
|
|
134
|
+
type: 'notification',
|
|
135
|
+
kind: (settings.notification.kind !== undefined)?settings.notification.kind:'success'
|
|
136
|
+
}));
|
|
137
|
+
}else{
|
|
138
|
+
dispatch(notify({
|
|
139
|
+
title: (settings.notification.title !== undefined)?settings.notification.title:message,//response.data.message,
|
|
140
|
+
kind: (settings.notification.kind !== undefined)?settings.notification.kind:'success'
|
|
141
|
+
}));
|
|
142
|
+
}
|
|
143
|
+
}
|
|
142
144
|
|
|
143
145
|
}else{
|
|
144
146
|
errorHandler(response.data.error);
|
|
145
147
|
message = (response.data.error.message !== undefined)?response.data.error.message:response.data.error;
|
|
146
148
|
|
|
147
149
|
dispatch(notify({
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
150
|
+
title: settings.error.title,
|
|
151
|
+
message: message || settings.error.message,
|
|
152
|
+
type: 'notification',
|
|
153
|
+
kind: (settings.error.kind !== undefined)?settings.error.kind:'error'
|
|
154
|
+
}));
|
|
153
155
|
}
|
|
154
156
|
return response.data;
|
|
155
157
|
})
|
|
@@ -164,13 +166,13 @@ export class Perform extends BaseAction {
|
|
|
164
166
|
if(settings.error.type !== undefined && settings.error.type === 'notification'){
|
|
165
167
|
dispatch(notify({
|
|
166
168
|
title: settings.error.title,
|
|
167
|
-
message: (settings.error.message !== undefined)?settings.error.message:
|
|
169
|
+
message: error.response.data.message ? error.response.data.message : (settings.error.message !== undefined)?settings.error.message:'',
|
|
168
170
|
type: 'notification',
|
|
169
171
|
kind: (settings.error.kind !== undefined)?settings.error.kind:'error'
|
|
170
172
|
}));
|
|
171
173
|
}else{
|
|
172
174
|
dispatch(notify({
|
|
173
|
-
title: (settings.error.title !== undefined)?settings.error.title:
|
|
175
|
+
title: error.response.data.message ? error.response.data.message : (settings.error.title !== undefined)?settings.error.title:'',
|
|
174
176
|
kind: (settings.error.kind !== undefined)?settings.error.kind:'error'
|
|
175
177
|
}));
|
|
176
178
|
}
|
package/src/actions/Update.js
CHANGED
package/src/reducers/bulk.js
CHANGED
|
@@ -81,6 +81,8 @@ export const start = (state, action) => {
|
|
|
81
81
|
error: false,
|
|
82
82
|
errorMessage: null,
|
|
83
83
|
isSaving: true,
|
|
84
|
+
isFetching: false,
|
|
85
|
+
isFetchingSingle: false,
|
|
84
86
|
})));
|
|
85
87
|
//}
|
|
86
88
|
return state;
|
|
@@ -112,6 +114,8 @@ export const start = (state, action) => {
|
|
|
112
114
|
error: false,
|
|
113
115
|
errorMessage: null,
|
|
114
116
|
isSaving: true,
|
|
117
|
+
isFetching: false,
|
|
118
|
+
isFetchingSingle: false,
|
|
115
119
|
})));
|
|
116
120
|
|
|
117
121
|
}
|
package/src/reducers/create.js
CHANGED
|
@@ -49,6 +49,8 @@ export const start = (state, action) => {
|
|
|
49
49
|
error: false,
|
|
50
50
|
errorMessage: null,
|
|
51
51
|
isSaving: true,
|
|
52
|
+
isFetching: false,
|
|
53
|
+
isFetchingSingle: false,
|
|
52
54
|
})));
|
|
53
55
|
|
|
54
56
|
return state;
|
|
@@ -89,7 +91,9 @@ export const start = (state, action) => {
|
|
|
89
91
|
map.mergeIn(['instances', action.instance, 'additionalData'], Immutable.fromJS(Object.assign({}, action.additionalData, {
|
|
90
92
|
error: false,
|
|
91
93
|
errorMessage: null,
|
|
92
|
-
isSaving: true
|
|
94
|
+
isSaving: true,
|
|
95
|
+
isFetching: false,
|
|
96
|
+
isFetchingSingle: false,
|
|
93
97
|
})));
|
|
94
98
|
|
|
95
99
|
})
|
package/src/reducers/perform.js
CHANGED
|
@@ -17,6 +17,8 @@ export const start = (state, action) => {
|
|
|
17
17
|
error: false,
|
|
18
18
|
errorMessage: null,
|
|
19
19
|
isSaving: true,
|
|
20
|
+
isFetching: false,
|
|
21
|
+
isFetchingSingle: false,
|
|
20
22
|
})));
|
|
21
23
|
}
|
|
22
24
|
})
|
|
@@ -73,7 +75,13 @@ export const start = (state, action) => {
|
|
|
73
75
|
map.set('raw', state.get('raw').merge(newRecord))
|
|
74
76
|
|
|
75
77
|
// Add new record to instance array using permanent uid
|
|
76
|
-
|
|
78
|
+
const instanceData = map.getIn(['instances', action.instance, 'data'], List());
|
|
79
|
+
// Check if key already present in instance
|
|
80
|
+
if(!instanceData.includes(uid)){
|
|
81
|
+
map.setIn(['instances', action.instance, 'data'], instanceData.push(uid));
|
|
82
|
+
}
|
|
83
|
+
// OLD method
|
|
84
|
+
//map.setIn(['instances', action.instance, 'data'], map.getIn(['instances', action.instance, 'data']).push(uid));
|
|
77
85
|
|
|
78
86
|
// UPDATE TOTAL COUNT FOR THIS INSTANCE
|
|
79
87
|
map.setIn(['instances', action.instance, 'additionalData', 'total'], map.getIn(['instances', action.instance, 'additionalData', 'total']) + 1 );
|
package/src/reducers/remove.js
CHANGED
|
@@ -51,7 +51,9 @@ export const start = (state, action) => {
|
|
|
51
51
|
state = state.mergeIn(['instances', action.instance, 'additionalData'], Immutable.fromJS(Object.assign({}, action.additionalData, {
|
|
52
52
|
error: false,
|
|
53
53
|
errorMessage: null,
|
|
54
|
-
isDeleting: true
|
|
54
|
+
isDeleting: true,
|
|
55
|
+
isFetching: false,
|
|
56
|
+
isFetchingSingle: false,
|
|
55
57
|
})));
|
|
56
58
|
|
|
57
59
|
return state;
|
package/src/reducers/update.js
CHANGED
|
@@ -54,7 +54,9 @@ export const start = (state, action) => {
|
|
|
54
54
|
state = state.mergeIn(['instances', action.instance, 'additionalData'], Immutable.fromJS(Object.assign({}, action.additionalData, {
|
|
55
55
|
error: false,
|
|
56
56
|
errorMessage: null,
|
|
57
|
-
isSaving: true
|
|
57
|
+
isSaving: true,
|
|
58
|
+
isFetching: false,
|
|
59
|
+
isFetchingSingle: false,
|
|
58
60
|
})));
|
|
59
61
|
|
|
60
62
|
return state;
|
|
@@ -92,7 +94,9 @@ export const start = (state, action) => {
|
|
|
92
94
|
map.mergeIn(['instances', action.instance, 'additionalData'], Immutable.fromJS(Object.assign({}, action.additionalData, {
|
|
93
95
|
error: false,
|
|
94
96
|
errorMessage: null,
|
|
95
|
-
isSaving: true
|
|
97
|
+
isSaving: true,
|
|
98
|
+
isFetching: false,
|
|
99
|
+
isFetchingSingle: false,
|
|
96
100
|
})));
|
|
97
101
|
|
|
98
102
|
})
|
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
|