@zohodesk/library-platform 1.0.0-exp.5 → 1.0.0-exp.6
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 +6 -1
- package/es/bc/zrecord/Constants.js +5 -0
- package/es/cc/fields/boolean/Model.js +3 -1
- package/es/cc/fields/field/Types.js +1 -0
- package/es/cc/table-connected/Properties.js +9 -0
- package/es/desk-frameworks/table-connected/frameworks/ListSdkFactory.js +17 -3
- package/es/desk-frameworks/table-connected/frameworks/TableConnectedView.js +1 -0
- package/es/library/dot/components/table-list/frameworks/ui/css/TableList.module.css +1 -1
- package/es/library/dot/legacy-to-new-arch/table-field-components/avatar-lookup-field/frameworks/ui/AvatarLookupField.js +12 -0
- package/es/library/dot/legacy-to-new-arch/table-field-components/avatar-lookup-field/frameworks/ui/AvatarLookupFieldView.js +18 -0
- package/es/library/dot/legacy-to-new-arch/{field-components/lookup-field → table-field-components/avatar-lookup-field}/frameworks/ui/LookupField.js +3 -2
- package/es/library/dot/legacy-to-new-arch/{field-components/lookup-field → table-field-components/avatar-lookup-field}/frameworks/ui/LookupFieldView.js +1 -2
- package/es/library/dot/legacy-to-new-arch/table-field-components/lookup-field copy/frameworks/ui/LookupField.js +12 -0
- package/es/library/dot/legacy-to-new-arch/table-field-components/lookup-field copy/frameworks/ui/LookupFieldView.js +18 -0
- package/es/platform/data-broker/http-template/deleteRecord.js +27 -0
- package/es/platform/data-broker/http-template/deleteRecords.js +1 -1
- package/es/platform/zfield/entities/api-template/APITemplate.js +26 -3
- package/es/platform/zhttp/adapters/controllers/FetchController.js +3 -1
- package/es/platform/zhttp/usecases/interactors/FetchUseCase.js +47 -19
- package/es/platform/zlist/adapters/controllers/DeleteSingleRecordController.js +23 -0
- package/es/platform/zlist/adapters/controllers/RecordExecuteFailedController.js +25 -0
- package/es/platform/zlist/adapters/controllers/RecordExecuteSucceededController.js +25 -0
- package/es/platform/zlist/adapters/gateways/Service.js +12 -0
- package/es/platform/zlist/adapters/presenters/translators/ColumnTranslator.js +3 -1
- package/es/platform/zlist/adapters/presenters/translators/fields/BooleanFieldTranslator.js +2 -1
- package/es/platform/zlist/entities/List.js +90 -2
- package/es/platform/zlist/entities/interfaces/RecordExecuteAfterMetaData.js +1 -0
- package/es/platform/zlist/frameworks/EventHandlersFactory.js +11 -1
- package/es/platform/zlist/usecases/interactors/DeleteSingleRecordUseCase.js +19 -0
- package/es/platform/zlist/usecases/interactors/RecordExecuteFailedUseCase.js +22 -0
- package/es/platform/zlist/usecases/interactors/RecordExecuteSucceededUseCase.js +22 -0
- package/es/platform/zlist/usecases/interfaces/input/DeleteSingleRecordUseCaseInput.js +1 -0
- package/es/platform/zlist/usecases/interfaces/input/RecordExecuteFailedUseCaseInput.js +1 -0
- package/es/platform/zlist/usecases/interfaces/input/RecordExecuteSucceededUseCaseInput.js +1 -0
- package/es/platform/zrecord/adapters/controllers/SetRecordsController.js +29 -0
- package/es/platform/zrecord/adapters/gateways/Service.js +4 -0
- package/es/platform/zrecord/entities/APITemplate.js +25 -3
- package/es/platform/zrecord/entities/RecordsManager.js +247 -37
- package/es/platform/zrecord/entities/interfaces/MetaData.js +1 -1
- package/es/platform/zrecord/frameworks/ActionsHandlersFactory.js +4 -1
- package/es/platform/zrecord/usecases/interactors/ExecuteActionUseCase.js +6 -2
- package/es/platform/zrecord/usecases/interactors/FailureUseCase.js +7 -5
- package/es/platform/zrecord/usecases/interactors/FetchMoreUseCase.js +1 -1
- package/es/platform/zrecord/usecases/interactors/NoContentUseCase.js +1 -0
- package/es/platform/zrecord/usecases/interactors/SetRecordsUseCase.js +22 -0
- package/es/platform/zrecord/usecases/interactors/SuccessUseCase.js +11 -4
- package/es/platform/zrecord/usecases/interfaces/input/SetRecordsInputModel.js +1 -0
- package/package.json +1 -1
- package/es/library/behaviours/sort-by/adapters/controllers/Initialize.js +0 -14
- package/es/library/custom-component/adapters/gateways/validator/jsonValidator.js +0 -5
- package/es/library/custom-component/entities/getRef.js +0 -10
- package/es/library/dot/components/action-location/adapters/gateway/RepositoryOld.js +0 -32
- package/es/library/dot/legacy-to-new-arch/field-components/checkbox-field/frameworks/ui/CheckboxField.js +0 -13
- package/es/library/dot/legacy-to-new-arch/field-components/checkbox-field/frameworks/ui/CheckboxFieldView.js +0 -19
- package/es/library/dot/legacy-to-new-arch/field-components/checkbox-field/frameworks/ui/EventHandlersFactory.js +0 -29
- package/es/library/dot/legacy-to-new-arch/field-components/email-field/frameworks/ui/EmailField.js +0 -11
- package/es/library/dot/legacy-to-new-arch/field-components/email-field/frameworks/ui/EmailFieldView.js +0 -15
- package/es/library/dot/legacy-to-new-arch/field-components/index.js +0 -15
- package/es/library/dot/legacy-to-new-arch/field-components/multiselect-field/frameworks/ui/MultiSelectField.js +0 -11
- package/es/library/dot/legacy-to-new-arch/field-components/multiselect-field/frameworks/ui/MultiSelectFieldView.js +0 -21
- package/es/library/dot/legacy-to-new-arch/field-components/phone-field/frameworks/ui/PhoneField.js +0 -11
- package/es/library/dot/legacy-to-new-arch/field-components/phone-field/frameworks/ui/PhoneFieldView.js +0 -22
- package/es/library/dot/legacy-to-new-arch/field-components/picklist-field/frameworks/ui/PickListField.js +0 -11
- package/es/library/dot/legacy-to-new-arch/field-components/picklist-field/frameworks/ui/PickListFieldView.js +0 -19
- package/es/library/dot/legacy-to-new-arch/field-components/switch-field/frameworks/ui/EventHandlersFactory.js +0 -29
- package/es/library/dot/legacy-to-new-arch/field-components/switch-field/frameworks/ui/SwitchField.js +0 -13
- package/es/library/dot/legacy-to-new-arch/field-components/switch-field/frameworks/ui/SwitchFieldView.js +0 -18
- package/es/library/dot/legacy-to-new-arch/field-components/text-field/frameworks/ui/EventHandlersFactory.js +0 -26
- package/es/library/dot/legacy-to-new-arch/field-components/text-field/frameworks/ui/TextField.js +0 -13
- package/es/library/dot/legacy-to-new-arch/field-components/text-field/frameworks/ui/TextFieldView.js +0 -16
- package/es/library/dot/legacy-to-new-arch/field-components/url-field/frameworks/ui/EventHandlersFactory.js +0 -26
- package/es/library/dot/legacy-to-new-arch/field-components/url-field/frameworks/ui/UrlField.js +0 -13
- package/es/library/dot/legacy-to-new-arch/field-components/url-field/frameworks/ui/UrlFieldView.js +0 -18
- package/es/platform/zfield/entities/interfaces/FieldTypes.js +0 -20
- package/es/platform/zfield/usecases/entity-factory/FieldBuilder.js +0 -109
- package/es/platform/zfield/usecases/entity-factory/FieldFactory.js +0 -10
- package/es/platform/zfield/usecases/entity-factory/FieldsManagerBuilder.js +0 -49
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -4,7 +4,7 @@ import Service from "../adapters/gateways/Service";
|
|
|
4
4
|
import Repository from "../adapters/gateways/Repository";
|
|
5
5
|
import MountController from "../adapters/controllers/MountController";
|
|
6
6
|
import PropertiesChangeController from "../adapters/controllers/PropertiesChangeController";
|
|
7
|
-
import { ZLIST_DELETE_RECORDS, ZLIST_FETCH_MORE, ZLIST_FETCH_SORTED, ZLIST_RECORD_UPDATE } from "../../../bc/zlist/Constants";
|
|
7
|
+
import { ZLIST_DELETE_RECORD, ZLIST_DELETE_RECORDS, ZLIST_FETCH_MORE, ZLIST_FETCH_SORTED, ZLIST_RECORD_UPDATE } from "../../../bc/zlist/Constants";
|
|
8
8
|
import FetchMoreController from "../adapters/controllers/FetchMoreController";
|
|
9
9
|
import SortController from "../adapters/controllers/SortController";
|
|
10
10
|
import FieldChangeController from "../adapters/controllers/FieldChangeController";
|
|
@@ -12,6 +12,10 @@ import LifeCycleAction from "../../../cc/architecture/LifeCycleActionEnum";
|
|
|
12
12
|
import SortBy from "../adapters/gateways/SortBy";
|
|
13
13
|
import DeleteMultipleRecordController from "../adapters/controllers/DeleteMultipleRecordController";
|
|
14
14
|
import RecordUpdateController from "../adapters/controllers/RecordUpdateController";
|
|
15
|
+
import DeleteSingleRecordController from "../adapters/controllers/DeleteSingleRecordController";
|
|
16
|
+
import RecordExecuteFailedController from "../adapters/controllers/RecordExecuteFailedController";
|
|
17
|
+
import RecordExecuteSucceededController from "../adapters/controllers/RecordExecuteSucceededController";
|
|
18
|
+
import { RECORD_EXECUTE_FAILED, RECORD_EXECUTE_SUCCEEDED } from "../../../bc/zrecord/Constants";
|
|
15
19
|
export default class ActionHandlersFactory {
|
|
16
20
|
static create() {
|
|
17
21
|
const repository = new Repository();
|
|
@@ -27,6 +31,9 @@ export default class ActionHandlersFactory {
|
|
|
27
31
|
fieldChange: new FieldChangeController(service).handle,
|
|
28
32
|
recordUpdate: new RecordUpdateController(service).handle,
|
|
29
33
|
deleteMultipleRecord: new DeleteMultipleRecordController(service).handle,
|
|
34
|
+
deleteRecord: new DeleteSingleRecordController(service).handle,
|
|
35
|
+
recordExecuteSucceeded: new RecordExecuteSucceededController(service).handle,
|
|
36
|
+
recordExecuteFailed: new RecordExecuteFailedController(service).handle,
|
|
30
37
|
sort: new SortController(service).handle
|
|
31
38
|
};
|
|
32
39
|
return {
|
|
@@ -36,6 +43,9 @@ export default class ActionHandlersFactory {
|
|
|
36
43
|
[ZLIST_FETCH_MORE]: controller.fetchMore,
|
|
37
44
|
[ZLIST_RECORD_UPDATE]: controller.recordUpdate,
|
|
38
45
|
[TableListConstants.TABLE_LIST_FIELD_CHANGED]: controller.fieldChange,
|
|
46
|
+
[ZLIST_DELETE_RECORD]: controller.deleteRecord,
|
|
47
|
+
[RECORD_EXECUTE_SUCCEEDED]: controller.recordExecuteSucceeded,
|
|
48
|
+
[RECORD_EXECUTE_FAILED]: controller.recordExecuteFailed,
|
|
39
49
|
[ZLIST_FETCH_SORTED]: controller.sort
|
|
40
50
|
};
|
|
41
51
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
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;
|
|
@@ -0,0 +1,22 @@
|
|
|
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;
|
|
@@ -0,0 +1,22 @@
|
|
|
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;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
2
|
+
|
|
3
|
+
export default class SetRecordsController {
|
|
4
|
+
constructor(service) {
|
|
5
|
+
this.service = service;
|
|
6
|
+
|
|
7
|
+
_defineProperty(this, "handle", event => {
|
|
8
|
+
const {
|
|
9
|
+
state,
|
|
10
|
+
updateState,
|
|
11
|
+
action
|
|
12
|
+
} = event;
|
|
13
|
+
const {
|
|
14
|
+
payload
|
|
15
|
+
} = action;
|
|
16
|
+
const {
|
|
17
|
+
records
|
|
18
|
+
} = payload;
|
|
19
|
+
const {
|
|
20
|
+
setRecordsUseCase
|
|
21
|
+
} = this.service;
|
|
22
|
+
setRecordsUseCase.updateDependency(state, updateState);
|
|
23
|
+
setRecordsUseCase.execute({
|
|
24
|
+
records
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
}
|
|
@@ -11,6 +11,7 @@ import RecordUpdateLocalUseCase from "../../usecases/interactors/RecordUpdateLoc
|
|
|
11
11
|
import DeleteMultipleRecordUseCase from "../../usecases/interactors/DeleteMultipleRecordUseCase";
|
|
12
12
|
import AppendRecordsUseCase from "../../usecases/interactors/AppendRecordsUseCase";
|
|
13
13
|
import FieldChangeUseCase from "../../usecases/interactors/FieldChangeUseCase";
|
|
14
|
+
import SetRecordsUseCase from "../../usecases/interactors/SetRecordsUseCase";
|
|
14
15
|
export default class Service {
|
|
15
16
|
constructor(dependencies) {
|
|
16
17
|
_defineProperty(this, "initializeUseCase", void 0);
|
|
@@ -27,6 +28,8 @@ export default class Service {
|
|
|
27
28
|
|
|
28
29
|
_defineProperty(this, "appendRecordsUseCase", void 0);
|
|
29
30
|
|
|
31
|
+
_defineProperty(this, "setRecordsUseCase", void 0);
|
|
32
|
+
|
|
30
33
|
_defineProperty(this, "fieldChangeUseCase", void 0);
|
|
31
34
|
|
|
32
35
|
_defineProperty(this, "fetchMoreUseCase", void 0);
|
|
@@ -42,6 +45,7 @@ export default class Service {
|
|
|
42
45
|
this.refetchUseCase = new RefetchUseCase(dependencies);
|
|
43
46
|
this.noContentUseCase = new NoContentUseCase(dependencies);
|
|
44
47
|
this.appendRecordsUseCase = new AppendRecordsUseCase(dependencies);
|
|
48
|
+
this.setRecordsUseCase = new SetRecordsUseCase(dependencies);
|
|
45
49
|
this.fieldChangeUseCase = new FieldChangeUseCase(dependencies);
|
|
46
50
|
this.fetchMoreUseCase = new FetchMoreUseCase(dependencies);
|
|
47
51
|
this.recordUpdateLocalUseCase = new RecordUpdateLocalUseCase(dependencies);
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
2
2
|
|
|
3
|
+
import API_METHODS from "./interfaces/ApiEnum";
|
|
4
|
+
|
|
5
|
+
// import IAPITemplate from '../interfaces/api-template/IAPITemplate';
|
|
6
|
+
// import { API_METHODS, APITemplateModel, APIDetailsModel } from '../interfaces/api-template/APIModels';
|
|
7
|
+
// import { ITemplateHelpers } from '../interfaces/api-template/ITemplateHelpers';
|
|
3
8
|
class APITemplate {
|
|
4
9
|
constructor(input, templateHelpers) {
|
|
5
10
|
_defineProperty(this, "input", void 0);
|
|
@@ -14,11 +19,14 @@ class APITemplate {
|
|
|
14
19
|
|
|
15
20
|
_defineProperty(this, "helper", void 0);
|
|
16
21
|
|
|
22
|
+
_defineProperty(this, "getResponseInTemplate", void 0);
|
|
23
|
+
|
|
17
24
|
this.input = input;
|
|
18
25
|
this.api = input.api;
|
|
26
|
+
this.getResponseInTemplate = input.getResponse;
|
|
19
27
|
this.payload = input.requestBody;
|
|
20
28
|
this.parameters = input.parameters;
|
|
21
|
-
this.type = input.type;
|
|
29
|
+
this.type = API_METHODS[input.type];
|
|
22
30
|
this.helper = templateHelpers;
|
|
23
31
|
}
|
|
24
32
|
|
|
@@ -51,15 +59,29 @@ class APITemplate {
|
|
|
51
59
|
}
|
|
52
60
|
|
|
53
61
|
return `${this.getApi(obj)}?${query}`;
|
|
54
|
-
}
|
|
62
|
+
} // eslint-disable-next-line max-lines-per-function
|
|
63
|
+
|
|
55
64
|
|
|
56
65
|
getApiDetails(obj) {
|
|
57
|
-
|
|
66
|
+
const apiDetails = {
|
|
58
67
|
url: this.constructURL(obj),
|
|
59
68
|
type: this.type,
|
|
60
69
|
method: this.type,
|
|
61
70
|
payload: this.getPayload(obj)
|
|
62
71
|
};
|
|
72
|
+
|
|
73
|
+
if (this.getResponseInTemplate) {
|
|
74
|
+
apiDetails.getResponse = () => {
|
|
75
|
+
const payload = JSON.parse(this.getPayload(obj));
|
|
76
|
+
const params = JSON.parse(this.getParameter(obj));
|
|
77
|
+
return this.getResponseInTemplate({
|
|
78
|
+
payload,
|
|
79
|
+
params
|
|
80
|
+
});
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
return apiDetails;
|
|
63
85
|
}
|
|
64
86
|
|
|
65
87
|
getTransformer() {
|
|
@@ -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, RECORD_LOCAL_MULTIPLE_DELETE, RECORD_LOCAL_UPDATE, RecordApiActionName } from "../../../bc/zrecord/Constants";
|
|
4
|
+
import { APPEND_RECORDS, SET_RECORDS, RECORD_EXECUTE_FAILED, RECORD_EXECUTE_SUCCEEDED, 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,20 +16,46 @@ 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
|
+
|
|
19
26
|
createFetchRecordMeta(actionName, apiName, headers, props) {
|
|
20
27
|
let successMeta = {
|
|
21
|
-
type:
|
|
22
|
-
metaData: {
|
|
28
|
+
type: '',
|
|
29
|
+
metaData: {
|
|
30
|
+
props
|
|
31
|
+
}
|
|
23
32
|
};
|
|
24
33
|
let successNoContentMeta = {
|
|
25
34
|
type: '',
|
|
26
|
-
metaData: {
|
|
35
|
+
metaData: {
|
|
36
|
+
props
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
let failureMeta = {
|
|
40
|
+
type: '',
|
|
41
|
+
metaData: {
|
|
42
|
+
props
|
|
43
|
+
}
|
|
27
44
|
};
|
|
28
45
|
|
|
29
46
|
if (RecordApiActionName.UPDATE_RECORD === actionName) {
|
|
30
47
|
successMeta = {
|
|
31
48
|
type: RECORD_LOCAL_UPDATE,
|
|
32
|
-
metaData: {
|
|
49
|
+
metaData: {
|
|
50
|
+
props
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
} else if (RecordApiActionName.GET_RECORDS === actionName) {
|
|
54
|
+
successMeta = {
|
|
55
|
+
type: SET_RECORDS,
|
|
56
|
+
metaData: {
|
|
57
|
+
props
|
|
58
|
+
}
|
|
33
59
|
};
|
|
34
60
|
} else if (RecordApiActionName.DELETE_RECORDS === actionName) {
|
|
35
61
|
successMeta = {
|
|
@@ -44,6 +70,19 @@ export default class RecordsManager {
|
|
|
44
70
|
props
|
|
45
71
|
}
|
|
46
72
|
};
|
|
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
|
+
};
|
|
47
86
|
}
|
|
48
87
|
|
|
49
88
|
return {
|
|
@@ -51,22 +90,41 @@ export default class RecordsManager {
|
|
|
51
90
|
apiName,
|
|
52
91
|
actionName,
|
|
53
92
|
[RECORD_NO_CONTENT]: successNoContentMeta,
|
|
93
|
+
[RECORD_FAILURE]: failureMeta,
|
|
54
94
|
[RECORD_SUCCESS]: successMeta
|
|
55
95
|
};
|
|
56
96
|
}
|
|
57
97
|
|
|
58
|
-
createFetchMoreRecordMeta(actionName, apiName, headers) {
|
|
98
|
+
createFetchMoreRecordMeta(actionName, apiName, headers, props) {
|
|
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
|
+
};
|
|
59
117
|
return {
|
|
60
118
|
headers,
|
|
61
119
|
apiName,
|
|
62
120
|
actionName,
|
|
63
|
-
[
|
|
64
|
-
|
|
65
|
-
|
|
121
|
+
[RECORD_NO_CONTENT]: successNoContentMeta,
|
|
122
|
+
[RECORD_FAILURE]: failureMeta,
|
|
123
|
+
[RECORD_SUCCESS]: successMeta
|
|
66
124
|
};
|
|
67
125
|
}
|
|
68
126
|
|
|
69
|
-
|
|
127
|
+
createSuccessActions(transformedResponse, metaData) {
|
|
70
128
|
const {
|
|
71
129
|
actionName
|
|
72
130
|
} = metaData;
|
|
@@ -74,32 +132,83 @@ export default class RecordsManager {
|
|
|
74
132
|
type,
|
|
75
133
|
metaData: successMeta
|
|
76
134
|
} = metaData[RECORD_SUCCESS];
|
|
135
|
+
const actions = [];
|
|
77
136
|
|
|
78
137
|
if (RecordApiActionName.UPDATE_RECORD === actionName) {
|
|
79
|
-
|
|
138
|
+
const record = transformedResponse;
|
|
139
|
+
const recordId = transformedResponse.id;
|
|
140
|
+
type && actions.push({
|
|
80
141
|
type,
|
|
142
|
+
metaData,
|
|
81
143
|
payload: {
|
|
82
|
-
record
|
|
83
|
-
recordId
|
|
144
|
+
record,
|
|
145
|
+
recordId
|
|
84
146
|
}
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
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({
|
|
90
160
|
type,
|
|
161
|
+
metaData,
|
|
91
162
|
payload: {
|
|
92
|
-
recordIds
|
|
163
|
+
recordIds
|
|
93
164
|
}
|
|
94
|
-
};
|
|
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({
|
|
178
|
+
type,
|
|
179
|
+
metaData,
|
|
180
|
+
payload: {
|
|
181
|
+
recordIds
|
|
182
|
+
}
|
|
183
|
+
});
|
|
184
|
+
actions.push({
|
|
185
|
+
type: RECORD_EXECUTE_SUCCEEDED,
|
|
186
|
+
metaData,
|
|
187
|
+
payload: {
|
|
188
|
+
actionName,
|
|
189
|
+
recordId
|
|
190
|
+
}
|
|
191
|
+
});
|
|
192
|
+
} else if (RecordApiActionName.GET_RECORDS === actionName) {
|
|
193
|
+
const records = transformedResponse;
|
|
194
|
+
actions.push({
|
|
195
|
+
type,
|
|
196
|
+
metaData,
|
|
197
|
+
payload: {
|
|
198
|
+
records
|
|
199
|
+
}
|
|
200
|
+
});
|
|
201
|
+
actions.push({
|
|
202
|
+
type: RECORD_EXECUTE_SUCCEEDED,
|
|
203
|
+
metaData,
|
|
204
|
+
payload: {
|
|
205
|
+
actionName,
|
|
206
|
+
records
|
|
207
|
+
}
|
|
208
|
+
});
|
|
95
209
|
}
|
|
96
210
|
|
|
97
|
-
return
|
|
98
|
-
type,
|
|
99
|
-
payload: {
|
|
100
|
-
records: transformedRes
|
|
101
|
-
}
|
|
102
|
-
};
|
|
211
|
+
return actions;
|
|
103
212
|
}
|
|
104
213
|
|
|
105
214
|
createNoContentAction(metaData) {
|
|
@@ -108,40 +217,132 @@ export default class RecordsManager {
|
|
|
108
217
|
} = metaData;
|
|
109
218
|
const {
|
|
110
219
|
type,
|
|
111
|
-
payload,
|
|
112
220
|
metaData: noContentMeta
|
|
113
221
|
} = metaData[RECORD_NO_CONTENT];
|
|
114
222
|
|
|
115
223
|
if (RecordApiActionName.DELETE_RECORDS === actionName) {
|
|
116
224
|
return {
|
|
117
225
|
type,
|
|
226
|
+
metaData,
|
|
118
227
|
payload: {
|
|
119
228
|
recordIds: noContentMeta.props.recordIds
|
|
120
229
|
}
|
|
121
230
|
};
|
|
122
231
|
}
|
|
123
232
|
|
|
233
|
+
if (RecordApiActionName.DELETE_RECORD === actionName) {
|
|
234
|
+
return {
|
|
235
|
+
type,
|
|
236
|
+
metaData,
|
|
237
|
+
payload: {
|
|
238
|
+
recordId: noContentMeta.props.recordId
|
|
239
|
+
}
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
|
|
124
243
|
return {
|
|
125
244
|
type,
|
|
126
|
-
|
|
245
|
+
metaData,
|
|
246
|
+
payload: {}
|
|
127
247
|
};
|
|
128
248
|
}
|
|
129
249
|
|
|
130
|
-
|
|
250
|
+
createFailureActions(error, metaData) {
|
|
251
|
+
const {
|
|
252
|
+
actionName
|
|
253
|
+
} = metaData;
|
|
131
254
|
const {
|
|
132
|
-
type
|
|
133
|
-
} = metaData[RECORD_FAILURE];
|
|
134
|
-
return {
|
|
135
255
|
type,
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
256
|
+
metaData: failureMeta
|
|
257
|
+
} = metaData[RECORD_FAILURE];
|
|
258
|
+
const actions = [];
|
|
259
|
+
|
|
260
|
+
if (RecordApiActionName.UPDATE_RECORD === actionName) {
|
|
261
|
+
const {
|
|
262
|
+
recordId
|
|
263
|
+
} = failureMeta.props;
|
|
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;
|
|
140
341
|
}
|
|
141
342
|
|
|
142
343
|
getApiDetails(actionName, props) {
|
|
143
344
|
return this.apiTemplates.getApiDetails(actionName, { ...props,
|
|
144
|
-
from: this.records.getRecordsLength()
|
|
345
|
+
from: this.records.getRecordsLength() + 1
|
|
145
346
|
});
|
|
146
347
|
}
|
|
147
348
|
|
|
@@ -158,6 +359,10 @@ export default class RecordsManager {
|
|
|
158
359
|
this.records.setHasMore(true);
|
|
159
360
|
}
|
|
160
361
|
|
|
362
|
+
setNoMoreDataInRecords() {
|
|
363
|
+
this.records.setHasMore(false);
|
|
364
|
+
}
|
|
365
|
+
|
|
161
366
|
hasMoreRecords() {
|
|
162
367
|
return this.records.hasMoreRecords();
|
|
163
368
|
}
|
|
@@ -166,6 +371,11 @@ export default class RecordsManager {
|
|
|
166
371
|
return this.records.isRecordsFetching();
|
|
167
372
|
}
|
|
168
373
|
|
|
374
|
+
setRecords(records) {
|
|
375
|
+
this.records.setRecords(records);
|
|
376
|
+
this.records.updateHasMore(records.length);
|
|
377
|
+
}
|
|
378
|
+
|
|
169
379
|
appendRecords(records) {
|
|
170
380
|
this.records.appendRecords(records);
|
|
171
381
|
this.records.updateHasMore(records.length);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import { RECORD_FAILURE, RECORD_SUCCESS } from "../../../../bc/zrecord/Symbols";
|
|
1
|
+
import { RECORD_FAILURE, RECORD_NO_CONTENT, 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, RECORD_REFETCH } from "../../../bc/zrecord/Constants";
|
|
2
|
+
import { APPEND_RECORDS, RECORD_EXECUTE, RECORD_FETCH_MORE, RECORD_FIELD_CHANGE, RECORD_LOCAL_MULTIPLE_DELETE, RECORD_LOCAL_UPDATE, SET_RECORDS, 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,6 +16,7 @@ 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";
|
|
19
20
|
export default class ActionsHandlersFactory {
|
|
20
21
|
static create(apiDetails) {
|
|
21
22
|
const presenter = new Presenter();
|
|
@@ -35,6 +36,7 @@ export default class ActionsHandlersFactory {
|
|
|
35
36
|
const refetchController = new RefetchController(service);
|
|
36
37
|
const noContentController = new NoContentController(service);
|
|
37
38
|
const appendRecordsController = new AppendRecordsController(service);
|
|
39
|
+
const setRecordsController = new SetRecordsController(service);
|
|
38
40
|
const fieldChangeController = new FieldChangeController(service);
|
|
39
41
|
const recordUpdateLocalController = new RecordUpdateLocalController(service);
|
|
40
42
|
const deleteMultipleRecordLocalController = new DeleteMultipleRecordLocalController(service);
|
|
@@ -47,6 +49,7 @@ export default class ActionsHandlersFactory {
|
|
|
47
49
|
[FETCH_SUCCESS]: successController.handle,
|
|
48
50
|
[RECORD_LOCAL_MULTIPLE_DELETE]: deleteMultipleRecordLocalController.handle,
|
|
49
51
|
[APPEND_RECORDS]: appendRecordsController.handle,
|
|
52
|
+
[SET_RECORDS]: setRecordsController.handle,
|
|
50
53
|
[RECORD_FIELD_CHANGE]: fieldChangeController.handle,
|
|
51
54
|
[RECORD_LOCAL_UPDATE]: recordUpdateLocalController.handle,
|
|
52
55
|
[FETCH_SUCCESS_NO_CONTENT]: noContentController.handle
|
|
@@ -22,8 +22,12 @@ 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
|
-
|
|
25
|
+
|
|
26
|
+
if (recordManager.isGetRecordsApi(metaData)) {
|
|
27
|
+
recordManager.fetchingStarted();
|
|
28
|
+
presenter.updateRecord(recordManager.toObject());
|
|
29
|
+
}
|
|
30
|
+
|
|
27
31
|
dispatch(recordManager.createFetchAction(apiDetails, metaData));
|
|
28
32
|
}
|
|
29
33
|
|