@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
|
@@ -15,6 +15,7 @@ import ScrollController from "../adapters/controllers/ScrollController";
|
|
|
15
15
|
import ColumnChooserUpdateController from "../adapters/controllers/ColumnChooserUpdateController";
|
|
16
16
|
import ColumnChooserOpenedController from "../adapters/controllers/ColumnChooserOpenedController";
|
|
17
17
|
import { platformSDK } from "../../../sdk/frameworks/Sdk";
|
|
18
|
+
import ErrorEventHandlersFactory from "./ErrorEventHandlersFactory";
|
|
18
19
|
const {
|
|
19
20
|
TABLE_LIST_RESIZE_START_REQUESTED,
|
|
20
21
|
TABLE_LIST_RESIZE_MOVE_REQUESTED,
|
|
@@ -46,7 +47,8 @@ export default class EventHandlersFactory {
|
|
|
46
47
|
}
|
|
47
48
|
|
|
48
49
|
static create(eventHandlers) {
|
|
49
|
-
|
|
50
|
+
const wrapped = EventHandlersFactory.getSdkWrappedEventHandler(eventHandlers);
|
|
51
|
+
const defaultEventHandlers = {
|
|
50
52
|
NAVIGATION: NavigationHandler,
|
|
51
53
|
[RESIZE_FINISHED]: new ResizeFinishController().handle,
|
|
52
54
|
[TABLE_LIST_RESIZE_START_REQUESTED]: new ResizeStartController().handle,
|
|
@@ -97,10 +99,41 @@ export default class EventHandlersFactory {
|
|
|
97
99
|
},
|
|
98
100
|
[TABLE_LIST_ROW_DRAG_END]: new ReOrderFinishController().handle
|
|
99
101
|
};
|
|
102
|
+
return mergeEventHandlers([defaultEventHandlers, ErrorEventHandlersFactory.create(), wrapped]);
|
|
100
103
|
}
|
|
101
104
|
|
|
102
105
|
}
|
|
103
106
|
|
|
107
|
+
function mergeEventHandlers(eventHandlersList) {
|
|
108
|
+
const mergedEventHandlers = {};
|
|
109
|
+
const allEventNames = new Set();
|
|
110
|
+
|
|
111
|
+
for (const handlers of eventHandlersList) {
|
|
112
|
+
Object.keys(handlers).forEach(eventName => allEventNames.add(eventName));
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
for (const eventName of allEventNames) {
|
|
116
|
+
mergedEventHandlers[eventName] = createMergedHandler(eventHandlersList, eventName);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
return mergedEventHandlers;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function createMergedHandler(eventHandlersList, eventName) {
|
|
123
|
+
return function () {
|
|
124
|
+
for (const handlers of eventHandlersList) {
|
|
125
|
+
const handler = handlers[eventName];
|
|
126
|
+
|
|
127
|
+
if (typeof handler === 'function') {
|
|
128
|
+
try {
|
|
129
|
+
handler(...arguments);
|
|
130
|
+
} catch {// Silently ignore errors
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
|
|
104
137
|
function NavigationHandler(event) {
|
|
105
138
|
const {
|
|
106
139
|
url
|
|
@@ -33,6 +33,7 @@ function combineDataSourceWithDefault(dataSource) {
|
|
|
33
33
|
};
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
+
import { SmartTableEventsContracts } from "../../../../cc/table-connected";
|
|
36
37
|
export default class TableConnectedFactory {
|
|
37
38
|
static create(_ref) {
|
|
38
39
|
let {
|
|
@@ -52,6 +53,7 @@ export default class TableConnectedFactory {
|
|
|
52
53
|
return createCustomComponent({
|
|
53
54
|
name: name,
|
|
54
55
|
View: View,
|
|
56
|
+
events: SmartTableEventsContracts,
|
|
55
57
|
properties: Properties,
|
|
56
58
|
eventHandlers: EventHandlersFactory.create(eventHandlers),
|
|
57
59
|
transformState: TableTranslator.transformState,
|
|
@@ -20,7 +20,8 @@ function View(_ref, ref) {
|
|
|
20
20
|
reOrderConfig
|
|
21
21
|
} = state.viewModel;
|
|
22
22
|
const {
|
|
23
|
-
resizerState
|
|
23
|
+
resizerState,
|
|
24
|
+
isError
|
|
24
25
|
} = state.viewModel;
|
|
25
26
|
const {
|
|
26
27
|
preferences,
|
|
@@ -33,6 +34,7 @@ function View(_ref, ref) {
|
|
|
33
34
|
reOrderConfig: reOrderConfig,
|
|
34
35
|
isReOrderLoading: isReOrderLoading,
|
|
35
36
|
data: data,
|
|
37
|
+
isError: isError,
|
|
36
38
|
rowCursor: rowCursor,
|
|
37
39
|
sortBy: sortBy,
|
|
38
40
|
resizerState: resizerState,
|
|
@@ -76,21 +76,27 @@ export default class DataSource {
|
|
|
76
76
|
const {
|
|
77
77
|
actionName
|
|
78
78
|
} = fullMetaData;
|
|
79
|
-
const {
|
|
80
|
-
type,
|
|
81
|
-
metaData
|
|
82
|
-
} = fullMetaData[DATA_SOURCE_FAILURE];
|
|
83
79
|
const actions = [];
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
80
|
+
let failureMetaData = {};
|
|
81
|
+
|
|
82
|
+
if (fullMetaData[DATA_SOURCE_FAILURE]) {
|
|
83
|
+
const {
|
|
84
|
+
type,
|
|
85
|
+
metaData
|
|
86
|
+
} = fullMetaData[DATA_SOURCE_FAILURE];
|
|
87
|
+
failureMetaData = metaData;
|
|
88
|
+
type && actions.push({
|
|
89
|
+
type,
|
|
90
|
+
metaData: failureMetaData,
|
|
91
|
+
payload: {
|
|
92
|
+
error
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
|
|
91
97
|
actions.push({
|
|
92
98
|
type: DATA_SOURCE_EXECUTE_FAILED,
|
|
93
|
-
metaData,
|
|
99
|
+
metaData: failureMetaData,
|
|
94
100
|
payload: {
|
|
95
101
|
actionName,
|
|
96
102
|
error
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { FIELD_FETCH_FAILURE, FIELD_FETCH_NO_CONTENT, FIELD_FETCH_SUCCESS } from "../../../../../bc/zfield/Constants";
|
|
2
2
|
import FieldApiName from "../interfaces/FieldApiName";
|
|
3
3
|
import { DATA_SOURCE_EXECUTE } from "../../../../../bc/zdata-source/Constants";
|
|
4
|
-
import { DATA_SOURCE_SUCCESS } from "../../../../../bc/zdata-source/Symbols";
|
|
4
|
+
import { DATA_SOURCE_FAILURE, DATA_SOURCE_SUCCESS } from "../../../../../bc/zdata-source/Symbols";
|
|
5
5
|
|
|
6
6
|
class FieldManager {
|
|
7
7
|
constructor(fields, selectedFields, isFieldsFetching, isSelectedFieldsFetching) {
|
|
@@ -52,6 +52,12 @@ class FieldManager {
|
|
|
52
52
|
metaData: {
|
|
53
53
|
apiName
|
|
54
54
|
}
|
|
55
|
+
},
|
|
56
|
+
[DATA_SOURCE_FAILURE]: {
|
|
57
|
+
metaData: {
|
|
58
|
+
apiName,
|
|
59
|
+
actionName: apiName
|
|
60
|
+
}
|
|
55
61
|
}
|
|
56
62
|
}
|
|
57
63
|
};
|
|
@@ -5,16 +5,23 @@ class FieldValueChangeController extends AbstractController {
|
|
|
5
5
|
const {
|
|
6
6
|
fieldValueChangeRequestUseCase
|
|
7
7
|
} = this.service;
|
|
8
|
-
|
|
8
|
+
const {
|
|
9
9
|
state,
|
|
10
10
|
updateState,
|
|
11
11
|
action,
|
|
12
12
|
dispatch
|
|
13
13
|
} = event;
|
|
14
|
+
const {
|
|
15
|
+
fieldName,
|
|
16
|
+
value,
|
|
17
|
+
sectionId
|
|
18
|
+
} = action.payload;
|
|
14
19
|
fieldValueChangeRequestUseCase.updateDependency(state, updateState);
|
|
15
20
|
fieldValueChangeRequestUseCase.execute({
|
|
16
|
-
fieldName
|
|
17
|
-
newValue:
|
|
21
|
+
fieldName,
|
|
22
|
+
newValue: value,
|
|
23
|
+
sectionId,
|
|
24
|
+
dispatch
|
|
18
25
|
});
|
|
19
26
|
}
|
|
20
27
|
|
|
@@ -17,7 +17,6 @@ const CurrencyFieldTranslator = _ref => {
|
|
|
17
17
|
placeholder: field.toolTipType === "placeholder" ? field.toolTip : "",
|
|
18
18
|
required: field.isMandatory,
|
|
19
19
|
readonly: field.isReadOnly,
|
|
20
|
-
// visibility: field.isVisible,
|
|
21
20
|
isVisible: field.isVisible,
|
|
22
21
|
errorMessage: field.errorMessage || ''
|
|
23
22
|
}; // if (ePHIFields[field.type]) {
|
|
@@ -17,7 +17,6 @@ const DecimalFieldTranslator = _ref => {
|
|
|
17
17
|
placeholder: field.toolTipType === "placeholder" ? field.toolTip : "",
|
|
18
18
|
required: field.isMandatory,
|
|
19
19
|
readonly: field.isReadOnly,
|
|
20
|
-
// visibility: field.isVisible,
|
|
21
20
|
isVisible: field.isVisible,
|
|
22
21
|
errorMessage: field.errorMessage || ''
|
|
23
22
|
}; // if (ePHIFields[field.type]) {
|
|
@@ -17,7 +17,6 @@ const PhoneFieldTranslator = _ref => {
|
|
|
17
17
|
placeholder: field.toolTipType === "placeholder" ? field.toolTip : "",
|
|
18
18
|
required: field.isMandatory,
|
|
19
19
|
readonly: field.isReadOnly,
|
|
20
|
-
visibility: field.isVisible,
|
|
21
20
|
isVisible: field.isVisible,
|
|
22
21
|
errorMessage: field.errorMessage || ''
|
|
23
22
|
}; // if (ePHIFields[field.type]) {
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import AbstractUseCase from "./AbstractUseCase";
|
|
2
|
+
import { ZFORM_FIELD_VALUE_CHANGED } from "../../../../bc/zform/Symbol";
|
|
2
3
|
|
|
3
4
|
class FieldValueChangeRequestUseCase extends AbstractUseCase {
|
|
4
5
|
execute(input) {
|
|
5
6
|
let {
|
|
7
|
+
sectionId,
|
|
6
8
|
fieldName,
|
|
7
|
-
newValue
|
|
9
|
+
newValue,
|
|
10
|
+
dispatch
|
|
8
11
|
} = input;
|
|
9
12
|
let {
|
|
10
13
|
layoutRuleApplier
|
|
@@ -29,6 +32,15 @@ class FieldValueChangeRequestUseCase extends AbstractUseCase {
|
|
|
29
32
|
// zform=zformEntitiy.toObject();
|
|
30
33
|
|
|
31
34
|
this.dependencies.presenter.updateFormResponse(zform);
|
|
35
|
+
dispatch({
|
|
36
|
+
type: ZFORM_FIELD_VALUE_CHANGED,
|
|
37
|
+
payload: {
|
|
38
|
+
sectionId,
|
|
39
|
+
fieldName,
|
|
40
|
+
value: newValue
|
|
41
|
+
},
|
|
42
|
+
metaData: {}
|
|
43
|
+
});
|
|
32
44
|
}
|
|
33
45
|
|
|
34
46
|
}
|
|
@@ -1,7 +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
3
|
export default class ZField {
|
|
4
|
-
// visibility:boolean;
|
|
5
4
|
constructor(_ref) {
|
|
6
5
|
let {
|
|
7
6
|
displayLabel,
|
|
@@ -19,7 +18,6 @@ export default class ZField {
|
|
|
19
18
|
isMandatory,
|
|
20
19
|
value,
|
|
21
20
|
errorMessage,
|
|
22
|
-
// visibility=true,
|
|
23
21
|
isVisible = true,
|
|
24
22
|
pickListValues,
|
|
25
23
|
toolTip,
|
|
@@ -86,8 +84,7 @@ export default class ZField {
|
|
|
86
84
|
this.maxLength = maxLength;
|
|
87
85
|
this.isMandatory = isMandatory;
|
|
88
86
|
this.value = value;
|
|
89
|
-
this.errorMessage = errorMessage;
|
|
90
|
-
|
|
87
|
+
this.errorMessage = errorMessage;
|
|
91
88
|
this.isVisible = isVisible;
|
|
92
89
|
this.defaultPickListValues = pickListValues;
|
|
93
90
|
this.pickListValues = pickListValues;
|
|
@@ -167,12 +164,10 @@ export default class ZField {
|
|
|
167
164
|
}
|
|
168
165
|
|
|
169
166
|
toggleVisibility() {
|
|
170
|
-
// this.visibility=!this.visibility;
|
|
171
167
|
this.isVisible = !this.isVisible;
|
|
172
168
|
}
|
|
173
169
|
|
|
174
170
|
setVisibility(visibility) {
|
|
175
|
-
// this.visibility=visibility;
|
|
176
171
|
this.isVisible = visibility;
|
|
177
172
|
}
|
|
178
173
|
|
|
@@ -206,7 +201,8 @@ export default class ZField {
|
|
|
206
201
|
isMandatory: this.isMandatory,
|
|
207
202
|
value: this.value,
|
|
208
203
|
errorMessage: this.errorMessage,
|
|
209
|
-
//
|
|
204
|
+
// NOTE: visibility is now isVisible, visibility is deprecated, only for backward compatibility of layout rules
|
|
205
|
+
visibility: this.isVisible,
|
|
210
206
|
isVisible: this.isVisible,
|
|
211
207
|
pickListValues: this.pickListValues,
|
|
212
208
|
toolTip: this.toolTip,
|
|
@@ -209,11 +209,17 @@ class EventHandlersFactory {
|
|
|
209
209
|
action,
|
|
210
210
|
dispatch
|
|
211
211
|
} = _ref8;
|
|
212
|
+
const {
|
|
213
|
+
sectionId,
|
|
214
|
+
fieldName,
|
|
215
|
+
value
|
|
216
|
+
} = action.payload;
|
|
212
217
|
dispatch({
|
|
213
218
|
type: ZFORM_FIELD_VALUE_CHANGE_REQUEST,
|
|
214
219
|
payload: {
|
|
215
|
-
|
|
216
|
-
|
|
220
|
+
sectionId,
|
|
221
|
+
fieldName,
|
|
222
|
+
value
|
|
217
223
|
},
|
|
218
224
|
metaData: {}
|
|
219
225
|
});
|
|
@@ -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
|
}
|
|
@@ -50,6 +50,7 @@ export default class TableTranslator {
|
|
|
50
50
|
|
|
51
51
|
const {
|
|
52
52
|
sortBy,
|
|
53
|
+
errorState,
|
|
53
54
|
isReOrderLoading
|
|
54
55
|
} = fallbackToDefault(zlist, {}); // FIX: zlist should be available by default
|
|
55
56
|
|
|
@@ -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,
|
|
@@ -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 {
|