@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
|
@@ -23,9 +23,13 @@ export function parseCssNumberWithUnit(value) {
|
|
|
23
23
|
unit: match[3] || ""
|
|
24
24
|
};
|
|
25
25
|
}
|
|
26
|
-
export function
|
|
26
|
+
export function setTableInteractionClass(ref, className, add) {
|
|
27
27
|
if (ref.current) {
|
|
28
|
-
ref.current.
|
|
28
|
+
if (add && !ref.current.classList.contains(className)) {
|
|
29
|
+
ref.current.classList.add(className);
|
|
30
|
+
} else if (!add && ref.current.classList.contains(className)) {
|
|
31
|
+
ref.current.classList.remove(className);
|
|
32
|
+
}
|
|
29
33
|
}
|
|
30
34
|
}
|
|
31
35
|
export function adjustHelperElementPosition(ref, draggingClass) {
|
|
@@ -39,6 +43,8 @@ export function adjustHelperElementPosition(ref, draggingClass) {
|
|
|
39
43
|
if (helperLeft && helperLeft.unit === 'px') {
|
|
40
44
|
helperElement.style.left = `${helperLeft.number + TableScrollLeft}px`;
|
|
41
45
|
}
|
|
46
|
+
|
|
47
|
+
helperElement.scrollLeft = TableScrollLeft;
|
|
42
48
|
}
|
|
43
49
|
}
|
|
44
50
|
}
|
|
@@ -52,21 +58,29 @@ export function getDropIndicator(_ref) {
|
|
|
52
58
|
const isMovingDown = newIndex > oldIndex;
|
|
53
59
|
let dropIndex, normalizedDropIndex, dropPosition;
|
|
54
60
|
|
|
55
|
-
if (
|
|
56
|
-
|
|
61
|
+
if (index === newIndex && newIndex === 0) {
|
|
62
|
+
normalizedDropIndex = 1;
|
|
63
|
+
dropPosition = 'downward';
|
|
64
|
+
} else if (index === newIndex && newIndex === rowsLength - 1) {
|
|
65
|
+
normalizedDropIndex = rowsLength - 2;
|
|
66
|
+
dropPosition = 'upward';
|
|
57
67
|
} else {
|
|
58
|
-
|
|
59
|
-
|
|
68
|
+
if (isMovingDown) {
|
|
69
|
+
dropIndex = newIndex < index ? newIndex : newIndex + 1;
|
|
70
|
+
} else {
|
|
71
|
+
dropIndex = newIndex <= index ? newIndex - 1 : newIndex;
|
|
72
|
+
}
|
|
60
73
|
|
|
61
|
-
|
|
62
|
-
|
|
74
|
+
normalizedDropIndex = dropIndex;
|
|
75
|
+
dropPosition = isMovingDown ? 'downward' : 'upward';
|
|
63
76
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
77
|
+
if (dropIndex < 0) {
|
|
78
|
+
normalizedDropIndex = 0;
|
|
79
|
+
dropPosition = 'downward';
|
|
80
|
+
} else if (dropIndex >= rowsLength) {
|
|
81
|
+
normalizedDropIndex = rowsLength - 1;
|
|
82
|
+
dropPosition = 'upward';
|
|
83
|
+
}
|
|
70
84
|
}
|
|
71
85
|
|
|
72
86
|
return {
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { createCustomComponent } from "../../../../../../library/custom-component";
|
|
2
|
+
import ActionEventMediatorProperties from "../../../../cc/action-event-mediator/Properties";
|
|
3
|
+
import EventHandlersFactory from "./EventHandlersFactory";
|
|
4
|
+
import ActionEventMediatorView from "./ActionEventMediatorView"; // import ClientActionsSDKFactory from '../../../../behaviour/zclient-actions/frameworks/sdk/ClientActionsSDKFactory'; TODO: Add support for returning clientActionsSDK factory when client actions SDK is merged to V2
|
|
5
|
+
|
|
6
|
+
import ClientActionsBehaviourFactory from "../../../../behaviour/zclient-actions/frameworks/ClientActionsBehaviourFactory";
|
|
7
|
+
import getClientActions from "../../../../../data-source/http-template/getClientActions";
|
|
8
|
+
import ClientActionsTranslator from "../../../../translators/client-actions-translator";
|
|
9
|
+
import FetchGateWay from "../../../../../zhttp/adapters/gateway/FetchGateWay";
|
|
10
|
+
import APITemplate from "../../../../../zdata-source/domain/entities/APITemplate";
|
|
11
|
+
import TemplateHelpers from "../../../../../zdata-source/adapters/gateways/TemplateHelpers";
|
|
12
|
+
;
|
|
13
|
+
const windowWrapper = window;
|
|
14
|
+
const ClientActionsAdapterUtils = {
|
|
15
|
+
getClientActionsAPIDetails(args) {
|
|
16
|
+
const apiTemplate = new APITemplate(getClientActions, new TemplateHelpers());
|
|
17
|
+
args.servicePrefix = 'supportapi/zd';
|
|
18
|
+
args.orgName = windowWrapper.currentOrg.portalName;
|
|
19
|
+
const apiDetails = apiTemplate.getApiDetails(args);
|
|
20
|
+
apiDetails.options = {
|
|
21
|
+
headers: {
|
|
22
|
+
orgId: windowWrapper.currentOrg.id
|
|
23
|
+
},
|
|
24
|
+
method: apiDetails.method
|
|
25
|
+
};
|
|
26
|
+
return apiDetails;
|
|
27
|
+
},
|
|
28
|
+
|
|
29
|
+
transform(input) {
|
|
30
|
+
return ClientActionsTranslator.transform(input, {
|
|
31
|
+
departmentName: windowWrapper.currentDepartment.sanitizedName,
|
|
32
|
+
orgId: windowWrapper.currentOrg.id,
|
|
33
|
+
orgName: windowWrapper.currentOrg.portalName,
|
|
34
|
+
servicePrefix: 'supportapi/zd'
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
};
|
|
39
|
+
const ClientActionsAdapter = {
|
|
40
|
+
createEventHandler(clientScript) {
|
|
41
|
+
return event => {
|
|
42
|
+
let response = {
|
|
43
|
+
event: event,
|
|
44
|
+
sdk: {}
|
|
45
|
+
}; // response.sdks.clientActions = ClientActionsSDKFactory.create({ TODO: Add support for returning clientActionsSDK factory when client actions SDK is merged to V2
|
|
46
|
+
// state: event.state,
|
|
47
|
+
// dispatch: event.dispatch
|
|
48
|
+
// });
|
|
49
|
+
|
|
50
|
+
clientScript(response);
|
|
51
|
+
};
|
|
52
|
+
},
|
|
53
|
+
|
|
54
|
+
createActionToEventHandlers(clientScripts) {
|
|
55
|
+
const actionEventHandlers = {};
|
|
56
|
+
Object.keys(clientScripts).map(targetEvent => {
|
|
57
|
+
const clientScript = clientScripts[targetEvent];
|
|
58
|
+
actionEventHandlers[targetEvent] = ClientActionsAdapter.createEventHandler(clientScript);
|
|
59
|
+
});
|
|
60
|
+
return actionEventHandlers;
|
|
61
|
+
},
|
|
62
|
+
|
|
63
|
+
fetchClientActions(args) {
|
|
64
|
+
const apiDetails = ClientActionsAdapterUtils.getClientActionsAPIDetails(args);
|
|
65
|
+
const fetchGateway = new FetchGateWay(window.fetch.bind(window));
|
|
66
|
+
return fetchGateway.fetch(apiDetails.url, apiDetails.options).then(response => {
|
|
67
|
+
return response.json();
|
|
68
|
+
}).then(response => {
|
|
69
|
+
if (response.errorCode) {
|
|
70
|
+
return Promise.reject(response);
|
|
71
|
+
} else {
|
|
72
|
+
const actions = ClientActionsAdapterUtils.transform(response);
|
|
73
|
+
return Promise.resolve(actions);
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
},
|
|
77
|
+
|
|
78
|
+
getClientActionComponent: clientScripts => {
|
|
79
|
+
return createCustomComponent({
|
|
80
|
+
name: 'ClientActionsAdapter',
|
|
81
|
+
properties: ActionEventMediatorProperties,
|
|
82
|
+
setInitialState: () => ({
|
|
83
|
+
handlers: {}
|
|
84
|
+
}),
|
|
85
|
+
eventHandlers: { ...EventHandlersFactory.createClientActionsAdapterEventHandlers(),
|
|
86
|
+
...ClientActionsAdapter.createActionToEventHandlers(clientScripts)
|
|
87
|
+
},
|
|
88
|
+
behaviours: [ClientActionsBehaviourFactory.create({
|
|
89
|
+
getClientActions: getClientActions
|
|
90
|
+
})],
|
|
91
|
+
View: ActionEventMediatorView
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
export const getClientActionsAdapter = ClientActionsAdapter.getClientActionComponent;
|
|
96
|
+
export const fetchClientActions = ClientActionsAdapter.fetchClientActions;
|
|
@@ -9,6 +9,14 @@ import PropertiesChangeController from "../../adapters/controllers/PropertiesCha
|
|
|
9
9
|
import LifeCycleEvents from "../../../../../../cc/component/LifeCycleEventsEnum";
|
|
10
10
|
export default class EventHandlersFactory {
|
|
11
11
|
static create() {
|
|
12
|
+
return EventHandlersFactory.createClientActionsLifeCycleEventHandlers('ActionEventMediator');
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
static createClientActionsAdapterEventHandlers() {
|
|
16
|
+
return EventHandlersFactory.createClientActionsLifeCycleEventHandlers('ClientActionsAdapter');
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
static createClientActionsLifeCycleEventHandlers(componentName) {
|
|
12
20
|
const repository = new Repository();
|
|
13
21
|
const presenter = new Presenter();
|
|
14
22
|
const dependencies = {
|
|
@@ -22,9 +30,9 @@ export default class EventHandlersFactory {
|
|
|
22
30
|
const unmountController = new UnmountController(destroyUseCase);
|
|
23
31
|
const propertiesChangeController = new PropertiesChangeController(propertiesChangeUseCase);
|
|
24
32
|
return {
|
|
25
|
-
[
|
|
26
|
-
[
|
|
27
|
-
[
|
|
33
|
+
[`${componentName}#${LifeCycleEvents.MOUNT}`]: initializeController.handle,
|
|
34
|
+
[`${componentName}#${LifeCycleEvents.UPDATE_PROPERTIES}`]: propertiesChangeController.handle,
|
|
35
|
+
[`${componentName}#${LifeCycleEvents.UN_MOUNT}`]: unmountController.handle
|
|
28
36
|
};
|
|
29
37
|
}
|
|
30
38
|
|
|
@@ -4,7 +4,7 @@ export class ActionContextResolver {
|
|
|
4
4
|
|
|
5
5
|
static resolveContextInEventMappingPayload(eventMapping, context) {
|
|
6
6
|
return { ...eventMapping,
|
|
7
|
-
payloadValueMapping: TemplateResolver.replaceContextVariablesInObject(eventMapping.
|
|
7
|
+
payloadValueMapping: TemplateResolver.replaceContextVariablesInObject(eventMapping.payloadValueMapping, context)
|
|
8
8
|
};
|
|
9
9
|
}
|
|
10
10
|
|
|
@@ -14,9 +14,9 @@ export class ActionContextResolver {
|
|
|
14
14
|
pattern
|
|
15
15
|
} = condition;
|
|
16
16
|
const resolvedFields = fields.map(field => {
|
|
17
|
-
const resolvedValue = TemplateResolver.replaceContextVariables(field.value.join(
|
|
17
|
+
const resolvedValue = TemplateResolver.replaceContextVariables(field.value.join(','), templateContext);
|
|
18
18
|
return { ...field,
|
|
19
|
-
value: resolvedValue.split(
|
|
19
|
+
value: resolvedValue.split(',')
|
|
20
20
|
};
|
|
21
21
|
});
|
|
22
22
|
return { ...condition,
|
|
@@ -31,10 +31,10 @@ export class ActionContextResolver {
|
|
|
31
31
|
|
|
32
32
|
static resolveAction(action, context) {
|
|
33
33
|
const eventMappings = action.uiComponentMapping.eventMappings;
|
|
34
|
-
const conditions = action.
|
|
34
|
+
const conditions = action.conditions;
|
|
35
35
|
const resolvedEventMappings = eventMappings.map(eventMapping => this.resolveContextInEventMappingPayload(eventMapping, context));
|
|
36
|
-
const resolvedProperty = this.resolveContextInProperties(action.uiComponentMapping.
|
|
37
|
-
const resolveConditionValues = this.resolveConditionValueContext(conditions, context);
|
|
36
|
+
const resolvedProperty = this.resolveContextInProperties(action.uiComponentMapping.propertiesValueMapping, context);
|
|
37
|
+
const resolveConditionValues = conditions ? this.resolveConditionValueContext(conditions, context) : conditions;
|
|
38
38
|
return { ...action,
|
|
39
39
|
conditions: resolveConditionValues,
|
|
40
40
|
uiComponentMapping: { ...action.uiComponentMapping,
|
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
|
+
}
|
|
@@ -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,
|
|
@@ -8,6 +8,7 @@ function View(_ref, ref) {
|
|
|
8
8
|
} = _ref;
|
|
9
9
|
const {
|
|
10
10
|
isLoading,
|
|
11
|
+
isReOrderLoading,
|
|
11
12
|
data = [],
|
|
12
13
|
rowActionsConfig,
|
|
13
14
|
rowCursor,
|
|
@@ -19,7 +20,8 @@ function View(_ref, ref) {
|
|
|
19
20
|
reOrderConfig
|
|
20
21
|
} = state.viewModel;
|
|
21
22
|
const {
|
|
22
|
-
resizerState
|
|
23
|
+
resizerState,
|
|
24
|
+
isError
|
|
23
25
|
} = state.viewModel;
|
|
24
26
|
const {
|
|
25
27
|
preferences,
|
|
@@ -30,7 +32,9 @@ function View(_ref, ref) {
|
|
|
30
32
|
} = preferences ? preferences : {};
|
|
31
33
|
return /*#__PURE__*/React.createElement(TableList, {
|
|
32
34
|
reOrderConfig: reOrderConfig,
|
|
35
|
+
isReOrderLoading: isReOrderLoading,
|
|
33
36
|
data: data,
|
|
37
|
+
isError: isError,
|
|
34
38
|
rowCursor: rowCursor,
|
|
35
39
|
sortBy: sortBy,
|
|
36
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
|