@zohodesk/library-platform 1.1.3-temp-1 → 1.1.3-temp-1.1
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/ChangeLogs.md +201 -0
- package/README.md +1 -1
- package/es/bc/zform/Symbol.js +1 -0
- 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/form/Constants.js +2 -0
- package/es/cc/form/Events.js +20 -0
- package/es/cc/form-connected/Constants.js +13 -0
- package/es/cc/index.js +1 -0
- package/es/cc/link/Properties.js +0 -1
- package/es/cc/section/Constants.js +2 -0
- package/es/cc/section/Events.js +20 -0
- 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/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/form/frameworks/ui/EventHandlerFactory.js +23 -3
- package/es/library/dot/components/form/frameworks/ui/FormView.js +6 -3
- package/es/library/dot/components/form/frameworks/ui/css/Form.module.css +4 -0
- package/es/library/dot/components/form-fields/checkbox/frameworks/ui/CheckboxView.js +1 -0
- package/es/library/dot/components/form-fields/currency/frameworks/ui/CurrencyView.js +1 -0
- package/es/library/dot/components/form-fields/date/frameworks/ui/DateView.js +1 -0
- package/es/library/dot/components/form-fields/datetime/frameworks/ui/DateTimeView.js +1 -0
- package/es/library/dot/components/form-fields/decimal/frameworks/ui/DecimalView.js +1 -0
- package/es/library/dot/components/form-fields/email/frameworks/ui/EmailView.js +1 -0
- package/es/library/dot/components/form-fields/multi-select/frameworks/ui/MultiSelectView.js +1 -0
- package/es/library/dot/components/form-fields/number/frameworks/ui/NumberView.js +1 -0
- package/es/library/dot/components/form-fields/percentage/frameworks/ui/PercentageView.js +1 -0
- package/es/library/dot/components/form-fields/phone/frameworks/ui/PhoneView.js +1 -0
- package/es/library/dot/components/form-fields/pick-list/frameworks/ui/PickListView.js +1 -0
- package/es/library/dot/components/form-fields/textarea/frameworks/ui/TextAreaView.js +1 -0
- package/es/library/dot/components/form-fields/textbox/frameworks/ui/TextBoxView.js +1 -0
- package/es/library/dot/components/form-fields/url/frameworks/ui/UrlView.js +1 -0
- package/es/library/dot/components/section/frameworks/ui/EventHandlerFactory.js +26 -3
- package/es/library/dot/components/table-list/frameworks/hooks/useRowData.js +12 -5
- package/es/library/dot/components/table-list/frameworks/ui/css/TableList.module.css +19 -20
- package/es/platform/components/form-connected/frameworks/EventHandlersFactory.js +68 -1
- 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 +3 -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/controllers/FieldValueChangeController.js +10 -3
- package/es/platform/zform/adapters/presenter/translators/fields/CurrencyFieldTranslator.js +0 -1
- package/es/platform/zform/adapters/presenter/translators/fields/DateFieldTranslator.js +0 -1
- package/es/platform/zform/adapters/presenter/translators/fields/DecimalFieldTranslator.js +0 -1
- package/es/platform/zform/adapters/presenter/translators/fields/PhoneFieldTranslator.js +0 -1
- package/es/platform/zform/applications/usecases/FieldValueChangeRequestUseCase.js +13 -1
- package/es/platform/zform/domain/ZField.js +3 -7
- package/es/platform/zform/frameworks/ui/EventHandlerFactory.js +8 -2
- 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 +9 -2
- 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 +9 -9
- package/es/library/custom-component/frameworks/object-path-immutable/ImmutableHelper.js +0 -5
|
@@ -27,6 +27,7 @@ function MultiSelectView(_ref, ref) {
|
|
|
27
27
|
actions
|
|
28
28
|
} = state.properties;
|
|
29
29
|
return /*#__PURE__*/React.createElement("div", {
|
|
30
|
+
"data-test-id": "smart_form_field_multiselect",
|
|
30
31
|
ref: ref,
|
|
31
32
|
className: style.fieldWrapper
|
|
32
33
|
}, /*#__PURE__*/React.createElement(Label, {
|
|
@@ -21,6 +21,7 @@ function PercentageView(_ref, ref) {
|
|
|
21
21
|
required
|
|
22
22
|
} = state.viewModel;
|
|
23
23
|
return /*#__PURE__*/React.createElement("div", {
|
|
24
|
+
"data-test-id": "smart_form_field_percentage",
|
|
24
25
|
ref: ref,
|
|
25
26
|
className: style.fieldWrapper
|
|
26
27
|
}, /*#__PURE__*/React.createElement(Label, {
|
|
@@ -27,6 +27,7 @@ function PickListView(_ref, ref) {
|
|
|
27
27
|
actions
|
|
28
28
|
} = state.properties;
|
|
29
29
|
return /*#__PURE__*/React.createElement("div", {
|
|
30
|
+
"data-test-id": "smart_form_field_picklist",
|
|
30
31
|
ref: ref,
|
|
31
32
|
className: style.fieldWrapper
|
|
32
33
|
}, /*#__PURE__*/React.createElement(Label, {
|
|
@@ -21,6 +21,7 @@ function TextAreaView(_ref, ref) {
|
|
|
21
21
|
required
|
|
22
22
|
} = state.properties;
|
|
23
23
|
return /*#__PURE__*/React.createElement("div", {
|
|
24
|
+
"data-test-id": "smart_form_field_textarea",
|
|
24
25
|
ref: ref,
|
|
25
26
|
className: style.fieldWrapper
|
|
26
27
|
}, /*#__PURE__*/React.createElement(Label, {
|
|
@@ -21,6 +21,7 @@ function TextBoxView(_ref, ref) {
|
|
|
21
21
|
required
|
|
22
22
|
} = state.properties;
|
|
23
23
|
return /*#__PURE__*/React.createElement("div", {
|
|
24
|
+
"data-test-id": "smart_form_field_textbox",
|
|
24
25
|
ref: ref,
|
|
25
26
|
className: style.fieldWrapper
|
|
26
27
|
}, /*#__PURE__*/React.createElement(Label, {
|
|
@@ -4,12 +4,13 @@ import FieldConstants from "../../../../../../cc/fields/field/Constants";
|
|
|
4
4
|
class EventHandlersFactory {
|
|
5
5
|
static create() {
|
|
6
6
|
return {
|
|
7
|
+
[FieldConstants.FIELD_FOCUSED]: this.handleFieldFocused,
|
|
7
8
|
[FieldConstants.FIELD_BLURRED]: this.handleFieldBlurred,
|
|
8
9
|
[FieldConstants.FIELD_CHANGED]: this.handleFieldChanged
|
|
9
10
|
};
|
|
10
11
|
}
|
|
11
12
|
|
|
12
|
-
static
|
|
13
|
+
static handleFieldFocused(_ref) {
|
|
13
14
|
let {
|
|
14
15
|
action,
|
|
15
16
|
state,
|
|
@@ -22,7 +23,7 @@ class EventHandlersFactory {
|
|
|
22
23
|
fieldName
|
|
23
24
|
} = action.payload;
|
|
24
25
|
dispatch({
|
|
25
|
-
type: SectionConstants.
|
|
26
|
+
type: SectionConstants.SECTION_FIELD_FOCUSED,
|
|
26
27
|
payload: {
|
|
27
28
|
id,
|
|
28
29
|
fieldName
|
|
@@ -31,7 +32,7 @@ class EventHandlersFactory {
|
|
|
31
32
|
});
|
|
32
33
|
}
|
|
33
34
|
|
|
34
|
-
static
|
|
35
|
+
static handleFieldBlurred(_ref2) {
|
|
35
36
|
let {
|
|
36
37
|
action,
|
|
37
38
|
state,
|
|
@@ -40,6 +41,28 @@ class EventHandlersFactory {
|
|
|
40
41
|
const {
|
|
41
42
|
id
|
|
42
43
|
} = state.properties;
|
|
44
|
+
const {
|
|
45
|
+
fieldName
|
|
46
|
+
} = action.payload;
|
|
47
|
+
dispatch({
|
|
48
|
+
type: SectionConstants.SECTION_FIELD_BLURRED,
|
|
49
|
+
payload: {
|
|
50
|
+
id,
|
|
51
|
+
fieldName
|
|
52
|
+
},
|
|
53
|
+
metaData: {}
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
static handleFieldChanged(_ref3) {
|
|
58
|
+
let {
|
|
59
|
+
action,
|
|
60
|
+
state,
|
|
61
|
+
dispatch
|
|
62
|
+
} = _ref3;
|
|
63
|
+
const {
|
|
64
|
+
id
|
|
65
|
+
} = state.properties;
|
|
43
66
|
const {
|
|
44
67
|
fieldName,
|
|
45
68
|
value
|
|
@@ -1,8 +1,15 @@
|
|
|
1
|
-
import { useState,
|
|
1
|
+
import { useState, useMemo, useRef } from 'react';
|
|
2
2
|
export function useRowData(rows) {
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
const rowRef = useRef(null);
|
|
4
|
+
useMemo(() => {
|
|
5
|
+
rowRef.current = rows;
|
|
6
6
|
}, [rows]);
|
|
7
|
-
|
|
7
|
+
const [, forceUpdate] = useState(rows);
|
|
8
|
+
|
|
9
|
+
function setRowData(rows) {
|
|
10
|
+
rowRef.current = rows;
|
|
11
|
+
forceUpdate(rows);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
return [rowRef.current, setRowData];
|
|
8
15
|
}
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
|
|
27
27
|
/* Keyboard only */
|
|
28
28
|
.tableListRow-kbd {
|
|
29
|
-
|
|
29
|
+
/* */
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
/* Reorder + Selection, no Keyboard */
|
|
@@ -205,13 +205,13 @@
|
|
|
205
205
|
}
|
|
206
206
|
|
|
207
207
|
[dir=ltr] .dragHandleWrapper {
|
|
208
|
-
left: var(--local-tableList-reorder-left,
|
|
209
|
-
padding: 0 var(--local-tableList-reorder-paddingRight,
|
|
208
|
+
left: var(--local-tableList-reorder-left, 0);
|
|
209
|
+
padding: 0 var(--local-tableList-reorder-paddingRight, 0) 0 var(--local-tableList-reorder-paddingLeft, 0);
|
|
210
210
|
}
|
|
211
211
|
|
|
212
212
|
[dir=rtl] .dragHandleWrapper {
|
|
213
|
-
right: var(--local-tableList-reorder-left,
|
|
214
|
-
padding: 0 var(--local-tableList-reorder-paddingLeft,
|
|
213
|
+
right: var(--local-tableList-reorder-left, 0);
|
|
214
|
+
padding: 0 var(--local-tableList-reorder-paddingLeft, 0) 0 var(--local-tableList-reorder-paddingRight, 0);
|
|
215
215
|
}
|
|
216
216
|
|
|
217
217
|
.rowDropIndicator {
|
|
@@ -233,7 +233,6 @@
|
|
|
233
233
|
|
|
234
234
|
.row {
|
|
235
235
|
--local_padding_left: var(--local-tableList-row-paddingLeft);
|
|
236
|
-
--local_margin_right: var(--local-tableList-row-marginRight);
|
|
237
236
|
}
|
|
238
237
|
|
|
239
238
|
.tableListSelectContainer {
|
|
@@ -242,15 +241,15 @@
|
|
|
242
241
|
}
|
|
243
242
|
|
|
244
243
|
[dir=ltr] .tableListSelectContainer {
|
|
245
|
-
left: var(--local-tableList-selectionColumn-left,
|
|
246
|
-
padding-left: var(--local-tableList-selectionColumn-paddingLeft,
|
|
247
|
-
padding-right: var(--local-tableList-selectionColumn-paddingRight,
|
|
244
|
+
left: var(--local-tableList-selectionColumn-left, 0);
|
|
245
|
+
padding-left: var(--local-tableList-selectionColumn-paddingLeft, 0);
|
|
246
|
+
padding-right: var(--local-tableList-selectionColumn-paddingRight, 0);
|
|
248
247
|
}
|
|
249
248
|
|
|
250
249
|
[dir=rtl] .tableListSelectContainer {
|
|
251
|
-
right: var(--local-tableList-selectionColumn-left,
|
|
252
|
-
padding-right: var(--local-tableList-selectionColumn-paddingLeft,
|
|
253
|
-
padding-left: var(--local-tableList-selectionColumn-paddingRight,
|
|
250
|
+
right: var(--local-tableList-selectionColumn-left, 0);
|
|
251
|
+
padding-right: var(--local-tableList-selectionColumn-paddingLeft, 0);
|
|
252
|
+
padding-left: var(--local-tableList-selectionColumn-paddingRight, 0);
|
|
254
253
|
}
|
|
255
254
|
|
|
256
255
|
.header {
|
|
@@ -262,13 +261,13 @@
|
|
|
262
261
|
}
|
|
263
262
|
|
|
264
263
|
[dir=ltr] .reOrderHeader {
|
|
265
|
-
left: var(--local-tableList-reorderHeader-left,
|
|
266
|
-
padding-right: var(--local-tableList-reorderHeader-paddingRight,
|
|
264
|
+
left: var(--local-tableList-reorderHeader-left, 0);
|
|
265
|
+
padding-right: var(--local-tableList-reorderHeader-paddingRight, 0);
|
|
267
266
|
}
|
|
268
267
|
|
|
269
268
|
[dir=rtl] .reOrderHeader {
|
|
270
|
-
right: var(--local-tableList-reorderHeader-left,
|
|
271
|
-
padding-left: var(--local-tableList-reorderHeader-paddingRight,
|
|
269
|
+
right: var(--local-tableList-reorderHeader-left, 0);
|
|
270
|
+
padding-left: var(--local-tableList-reorderHeader-paddingRight, 0);
|
|
272
271
|
}
|
|
273
272
|
|
|
274
273
|
.massActionHeader {
|
|
@@ -276,11 +275,11 @@
|
|
|
276
275
|
}
|
|
277
276
|
|
|
278
277
|
[dir=ltr] .massActionHeader {
|
|
279
|
-
left: var(--local-tableList-massActionHeader-left,
|
|
280
|
-
padding-right: var(--local-tableList-massActionHeader-paddingRight,
|
|
278
|
+
left: var(--local-tableList-massActionHeader-left, 0);
|
|
279
|
+
padding-right: var(--local-tableList-massActionHeader-paddingRight, 0);
|
|
281
280
|
}
|
|
282
281
|
|
|
283
282
|
[dir=rtl] .massActionHeader {
|
|
284
|
-
right: var(--local-tableList-massActionHeader-left,
|
|
285
|
-
padding-left: var(--local-tableList-massActionHeader-paddingRight,
|
|
283
|
+
right: var(--local-tableList-massActionHeader-left, 0);
|
|
284
|
+
padding-left: var(--local-tableList-massActionHeader-paddingRight, 0);
|
|
286
285
|
}
|
|
@@ -1,4 +1,12 @@
|
|
|
1
|
+
import SmartFormConstants from "../../../../cc/form-connected/Constants";
|
|
1
2
|
import FormSdkFactory from "./FormSdkFactory";
|
|
3
|
+
import FormConstants from "../../../../cc/form/Constants";
|
|
4
|
+
import { ZFORM_FIELD_VALUE_CHANGED } from "../../../../bc/zform/Symbol";
|
|
5
|
+
const {
|
|
6
|
+
SMART_FORM_FIELD_FOCUSED,
|
|
7
|
+
SMART_FORM_FIELD_BLURRED,
|
|
8
|
+
SMART_FORM_FIELD_VALUE_CHANGED
|
|
9
|
+
} = SmartFormConstants;
|
|
2
10
|
|
|
3
11
|
function createHandlerWithSdk(handler) {
|
|
4
12
|
return input => {
|
|
@@ -14,11 +22,70 @@ function createHandlerWithSdk(handler) {
|
|
|
14
22
|
}
|
|
15
23
|
|
|
16
24
|
export default class EventHandlersFactory {
|
|
17
|
-
static
|
|
25
|
+
static createWrapped(eventHandlers) {
|
|
18
26
|
return Object.fromEntries(Object.keys(eventHandlers).map(eventName => {
|
|
19
27
|
const handler = createHandlerWithSdk(eventHandlers[eventName]);
|
|
20
28
|
return [eventName, handler];
|
|
21
29
|
}));
|
|
22
30
|
}
|
|
23
31
|
|
|
32
|
+
static create(eventHandlers) {
|
|
33
|
+
const wrapped = EventHandlersFactory.createWrapped(eventHandlers);
|
|
34
|
+
return { ...wrapped,
|
|
35
|
+
[FormConstants.FORM_FIELD_FOCUSED]: _ref => {
|
|
36
|
+
let {
|
|
37
|
+
action,
|
|
38
|
+
dispatch
|
|
39
|
+
} = _ref;
|
|
40
|
+
const {
|
|
41
|
+
sectionId,
|
|
42
|
+
fieldName
|
|
43
|
+
} = action.payload;
|
|
44
|
+
dispatch({
|
|
45
|
+
type: SMART_FORM_FIELD_FOCUSED,
|
|
46
|
+
payload: {
|
|
47
|
+
sectionId,
|
|
48
|
+
fieldName
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
},
|
|
52
|
+
[FormConstants.FORM_FIELD_BLURRED]: _ref2 => {
|
|
53
|
+
let {
|
|
54
|
+
action,
|
|
55
|
+
dispatch
|
|
56
|
+
} = _ref2;
|
|
57
|
+
const {
|
|
58
|
+
sectionId,
|
|
59
|
+
fieldName
|
|
60
|
+
} = action.payload;
|
|
61
|
+
dispatch({
|
|
62
|
+
type: SMART_FORM_FIELD_BLURRED,
|
|
63
|
+
payload: {
|
|
64
|
+
sectionId,
|
|
65
|
+
fieldName
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
},
|
|
69
|
+
[ZFORM_FIELD_VALUE_CHANGED]: _ref3 => {
|
|
70
|
+
let {
|
|
71
|
+
action,
|
|
72
|
+
dispatch
|
|
73
|
+
} = _ref3;
|
|
74
|
+
const {
|
|
75
|
+
sectionId,
|
|
76
|
+
fieldName,
|
|
77
|
+
value
|
|
78
|
+
} = action.payload;
|
|
79
|
+
dispatch({
|
|
80
|
+
type: SMART_FORM_FIELD_VALUE_CHANGED,
|
|
81
|
+
payload: {
|
|
82
|
+
sectionId,
|
|
83
|
+
fieldName,
|
|
84
|
+
value
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
|
|
24
91
|
}
|
package/es/platform/components/table-connected/adapters/controllers/ColumnChooserOpenedController.js
CHANGED
|
@@ -10,7 +10,7 @@ export default class ColumnChooserOpenedController extends AbstractController {
|
|
|
10
10
|
fields: availableFields,
|
|
11
11
|
selectedFields
|
|
12
12
|
} = zfield;
|
|
13
|
-
const columnChooserOptionsOrder = selectedFields;
|
|
13
|
+
const columnChooserOptionsOrder = [...selectedFields];
|
|
14
14
|
availableFields.forEach(field => {
|
|
15
15
|
if (!selectedFields.includes(field.name)) {
|
|
16
16
|
columnChooserOptionsOrder.push(field.name);
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export default class ErrorPrinter {
|
|
2
|
+
static printError(error) {
|
|
3
|
+
console.error('Error occurred:', error);
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
static displaySchemaErrors(title, errors) {
|
|
7
|
+
let dataName = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '(root)';
|
|
8
|
+
console.group(title.msg, ...title.styles);
|
|
9
|
+
errors.forEach((_ref, i) => {
|
|
10
|
+
let {
|
|
11
|
+
dataPath,
|
|
12
|
+
keyword,
|
|
13
|
+
message
|
|
14
|
+
} = _ref;
|
|
15
|
+
console.error(`%c${i + 1}. %c${dataName + dataPath}%c → ${keyword} ${message}`, 'color: initial;', 'color: #FF6F61; font-weight: bold;', 'color: #FFA500;');
|
|
16
|
+
});
|
|
17
|
+
console.groupEnd();
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
}
|
|
@@ -16,11 +16,54 @@ import RecordUpdateUseCase from "../../../../zlist/applications/usecases/RecordU
|
|
|
16
16
|
import UpdateMultipleRecordUseCase from "../../../../zlist/applications/usecases/UpdateMultipleRecordUseCase";
|
|
17
17
|
import GetContextUseCase from "../../../../zlist/applications/usecases/GetContextUseCase";
|
|
18
18
|
import ReOrderUseCase from "../../../../zlist/applications/usecases/ReOrderUseCase";
|
|
19
|
+
import { SdkContracts } from "../../../../../cc/table-connected/SdkContract";
|
|
20
|
+
import Validator from "../../../../../library/custom-component/frameworks/json-schema-validator/Validator";
|
|
21
|
+
import ErrorPrinter from "./ErrorPrinter";
|
|
19
22
|
export class SmartTableResource extends AbstractResource {
|
|
20
23
|
initialize() {}
|
|
21
24
|
|
|
22
25
|
destroy() {}
|
|
23
26
|
|
|
27
|
+
safeValidateInput(meta, input) {
|
|
28
|
+
try {
|
|
29
|
+
const result = Validator.validate(meta, input);
|
|
30
|
+
return result;
|
|
31
|
+
} catch (error) {
|
|
32
|
+
return {
|
|
33
|
+
isValid: false,
|
|
34
|
+
errors: [{
|
|
35
|
+
dataPath: '',
|
|
36
|
+
keyword: 'internal',
|
|
37
|
+
message: 'invalid schema'
|
|
38
|
+
}]
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
validateInput(methodName, input, meta) {
|
|
44
|
+
const {
|
|
45
|
+
isValid,
|
|
46
|
+
errors
|
|
47
|
+
} = this.safeValidateInput(meta, input);
|
|
48
|
+
|
|
49
|
+
if (!isValid) {
|
|
50
|
+
const title = `%c Invalid sdk input for %c${methodName}`;
|
|
51
|
+
const styles = ['color: red; font-weight: bold;', 'color: #FF6F61; font-weight: bold;'];
|
|
52
|
+
ErrorPrinter.displaySchemaErrors({
|
|
53
|
+
msg: title,
|
|
54
|
+
styles
|
|
55
|
+
}, errors, '');
|
|
56
|
+
throw {
|
|
57
|
+
code: 'ValidationError',
|
|
58
|
+
message: `Invalid input for ${methodName}`,
|
|
59
|
+
details: {
|
|
60
|
+
methodName,
|
|
61
|
+
errors
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
24
67
|
getRecordDependencies() {
|
|
25
68
|
const dependencies = {
|
|
26
69
|
repository: new ZRecordRepository(),
|
|
@@ -83,6 +126,9 @@ export class SmartTableResource extends AbstractResource {
|
|
|
83
126
|
}
|
|
84
127
|
|
|
85
128
|
getRecord(recordId) {
|
|
129
|
+
this.validateInput('getRecord', {
|
|
130
|
+
recordId
|
|
131
|
+
}, SdkContracts.getRecordInputMeta);
|
|
86
132
|
const {
|
|
87
133
|
getData,
|
|
88
134
|
setData
|
|
@@ -97,6 +143,9 @@ export class SmartTableResource extends AbstractResource {
|
|
|
97
143
|
}
|
|
98
144
|
|
|
99
145
|
getContext(variableName) {
|
|
146
|
+
this.validateInput('getContext', {
|
|
147
|
+
variableName
|
|
148
|
+
}, SdkContracts.getContextInputMeta);
|
|
100
149
|
const {
|
|
101
150
|
getData,
|
|
102
151
|
setData
|
|
@@ -111,6 +160,9 @@ export class SmartTableResource extends AbstractResource {
|
|
|
111
160
|
}
|
|
112
161
|
|
|
113
162
|
deleteRecord(recordId) {
|
|
163
|
+
this.validateInput('deleteRecord', {
|
|
164
|
+
recordId
|
|
165
|
+
}, SdkContracts.deleteRecordInputMeta);
|
|
114
166
|
const {
|
|
115
167
|
dispatch
|
|
116
168
|
} = this.dependencies;
|
|
@@ -130,6 +182,10 @@ export class SmartTableResource extends AbstractResource {
|
|
|
130
182
|
|
|
131
183
|
deleteRecords(recordIds) {
|
|
132
184
|
let shouldFetch = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
185
|
+
this.validateInput('deleteRecords', {
|
|
186
|
+
recordIds,
|
|
187
|
+
shouldFetch
|
|
188
|
+
}, SdkContracts.deleteRecordsInputMeta);
|
|
133
189
|
const {
|
|
134
190
|
dispatch
|
|
135
191
|
} = this.dependencies;
|
|
@@ -150,6 +206,11 @@ export class SmartTableResource extends AbstractResource {
|
|
|
150
206
|
|
|
151
207
|
updateRecord(recordId, record) {
|
|
152
208
|
let shouldFetch = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
209
|
+
this.validateInput('updateRecord', {
|
|
210
|
+
recordId,
|
|
211
|
+
record,
|
|
212
|
+
shouldFetch
|
|
213
|
+
}, SdkContracts.updateRecordInputMeta);
|
|
153
214
|
const {
|
|
154
215
|
dispatch
|
|
155
216
|
} = this.dependencies;
|
|
@@ -171,6 +232,10 @@ export class SmartTableResource extends AbstractResource {
|
|
|
171
232
|
|
|
172
233
|
updateRecords(recordsMap) {
|
|
173
234
|
let shouldFetch = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
235
|
+
this.validateInput('updateRecords', {
|
|
236
|
+
recordsMap,
|
|
237
|
+
shouldFetch
|
|
238
|
+
}, SdkContracts.updateRecordsInputMeta);
|
|
174
239
|
const {
|
|
175
240
|
dispatch
|
|
176
241
|
} = this.dependencies;
|
|
@@ -190,6 +255,9 @@ export class SmartTableResource extends AbstractResource {
|
|
|
190
255
|
}
|
|
191
256
|
|
|
192
257
|
selectRecords(ids) {
|
|
258
|
+
this.validateInput('selectRecords', {
|
|
259
|
+
ids
|
|
260
|
+
}, SdkContracts.selectRecordsInputMeta);
|
|
193
261
|
const {
|
|
194
262
|
dispatch
|
|
195
263
|
} = this.dependencies;
|
|
@@ -202,6 +270,9 @@ export class SmartTableResource extends AbstractResource {
|
|
|
202
270
|
}
|
|
203
271
|
|
|
204
272
|
deselectRecords(ids) {
|
|
273
|
+
this.validateInput('deselectRecords', {
|
|
274
|
+
ids
|
|
275
|
+
}, SdkContracts.deselectRecordsInputMeta);
|
|
205
276
|
const {
|
|
206
277
|
dispatch
|
|
207
278
|
} = this.dependencies;
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { ZLIST_FETCH_MORE_RECORDS_FAILED, ZLIST_INITIAL_AVAILABLE_FIELDS_FETCH_FAILED, ZLIST_INITIAL_CLIENT_ACTIONS_FETCH_FAILED, ZLIST_INITIAL_RECORDS_FETCH_FAILED, ZLIST_INITIAL_SELECTED_FIELDS_FETCH_FAILED, ZLIST_RECORD_DELETE_FAILED, ZLIST_RECORD_UPDATE_FAILED } from "../../../../bc/zlist/Constants";
|
|
2
|
+
import { ERROR_OCCURRED } from "../../../../cc/table-connected/constants/Events";
|
|
3
|
+
import { ErrorCode } from "../../../../cc/table-connected/ErrorEventType";
|
|
4
|
+
export default class ErrorEventHandlersFactory {
|
|
5
|
+
static create() {
|
|
6
|
+
return {
|
|
7
|
+
[ZLIST_FETCH_MORE_RECORDS_FAILED]: _ref => {
|
|
8
|
+
let {
|
|
9
|
+
action,
|
|
10
|
+
dispatch
|
|
11
|
+
} = _ref;
|
|
12
|
+
return dispatch({
|
|
13
|
+
type: ERROR_OCCURRED,
|
|
14
|
+
payload: {
|
|
15
|
+
code: ErrorCode.FETCH_MORE_RECORDS_FAILED,
|
|
16
|
+
message: action.payload.error.message,
|
|
17
|
+
errorDetails: {
|
|
18
|
+
from: action.payload.from,
|
|
19
|
+
limit: action.payload.limit,
|
|
20
|
+
error: action.payload.error
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
},
|
|
25
|
+
[ZLIST_INITIAL_AVAILABLE_FIELDS_FETCH_FAILED]: _ref2 => {
|
|
26
|
+
let {
|
|
27
|
+
action,
|
|
28
|
+
dispatch
|
|
29
|
+
} = _ref2;
|
|
30
|
+
return dispatch({
|
|
31
|
+
type: ERROR_OCCURRED,
|
|
32
|
+
payload: {
|
|
33
|
+
code: ErrorCode.INITIAL_AVAILABLE_FIELDS_FETCH_FAILED,
|
|
34
|
+
message: action.payload.error.message,
|
|
35
|
+
errorDetails: {
|
|
36
|
+
error: action.payload.error
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
},
|
|
41
|
+
[ZLIST_INITIAL_CLIENT_ACTIONS_FETCH_FAILED]: _ref3 => {
|
|
42
|
+
let {
|
|
43
|
+
action,
|
|
44
|
+
dispatch
|
|
45
|
+
} = _ref3;
|
|
46
|
+
return dispatch({
|
|
47
|
+
type: ERROR_OCCURRED,
|
|
48
|
+
payload: {
|
|
49
|
+
code: ErrorCode.INITIAL_CLIENT_ACTIONS_FETCH_FAILED,
|
|
50
|
+
message: action.payload.error.message,
|
|
51
|
+
errorDetails: {
|
|
52
|
+
error: action.payload.error
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
},
|
|
57
|
+
[ZLIST_INITIAL_RECORDS_FETCH_FAILED]: _ref4 => {
|
|
58
|
+
let {
|
|
59
|
+
action,
|
|
60
|
+
dispatch
|
|
61
|
+
} = _ref4;
|
|
62
|
+
return dispatch({
|
|
63
|
+
type: ERROR_OCCURRED,
|
|
64
|
+
payload: {
|
|
65
|
+
code: ErrorCode.INITIAL_RECORDS_FETCH_FAILED,
|
|
66
|
+
message: action.payload.error.message,
|
|
67
|
+
errorDetails: {
|
|
68
|
+
error: action.payload.error
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
},
|
|
73
|
+
[ZLIST_INITIAL_SELECTED_FIELDS_FETCH_FAILED]: _ref5 => {
|
|
74
|
+
let {
|
|
75
|
+
action,
|
|
76
|
+
dispatch
|
|
77
|
+
} = _ref5;
|
|
78
|
+
return dispatch({
|
|
79
|
+
type: ERROR_OCCURRED,
|
|
80
|
+
payload: {
|
|
81
|
+
code: ErrorCode.INITIAL_SELECTED_FIELDS_FETCH_FAILED,
|
|
82
|
+
message: action.payload.error.message,
|
|
83
|
+
errorDetails: {
|
|
84
|
+
error: action.payload.error
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
},
|
|
89
|
+
[ZLIST_RECORD_DELETE_FAILED]: _ref6 => {
|
|
90
|
+
let {
|
|
91
|
+
action,
|
|
92
|
+
dispatch
|
|
93
|
+
} = _ref6;
|
|
94
|
+
return dispatch({
|
|
95
|
+
type: ERROR_OCCURRED,
|
|
96
|
+
payload: {
|
|
97
|
+
code: ErrorCode.RECORD_DELETE_FAILED,
|
|
98
|
+
message: action.payload.error.message,
|
|
99
|
+
errorDetails: {
|
|
100
|
+
recordId: action.payload.recordId,
|
|
101
|
+
error: action.payload.error
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
},
|
|
106
|
+
[ZLIST_RECORD_UPDATE_FAILED]: _ref7 => {
|
|
107
|
+
let {
|
|
108
|
+
action,
|
|
109
|
+
dispatch
|
|
110
|
+
} = _ref7;
|
|
111
|
+
return dispatch({
|
|
112
|
+
type: ERROR_OCCURRED,
|
|
113
|
+
payload: {
|
|
114
|
+
code: ErrorCode.RECORD_UPDATE_FAILED,
|
|
115
|
+
message: action.payload.error.message,
|
|
116
|
+
errorDetails: {
|
|
117
|
+
recordId: action.payload.recordId,
|
|
118
|
+
error: action.payload.error
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
}
|