@zohodesk/library-platform 1.1.3-exp.2 → 1.1.3-exp.4
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/zhttp/Errors.js +14 -0
- package/es/bc/zhttp/index.js +3 -1
- package/es/bc/zlist/Constants.js +6 -1
- package/es/bc/zlist/Events.js +140 -0
- package/es/bc/zlist/index.js +2 -1
- package/es/cc/component/FallbackView.js +1 -0
- package/es/cc/fields/currency/Model.js +2 -0
- package/es/cc/fields/field/Properties.js +1 -1
- package/es/cc/fields/formula/Model.js +5 -0
- package/es/cc/index.js +1 -0
- package/es/cc/link/Properties.js +0 -1
- package/es/cc/table-connected/ErrorEventType.js +32 -0
- package/es/cc/table-connected/Events.js +96 -0
- package/es/cc/table-connected/SdkContract.js +120 -0
- package/es/cc/table-connected/constants/Events.js +2 -0
- package/es/cc/table-connected/index.js +3 -1
- package/es/cc/table-list/Properties.js +9 -0
- package/es/cc/table-list/row/Properties.js +9 -0
- package/es/index.js +2 -1
- package/es/library/custom-component/adapters/gateways/event-manager/EventManager.js +116 -4
- package/es/library/custom-component/applications/interfaces/gateways/ISchemaValidator.js +1 -0
- package/es/library/custom-component/applications/usecases/InitializeUseCase.js +3 -2
- package/es/library/custom-component/applications/usecases/UpdatePropertyUseCase.js +3 -2
- package/es/library/custom-component/domain/entities/Component.js +16 -3
- package/es/library/custom-component/domain/entities/Properties.js +19 -1
- package/es/library/custom-component/frameworks/json-schema-validator/Validator.js +36 -1
- package/es/library/custom-component/frameworks/ui/CreateCustomComponent.js +23 -11
- package/es/library/custom-component/frameworks/ui/DependencyFactory.js +4 -3
- package/es/library/dot/components/table-list/frameworks/hooks/useRowData.js +12 -5
- package/es/library/dot/components/table-list/frameworks/hooks/useTableRowReorder.js +17 -5
- package/es/library/dot/components/table-list/frameworks/ui/TableListView.js +35 -26
- package/es/library/dot/components/table-list/frameworks/ui/css/TableList.module.css +152 -56
- package/es/library/dot/components/table-list/frameworks/ui/sub-components/Header.js +22 -16
- package/es/library/dot/components/table-list/frameworks/ui/sub-components/Rows.js +7 -4
- package/es/library/dot/components/table-list/frameworks/ui/sub-components/header/MassAction.js +5 -13
- package/es/library/dot/components/table-list/frameworks/ui/sub-components/row/Row.js +31 -34
- package/es/library/dot/components/table-list/frameworks/ui/sub-components/row/RowSelection.js +3 -8
- package/es/library/dot/components/table-list/frameworks/utils/getHeaderClasses.js +37 -0
- package/es/library/dot/components/table-list/frameworks/utils/getTableListClassName.js +37 -0
- package/es/library/dot/components/table-list/frameworks/utils/reOrder.js +28 -14
- package/es/library/dot/legacy-to-new-arch/text-area/frameworks/ui/TextAreaView.js +1 -1
- package/es/platform/client-actions/components/action-event-mediator/frameworks/ui/ClientActionsAdapter.js +96 -0
- package/es/platform/client-actions/components/action-event-mediator/frameworks/ui/EventHandlersFactory.js +11 -3
- package/es/platform/client-actions/template-resolver/index.js +1 -0
- package/es/platform/client-actions/translators/context-resolver/index.js +6 -6
- package/es/platform/components/table-connected/adapters/controllers/ColumnChooserOpenedController.js +1 -1
- package/es/platform/components/table-connected/adapters/resources/ErrorPrinter.js +20 -0
- package/es/platform/components/table-connected/adapters/resources/SmartTableResource.js +71 -0
- package/es/platform/components/table-connected/frameworks/ErrorEventHandlersFactory.js +126 -0
- package/es/platform/components/table-connected/frameworks/EventHandlersFactory.js +34 -1
- package/es/platform/components/table-connected/frameworks/TableConnectedFactory.js +2 -0
- package/es/platform/components/table-connected/frameworks/TableConnectedView.js +5 -1
- package/es/platform/zdata-source/domain/entities/DataSource.js +18 -12
- package/es/platform/zfield/domain/entities/fields-manager/FieldsManager.js +7 -1
- package/es/platform/zform/adapters/presenter/FormTranslator.js +6 -127
- package/es/platform/zform/adapters/presenter/translators/SectionTranslator.js +32 -0
- package/es/platform/zform/adapters/presenter/translators/fields/BooleanFieldTranslator.js +20 -0
- package/es/platform/zform/adapters/presenter/translators/fields/CurrencyFieldTranslator.js +29 -0
- package/es/platform/zform/adapters/presenter/translators/fields/DateFieldTranslator.js +20 -0
- package/es/platform/zform/adapters/presenter/translators/fields/DateTimeFieldTranslator.js +21 -0
- package/es/platform/zform/adapters/presenter/translators/fields/DecimalFieldTranslator.js +29 -0
- package/es/platform/zform/adapters/presenter/translators/fields/EmailFieldTranslator.js +30 -0
- package/es/platform/zform/adapters/presenter/translators/fields/LookUpFieldTranslator.js +30 -0
- package/es/platform/zform/adapters/presenter/translators/fields/MultiselectFieldTranslator.js +29 -0
- package/es/platform/zform/adapters/presenter/translators/fields/NumberFieldTranslator.js +30 -0
- package/es/platform/zform/adapters/presenter/translators/fields/PercentageFieldTranslator.js +30 -0
- package/es/platform/zform/adapters/presenter/translators/fields/PhoneFieldTranslator.js +29 -0
- package/es/platform/zform/adapters/presenter/translators/fields/PicklistFieldTranslator.js +29 -0
- package/es/platform/zform/adapters/presenter/translators/fields/TextAreaFieldTranslator.js +30 -0
- package/es/platform/zform/adapters/presenter/translators/fields/TextFieldTranslator.js +27 -0
- package/es/platform/zform/adapters/presenter/translators/fields/URLFieldTranslator.js +30 -0
- package/es/platform/zform/adapters/presenter/translators/fields/index.js +15 -0
- package/es/platform/zform/applications/usecases/MyFormSuccessUseCase.js +3 -1
- package/es/platform/zform/domain/ZField.js +61 -16
- package/es/platform/zform/domain/ZSection.js +20 -7
- package/es/platform/zhttp/applications/usecases/FetchUseCase.js +111 -66
- package/es/platform/zlist/adapters/controllers/FieldExecuteFailedController.js +25 -0
- package/es/platform/zlist/adapters/gateways/Repository.js +5 -2
- package/es/platform/zlist/adapters/presenters/TableTranslator.js +12 -5
- package/es/platform/zlist/adapters/presenters/translators/ColumnTranslator.js +2 -2
- package/es/platform/zlist/adapters/presenters/translators/EmptyViewModel.js +2 -1
- package/es/platform/zlist/adapters/presenters/translators/Header.js +3 -2
- package/es/platform/zlist/adapters/presenters/translators/HeadersTranslator.js +3 -2
- package/es/platform/zlist/adapters/presenters/translators/fields/CurrencyFieldTranslator.js +1 -0
- package/es/platform/zlist/adapters/presenters/translators/fields/FormulaFieldTranslator.js +3 -0
- package/es/platform/zlist/applications/entities-factory/ListFactory.js +3 -2
- package/es/platform/zlist/applications/usecases/FetchMoreUseCase.js +1 -1
- package/es/platform/zlist/applications/usecases/RecordExecuteFailedUseCase.js +3 -2
- package/es/platform/zlist/domain/entities/List.js +12 -63
- package/es/platform/zlist/domain/entities/ListErrorState.js +167 -0
- package/es/platform/zlist/frameworks/EventHandlersFactory.js +6 -0
- package/es/platform/zlist/frameworks/ZListBehaviourFactory.js +6 -1
- package/package.json +3 -3
|
@@ -18,8 +18,11 @@ export default class ZField {
|
|
|
18
18
|
isMandatory,
|
|
19
19
|
value,
|
|
20
20
|
errorMessage,
|
|
21
|
-
|
|
21
|
+
isVisible = true,
|
|
22
22
|
pickListValues,
|
|
23
|
+
toolTip,
|
|
24
|
+
toolTipType,
|
|
25
|
+
defaultValue,
|
|
23
26
|
subType
|
|
24
27
|
} = _ref;
|
|
25
28
|
|
|
@@ -53,7 +56,7 @@ export default class ZField {
|
|
|
53
56
|
|
|
54
57
|
_defineProperty(this, "errorMessage", void 0);
|
|
55
58
|
|
|
56
|
-
_defineProperty(this, "
|
|
59
|
+
_defineProperty(this, "isVisible", void 0);
|
|
57
60
|
|
|
58
61
|
_defineProperty(this, "pickListValues", void 0);
|
|
59
62
|
|
|
@@ -61,6 +64,12 @@ export default class ZField {
|
|
|
61
64
|
|
|
62
65
|
_defineProperty(this, "subType", void 0);
|
|
63
66
|
|
|
67
|
+
_defineProperty(this, "toolTip", void 0);
|
|
68
|
+
|
|
69
|
+
_defineProperty(this, "toolTipType", void 0);
|
|
70
|
+
|
|
71
|
+
_defineProperty(this, "defaultValue", void 0);
|
|
72
|
+
|
|
64
73
|
this.displayLabel = displayLabel;
|
|
65
74
|
this.apiName = apiName;
|
|
66
75
|
this.isCustomField = isCustomField;
|
|
@@ -76,23 +85,53 @@ export default class ZField {
|
|
|
76
85
|
this.isMandatory = isMandatory;
|
|
77
86
|
this.value = value;
|
|
78
87
|
this.errorMessage = errorMessage;
|
|
79
|
-
this.
|
|
88
|
+
this.isVisible = isVisible;
|
|
80
89
|
this.defaultPickListValues = pickListValues;
|
|
81
90
|
this.pickListValues = pickListValues;
|
|
82
91
|
this.subType = subType;
|
|
92
|
+
this.toolTip = toolTip;
|
|
93
|
+
this.toolTipType = toolTipType;
|
|
94
|
+
this.defaultValue = defaultValue; // if(value===undefined){
|
|
95
|
+
// this.setDefaultValue()
|
|
96
|
+
// }
|
|
97
|
+
}
|
|
83
98
|
|
|
84
|
-
|
|
85
|
-
|
|
99
|
+
decideValueForBoolean(defaultValue) {
|
|
100
|
+
if (defaultValue === undefined || defaultValue === null) {
|
|
101
|
+
return false;
|
|
86
102
|
}
|
|
103
|
+
|
|
104
|
+
if (typeof defaultValue === "string") {
|
|
105
|
+
return defaultValue === "true" ? true : false;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
return defaultValue;
|
|
87
109
|
}
|
|
88
110
|
|
|
89
|
-
|
|
90
|
-
if (
|
|
91
|
-
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
111
|
+
decideValueForMultiselect(defaultValue) {
|
|
112
|
+
if (defaultValue === undefined || defaultValue === null) {
|
|
113
|
+
return [];
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
if (typeof defaultValue === "string") {
|
|
117
|
+
return defaultValue.split(";");
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
return defaultValue;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
decideDefaultValue() {
|
|
124
|
+
switch (this.type) {
|
|
125
|
+
case 'Boolean':
|
|
126
|
+
this.value = this.decideValueForBoolean(this.defaultValue);
|
|
127
|
+
break;
|
|
128
|
+
|
|
129
|
+
case 'Multiselect':
|
|
130
|
+
this.value = this.decideValueForMultiselect(this.defaultValue);
|
|
131
|
+
break;
|
|
132
|
+
|
|
133
|
+
default:
|
|
134
|
+
this.value = this.defaultValue === undefined ? '' : this.defaultValue;
|
|
96
135
|
}
|
|
97
136
|
}
|
|
98
137
|
|
|
@@ -125,15 +164,16 @@ export default class ZField {
|
|
|
125
164
|
}
|
|
126
165
|
|
|
127
166
|
toggleVisibility() {
|
|
128
|
-
this.
|
|
167
|
+
this.isVisible = !this.isVisible;
|
|
129
168
|
}
|
|
130
169
|
|
|
131
170
|
setVisibility(visibility) {
|
|
132
|
-
this.
|
|
171
|
+
this.isVisible = visibility;
|
|
133
172
|
}
|
|
134
173
|
|
|
135
174
|
isVisibile() {
|
|
136
|
-
return this.visibility;
|
|
175
|
+
// return this.visibility;
|
|
176
|
+
return this.isVisible;
|
|
137
177
|
}
|
|
138
178
|
|
|
139
179
|
setMandatory(isMandatory) {
|
|
@@ -161,8 +201,13 @@ export default class ZField {
|
|
|
161
201
|
isMandatory: this.isMandatory,
|
|
162
202
|
value: this.value,
|
|
163
203
|
errorMessage: this.errorMessage,
|
|
164
|
-
|
|
204
|
+
// NOTE: visibility is now isVisible, visibility is deprecated, only for backward compatibility of layout rules
|
|
205
|
+
visibility: this.isVisible,
|
|
206
|
+
isVisible: this.isVisible,
|
|
165
207
|
pickListValues: this.pickListValues,
|
|
208
|
+
toolTip: this.toolTip,
|
|
209
|
+
toolTipType: this.toolTipType,
|
|
210
|
+
defaultValue: this.defaultValue,
|
|
166
211
|
subType: this.subType
|
|
167
212
|
};
|
|
168
213
|
}
|
|
@@ -1,14 +1,18 @@
|
|
|
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
3
|
export default class ZSection {
|
|
4
|
+
// Optional field for description
|
|
5
|
+
// private visibility:boolean;
|
|
4
6
|
constructor(_ref) {
|
|
5
7
|
let {
|
|
6
8
|
name,
|
|
7
9
|
i18NLabel,
|
|
8
10
|
isCustomSection,
|
|
11
|
+
description,
|
|
9
12
|
id,
|
|
10
13
|
fields,
|
|
11
|
-
visibility
|
|
14
|
+
// visibility
|
|
15
|
+
isVisible
|
|
12
16
|
} = _ref;
|
|
13
17
|
|
|
14
18
|
_defineProperty(this, "name", void 0);
|
|
@@ -17,18 +21,23 @@ export default class ZSection {
|
|
|
17
21
|
|
|
18
22
|
_defineProperty(this, "isCustomSection", void 0);
|
|
19
23
|
|
|
24
|
+
_defineProperty(this, "description", void 0);
|
|
25
|
+
|
|
20
26
|
_defineProperty(this, "id", void 0);
|
|
21
27
|
|
|
22
28
|
_defineProperty(this, "fields", void 0);
|
|
23
29
|
|
|
24
|
-
_defineProperty(this, "
|
|
30
|
+
_defineProperty(this, "isVisible", void 0);
|
|
25
31
|
|
|
26
32
|
this.name = name;
|
|
27
33
|
this.i18NLabel = i18NLabel;
|
|
28
34
|
this.isCustomSection = isCustomSection;
|
|
35
|
+
this.description = description || ''; // Default to empty string if not provided
|
|
36
|
+
|
|
29
37
|
this.id = id;
|
|
30
|
-
this.fields = fields;
|
|
31
|
-
|
|
38
|
+
this.fields = fields; // this.visibility=visibility;
|
|
39
|
+
|
|
40
|
+
this.isVisible = isVisible;
|
|
32
41
|
}
|
|
33
42
|
|
|
34
43
|
getName() {
|
|
@@ -40,7 +49,8 @@ export default class ZSection {
|
|
|
40
49
|
}
|
|
41
50
|
|
|
42
51
|
toggleVisibility() {
|
|
43
|
-
this.visibility
|
|
52
|
+
// this.visibility=!this.visibility
|
|
53
|
+
this.isVisible = !this.isVisible;
|
|
44
54
|
}
|
|
45
55
|
|
|
46
56
|
appendField(field) {
|
|
@@ -74,7 +84,8 @@ export default class ZSection {
|
|
|
74
84
|
}
|
|
75
85
|
|
|
76
86
|
setVisibility(visibility) {
|
|
77
|
-
this.visibility
|
|
87
|
+
// this.visibility=visibility;
|
|
88
|
+
this.isVisible = visibility;
|
|
78
89
|
}
|
|
79
90
|
|
|
80
91
|
setFieldErrorMessage(fieldApiName, errorMessage) {
|
|
@@ -102,11 +113,13 @@ export default class ZSection {
|
|
|
102
113
|
name: this.name,
|
|
103
114
|
i18NLabel: this.i18NLabel,
|
|
104
115
|
isCustomSection: this.isCustomSection,
|
|
116
|
+
description: this.description,
|
|
105
117
|
id: this.id,
|
|
106
118
|
fields: this.fields.map(field => {
|
|
107
119
|
return field.toObject();
|
|
108
120
|
}),
|
|
109
|
-
visibility:
|
|
121
|
+
// visibility:this.visibility
|
|
122
|
+
isVisible: this.isVisible
|
|
110
123
|
};
|
|
111
124
|
}
|
|
112
125
|
|
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
/* eslint-disable @zohodesk/architecturerules/
|
|
2
|
-
|
|
3
|
-
/* eslint-disable max-lines-per-function */
|
|
1
|
+
/* eslint-disable @zohodesk/architecturerules/define-property-schema */
|
|
4
2
|
import { FETCH_FAILED, FETCH_SUCCESS_NO_CONTENT, FETCH_REQUESTED, FETCH_SUCCESS } from "../../../../bc/zhttp/Constants";
|
|
5
3
|
import AbstractUseCase from "./AbstractUseCase";
|
|
4
|
+
import { ZHttpErrorSource, ZHttpErrorCode } from "../../../../bc/zhttp/Errors";
|
|
6
5
|
|
|
7
6
|
class FetchUseCase extends AbstractUseCase {
|
|
8
7
|
async execute(inputModel) {
|
|
9
|
-
const {
|
|
10
|
-
fetchGateWay
|
|
11
|
-
} = this.dependencies;
|
|
12
8
|
const {
|
|
13
9
|
url,
|
|
14
10
|
method = 'GET',
|
|
@@ -17,7 +13,6 @@ class FetchUseCase extends AbstractUseCase {
|
|
|
17
13
|
const {
|
|
18
14
|
metaData,
|
|
19
15
|
dispatch,
|
|
20
|
-
payload,
|
|
21
16
|
headers
|
|
22
17
|
} = inputModel;
|
|
23
18
|
dispatch({
|
|
@@ -28,80 +23,130 @@ class FetchUseCase extends AbstractUseCase {
|
|
|
28
23
|
headers,
|
|
29
24
|
metaData
|
|
30
25
|
}
|
|
31
|
-
});
|
|
26
|
+
}); // NOTE: getResponse is hacky solution to get the data using function call instead of fetch, So any handling added to here needs to be added to fetch and vise versa
|
|
27
|
+
|
|
28
|
+
if (typeof getResponse === 'function') {
|
|
29
|
+
await this.handleGetResponseAsFunction(inputModel);
|
|
30
|
+
} else {
|
|
31
|
+
await this.handleFetchResponse(inputModel);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
async handleGetResponseAsFunction(inputModel) {
|
|
36
|
+
const {
|
|
37
|
+
getResponse,
|
|
38
|
+
headers,
|
|
39
|
+
dispatch,
|
|
40
|
+
metaData
|
|
41
|
+
} = inputModel;
|
|
32
42
|
|
|
33
43
|
try {
|
|
34
|
-
|
|
35
|
-
if (typeof getResponse === 'function') {
|
|
36
|
-
const data = await getResponse(headers);
|
|
44
|
+
const data = await getResponse(headers);
|
|
37
45
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
} else {
|
|
45
|
-
dispatch({
|
|
46
|
-
type: FETCH_SUCCESS,
|
|
47
|
-
payload: {
|
|
48
|
-
response: data
|
|
49
|
-
},
|
|
50
|
-
metaData
|
|
51
|
-
});
|
|
52
|
-
}
|
|
46
|
+
if (data === undefined) {
|
|
47
|
+
dispatch({
|
|
48
|
+
type: FETCH_SUCCESS_NO_CONTENT,
|
|
49
|
+
payload: {},
|
|
50
|
+
metaData
|
|
51
|
+
});
|
|
53
52
|
} else {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
53
|
+
dispatch({
|
|
54
|
+
type: FETCH_SUCCESS,
|
|
55
|
+
payload: {
|
|
56
|
+
response: data
|
|
57
|
+
},
|
|
58
|
+
metaData
|
|
58
59
|
});
|
|
60
|
+
}
|
|
61
|
+
} catch (errorObj) {
|
|
62
|
+
this.dispatchException(inputModel, errorObj, ZHttpErrorSource.GetResponse, ZHttpErrorCode.UnknownError);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
async handleFetchResponse(inputModel) {
|
|
67
|
+
const {
|
|
68
|
+
fetchGateWay
|
|
69
|
+
} = this.dependencies;
|
|
70
|
+
const {
|
|
71
|
+
url,
|
|
72
|
+
method = 'GET',
|
|
73
|
+
headers,
|
|
74
|
+
payload
|
|
75
|
+
} = inputModel;
|
|
76
|
+
|
|
77
|
+
try {
|
|
78
|
+
const response = await fetchGateWay.fetch(url, {
|
|
79
|
+
headers,
|
|
80
|
+
method,
|
|
81
|
+
body: method === 'GET' ? null : payload
|
|
82
|
+
});
|
|
59
83
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
dispatch({
|
|
69
|
-
type: FETCH_SUCCESS,
|
|
70
|
-
payload: {},
|
|
71
|
-
metaData
|
|
72
|
-
});
|
|
73
|
-
} else {
|
|
74
|
-
const data = await response.json();
|
|
75
|
-
dispatch({
|
|
76
|
-
type: FETCH_SUCCESS,
|
|
77
|
-
payload: {
|
|
78
|
-
response: data
|
|
79
|
-
},
|
|
80
|
-
metaData
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
} else {
|
|
84
|
-
const data = await response.json();
|
|
85
|
-
dispatch({
|
|
86
|
-
type: FETCH_FAILED,
|
|
87
|
-
payload: {
|
|
88
|
-
error: data
|
|
89
|
-
},
|
|
90
|
-
metaData
|
|
91
|
-
});
|
|
92
|
-
}
|
|
84
|
+
if (response.ok) {
|
|
85
|
+
await this.handleSuccessResponse(response, inputModel);
|
|
86
|
+
} else {
|
|
87
|
+
const data = await response.json();
|
|
88
|
+
const errorObj = { ...data,
|
|
89
|
+
statusCode: response.status
|
|
90
|
+
};
|
|
91
|
+
this.dispatchException(inputModel, errorObj, ZHttpErrorSource.Fetch, ZHttpErrorCode.ApiError);
|
|
93
92
|
}
|
|
94
|
-
} catch (
|
|
93
|
+
} catch (errorObj) {
|
|
94
|
+
this.dispatchException(inputModel, errorObj, ZHttpErrorSource.Fetch, ZHttpErrorCode.UnknownError);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
async handleSuccessResponse(response, inputModel) {
|
|
99
|
+
const {
|
|
100
|
+
method = 'GET',
|
|
101
|
+
dispatch,
|
|
102
|
+
metaData
|
|
103
|
+
} = inputModel;
|
|
104
|
+
const statusCode = response.status;
|
|
105
|
+
|
|
106
|
+
if (statusCode === 204) {
|
|
107
|
+
dispatch({
|
|
108
|
+
type: FETCH_SUCCESS_NO_CONTENT,
|
|
109
|
+
payload: {},
|
|
110
|
+
metaData
|
|
111
|
+
});
|
|
112
|
+
} else if (statusCode === 200 && method === 'DELETE') {
|
|
95
113
|
dispatch({
|
|
96
|
-
type:
|
|
114
|
+
type: FETCH_SUCCESS,
|
|
115
|
+
payload: {},
|
|
116
|
+
metaData
|
|
117
|
+
});
|
|
118
|
+
} else {
|
|
119
|
+
const data = await response.json();
|
|
120
|
+
dispatch({
|
|
121
|
+
type: FETCH_SUCCESS,
|
|
97
122
|
payload: {
|
|
98
|
-
|
|
123
|
+
response: data
|
|
99
124
|
},
|
|
100
125
|
metaData
|
|
101
126
|
});
|
|
102
127
|
}
|
|
103
128
|
}
|
|
104
129
|
|
|
130
|
+
dispatchException(inputModel, errorObj, source, code) {
|
|
131
|
+
const {
|
|
132
|
+
dispatch,
|
|
133
|
+
metaData
|
|
134
|
+
} = inputModel;
|
|
135
|
+
const error = {
|
|
136
|
+
code,
|
|
137
|
+
message: errorObj.message,
|
|
138
|
+
source,
|
|
139
|
+
info: errorObj
|
|
140
|
+
};
|
|
141
|
+
dispatch({
|
|
142
|
+
type: FETCH_FAILED,
|
|
143
|
+
payload: {
|
|
144
|
+
error
|
|
145
|
+
},
|
|
146
|
+
metaData
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
|
|
105
150
|
}
|
|
106
151
|
|
|
107
152
|
export default FetchUseCase;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import AbstractController from "./AbstractController";
|
|
2
|
+
export default class FieldExecuteFailedController 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,5 +1,6 @@
|
|
|
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 ListErrorState from "../../domain/entities/ListErrorState";
|
|
3
4
|
import ListFactory from "../../applications/entities-factory/ListFactory";
|
|
4
5
|
import SortBy from "../../domain/entities/SortBy";
|
|
5
6
|
|
|
@@ -22,7 +23,8 @@ class Repository {
|
|
|
22
23
|
} = this.state.properties;
|
|
23
24
|
const {
|
|
24
25
|
sortBy,
|
|
25
|
-
|
|
26
|
+
errorState,
|
|
27
|
+
isReOrderLoading
|
|
26
28
|
} = this.getZListState();
|
|
27
29
|
const list = ListFactory.createList({
|
|
28
30
|
context,
|
|
@@ -34,7 +36,8 @@ class Repository {
|
|
|
34
36
|
},
|
|
35
37
|
sortBy: new SortBy(sortBy.id, sortBy.name, sortBy.order),
|
|
36
38
|
limit: 50,
|
|
37
|
-
|
|
39
|
+
isReOrderLoading,
|
|
40
|
+
errorState: new ListErrorState(errorState)
|
|
38
41
|
});
|
|
39
42
|
return list;
|
|
40
43
|
}
|
|
@@ -47,10 +47,11 @@ export default class TableTranslator {
|
|
|
47
47
|
zfield,
|
|
48
48
|
zclientAction
|
|
49
49
|
} = fallbackToDefault(behaviours, {}); // FIX: behaviours should be available by default
|
|
50
|
-
// const { sortBy, isReOrderLoading } = fallbackToDefault(zlist, {}); // FIX: zlist should be available by default
|
|
51
50
|
|
|
52
51
|
const {
|
|
53
|
-
sortBy
|
|
52
|
+
sortBy,
|
|
53
|
+
errorState,
|
|
54
|
+
isReOrderLoading
|
|
54
55
|
} = fallbackToDefault(zlist, {}); // FIX: zlist should be available by default
|
|
55
56
|
|
|
56
57
|
const {
|
|
@@ -69,6 +70,10 @@ export default class TableTranslator {
|
|
|
69
70
|
|
|
70
71
|
const fieldComponentMapping = fallbackToDefault(componentMapping.fields, {});
|
|
71
72
|
const rowActionsUiType = componentMapping.rowActionsComponentName;
|
|
73
|
+
const {
|
|
74
|
+
shouldClearRecords: isRecordsShouldBeEmptied,
|
|
75
|
+
canErrorPage: isError
|
|
76
|
+
} = errorState;
|
|
72
77
|
const {
|
|
73
78
|
fields: availableFields,
|
|
74
79
|
selectedFields,
|
|
@@ -94,8 +99,9 @@ export default class TableTranslator {
|
|
|
94
99
|
|
|
95
100
|
const localStorageFieldWidths = fallbackToDefault(localStorageBehaviour === null || localStorageBehaviour === void 0 ? void 0 : (_localStorageBehaviou = localStorageBehaviour[moduleName]) === null || _localStorageBehaviou === void 0 ? void 0 : (_localStorageBehaviou2 = _localStorageBehaviou[viewId]) === null || _localStorageBehaviou2 === void 0 ? void 0 : _localStorageBehaviou2.modifiedWidths, EMPTY_OBJECT);
|
|
96
101
|
const modifiedWidths = calculateFieldWidths(fields, localStorageFieldWidths, preferences);
|
|
97
|
-
const
|
|
98
|
-
const
|
|
102
|
+
const recordsForDisplay = isRecordsShouldBeEmptied ? EMPTY_ARRAY : records;
|
|
103
|
+
const headersTranslator = new HeadersTranslator(fields, headerActions, context, modifiedWidths, sortBy, records);
|
|
104
|
+
const rowsTranslator = new RowsTranslator(recordsForDisplay, fields, rowActions, context, fieldComponentMapping, rowActionsUiType, fieldActions); // const actionTranslator = new ClientActionsTranslator(clientActions, records, fields, pageContext);
|
|
99
105
|
// const translators = [headersTranslator.getTranslator(), rowsTranslator.getTranslator(), actionTranslator.getTranslator()];
|
|
100
106
|
|
|
101
107
|
const translators = [headersTranslator.getTranslator(), rowsTranslator.getTranslator()];
|
|
@@ -106,6 +112,7 @@ export default class TableTranslator {
|
|
|
106
112
|
behaviours,
|
|
107
113
|
viewModel: {
|
|
108
114
|
reOrderConfig,
|
|
115
|
+
isError,
|
|
109
116
|
selection: SelectionTranslator(state),
|
|
110
117
|
focussedRow: focussedIndex,
|
|
111
118
|
sortBy,
|
|
@@ -123,7 +130,7 @@ export default class TableTranslator {
|
|
|
123
130
|
},
|
|
124
131
|
keyboardControlsConfig,
|
|
125
132
|
isLoading,
|
|
126
|
-
|
|
133
|
+
isReOrderLoading,
|
|
127
134
|
emptyStateUiType: componentMapping.emptyState || '',
|
|
128
135
|
data: fields.length ? data : {
|
|
129
136
|
headers: EMPTY_ARRAY,
|
|
@@ -42,7 +42,7 @@ function ColumnTranslator(field, record, fieldComponentMapping, fieldActions, co
|
|
|
42
42
|
});
|
|
43
43
|
|
|
44
44
|
if (!value && value !== false) {
|
|
45
|
-
return EmptyViewModel();
|
|
45
|
+
return EmptyViewModel(name);
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
if (fieldComponentMapping[name]) {
|
|
@@ -53,7 +53,7 @@ function ColumnTranslator(field, record, fieldComponentMapping, fieldActions, co
|
|
|
53
53
|
|
|
54
54
|
if (!fieldTranslator) {
|
|
55
55
|
console.error(`Field type ${type} not supported`);
|
|
56
|
-
return EmptyViewModel();
|
|
56
|
+
return EmptyViewModel(name);
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
if (field.type == "LookUp") {
|
|
@@ -3,7 +3,7 @@ import ClientActionsTranslator from "../../../../client-actions/translators/clie
|
|
|
3
3
|
import { SortOrder } from "../../../../zlist/domain/entities/interfaces/Properties";
|
|
4
4
|
import { i18NProviderUtils } from '@zohodesk/i18n';
|
|
5
5
|
|
|
6
|
-
function HeaderTranslator(field, actions, context, modifiedWidths, sortBy) {
|
|
6
|
+
function HeaderTranslator(field, actions, context, modifiedWidths, sortBy, records) {
|
|
7
7
|
const {
|
|
8
8
|
id,
|
|
9
9
|
name,
|
|
@@ -15,7 +15,8 @@ function HeaderTranslator(field, actions, context, modifiedWidths, sortBy) {
|
|
|
15
15
|
sort: translateSortBy(field.id, sortBy)
|
|
16
16
|
};
|
|
17
17
|
const transformedActions = ClientActionsTranslator.transform(actions, { ...context,
|
|
18
|
-
field: newField
|
|
18
|
+
field: newField,
|
|
19
|
+
recordsLength: records.length.toString()
|
|
19
20
|
});
|
|
20
21
|
const width = modifiedWidths[name];
|
|
21
22
|
return {
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import HeaderTranslator from "./Header";
|
|
2
2
|
export default class HeadersTranslator {
|
|
3
|
-
constructor(fields, actions, context, modifiedWidths, sortBy) {
|
|
3
|
+
constructor(fields, actions, context, modifiedWidths, sortBy, records) {
|
|
4
4
|
this.fields = fields;
|
|
5
5
|
this.actions = actions;
|
|
6
6
|
this.context = context;
|
|
7
7
|
this.modifiedWidths = modifiedWidths;
|
|
8
8
|
this.sortBy = sortBy;
|
|
9
|
+
this.records = records;
|
|
9
10
|
this.pipe = this.pipe.bind(this);
|
|
10
11
|
}
|
|
11
12
|
|
|
@@ -14,7 +15,7 @@ export default class HeadersTranslator {
|
|
|
14
15
|
return [];
|
|
15
16
|
}
|
|
16
17
|
|
|
17
|
-
return this.fields.map(field => HeaderTranslator(field, this.actions, this.context, this.modifiedWidths, this.sortBy));
|
|
18
|
+
return this.fields.map(field => HeaderTranslator(field, this.actions, this.context, this.modifiedWidths, this.sortBy, this.records));
|
|
18
19
|
}
|
|
19
20
|
|
|
20
21
|
pipe(viewModel) {
|
|
@@ -7,9 +7,10 @@ class ListFactory {
|
|
|
7
7
|
sortBy,
|
|
8
8
|
query,
|
|
9
9
|
context,
|
|
10
|
-
|
|
10
|
+
errorState,
|
|
11
|
+
isReOrderLoading
|
|
11
12
|
} = input;
|
|
12
|
-
return new List(limit, sortBy, query, context,
|
|
13
|
+
return new List(limit, sortBy, query, context, isReOrderLoading, errorState);
|
|
13
14
|
}
|
|
14
15
|
|
|
15
16
|
}
|
|
@@ -10,7 +10,7 @@ class FetchMoreUseCase extends AbstractUseCase {
|
|
|
10
10
|
} = this.dependencies;
|
|
11
11
|
const list = repository.getList();
|
|
12
12
|
|
|
13
|
-
if (!list.
|
|
13
|
+
if (!list.hasFetchingFailedInMoreRecords()) {
|
|
14
14
|
dispatch(list.createMoreRecordFetchAction());
|
|
15
15
|
}
|
|
16
16
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import AbstractUseCase from "./AbstractUseCase";
|
|
1
|
+
import AbstractUseCase from "./AbstractUseCase"; // TODO Rename this file to ApiFailedHandleUseCase.ts
|
|
2
2
|
|
|
3
3
|
class RecordExecuteFailedUseCase extends AbstractUseCase {
|
|
4
4
|
execute(input) {
|
|
@@ -12,8 +12,9 @@ class RecordExecuteFailedUseCase extends AbstractUseCase {
|
|
|
12
12
|
presenter
|
|
13
13
|
} = this.dependencies;
|
|
14
14
|
const list = repository.getList();
|
|
15
|
-
|
|
15
|
+
list.processApiError(payload, metaData);
|
|
16
16
|
presenter.updateView(list.toObject());
|
|
17
|
+
const actions = list.generateApiErrorEvent(payload, metaData);
|
|
17
18
|
actions.forEach(action => {
|
|
18
19
|
dispatch(action);
|
|
19
20
|
});
|