redux-clerk2 2.0.15 → 2.0.18
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 +79 -0
- package/lib/actions/BaseAction.js +1 -1
- package/lib/actions/Create.js +13 -13
- package/lib/actions/Perform.js +202 -200
- package/package.json +1 -1
- package/src/.DS_Store +0 -0
- package/src/actions/BaseAction.js +1 -1
- package/src/actions/Create.js +34 -80
- package/src/actions/Perform.js +22 -20
- package/src/actions/Update.js +1 -1
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
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
|
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/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/package.json
CHANGED
package/src/.DS_Store
ADDED
|
Binary file
|
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/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
|
}
|