@zohodesk/library-platform 1.0.0-exp.4 → 1.0.0-exp.5
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/es/bc/zlist/Constants.js +1 -6
- package/es/bc/zrecord/Constants.js +0 -5
- package/es/cc/fields/boolean/Model.js +1 -3
- package/es/desk-frameworks/table-connected/frameworks/ListSdkFactory.js +3 -17
- package/es/library/behaviours/sort-by/adapters/controllers/Initialize.js +14 -0
- package/es/library/custom-component/adapters/gateways/validator/jsonValidator.js +5 -0
- package/es/library/custom-component/entities/getRef.js +10 -0
- package/es/library/dot/components/action-location/adapters/gateway/RepositoryOld.js +32 -0
- package/es/library/dot/components/table-list/frameworks/ui/css/TableList.module.css +1 -1
- package/es/library/dot/legacy-to-new-arch/field-components/checkbox-field/frameworks/ui/CheckboxField.js +13 -0
- package/es/library/dot/legacy-to-new-arch/field-components/checkbox-field/frameworks/ui/CheckboxFieldView.js +19 -0
- package/es/library/dot/legacy-to-new-arch/field-components/checkbox-field/frameworks/ui/EventHandlersFactory.js +29 -0
- package/es/library/dot/legacy-to-new-arch/field-components/email-field/frameworks/ui/EmailField.js +11 -0
- package/es/library/dot/legacy-to-new-arch/field-components/email-field/frameworks/ui/EmailFieldView.js +15 -0
- package/es/library/dot/legacy-to-new-arch/field-components/index.js +15 -0
- package/es/library/dot/legacy-to-new-arch/field-components/lookup-field/frameworks/ui/LookupField.js +11 -0
- package/es/library/dot/legacy-to-new-arch/field-components/lookup-field/frameworks/ui/LookupFieldView.js +19 -0
- package/es/library/dot/legacy-to-new-arch/field-components/multiselect-field/frameworks/ui/MultiSelectField.js +11 -0
- package/es/library/dot/legacy-to-new-arch/field-components/multiselect-field/frameworks/ui/MultiSelectFieldView.js +21 -0
- package/es/library/dot/legacy-to-new-arch/field-components/phone-field/frameworks/ui/PhoneField.js +11 -0
- package/es/library/dot/legacy-to-new-arch/field-components/phone-field/frameworks/ui/PhoneFieldView.js +22 -0
- package/es/library/dot/legacy-to-new-arch/field-components/picklist-field/frameworks/ui/PickListField.js +11 -0
- package/es/library/dot/legacy-to-new-arch/field-components/picklist-field/frameworks/ui/PickListFieldView.js +19 -0
- package/es/library/dot/legacy-to-new-arch/field-components/switch-field/frameworks/ui/EventHandlersFactory.js +29 -0
- package/es/library/dot/legacy-to-new-arch/field-components/switch-field/frameworks/ui/SwitchField.js +13 -0
- package/es/library/dot/legacy-to-new-arch/field-components/switch-field/frameworks/ui/SwitchFieldView.js +18 -0
- package/es/library/dot/legacy-to-new-arch/field-components/text-field/frameworks/ui/EventHandlersFactory.js +26 -0
- package/es/library/dot/legacy-to-new-arch/field-components/text-field/frameworks/ui/TextField.js +13 -0
- package/es/library/dot/legacy-to-new-arch/field-components/text-field/frameworks/ui/TextFieldView.js +16 -0
- package/es/library/dot/legacy-to-new-arch/field-components/url-field/frameworks/ui/EventHandlersFactory.js +26 -0
- package/es/library/dot/legacy-to-new-arch/field-components/url-field/frameworks/ui/UrlField.js +13 -0
- package/es/library/dot/legacy-to-new-arch/field-components/url-field/frameworks/ui/UrlFieldView.js +18 -0
- package/es/platform/zfield/entities/api-template/APITemplate.js +2 -19
- package/es/platform/zfield/entities/interfaces/FieldTypes.js +20 -0
- package/es/platform/zfield/usecases/entity-factory/FieldBuilder.js +109 -0
- package/es/platform/zfield/usecases/entity-factory/FieldFactory.js +10 -0
- package/es/platform/zfield/usecases/entity-factory/FieldsManagerBuilder.js +49 -0
- package/es/platform/zhttp/adapters/controllers/FetchController.js +1 -3
- package/es/platform/zhttp/usecases/interactors/FetchUseCase.js +19 -47
- package/es/platform/zlist/adapters/gateways/Service.js +0 -12
- package/es/platform/zlist/adapters/presenters/translators/ColumnTranslator.js +1 -3
- package/es/platform/zlist/adapters/presenters/translators/fields/BooleanFieldTranslator.js +1 -2
- package/es/platform/zlist/entities/List.js +2 -90
- package/es/platform/zlist/frameworks/EventHandlersFactory.js +1 -11
- package/es/platform/zrecord/adapters/gateways/Service.js +0 -4
- package/es/platform/zrecord/entities/APITemplate.js +10 -26
- package/es/platform/zrecord/entities/RecordsManager.js +37 -247
- package/es/platform/zrecord/entities/interfaces/MetaData.js +1 -1
- package/es/platform/zrecord/frameworks/ActionsHandlersFactory.js +1 -4
- package/es/platform/zrecord/usecases/interactors/ExecuteActionUseCase.js +2 -6
- package/es/platform/zrecord/usecases/interactors/FailureUseCase.js +5 -7
- package/es/platform/zrecord/usecases/interactors/FetchMoreUseCase.js +1 -1
- package/es/platform/zrecord/usecases/interactors/NoContentUseCase.js +0 -1
- package/es/platform/zrecord/usecases/interactors/SuccessUseCase.js +4 -11
- package/package.json +1 -1
- package/es/platform/data-broker/http-template/deleteRecord.js +0 -27
- package/es/platform/zlist/adapters/controllers/DeleteSingleRecordController.js +0 -23
- package/es/platform/zlist/adapters/controllers/RecordExecuteFailedController.js +0 -25
- package/es/platform/zlist/adapters/controllers/RecordExecuteSucceededController.js +0 -25
- package/es/platform/zlist/entities/interfaces/RecordExecuteAfterMetaData.js +0 -1
- package/es/platform/zlist/usecases/interactors/DeleteSingleRecordUseCase.js +0 -19
- package/es/platform/zlist/usecases/interactors/RecordExecuteFailedUseCase.js +0 -22
- package/es/platform/zlist/usecases/interactors/RecordExecuteSucceededUseCase.js +0 -22
- package/es/platform/zlist/usecases/interfaces/input/DeleteSingleRecordUseCaseInput.js +0 -1
- package/es/platform/zlist/usecases/interfaces/input/RecordExecuteFailedUseCaseInput.js +0 -1
- package/es/platform/zlist/usecases/interfaces/input/RecordExecuteSucceededUseCaseInput.js +0 -1
- package/es/platform/zrecord/adapters/controllers/SetRecordsController.js +0 -29
- package/es/platform/zrecord/usecases/interactors/SetRecordsUseCase.js +0 -22
- package/es/platform/zrecord/usecases/interfaces/input/SetRecordsInputModel.js +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* eslint-disable max-lines-per-function */
|
|
2
2
|
import { RECORD_FAILURE, RECORD_NO_CONTENT, RECORD_SUCCESS } from "../../../bc/zrecord/Symbols";
|
|
3
3
|
import { FETCH } from "../../../bc/zhttp/Constants";
|
|
4
|
-
import { APPEND_RECORDS,
|
|
4
|
+
import { APPEND_RECORDS, RECORD_LOCAL_MULTIPLE_DELETE, RECORD_LOCAL_UPDATE, RecordApiActionName } from "../../../bc/zrecord/Constants";
|
|
5
5
|
export default class RecordsManager {
|
|
6
6
|
constructor(apiTemplates, records) {
|
|
7
7
|
this.apiTemplates = apiTemplates;
|
|
@@ -16,46 +16,20 @@ export default class RecordsManager {
|
|
|
16
16
|
};
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
isGetRecordsApi(metaData) {
|
|
20
|
-
const {
|
|
21
|
-
actionName
|
|
22
|
-
} = metaData;
|
|
23
|
-
return RecordApiActionName.GET_RECORDS === actionName;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
19
|
createFetchRecordMeta(actionName, apiName, headers, props) {
|
|
27
20
|
let successMeta = {
|
|
28
|
-
type:
|
|
29
|
-
metaData: {
|
|
30
|
-
props
|
|
31
|
-
}
|
|
21
|
+
type: APPEND_RECORDS,
|
|
22
|
+
metaData: {}
|
|
32
23
|
};
|
|
33
24
|
let successNoContentMeta = {
|
|
34
25
|
type: '',
|
|
35
|
-
metaData: {
|
|
36
|
-
props
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
let failureMeta = {
|
|
40
|
-
type: '',
|
|
41
|
-
metaData: {
|
|
42
|
-
props
|
|
43
|
-
}
|
|
26
|
+
metaData: {}
|
|
44
27
|
};
|
|
45
28
|
|
|
46
29
|
if (RecordApiActionName.UPDATE_RECORD === actionName) {
|
|
47
30
|
successMeta = {
|
|
48
31
|
type: RECORD_LOCAL_UPDATE,
|
|
49
|
-
metaData: {
|
|
50
|
-
props
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
} else if (RecordApiActionName.GET_RECORDS === actionName) {
|
|
54
|
-
successMeta = {
|
|
55
|
-
type: SET_RECORDS,
|
|
56
|
-
metaData: {
|
|
57
|
-
props
|
|
58
|
-
}
|
|
32
|
+
metaData: {}
|
|
59
33
|
};
|
|
60
34
|
} else if (RecordApiActionName.DELETE_RECORDS === actionName) {
|
|
61
35
|
successMeta = {
|
|
@@ -70,19 +44,6 @@ export default class RecordsManager {
|
|
|
70
44
|
props
|
|
71
45
|
}
|
|
72
46
|
};
|
|
73
|
-
} else if (RecordApiActionName.DELETE_RECORD === actionName) {
|
|
74
|
-
successMeta = {
|
|
75
|
-
type: RECORD_LOCAL_MULTIPLE_DELETE,
|
|
76
|
-
metaData: {
|
|
77
|
-
props
|
|
78
|
-
}
|
|
79
|
-
};
|
|
80
|
-
successNoContentMeta = {
|
|
81
|
-
type: RECORD_LOCAL_MULTIPLE_DELETE,
|
|
82
|
-
metaData: {
|
|
83
|
-
props
|
|
84
|
-
}
|
|
85
|
-
};
|
|
86
47
|
}
|
|
87
48
|
|
|
88
49
|
return {
|
|
@@ -90,41 +51,22 @@ export default class RecordsManager {
|
|
|
90
51
|
apiName,
|
|
91
52
|
actionName,
|
|
92
53
|
[RECORD_NO_CONTENT]: successNoContentMeta,
|
|
93
|
-
[RECORD_FAILURE]: failureMeta,
|
|
94
54
|
[RECORD_SUCCESS]: successMeta
|
|
95
55
|
};
|
|
96
56
|
}
|
|
97
57
|
|
|
98
|
-
createFetchMoreRecordMeta(actionName, apiName, headers
|
|
99
|
-
const successMeta = {
|
|
100
|
-
type: APPEND_RECORDS,
|
|
101
|
-
metaData: {
|
|
102
|
-
props
|
|
103
|
-
}
|
|
104
|
-
};
|
|
105
|
-
const successNoContentMeta = {
|
|
106
|
-
type: '',
|
|
107
|
-
metaData: {
|
|
108
|
-
props
|
|
109
|
-
}
|
|
110
|
-
};
|
|
111
|
-
const failureMeta = {
|
|
112
|
-
type: '',
|
|
113
|
-
metaData: {
|
|
114
|
-
props
|
|
115
|
-
}
|
|
116
|
-
};
|
|
58
|
+
createFetchMoreRecordMeta(actionName, apiName, headers) {
|
|
117
59
|
return {
|
|
118
60
|
headers,
|
|
119
61
|
apiName,
|
|
120
62
|
actionName,
|
|
121
|
-
[
|
|
122
|
-
|
|
123
|
-
|
|
63
|
+
[RECORD_SUCCESS]: {
|
|
64
|
+
type: APPEND_RECORDS
|
|
65
|
+
}
|
|
124
66
|
};
|
|
125
67
|
}
|
|
126
68
|
|
|
127
|
-
|
|
69
|
+
createSuccessAction(transformedRes, metaData) {
|
|
128
70
|
const {
|
|
129
71
|
actionName
|
|
130
72
|
} = metaData;
|
|
@@ -132,83 +74,32 @@ export default class RecordsManager {
|
|
|
132
74
|
type,
|
|
133
75
|
metaData: successMeta
|
|
134
76
|
} = metaData[RECORD_SUCCESS];
|
|
135
|
-
const actions = [];
|
|
136
77
|
|
|
137
78
|
if (RecordApiActionName.UPDATE_RECORD === actionName) {
|
|
138
|
-
|
|
139
|
-
const recordId = transformedResponse.id;
|
|
140
|
-
type && actions.push({
|
|
141
|
-
type,
|
|
142
|
-
metaData,
|
|
143
|
-
payload: {
|
|
144
|
-
record,
|
|
145
|
-
recordId
|
|
146
|
-
}
|
|
147
|
-
});
|
|
148
|
-
actions.push({
|
|
149
|
-
type: RECORD_EXECUTE_SUCCEEDED,
|
|
150
|
-
metaData,
|
|
151
|
-
payload: {
|
|
152
|
-
actionName,
|
|
153
|
-
record,
|
|
154
|
-
recordId
|
|
155
|
-
}
|
|
156
|
-
});
|
|
157
|
-
} else if (RecordApiActionName.DELETE_RECORDS === actionName) {
|
|
158
|
-
const recordIds = successMeta.props.recordIds;
|
|
159
|
-
actions.push({
|
|
160
|
-
type,
|
|
161
|
-
metaData,
|
|
162
|
-
payload: {
|
|
163
|
-
recordIds
|
|
164
|
-
}
|
|
165
|
-
});
|
|
166
|
-
actions.push({
|
|
167
|
-
type: RECORD_EXECUTE_SUCCEEDED,
|
|
168
|
-
metaData,
|
|
169
|
-
payload: {
|
|
170
|
-
actionName,
|
|
171
|
-
recordIds
|
|
172
|
-
}
|
|
173
|
-
});
|
|
174
|
-
} else if (RecordApiActionName.DELETE_RECORD === actionName) {
|
|
175
|
-
const recordId = successMeta.props.recordId;
|
|
176
|
-
const recordIds = [recordId];
|
|
177
|
-
actions.push({
|
|
79
|
+
return {
|
|
178
80
|
type,
|
|
179
|
-
metaData,
|
|
180
|
-
payload: {
|
|
181
|
-
recordIds
|
|
182
|
-
}
|
|
183
|
-
});
|
|
184
|
-
actions.push({
|
|
185
|
-
type: RECORD_EXECUTE_SUCCEEDED,
|
|
186
|
-
metaData,
|
|
187
81
|
payload: {
|
|
188
|
-
|
|
189
|
-
recordId
|
|
82
|
+
record: transformedRes,
|
|
83
|
+
recordId: transformedRes.id
|
|
190
84
|
}
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
if (RecordApiActionName.DELETE_RECORDS === actionName) {
|
|
89
|
+
return {
|
|
195
90
|
type,
|
|
196
|
-
metaData,
|
|
197
|
-
payload: {
|
|
198
|
-
records
|
|
199
|
-
}
|
|
200
|
-
});
|
|
201
|
-
actions.push({
|
|
202
|
-
type: RECORD_EXECUTE_SUCCEEDED,
|
|
203
|
-
metaData,
|
|
204
91
|
payload: {
|
|
205
|
-
|
|
206
|
-
records
|
|
92
|
+
recordIds: successMeta.props.recordIds
|
|
207
93
|
}
|
|
208
|
-
}
|
|
94
|
+
};
|
|
209
95
|
}
|
|
210
96
|
|
|
211
|
-
return
|
|
97
|
+
return {
|
|
98
|
+
type,
|
|
99
|
+
payload: {
|
|
100
|
+
records: transformedRes
|
|
101
|
+
}
|
|
102
|
+
};
|
|
212
103
|
}
|
|
213
104
|
|
|
214
105
|
createNoContentAction(metaData) {
|
|
@@ -217,132 +108,40 @@ export default class RecordsManager {
|
|
|
217
108
|
} = metaData;
|
|
218
109
|
const {
|
|
219
110
|
type,
|
|
111
|
+
payload,
|
|
220
112
|
metaData: noContentMeta
|
|
221
113
|
} = metaData[RECORD_NO_CONTENT];
|
|
222
114
|
|
|
223
115
|
if (RecordApiActionName.DELETE_RECORDS === actionName) {
|
|
224
116
|
return {
|
|
225
117
|
type,
|
|
226
|
-
metaData,
|
|
227
118
|
payload: {
|
|
228
119
|
recordIds: noContentMeta.props.recordIds
|
|
229
120
|
}
|
|
230
121
|
};
|
|
231
122
|
}
|
|
232
123
|
|
|
233
|
-
if (RecordApiActionName.DELETE_RECORD === actionName) {
|
|
234
|
-
return {
|
|
235
|
-
type,
|
|
236
|
-
metaData,
|
|
237
|
-
payload: {
|
|
238
|
-
recordId: noContentMeta.props.recordId
|
|
239
|
-
}
|
|
240
|
-
};
|
|
241
|
-
}
|
|
242
|
-
|
|
243
124
|
return {
|
|
244
125
|
type,
|
|
245
|
-
|
|
246
|
-
payload: {}
|
|
126
|
+
payload
|
|
247
127
|
};
|
|
248
128
|
}
|
|
249
129
|
|
|
250
|
-
|
|
251
|
-
const {
|
|
252
|
-
actionName
|
|
253
|
-
} = metaData;
|
|
130
|
+
createFailureAction(error, metaData) {
|
|
254
131
|
const {
|
|
255
|
-
type
|
|
256
|
-
metaData: failureMeta
|
|
132
|
+
type
|
|
257
133
|
} = metaData[RECORD_FAILURE];
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
type && actions.push({
|
|
265
|
-
type,
|
|
266
|
-
metaData,
|
|
267
|
-
payload: {
|
|
268
|
-
error,
|
|
269
|
-
recordId
|
|
270
|
-
}
|
|
271
|
-
});
|
|
272
|
-
actions.push({
|
|
273
|
-
type: RECORD_EXECUTE_FAILED,
|
|
274
|
-
metaData,
|
|
275
|
-
payload: {
|
|
276
|
-
actionName,
|
|
277
|
-
error,
|
|
278
|
-
recordId
|
|
279
|
-
}
|
|
280
|
-
});
|
|
281
|
-
} else if (RecordApiActionName.DELETE_RECORD === actionName) {
|
|
282
|
-
const {
|
|
283
|
-
recordId
|
|
284
|
-
} = failureMeta.props;
|
|
285
|
-
type && actions.push({
|
|
286
|
-
type,
|
|
287
|
-
metaData,
|
|
288
|
-
payload: {
|
|
289
|
-
error,
|
|
290
|
-
recordId
|
|
291
|
-
}
|
|
292
|
-
});
|
|
293
|
-
actions.push({
|
|
294
|
-
type: RECORD_EXECUTE_FAILED,
|
|
295
|
-
metaData,
|
|
296
|
-
payload: {
|
|
297
|
-
actionName,
|
|
298
|
-
error,
|
|
299
|
-
recordId
|
|
300
|
-
}
|
|
301
|
-
});
|
|
302
|
-
} else if (RecordApiActionName.DELETE_RECORDS === actionName) {
|
|
303
|
-
const {
|
|
304
|
-
recordIds
|
|
305
|
-
} = failureMeta.props;
|
|
306
|
-
type && actions.push({
|
|
307
|
-
type,
|
|
308
|
-
metaData,
|
|
309
|
-
payload: {
|
|
310
|
-
error,
|
|
311
|
-
recordIds
|
|
312
|
-
}
|
|
313
|
-
});
|
|
314
|
-
actions.push({
|
|
315
|
-
type: RECORD_EXECUTE_FAILED,
|
|
316
|
-
metaData,
|
|
317
|
-
payload: {
|
|
318
|
-
actionName,
|
|
319
|
-
error,
|
|
320
|
-
recordIds
|
|
321
|
-
}
|
|
322
|
-
});
|
|
323
|
-
} else {
|
|
324
|
-
type && actions.push({
|
|
325
|
-
type,
|
|
326
|
-
metaData,
|
|
327
|
-
payload: {
|
|
328
|
-
error
|
|
329
|
-
}
|
|
330
|
-
});
|
|
331
|
-
actions.push({
|
|
332
|
-
type: RECORD_EXECUTE_FAILED,
|
|
333
|
-
metaData,
|
|
334
|
-
payload: {
|
|
335
|
-
error
|
|
336
|
-
}
|
|
337
|
-
});
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
return actions;
|
|
134
|
+
return {
|
|
135
|
+
type,
|
|
136
|
+
payload: {
|
|
137
|
+
error
|
|
138
|
+
}
|
|
139
|
+
};
|
|
341
140
|
}
|
|
342
141
|
|
|
343
142
|
getApiDetails(actionName, props) {
|
|
344
143
|
return this.apiTemplates.getApiDetails(actionName, { ...props,
|
|
345
|
-
from: this.records.getRecordsLength()
|
|
144
|
+
from: this.records.getRecordsLength()
|
|
346
145
|
});
|
|
347
146
|
}
|
|
348
147
|
|
|
@@ -359,10 +158,6 @@ export default class RecordsManager {
|
|
|
359
158
|
this.records.setHasMore(true);
|
|
360
159
|
}
|
|
361
160
|
|
|
362
|
-
setNoMoreDataInRecords() {
|
|
363
|
-
this.records.setHasMore(false);
|
|
364
|
-
}
|
|
365
|
-
|
|
366
161
|
hasMoreRecords() {
|
|
367
162
|
return this.records.hasMoreRecords();
|
|
368
163
|
}
|
|
@@ -371,11 +166,6 @@ export default class RecordsManager {
|
|
|
371
166
|
return this.records.isRecordsFetching();
|
|
372
167
|
}
|
|
373
168
|
|
|
374
|
-
setRecords(records) {
|
|
375
|
-
this.records.setRecords(records);
|
|
376
|
-
this.records.updateHasMore(records.length);
|
|
377
|
-
}
|
|
378
|
-
|
|
379
169
|
appendRecords(records) {
|
|
380
170
|
this.records.appendRecords(records);
|
|
381
171
|
this.records.updateHasMore(records.length);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import { RECORD_FAILURE,
|
|
1
|
+
import { RECORD_FAILURE, RECORD_SUCCESS } from "../../../../bc/zrecord/Symbols";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* eslint-disable max-lines-per-function */
|
|
2
|
-
import { APPEND_RECORDS, RECORD_EXECUTE, RECORD_FETCH_MORE, RECORD_FIELD_CHANGE, RECORD_LOCAL_MULTIPLE_DELETE, RECORD_LOCAL_UPDATE,
|
|
2
|
+
import { APPEND_RECORDS, RECORD_EXECUTE, RECORD_FETCH_MORE, RECORD_FIELD_CHANGE, RECORD_LOCAL_MULTIPLE_DELETE, RECORD_LOCAL_UPDATE, RECORD_REFETCH } from "../../../bc/zrecord/Constants";
|
|
3
3
|
import { FETCH_FAILED, FETCH_SUCCESS, FETCH_SUCCESS_NO_CONTENT } from "../../../bc/zhttp/Constants";
|
|
4
4
|
import MountController from "../adapters/controllers/MountController";
|
|
5
5
|
import Presenter from "../adapters/presenters/Presenter";
|
|
@@ -16,7 +16,6 @@ import FetchMoreController from "../adapters/controllers/FetchMoreController";
|
|
|
16
16
|
import FieldChangeController from "../adapters/controllers/FieldChangeController";
|
|
17
17
|
import RecordUpdateLocalController from "../adapters/controllers/RecordUpdateLocalController";
|
|
18
18
|
import DeleteMultipleRecordLocalController from "../adapters/controllers/DeleteMultipleRecordLocalController";
|
|
19
|
-
import SetRecordsController from "../adapters/controllers/SetRecordsController";
|
|
20
19
|
export default class ActionsHandlersFactory {
|
|
21
20
|
static create(apiDetails) {
|
|
22
21
|
const presenter = new Presenter();
|
|
@@ -36,7 +35,6 @@ export default class ActionsHandlersFactory {
|
|
|
36
35
|
const refetchController = new RefetchController(service);
|
|
37
36
|
const noContentController = new NoContentController(service);
|
|
38
37
|
const appendRecordsController = new AppendRecordsController(service);
|
|
39
|
-
const setRecordsController = new SetRecordsController(service);
|
|
40
38
|
const fieldChangeController = new FieldChangeController(service);
|
|
41
39
|
const recordUpdateLocalController = new RecordUpdateLocalController(service);
|
|
42
40
|
const deleteMultipleRecordLocalController = new DeleteMultipleRecordLocalController(service);
|
|
@@ -49,7 +47,6 @@ export default class ActionsHandlersFactory {
|
|
|
49
47
|
[FETCH_SUCCESS]: successController.handle,
|
|
50
48
|
[RECORD_LOCAL_MULTIPLE_DELETE]: deleteMultipleRecordLocalController.handle,
|
|
51
49
|
[APPEND_RECORDS]: appendRecordsController.handle,
|
|
52
|
-
[SET_RECORDS]: setRecordsController.handle,
|
|
53
50
|
[RECORD_FIELD_CHANGE]: fieldChangeController.handle,
|
|
54
51
|
[RECORD_LOCAL_UPDATE]: recordUpdateLocalController.handle,
|
|
55
52
|
[FETCH_SUCCESS_NO_CONTENT]: noContentController.handle
|
|
@@ -22,12 +22,8 @@ class ExecuteActionUseCase extends AbstractUseCase {
|
|
|
22
22
|
|
|
23
23
|
const apiDetails = recordManager.getApiDetails(actionName, props);
|
|
24
24
|
const metaData = recordManager.createFetchRecordMeta(actionName, apiName, inputMeta.headers, props);
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
recordManager.fetchingStarted();
|
|
28
|
-
presenter.updateRecord(recordManager.toObject());
|
|
29
|
-
}
|
|
30
|
-
|
|
25
|
+
recordManager.fetchingStarted();
|
|
26
|
+
presenter.updateRecord(recordManager.toObject());
|
|
31
27
|
dispatch(recordManager.createFetchAction(apiDetails, metaData));
|
|
32
28
|
}
|
|
33
29
|
|
|
@@ -14,15 +14,13 @@ class FailureUseCase extends AbstractUseCase {
|
|
|
14
14
|
} = input;
|
|
15
15
|
const recordManager = repository.getRecordsManagerEntity(templateHelpers);
|
|
16
16
|
|
|
17
|
-
if (recordManager.
|
|
18
|
-
|
|
19
|
-
presenter.updateRecord(recordManager.toObject());
|
|
17
|
+
if (recordManager.isFetchFailureIrrelevantToRecord(metaData)) {
|
|
18
|
+
return;
|
|
20
19
|
}
|
|
21
20
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
});
|
|
21
|
+
recordManager.fetchingFinished();
|
|
22
|
+
presenter.updateRecord(recordManager.toObject());
|
|
23
|
+
dispatch(recordManager.createFailureAction(error, metaData));
|
|
26
24
|
}
|
|
27
25
|
|
|
28
26
|
}
|
|
@@ -21,7 +21,7 @@ class FetchMoreUseCase extends AbstractUseCase {
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
const apiDetails = recordManager.getApiDetails(actionName, props);
|
|
24
|
-
const metaData = recordManager.
|
|
24
|
+
const metaData = recordManager.createFetchRecordMeta(actionName, apiName, inputMeta.headers, props);
|
|
25
25
|
recordManager.fetchingStarted();
|
|
26
26
|
presenter.updateRecord(recordManager.toObject());
|
|
27
27
|
dispatch(recordManager.createFetchAction(apiDetails, metaData));
|
|
@@ -22,17 +22,10 @@ class SuccessUseCase extends AbstractUseCase {
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
const transformer = recordManager.getTransformer(actionName);
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
presenter.updateRecord(recordManager.toObject());
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
const actions = recordManager.createSuccessActions(transformedResponse, metaData);
|
|
33
|
-
actions.forEach(action => {
|
|
34
|
-
dispatch(action);
|
|
35
|
-
});
|
|
25
|
+
const records = transformer(response);
|
|
26
|
+
recordManager.fetchingFinished();
|
|
27
|
+
presenter.updateRecord(recordManager.toObject());
|
|
28
|
+
dispatch(recordManager.createSuccessAction(records, metaData));
|
|
36
29
|
}
|
|
37
30
|
|
|
38
31
|
}
|
package/package.json
CHANGED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
const deleteRecord = {
|
|
2
|
-
name: 'records',
|
|
3
|
-
api: '/api/v1/{{moduleName}}/moveToTrash',
|
|
4
|
-
parameters: `{}`,
|
|
5
|
-
type: 'POST',
|
|
6
|
-
transformer: data => data,
|
|
7
|
-
requestBody: '{ "entityIds": ["{{recordId}}"] }',
|
|
8
|
-
properties: {
|
|
9
|
-
moduleName: {
|
|
10
|
-
required: true,
|
|
11
|
-
typeMetadata: {
|
|
12
|
-
schema: {
|
|
13
|
-
type: 'string'
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
},
|
|
17
|
-
recordId: {
|
|
18
|
-
required: true,
|
|
19
|
-
typeMetadata: {
|
|
20
|
-
schema: {
|
|
21
|
-
type: 'string'
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
export default deleteRecord;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import AbstractController from "./AbstractController";
|
|
2
|
-
export default class DeleteSingleRecordController extends AbstractController {
|
|
3
|
-
handle(event) {
|
|
4
|
-
const {
|
|
5
|
-
state,
|
|
6
|
-
updateState,
|
|
7
|
-
dispatch,
|
|
8
|
-
action
|
|
9
|
-
} = event;
|
|
10
|
-
const {
|
|
11
|
-
recordId
|
|
12
|
-
} = action.payload;
|
|
13
|
-
const {
|
|
14
|
-
deleteSingleRecordUseCase
|
|
15
|
-
} = this.service;
|
|
16
|
-
deleteSingleRecordUseCase.updateDependency(state, updateState);
|
|
17
|
-
deleteSingleRecordUseCase.execute({
|
|
18
|
-
dispatch,
|
|
19
|
-
recordId
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import AbstractController from "./AbstractController";
|
|
2
|
-
export default class RecordExecuteFailedController extends AbstractController {
|
|
3
|
-
handle(event) {
|
|
4
|
-
const {
|
|
5
|
-
state,
|
|
6
|
-
updateState,
|
|
7
|
-
dispatch,
|
|
8
|
-
action
|
|
9
|
-
} = event;
|
|
10
|
-
const {
|
|
11
|
-
payload,
|
|
12
|
-
metaData
|
|
13
|
-
} = action;
|
|
14
|
-
const {
|
|
15
|
-
recordExecuteFailedUseCase
|
|
16
|
-
} = this.service;
|
|
17
|
-
recordExecuteFailedUseCase.updateDependency(state, updateState);
|
|
18
|
-
recordExecuteFailedUseCase.execute({
|
|
19
|
-
dispatch,
|
|
20
|
-
payload,
|
|
21
|
-
metaData
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import AbstractController from "./AbstractController";
|
|
2
|
-
export default class RecordExecuteSucceededController extends AbstractController {
|
|
3
|
-
handle(event) {
|
|
4
|
-
const {
|
|
5
|
-
state,
|
|
6
|
-
updateState,
|
|
7
|
-
dispatch,
|
|
8
|
-
action
|
|
9
|
-
} = event;
|
|
10
|
-
const {
|
|
11
|
-
payload,
|
|
12
|
-
metaData
|
|
13
|
-
} = action;
|
|
14
|
-
const {
|
|
15
|
-
recordExecuteSucceededUseCase
|
|
16
|
-
} = this.service;
|
|
17
|
-
recordExecuteSucceededUseCase.updateDependency(state, updateState);
|
|
18
|
-
recordExecuteSucceededUseCase.execute({
|
|
19
|
-
dispatch,
|
|
20
|
-
payload,
|
|
21
|
-
metaData
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import AbstractUseCase from "./AbstractUseCase";
|
|
2
|
-
|
|
3
|
-
class DeleteSingleRecordUseCase extends AbstractUseCase {
|
|
4
|
-
execute(input) {
|
|
5
|
-
const {
|
|
6
|
-
dispatch,
|
|
7
|
-
recordId
|
|
8
|
-
} = input;
|
|
9
|
-
const {
|
|
10
|
-
repository
|
|
11
|
-
} = this.dependencies;
|
|
12
|
-
const list = repository.getList();
|
|
13
|
-
const action = list.getDeleteSingleRecordAction(recordId);
|
|
14
|
-
dispatch(action);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export default DeleteSingleRecordUseCase;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import AbstractUseCase from "./AbstractUseCase";
|
|
2
|
-
|
|
3
|
-
class RecordExecuteFailedUseCase extends AbstractUseCase {
|
|
4
|
-
execute(input) {
|
|
5
|
-
const {
|
|
6
|
-
dispatch,
|
|
7
|
-
metaData,
|
|
8
|
-
payload
|
|
9
|
-
} = input;
|
|
10
|
-
const {
|
|
11
|
-
repository
|
|
12
|
-
} = this.dependencies;
|
|
13
|
-
const list = repository.getList();
|
|
14
|
-
const actions = list.getRecordExecuteFailedActions(payload, metaData);
|
|
15
|
-
actions.forEach(action => {
|
|
16
|
-
dispatch(action);
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export default RecordExecuteFailedUseCase;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import AbstractUseCase from "./AbstractUseCase";
|
|
2
|
-
|
|
3
|
-
class RecordExecuteSucceededUseCase extends AbstractUseCase {
|
|
4
|
-
execute(input) {
|
|
5
|
-
const {
|
|
6
|
-
dispatch,
|
|
7
|
-
payload,
|
|
8
|
-
metaData
|
|
9
|
-
} = input;
|
|
10
|
-
const {
|
|
11
|
-
repository
|
|
12
|
-
} = this.dependencies;
|
|
13
|
-
const list = repository.getList();
|
|
14
|
-
const actions = list.getRecordExecuteSucceededActions(payload, metaData);
|
|
15
|
-
actions.forEach(action => {
|
|
16
|
-
dispatch(action);
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export default RecordExecuteSucceededUseCase;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|