@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
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
var FieldTypes = /*#__PURE__*/function (FieldTypes) {
|
|
2
|
+
FieldTypes["Boolean"] = "CheckboxField";
|
|
3
|
+
FieldTypes["SingleLine"] = "SingleLineField";
|
|
4
|
+
FieldTypes["MultiLine"] = "MultiLineField";
|
|
5
|
+
FieldTypes["URL"] = "URLField";
|
|
6
|
+
FieldTypes["Email"] = "EmailField";
|
|
7
|
+
FieldTypes["Phone"] = "PhoneField";
|
|
8
|
+
FieldTypes["Currency"] = "CurrencyField";
|
|
9
|
+
FieldTypes["Percentage"] = "PercentageField";
|
|
10
|
+
FieldTypes["Date"] = "DateField";
|
|
11
|
+
FieldTypes["DateTime"] = "DateTimeField";
|
|
12
|
+
FieldTypes["PickList"] = "PickListField";
|
|
13
|
+
FieldTypes["MultiSelect"] = "MultiSelectField";
|
|
14
|
+
FieldTypes["LookUp"] = "LookUpField";
|
|
15
|
+
FieldTypes["Number"] = "NumberField";
|
|
16
|
+
FieldTypes["Decimal"] = "DecimalField";
|
|
17
|
+
return FieldTypes;
|
|
18
|
+
}(FieldTypes || {});
|
|
19
|
+
|
|
20
|
+
export default FieldTypes;
|
|
@@ -0,0 +1,109 @@
|
|
|
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
|
+
import * as FieldEntities from "../../entities";
|
|
4
|
+
|
|
5
|
+
class FieldBuilder {
|
|
6
|
+
constructor() {
|
|
7
|
+
_defineProperty(this, "id", void 0);
|
|
8
|
+
|
|
9
|
+
_defineProperty(this, "type", void 0);
|
|
10
|
+
|
|
11
|
+
_defineProperty(this, "name", void 0);
|
|
12
|
+
|
|
13
|
+
_defineProperty(this, "displayLabel", void 0);
|
|
14
|
+
|
|
15
|
+
_defineProperty(this, "isCustomField", void 0);
|
|
16
|
+
|
|
17
|
+
_defineProperty(this, "i18NLabel", void 0);
|
|
18
|
+
|
|
19
|
+
_defineProperty(this, "isSortable", void 0);
|
|
20
|
+
|
|
21
|
+
_defineProperty(this, "isVisible", void 0);
|
|
22
|
+
|
|
23
|
+
_defineProperty(this, "isReadOnly", void 0);
|
|
24
|
+
|
|
25
|
+
_defineProperty(this, "isEncryptedField", void 0);
|
|
26
|
+
|
|
27
|
+
_defineProperty(this, "isPHI", void 0);
|
|
28
|
+
|
|
29
|
+
_defineProperty(this, "maxLength", void 0);
|
|
30
|
+
|
|
31
|
+
_defineProperty(this, "isMandatory", void 0);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
setId(id) {
|
|
35
|
+
this.id = id;
|
|
36
|
+
return this;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
setType(type) {
|
|
40
|
+
if (!FieldEntities[type]) {
|
|
41
|
+
throw new Error(`Invalid field type: ${type}`);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
this.type = type;
|
|
45
|
+
return this;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
setName(name) {
|
|
49
|
+
this.name = name;
|
|
50
|
+
return this;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
setDisplayLabel(displayLabel) {
|
|
54
|
+
this.displayLabel = displayLabel;
|
|
55
|
+
return this;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
setIsCustomField(isCustomField) {
|
|
59
|
+
this.isCustomField = isCustomField;
|
|
60
|
+
return this;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
setI18NLabel(i18NLabel) {
|
|
64
|
+
this.i18NLabel = i18NLabel;
|
|
65
|
+
return this;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
setIsSortable(isSortable) {
|
|
69
|
+
this.isSortable = isSortable;
|
|
70
|
+
return this;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
setIsVisible(isVisible) {
|
|
74
|
+
this.isVisible = isVisible;
|
|
75
|
+
return this;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
setIsReadOnly(isReadOnly) {
|
|
79
|
+
this.isReadOnly = isReadOnly;
|
|
80
|
+
return this;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
setIsEncryptedField(isEncryptedField) {
|
|
84
|
+
this.isEncryptedField = isEncryptedField;
|
|
85
|
+
return this;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
setIsPHI(isPHI) {
|
|
89
|
+
this.isPHI = isPHI;
|
|
90
|
+
return this;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
setMaxLength(maxLength) {
|
|
94
|
+
this.maxLength = maxLength;
|
|
95
|
+
return this;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
setIsMandatory(isMandatory) {
|
|
99
|
+
this.isMandatory = isMandatory;
|
|
100
|
+
return this;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
build() {
|
|
104
|
+
return new FieldEntities[this.type](this.id, this.type, this.name, this.displayLabel, this.isCustomField, this.i18NLabel, this.isSortable, this.isVisible, this.isReadOnly, this.isEncryptedField, this.isPHI, this.maxLength, this.isMandatory);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export default FieldBuilder;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import FieldBuilder from "./FieldBuilder";
|
|
2
|
+
|
|
3
|
+
class FieldFactory {
|
|
4
|
+
static create(input) {
|
|
5
|
+
return new FieldBuilder().setId(input.id).setType(input.type).setName(input.name).setDisplayLabel(input.displayLabel).setIsCustomField(input.isCustomField).setI18NLabel(input.i18NLabel).setIsSortable(input.isSortable).setIsVisible(input.isVisible).setIsReadOnly(input.isReadOnly).setIsEncryptedField(input.isEncryptedField).setIsPHI(input.isPHI).setMaxLength(input.maxLength).setIsMandatory(input.isMandatory).build();
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export default FieldFactory;
|
|
@@ -0,0 +1,49 @@
|
|
|
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
|
+
import FieldsManager from "../../entities/fields-manager/FieldsManager";
|
|
4
|
+
|
|
5
|
+
class FieldsManagerBuilder {
|
|
6
|
+
constructor() {
|
|
7
|
+
_defineProperty(this, "availableFields", void 0);
|
|
8
|
+
|
|
9
|
+
_defineProperty(this, "selectedFields", void 0);
|
|
10
|
+
|
|
11
|
+
_defineProperty(this, "isAvailableFieldsFetching", void 0);
|
|
12
|
+
|
|
13
|
+
_defineProperty(this, "isSelectedFieldsFetching", void 0);
|
|
14
|
+
|
|
15
|
+
_defineProperty(this, "apiTemplate", void 0);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
setAvailableFields(availableFields) {
|
|
19
|
+
this.availableFields = availableFields;
|
|
20
|
+
return this;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
setSelectedFields(selectedFields) {
|
|
24
|
+
this.selectedFields = selectedFields;
|
|
25
|
+
return this;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
setAvailableFieldsFetchingStatus(isAvailableFieldsFetching) {
|
|
29
|
+
this.isAvailableFieldsFetching = isAvailableFieldsFetching;
|
|
30
|
+
return this;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
setSelectedFieldsFetchingStatus(isSelectedFieldsFetching) {
|
|
34
|
+
this.isSelectedFieldsFetching = isSelectedFieldsFetching;
|
|
35
|
+
return this;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
setApiTemplate(apiTemplate) {
|
|
39
|
+
this.apiTemplate = apiTemplate;
|
|
40
|
+
return this;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
build() {
|
|
44
|
+
return new FieldsManager(this.availableFields, this.selectedFields, this.isAvailableFieldsFetching, this.isSelectedFieldsFetching, this.apiTemplate);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export default FieldsManagerBuilder;
|
|
@@ -17,14 +17,12 @@ class FetchController {
|
|
|
17
17
|
const {
|
|
18
18
|
url,
|
|
19
19
|
method,
|
|
20
|
-
headers
|
|
21
|
-
getResponse
|
|
20
|
+
headers
|
|
22
21
|
} = payload;
|
|
23
22
|
this.fetchUseCase.execute({
|
|
24
23
|
url,
|
|
25
24
|
method,
|
|
26
25
|
headers,
|
|
27
|
-
getResponse,
|
|
28
26
|
metaData,
|
|
29
27
|
dispatch,
|
|
30
28
|
payload: payload.payload
|
|
@@ -11,8 +11,7 @@ class FetchUseCase extends AbstractUseCase {
|
|
|
11
11
|
} = this.dependencies;
|
|
12
12
|
const {
|
|
13
13
|
url,
|
|
14
|
-
method = 'GET'
|
|
15
|
-
getResponse
|
|
14
|
+
method = 'GET'
|
|
16
15
|
} = inputModel;
|
|
17
16
|
const {
|
|
18
17
|
metaData,
|
|
@@ -33,54 +32,27 @@ class FetchUseCase extends AbstractUseCase {
|
|
|
33
32
|
});
|
|
34
33
|
|
|
35
34
|
try {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
35
|
+
const response = await fetchGateWay.fetch(url, {
|
|
36
|
+
headers,
|
|
37
|
+
method,
|
|
38
|
+
body: method === "GET" ? null : payload
|
|
39
|
+
});
|
|
39
40
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
} else {
|
|
47
|
-
dispatch({
|
|
48
|
-
type: FETCH_SUCCESS,
|
|
49
|
-
payload: {
|
|
50
|
-
response: data
|
|
51
|
-
},
|
|
52
|
-
metaData
|
|
53
|
-
});
|
|
54
|
-
}
|
|
41
|
+
if (response.status === 204) {
|
|
42
|
+
dispatch({
|
|
43
|
+
type: FETCH_SUCCESS_NO_CONTENT,
|
|
44
|
+
payload: {},
|
|
45
|
+
metaData
|
|
46
|
+
});
|
|
55
47
|
} else {
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
48
|
+
const data = await response.json();
|
|
49
|
+
dispatch({
|
|
50
|
+
type: FETCH_SUCCESS,
|
|
51
|
+
payload: {
|
|
52
|
+
response: data
|
|
53
|
+
},
|
|
54
|
+
metaData
|
|
60
55
|
});
|
|
61
|
-
|
|
62
|
-
if (response.status === 204) {
|
|
63
|
-
dispatch({
|
|
64
|
-
type: FETCH_SUCCESS_NO_CONTENT,
|
|
65
|
-
payload: {},
|
|
66
|
-
metaData
|
|
67
|
-
});
|
|
68
|
-
} else if (response.status === 200 && method === 'DELETE') {
|
|
69
|
-
dispatch({
|
|
70
|
-
type: FETCH_SUCCESS,
|
|
71
|
-
payload: {},
|
|
72
|
-
metaData
|
|
73
|
-
});
|
|
74
|
-
} else {
|
|
75
|
-
const data = await response.json();
|
|
76
|
-
dispatch({
|
|
77
|
-
type: FETCH_SUCCESS,
|
|
78
|
-
payload: {
|
|
79
|
-
response: data
|
|
80
|
-
},
|
|
81
|
-
metaData
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
56
|
}
|
|
85
57
|
} catch (e) {
|
|
86
58
|
dispatch({
|
|
@@ -7,9 +7,6 @@ import FieldChangeUseCase from "../../usecases/interactors/FieldChangeUseCase";
|
|
|
7
7
|
import DeleteMultipleRecordUseCase from "../../usecases/interactors/DeleteMultipleRecordUseCase";
|
|
8
8
|
import SortUseCase from "../../usecases/interactors/SortUseCase";
|
|
9
9
|
import RecordUpdateUseCase from "../../usecases/interactors/RecordUpdateUseCase";
|
|
10
|
-
import DeleteSingleRecordUseCase from "../../usecases/interactors/DeleteSingleRecordUseCase";
|
|
11
|
-
import RecordExecuteSucceededUseCase from "../../usecases/interactors/RecordExecuteSucceededUseCase";
|
|
12
|
-
import RecordExecuteFailedUseCase from "../../usecases/interactors/RecordExecuteFailedUseCase";
|
|
13
10
|
|
|
14
11
|
class Service {
|
|
15
12
|
constructor(dependencies) {
|
|
@@ -25,12 +22,6 @@ class Service {
|
|
|
25
22
|
|
|
26
23
|
_defineProperty(this, "deleteMultipleRecordUseCase", void 0);
|
|
27
24
|
|
|
28
|
-
_defineProperty(this, "deleteSingleRecordUseCase", void 0);
|
|
29
|
-
|
|
30
|
-
_defineProperty(this, "recordExecuteSucceededUseCase", void 0);
|
|
31
|
-
|
|
32
|
-
_defineProperty(this, "recordExecuteFailedUseCase", void 0);
|
|
33
|
-
|
|
34
25
|
_defineProperty(this, "sortUseCase", void 0);
|
|
35
26
|
|
|
36
27
|
_defineProperty(this, "recordUpdateUseCase", void 0);
|
|
@@ -41,9 +32,6 @@ class Service {
|
|
|
41
32
|
this.fieldChangeUseCase = new FieldChangeUseCase(this.dependencies);
|
|
42
33
|
this.sortUseCase = new SortUseCase(this.dependencies);
|
|
43
34
|
this.deleteMultipleRecordUseCase = new DeleteMultipleRecordUseCase(this.dependencies);
|
|
44
|
-
this.deleteSingleRecordUseCase = new DeleteSingleRecordUseCase(this.dependencies);
|
|
45
|
-
this.recordExecuteSucceededUseCase = new RecordExecuteSucceededUseCase(this.dependencies);
|
|
46
|
-
this.recordExecuteFailedUseCase = new RecordExecuteFailedUseCase(this.dependencies);
|
|
47
35
|
this.recordUpdateUseCase = new RecordUpdateUseCase(this.dependencies);
|
|
48
36
|
}
|
|
49
37
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import FieldTypes from "../../../../../../cc/fields/field/Types";
|
|
2
2
|
import BooleanFieldModel from "../../../../../../cc/fields/boolean/Model";
|
|
3
3
|
|
|
4
|
-
const BooleanFieldTranslator = (field, value
|
|
4
|
+
const BooleanFieldTranslator = (field, value) => {
|
|
5
5
|
const {
|
|
6
6
|
uiType,
|
|
7
7
|
name
|
|
@@ -16,7 +16,6 @@ const BooleanFieldTranslator = (field, value, appendToActionPayload) => {
|
|
|
16
16
|
return BooleanFieldModel({
|
|
17
17
|
uiType: uiType || FieldTypes.CheckboxField,
|
|
18
18
|
name,
|
|
19
|
-
appendToActionPayload,
|
|
20
19
|
value
|
|
21
20
|
});
|
|
22
21
|
};
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { RECORD_EXECUTE, RECORD_FETCH_MORE, RECORD_REFETCH, RecordApiActionName } from "../../../bc/zrecord/Constants";
|
|
2
2
|
import { FIELD_EXECUTE, FIELD_REFETCH } from "../../../bc/zfield/Constants";
|
|
3
|
-
import { ZLIST_RECORD_DELETE_FAILED, ZLIST_RECORD_DELETE_SUCCEEDED, ZLIST_RECORD_UPDATE_FAILED, ZLIST_RECORD_UPDATE_SUCCEEDED } from "../../../bc/zlist/Constants";
|
|
4
3
|
|
|
5
4
|
class List {
|
|
6
5
|
constructor(limit, sortBy, filter, headers) {
|
|
@@ -11,12 +10,14 @@ class List {
|
|
|
11
10
|
}
|
|
12
11
|
|
|
13
12
|
createApiProps() {
|
|
13
|
+
let from = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
|
|
14
14
|
const {
|
|
15
15
|
filter,
|
|
16
16
|
limit,
|
|
17
17
|
sortBy
|
|
18
18
|
} = this;
|
|
19
19
|
return {
|
|
20
|
+
from,
|
|
20
21
|
limit,
|
|
21
22
|
sortBy,
|
|
22
23
|
...filter
|
|
@@ -105,95 +106,6 @@ class List {
|
|
|
105
106
|
};
|
|
106
107
|
}
|
|
107
108
|
|
|
108
|
-
getDeleteSingleRecordAction(recordId) {
|
|
109
|
-
const props = this.createApiProps();
|
|
110
|
-
return {
|
|
111
|
-
type: RECORD_EXECUTE,
|
|
112
|
-
payload: {
|
|
113
|
-
actionName: RecordApiActionName.DELETE_RECORD,
|
|
114
|
-
props: { ...props,
|
|
115
|
-
recordId
|
|
116
|
-
},
|
|
117
|
-
apiName: 'records'
|
|
118
|
-
},
|
|
119
|
-
metaData: {
|
|
120
|
-
headers: this.headers
|
|
121
|
-
}
|
|
122
|
-
};
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
getRecordExecuteSucceededActions(payload, metaData) {
|
|
126
|
-
const {
|
|
127
|
-
actionName
|
|
128
|
-
} = metaData;
|
|
129
|
-
const actions = [];
|
|
130
|
-
|
|
131
|
-
if (actionName === RecordApiActionName.DELETE_RECORD) {
|
|
132
|
-
const {
|
|
133
|
-
recordId
|
|
134
|
-
} = payload;
|
|
135
|
-
actions.push({
|
|
136
|
-
type: ZLIST_RECORD_DELETE_SUCCEEDED,
|
|
137
|
-
payload: {
|
|
138
|
-
recordId
|
|
139
|
-
}
|
|
140
|
-
});
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
if (actionName === RecordApiActionName.UPDATE_RECORD) {
|
|
144
|
-
const {
|
|
145
|
-
recordId,
|
|
146
|
-
record
|
|
147
|
-
} = payload;
|
|
148
|
-
actions.push({
|
|
149
|
-
type: ZLIST_RECORD_UPDATE_SUCCEEDED,
|
|
150
|
-
payload: {
|
|
151
|
-
recordId,
|
|
152
|
-
record
|
|
153
|
-
}
|
|
154
|
-
});
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
return actions;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
getRecordExecuteFailedActions(payload, metaData) {
|
|
161
|
-
const {
|
|
162
|
-
actionName
|
|
163
|
-
} = metaData;
|
|
164
|
-
const actions = [];
|
|
165
|
-
|
|
166
|
-
if (actionName === RecordApiActionName.DELETE_RECORD) {
|
|
167
|
-
const {
|
|
168
|
-
recordId,
|
|
169
|
-
error
|
|
170
|
-
} = payload;
|
|
171
|
-
actions.push({
|
|
172
|
-
type: ZLIST_RECORD_DELETE_FAILED,
|
|
173
|
-
payload: {
|
|
174
|
-
recordId,
|
|
175
|
-
error
|
|
176
|
-
}
|
|
177
|
-
});
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
if (actionName === RecordApiActionName.UPDATE_RECORD) {
|
|
181
|
-
const {
|
|
182
|
-
recordId,
|
|
183
|
-
error
|
|
184
|
-
} = payload;
|
|
185
|
-
actions.push({
|
|
186
|
-
type: ZLIST_RECORD_UPDATE_FAILED,
|
|
187
|
-
payload: {
|
|
188
|
-
recordId,
|
|
189
|
-
error
|
|
190
|
-
}
|
|
191
|
-
});
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
return actions;
|
|
195
|
-
}
|
|
196
|
-
|
|
197
109
|
getDeleteMultipleRecordAction(recordIds) {
|
|
198
110
|
const props = this.createApiProps();
|
|
199
111
|
return {
|
|
@@ -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 {
|
|
7
|
+
import { 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,10 +12,6 @@ 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";
|
|
19
15
|
export default class ActionHandlersFactory {
|
|
20
16
|
static create() {
|
|
21
17
|
const repository = new Repository();
|
|
@@ -31,9 +27,6 @@ export default class ActionHandlersFactory {
|
|
|
31
27
|
fieldChange: new FieldChangeController(service).handle,
|
|
32
28
|
recordUpdate: new RecordUpdateController(service).handle,
|
|
33
29
|
deleteMultipleRecord: new DeleteMultipleRecordController(service).handle,
|
|
34
|
-
deleteRecord: new DeleteSingleRecordController(service).handle,
|
|
35
|
-
recordExecuteSucceeded: new RecordExecuteSucceededController(service).handle,
|
|
36
|
-
recordExecuteFailed: new RecordExecuteFailedController(service).handle,
|
|
37
30
|
sort: new SortController(service).handle
|
|
38
31
|
};
|
|
39
32
|
return {
|
|
@@ -43,9 +36,6 @@ export default class ActionHandlersFactory {
|
|
|
43
36
|
[ZLIST_FETCH_MORE]: controller.fetchMore,
|
|
44
37
|
[ZLIST_RECORD_UPDATE]: controller.recordUpdate,
|
|
45
38
|
[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,
|
|
49
39
|
[ZLIST_FETCH_SORTED]: controller.sort
|
|
50
40
|
};
|
|
51
41
|
}
|
|
@@ -11,7 +11,6 @@ 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";
|
|
15
14
|
export default class Service {
|
|
16
15
|
constructor(dependencies) {
|
|
17
16
|
_defineProperty(this, "initializeUseCase", void 0);
|
|
@@ -28,8 +27,6 @@ export default class Service {
|
|
|
28
27
|
|
|
29
28
|
_defineProperty(this, "appendRecordsUseCase", void 0);
|
|
30
29
|
|
|
31
|
-
_defineProperty(this, "setRecordsUseCase", void 0);
|
|
32
|
-
|
|
33
30
|
_defineProperty(this, "fieldChangeUseCase", void 0);
|
|
34
31
|
|
|
35
32
|
_defineProperty(this, "fetchMoreUseCase", void 0);
|
|
@@ -45,7 +42,6 @@ export default class Service {
|
|
|
45
42
|
this.refetchUseCase = new RefetchUseCase(dependencies);
|
|
46
43
|
this.noContentUseCase = new NoContentUseCase(dependencies);
|
|
47
44
|
this.appendRecordsUseCase = new AppendRecordsUseCase(dependencies);
|
|
48
|
-
this.setRecordsUseCase = new SetRecordsUseCase(dependencies);
|
|
49
45
|
this.fieldChangeUseCase = new FieldChangeUseCase(dependencies);
|
|
50
46
|
this.fetchMoreUseCase = new FetchMoreUseCase(dependencies);
|
|
51
47
|
this.recordUpdateLocalUseCase = new RecordUpdateLocalUseCase(dependencies);
|
|
@@ -1,10 +1,5 @@
|
|
|
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';
|
|
8
3
|
class APITemplate {
|
|
9
4
|
constructor(input, templateHelpers) {
|
|
10
5
|
_defineProperty(this, "input", void 0);
|
|
@@ -19,14 +14,11 @@ class APITemplate {
|
|
|
19
14
|
|
|
20
15
|
_defineProperty(this, "helper", void 0);
|
|
21
16
|
|
|
22
|
-
_defineProperty(this, "getResponseInTemplate", void 0);
|
|
23
|
-
|
|
24
17
|
this.input = input;
|
|
25
18
|
this.api = input.api;
|
|
26
|
-
this.getResponseInTemplate = input.getResponse;
|
|
27
19
|
this.payload = input.requestBody;
|
|
28
20
|
this.parameters = input.parameters;
|
|
29
|
-
this.type =
|
|
21
|
+
this.type = input.type;
|
|
30
22
|
this.helper = templateHelpers;
|
|
31
23
|
}
|
|
32
24
|
|
|
@@ -36,7 +28,7 @@ class APITemplate {
|
|
|
36
28
|
|
|
37
29
|
getPayload(obj) {
|
|
38
30
|
if (this.payload) {
|
|
39
|
-
return
|
|
31
|
+
return this.helper.replaceTemplateVariables(this.payload, obj);
|
|
40
32
|
} else {
|
|
41
33
|
return `{}`;
|
|
42
34
|
}
|
|
@@ -53,29 +45,21 @@ class APITemplate {
|
|
|
53
45
|
constructURL(obj) {
|
|
54
46
|
const queryObj = JSON.parse(this.getParameter(obj));
|
|
55
47
|
const query = this.helper.objectToQueryString(queryObj);
|
|
56
|
-
return `${this.getApi(obj)}?${query}`;
|
|
57
|
-
} // eslint-disable-next-line max-lines-per-function
|
|
58
48
|
|
|
49
|
+
if (query === '') {
|
|
50
|
+
return this.getApi(obj);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return `${this.getApi(obj)}?${query}`;
|
|
54
|
+
}
|
|
59
55
|
|
|
60
56
|
getApiDetails(obj) {
|
|
61
|
-
|
|
57
|
+
return {
|
|
62
58
|
url: this.constructURL(obj),
|
|
63
59
|
type: this.type,
|
|
60
|
+
method: this.type,
|
|
64
61
|
payload: this.getPayload(obj)
|
|
65
62
|
};
|
|
66
|
-
|
|
67
|
-
if (this.getResponseInTemplate) {
|
|
68
|
-
apiDetails.getResponse = () => {
|
|
69
|
-
const payload = this.getPayload(obj);
|
|
70
|
-
const params = JSON.parse(this.getParameter(obj));
|
|
71
|
-
return this.getResponseInTemplate({
|
|
72
|
-
payload,
|
|
73
|
-
params
|
|
74
|
-
});
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
return apiDetails;
|
|
79
63
|
}
|
|
80
64
|
|
|
81
65
|
getTransformer() {
|