@zohodesk/library-platform 1.1.6 → 1.1.7-exp.2
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/sdk/ResourceNamesEnum.js +2 -0
- package/es/bc/zform/Properties.js +3 -26
- package/es/bc/zform/Symbol.js +2 -0
- package/es/bc/zlist/Constants.js +3 -1
- package/es/bc/zrecord/Constants.js +1 -0
- package/es/cc/breadcrumb/Constants.js +7 -0
- package/es/cc/breadcrumb/Events.js +14 -0
- package/es/cc/breadcrumb/Properties.js +35 -0
- package/es/cc/breadcrumb/index.js +3 -0
- package/es/cc/fields/field/FormDefaultUIType.js +37 -0
- package/es/cc/fields/index.js +2 -1
- package/es/cc/form/Properties.js +54 -0
- package/es/cc/form-connected/Constants.js +8 -0
- package/es/cc/form-connected/Properties.js +95 -1
- package/es/cc/form-connected/SdkContract.js +159 -0
- package/es/cc/icon-button/Constants.js +7 -0
- package/es/cc/icon-button/Events.js +5 -0
- package/es/cc/icon-button/Properties.js +86 -0
- package/es/cc/icon-button/index.js +3 -0
- package/es/cc/index.js +1 -0
- package/es/cc/section/Properties.js +25 -0
- package/es/cc/table-connected/Properties.js +8 -0
- package/es/cc/table-connected/constants/Events.js +1 -0
- package/es/index.js +6 -1
- package/es/library/dot/components/action-location/frameworks/ui/ActionComponentMapping.js +5 -1
- package/es/library/dot/components/action-location/usecases/interactors/PropertiesChangeUseCase.js +1 -1
- package/es/library/dot/components/form/adapters/presenter/TransformState.js +70 -3
- package/es/library/dot/components/form/frameworks/ui/DefaultComponentRegister.js +28 -0
- package/es/library/dot/components/form/frameworks/ui/Form.js +2 -0
- package/es/library/dot/components/form/frameworks/ui/FormView.js +47 -26
- package/es/library/dot/components/form/frameworks/ui/css/Form.module.css +8 -4
- package/es/library/dot/components/form/frameworks/ui/sub-components/Sections.js +9 -9
- package/es/library/dot/components/section/frameworks/ui/RenderField.js +19 -0
- package/es/library/dot/components/section/frameworks/ui/Section.js +13 -4
- package/es/library/dot/components/section/frameworks/ui/SectionView.js +7 -28
- package/es/library/dot/components/table-list/frameworks/ui/css/TableList.module.css +72 -40
- package/es/library/dot/components/table-list/frameworks/ui/sub-components/Header.js +7 -13
- package/es/library/dot/components/table-list/frameworks/ui/sub-components/row/Row.js +2 -2
- package/es/library/dot/legacy-to-new-arch/breadcrumb/frameworks/ui/Breadcrumb.js +12 -0
- package/es/library/dot/legacy-to-new-arch/breadcrumb/frameworks/ui/BreadcrumbView.js +47 -0
- package/es/library/dot/legacy-to-new-arch/breadcrumb/frameworks/ui/css/Breadcrumb.module.css +19 -0
- package/es/library/dot/legacy-to-new-arch/breadcrumb/frameworks/ui/sub-components/BreadcrumbItem.js +58 -0
- package/es/library/dot/legacy-to-new-arch/icon-button/frameworks/ui/IconButton.js +12 -0
- package/es/library/dot/legacy-to-new-arch/icon-button/frameworks/ui/IconButtonView.js +43 -0
- package/es/platform/client-actions/bc/zclient-actions/SdkContract.js +35 -0
- package/es/platform/client-actions/behaviour/zclient-actions/adapters/resources/ClientActionResource.js +105 -0
- package/es/platform/client-actions/behaviour/zclient-actions/applications/interfaces/IClientActionResource.js +1 -0
- package/es/platform/client-actions/behaviour/zclient-actions/applications/interfaces/input/GetClientActionLocationInputModel.js +1 -0
- package/es/platform/client-actions/behaviour/zclient-actions/applications/interfaces/input/GetClientActionUIComponentPropertiesInputModel.js +1 -0
- package/es/platform/client-actions/behaviour/zclient-actions/applications/interfaces/input/GetClientActionsInputModel.js +1 -0
- package/es/platform/client-actions/behaviour/zclient-actions/applications/interfaces/input/UpdateClientActionUIComponentPropertiesInputModel.js +1 -0
- package/es/platform/client-actions/behaviour/zclient-actions/applications/usecases/GetClientActionLocationUseCase.js +20 -0
- package/es/platform/client-actions/behaviour/zclient-actions/applications/usecases/GetClientActionUIComponentPropertiesUseCase.js +20 -0
- package/es/platform/client-actions/behaviour/zclient-actions/applications/usecases/GetClientActionsUseCase.js +18 -0
- package/es/platform/client-actions/behaviour/zclient-actions/applications/usecases/UpdateClientActionUIComponentPropertiesUseCase.js +32 -0
- package/es/platform/client-actions/behaviour/zclient-actions/domain/entities/ClientAction.js +12 -0
- package/es/platform/client-actions/behaviour/zclient-actions/domain/entities/ClientActionManager.js +45 -0
- package/es/platform/client-actions/behaviour/zclient-actions/domain/entities/UIComponentMapping.js +10 -0
- package/es/platform/client-actions/behaviour/zclient-actions/frameworks/sdk/ClientActionsSDKFactory.js +29 -0
- package/es/platform/client-actions/cc/action-event-mediator/Properties.js +9 -0
- package/es/platform/client-actions/components/action-event-mediator/applications/usecases/PropertiesChangeUseCase.js +1 -1
- package/es/platform/client-actions/components/action-event-mediator/domain/entities/ActionEventMediatorEntity.js +7 -3
- package/es/platform/client-actions/components/action-event-mediator/frameworks/ui/ActionEventMediatorView.js +3 -1
- package/es/platform/client-actions/components/dynamic-component/frameworks/ui/DynamicActionComponentView.js +4 -2
- package/es/platform/client-actions/components/row-actions-renderer/frameworks/ui/RowActionsRenderer.module.css +4 -0
- package/es/platform/client-actions/components/row-actions-renderer/frameworks/ui/RowActionsRendererView.js +5 -2
- package/es/platform/components/form-connected/adapters/resources/SmartFormResources.js +210 -0
- package/es/platform/components/form-connected/application/interfaces/ISmartFormResources.js +1 -0
- package/es/platform/components/form-connected/frameworks/EventHandlersFactory.js +16 -8
- package/es/platform/components/form-connected/frameworks/FormConnectedFactory.js +27 -3
- package/es/platform/components/form-connected/frameworks/FormConnectedView.js +14 -2
- package/es/platform/components/form-connected/frameworks/FormSdkFactory.js +33 -13
- package/es/platform/components/table-connected/adapters/resources/SmartTableResource.js +0 -52
- package/es/platform/components/table-connected/frameworks/EventHandlersFactory.js +15 -1
- package/es/platform/components/table-connected/frameworks/TableConnectedFactory.js +6 -1
- package/es/platform/data-source/http-template/getClientActions.js +2 -2
- package/es/platform/sdk/application/interfaces/gateways/AbstractResource.js +52 -1
- package/es/platform/sdk/frameworks/Sdk.js +14 -0
- package/es/platform/zform/adapters/presenter/FormTranslator.js +90 -46
- package/es/platform/zform/adapters/presenter/translators/SectionTranslator.js +51 -26
- package/es/platform/zform/adapters/presenter/translators/interfaces/ComponentMapping.js +1 -0
- package/es/platform/zform/adapters/presenter/translators/interfaces/FieldContract.js +1 -0
- package/es/platform/zform/adapters/presenter/translators/interfaces/FormTranslatorState.js +1 -0
- package/es/platform/zform/adapters/presenter/translators/interfaces/SectionContract.js +1 -0
- package/es/platform/zform/adapters/presenter/utils/DefaultClientActions.js +59 -0
- package/es/platform/zform/applications/interfaces/input/DeleteFieldUseCaseInput.js +1 -0
- package/es/platform/zform/applications/interfaces/input/GetFieldValueUseCaseInput.js +1 -0
- package/es/platform/zform/applications/interfaces/input/HideFieldUseCaseInput.js +1 -0
- package/es/platform/zform/applications/interfaces/input/HideSectionUseCaseInput.js +1 -0
- package/es/platform/zform/applications/interfaces/input/InsertFieldUseCaseInput.js +1 -0
- package/es/platform/zform/applications/interfaces/input/SetFieldValueUseCaseInput.js +1 -0
- package/es/platform/zform/applications/interfaces/input/SetFieldsValuesUseCaseInput.js +1 -0
- package/es/platform/zform/applications/interfaces/input/ShowFieldUseCaseInput.js +1 -0
- package/es/platform/zform/applications/interfaces/input/ShowSectionUseCaseInput.js +1 -0
- package/es/platform/zform/applications/interfaces/input/SubmitUseCaseInput.js +1 -0
- package/es/platform/zform/applications/interfaces/input/UpdateFieldUseCaseInput.js +1 -0
- package/es/platform/zform/applications/usecases/DeleteFieldUseCase.js +22 -0
- package/es/platform/zform/applications/usecases/GetFieldValueUseCase.js +23 -0
- package/es/platform/zform/applications/usecases/HideFieldUseCase.js +19 -0
- package/es/platform/zform/applications/usecases/HideSectionUseCase.js +19 -0
- package/es/platform/zform/applications/usecases/InitializeUseCase.js +16 -0
- package/es/platform/zform/applications/usecases/InsertFieldUseCase.js +28 -0
- package/es/platform/zform/applications/usecases/SetFieldValueUseCase.js +44 -0
- package/es/platform/zform/applications/usecases/SetFieldsValuesUseCase.js +51 -0
- package/es/platform/zform/applications/usecases/ShowFieldUseCase.js +19 -0
- package/es/platform/zform/applications/usecases/ShowSectionUseCase.js +19 -0
- package/es/platform/zform/applications/usecases/SubmitUseCase.js +29 -0
- package/es/platform/zform/applications/usecases/UpdateFieldUseCase.js +22 -0
- package/es/platform/zform/domain/ZField.js +14 -0
- package/es/platform/zform/domain/ZForm.js +85 -3
- package/es/platform/zform/domain/ZSection.js +6 -0
- package/es/platform/zform/frameworks/layout-rules/calculateLayoutRulesResult.js +1 -1
- package/es/platform/zform/frameworks/layout-rules/runSingleFieldCondition.js +1 -1
- package/es/platform/zform/frameworks/layout-rules/validator.js +0 -1
- package/es/platform/zform/frameworks/ui/EventHandlerFactory.js +37 -15
- package/es/platform/zlist/adapters/presenters/TableTranslator.js +3 -2
- package/es/platform/zlist/applications/usecases/RecordSuccessCallbackUsecase.js +4 -1
- package/es/platform/zlist/domain/entities/List.js +9 -3
- package/es/platform/zrecord/adapters/controllers/CreateRecordController.js +5 -1
- package/es/platform/zrecord/adapters/controllers/SetRecordsController.js +7 -3
- package/es/platform/zrecord/applications/usecases/CreateRecordUseCase.js +5 -3
- package/es/platform/zrecord/applications/usecases/SetRecordsUseCase.js +11 -1
- package/package.json +8 -6
- package/es/library/dot/components/section/adapters/presenter/TransFormState.js +0 -26
|
@@ -1,6 +1,7 @@
|
|
|
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
|
+
import ErrorPrinter from "../../../../components/table-connected/adapters/resources/ErrorPrinter";
|
|
4
|
+
import Validator from "../../../../../library/custom-component/frameworks/json-schema-validator/Validator";
|
|
4
5
|
export class AbstractResource {
|
|
5
6
|
constructor() {
|
|
6
7
|
_defineProperty(this, "dependencies", void 0);
|
|
@@ -10,4 +11,54 @@ export class AbstractResource {
|
|
|
10
11
|
this.dependencies = dependencies;
|
|
11
12
|
}
|
|
12
13
|
|
|
14
|
+
safeValidateInput(meta, input) {
|
|
15
|
+
try {
|
|
16
|
+
const result = Validator.validate(meta, input);
|
|
17
|
+
return result;
|
|
18
|
+
} catch (error) {
|
|
19
|
+
return {
|
|
20
|
+
isValid: false,
|
|
21
|
+
errors: [{
|
|
22
|
+
dataPath: '',
|
|
23
|
+
keyword: 'internal',
|
|
24
|
+
message: 'invalid schema'
|
|
25
|
+
}]
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
validateInput(methodName, input, meta) {
|
|
31
|
+
const {
|
|
32
|
+
isValid,
|
|
33
|
+
errors
|
|
34
|
+
} = this.safeValidateInput(meta, input);
|
|
35
|
+
|
|
36
|
+
if (!isValid) {
|
|
37
|
+
const title = `%c Invalid sdk input for %c${methodName}`;
|
|
38
|
+
const styles = ['color: red; font-weight: bold;', 'color: #FF6F61; font-weight: bold;'];
|
|
39
|
+
ErrorPrinter.displaySchemaErrors({
|
|
40
|
+
msg: title,
|
|
41
|
+
styles
|
|
42
|
+
}, errors, '');
|
|
43
|
+
throw {
|
|
44
|
+
code: 'ValidationError',
|
|
45
|
+
message: `Invalid input for ${methodName}`,
|
|
46
|
+
details: {
|
|
47
|
+
methodName,
|
|
48
|
+
errors
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
createCallback() {
|
|
55
|
+
let temp = null;
|
|
56
|
+
return {
|
|
57
|
+
setData: data => {
|
|
58
|
+
temp = data;
|
|
59
|
+
},
|
|
60
|
+
getData: () => temp
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
|
|
13
64
|
}
|
|
@@ -6,6 +6,20 @@ export const platformSDK = {
|
|
|
6
6
|
resourceName: ResourceNamesEnum.SMART_TABLE,
|
|
7
7
|
instanceName
|
|
8
8
|
});
|
|
9
|
+
},
|
|
10
|
+
|
|
11
|
+
[ResourceNamesEnum.SMART_FORM](instanceName) {
|
|
12
|
+
return sdkRegistry.getResourceInstance({
|
|
13
|
+
resourceName: ResourceNamesEnum.SMART_FORM,
|
|
14
|
+
instanceName: instanceName
|
|
15
|
+
});
|
|
16
|
+
},
|
|
17
|
+
|
|
18
|
+
[ResourceNamesEnum.CLIENT_ACTION](instanceName) {
|
|
19
|
+
return sdkRegistry.getResourceInstance({
|
|
20
|
+
resourceName: ResourceNamesEnum.CLIENT_ACTION,
|
|
21
|
+
instanceName
|
|
22
|
+
});
|
|
9
23
|
}
|
|
10
24
|
|
|
11
25
|
};
|
|
@@ -1,64 +1,108 @@
|
|
|
1
|
+
import ClientActionsTranslator from "../../../client-actions/translators/client-actions-translator";
|
|
1
2
|
import SectionTranslator from "./translators/SectionTranslator";
|
|
2
|
-
|
|
3
|
-
Text: 'TextBox',
|
|
4
|
-
Textarea: 'TextArea',
|
|
5
|
-
Boolean: 'Checkbox',
|
|
6
|
-
URL: 'Url',
|
|
7
|
-
Picklist: 'PickList',
|
|
8
|
-
AutoNumber: 'TextBox',
|
|
9
|
-
Number: 'Number',
|
|
10
|
-
Decimal: 'Decimal',
|
|
11
|
-
Email: 'Email',
|
|
12
|
-
Phone: 'Phone',
|
|
13
|
-
Currency: 'Currency',
|
|
14
|
-
Percent: 'Percentage',
|
|
15
|
-
Date: 'Date',
|
|
16
|
-
DateTime: 'DateTime',
|
|
17
|
-
Multiselect: 'MultiSelect',
|
|
18
|
-
LookUp: 'TextBox'
|
|
19
|
-
};
|
|
20
|
-
const ePHIFields = {
|
|
21
|
-
Text: true,
|
|
22
|
-
Textarea: true,
|
|
23
|
-
URL: true,
|
|
24
|
-
Picklist: true,
|
|
25
|
-
Number: true,
|
|
26
|
-
Decimal: true,
|
|
27
|
-
Email: false,
|
|
28
|
-
Phone: true,
|
|
29
|
-
Currency: false,
|
|
30
|
-
Percent: true,
|
|
31
|
-
AutoNumber: false,
|
|
32
|
-
Date: false,
|
|
33
|
-
DateTime: false,
|
|
34
|
-
Multiselect: false,
|
|
35
|
-
Boolean: false,
|
|
36
|
-
LookUp: false
|
|
37
|
-
};
|
|
3
|
+
import DefaultFormClientActions from "./utils/DefaultClientActions";
|
|
38
4
|
export default class FormTranslator {
|
|
39
5
|
static transformState(state) {
|
|
40
|
-
|
|
6
|
+
const {
|
|
7
|
+
componentMapping,
|
|
8
|
+
context,
|
|
9
|
+
isHeaderEnabled = true,
|
|
10
|
+
isFooterEnabled = true,
|
|
11
|
+
submitConfig = {
|
|
12
|
+
text: "Submit",
|
|
13
|
+
isEnabled: true
|
|
14
|
+
},
|
|
15
|
+
cancelConfig = {
|
|
16
|
+
text: "Cancel",
|
|
17
|
+
isEnabled: true
|
|
18
|
+
}
|
|
19
|
+
} = state.properties;
|
|
20
|
+
const {
|
|
21
|
+
zform,
|
|
22
|
+
zclientAction
|
|
23
|
+
} = state.behaviours;
|
|
24
|
+
const {
|
|
25
|
+
clientActions,
|
|
26
|
+
isFetching: isClientActionsFetching
|
|
27
|
+
} = zclientAction || {};
|
|
28
|
+
let combinedClientActions = DefaultFormClientActions({
|
|
29
|
+
clientActions,
|
|
30
|
+
submitConfig,
|
|
31
|
+
cancelConfig
|
|
32
|
+
});
|
|
33
|
+
const mappedClientActions = mapper(combinedClientActions || []);
|
|
34
|
+
const transformedClientActions = {};
|
|
35
|
+
Object.entries(mappedClientActions).forEach(_ref => {
|
|
36
|
+
let [key, value] = _ref;
|
|
41
37
|
|
|
42
|
-
|
|
38
|
+
if (isFooterEnabled && (key === 'footerRightActions' || key === 'footerLeftActions')) {
|
|
39
|
+
let footerActions = ClientActionsTranslator.transform(value, context);
|
|
40
|
+
transformedClientActions[key] = footerActions;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (isHeaderEnabled && (key === 'headerLeftActions' || key === 'headerRightActions')) {
|
|
44
|
+
let headerActions = ClientActionsTranslator.transform(value, context);
|
|
45
|
+
transformedClientActions[key] = headerActions;
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
const {
|
|
49
|
+
headerLeftActions,
|
|
50
|
+
headerRightActions,
|
|
51
|
+
footerLeftActions,
|
|
52
|
+
footerRightActions
|
|
53
|
+
} = transformedClientActions;
|
|
54
|
+
const {
|
|
55
|
+
isMyFormFetching,
|
|
56
|
+
isDependencyFetching,
|
|
57
|
+
isLayoutRulesFetching,
|
|
58
|
+
isValidationRulesFetching,
|
|
59
|
+
sections
|
|
60
|
+
} = zform;
|
|
61
|
+
const isLoading = isMyFormFetching || isDependencyFetching || isLayoutRulesFetching || isValidationRulesFetching;
|
|
62
|
+
|
|
63
|
+
if (isLoading) {
|
|
64
|
+
return { ...state,
|
|
65
|
+
viewModel: {
|
|
66
|
+
isLoading: true
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (isLoading) {
|
|
43
72
|
return { ...state,
|
|
44
73
|
viewModel: {
|
|
45
74
|
isLoading: true
|
|
46
75
|
}
|
|
47
76
|
};
|
|
48
77
|
} else {
|
|
49
|
-
let sections = SectionTranslator({
|
|
50
|
-
state,
|
|
51
|
-
fieldTypeToUIType,
|
|
52
|
-
ePHIFields,
|
|
53
|
-
uiMapping
|
|
54
|
-
});
|
|
55
78
|
return { ...state,
|
|
79
|
+
...zclientAction,
|
|
56
80
|
viewModel: {
|
|
57
|
-
sections
|
|
81
|
+
sections: sections.map(section => {
|
|
82
|
+
const sectionViewModel = SectionTranslator({
|
|
83
|
+
section,
|
|
84
|
+
componentMapping,
|
|
85
|
+
context
|
|
86
|
+
});
|
|
87
|
+
return sectionViewModel;
|
|
88
|
+
}),
|
|
89
|
+
isHeaderEnabled,
|
|
90
|
+
isFooterEnabled,
|
|
91
|
+
headerLeftActions,
|
|
92
|
+
headerRightActions,
|
|
93
|
+
footerLeftActions,
|
|
94
|
+
footerRightActions,
|
|
58
95
|
isLoading: false
|
|
59
96
|
}
|
|
60
97
|
};
|
|
61
98
|
}
|
|
62
99
|
}
|
|
63
100
|
|
|
64
|
-
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const mapper = clientAction => ({
|
|
104
|
+
headerLeftActions: clientAction.filter(action => action.location === 'header_left_actions'),
|
|
105
|
+
headerRightActions: clientAction.filter(action => action.location === 'header_right_actions'),
|
|
106
|
+
footerLeftActions: clientAction.filter(action => action.location === 'footer_left_actions'),
|
|
107
|
+
footerRightActions: clientAction.filter(action => action.location === 'footer_right_actions')
|
|
108
|
+
});
|
|
@@ -1,32 +1,57 @@
|
|
|
1
|
+
import { DefaultFormSectionUIType, fieldTypeToUIType } from "../../../../../cc/fields/field/FormDefaultUIType";
|
|
1
2
|
import * as FieldTranslators from "./fields";
|
|
2
3
|
|
|
3
|
-
|
|
4
|
+
function SectionTranslator(_ref) {
|
|
5
|
+
var _componentMapping$sec;
|
|
6
|
+
|
|
4
7
|
let {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
uiMapping
|
|
8
|
+
section,
|
|
9
|
+
componentMapping,
|
|
10
|
+
context
|
|
9
11
|
} = _ref;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
12
|
+
const mapping = componentMapping === null || componentMapping === void 0 ? void 0 : (_componentMapping$sec = componentMapping.sections) === null || _componentMapping$sec === void 0 ? void 0 : _componentMapping$sec[section.name];
|
|
13
|
+
|
|
14
|
+
const sectionVisibility = section => {
|
|
15
|
+
let allFieldHidden = section.fields.every(field => !field.isVisible);
|
|
16
|
+
return !allFieldHidden;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const defaultViewModel = {
|
|
20
|
+
type: mapping !== null && mapping !== void 0 && mapping.UIComponentName ? mapping.UIComponentName : DefaultFormSectionUIType,
|
|
21
|
+
id: section.id + '',
|
|
22
|
+
name: section.name,
|
|
23
|
+
title: section.i18NLabel,
|
|
24
|
+
description: section.description,
|
|
25
|
+
isCollapsed: section.isCollapsed,
|
|
26
|
+
isVisible: section.isVisible && sectionVisibility(section),
|
|
27
|
+
fields: section.fields.map(field => {
|
|
28
|
+
var _componentMapping$fie;
|
|
29
|
+
|
|
30
|
+
const fieldTranslator = FieldTranslators[field.type];
|
|
31
|
+
const {
|
|
32
|
+
UIComponentName,
|
|
33
|
+
translator
|
|
34
|
+
} = (componentMapping === null || componentMapping === void 0 ? void 0 : (_componentMapping$fie = componentMapping.fields) === null || _componentMapping$fie === void 0 ? void 0 : _componentMapping$fie[field.apiName]) || {};
|
|
35
|
+
const type = UIComponentName || fieldTypeToUIType[field.type];
|
|
36
|
+
const viewModel = fieldTranslator({
|
|
37
|
+
field,
|
|
38
|
+
type
|
|
39
|
+
});
|
|
40
|
+
return translator ? translator({
|
|
41
|
+
context,
|
|
42
|
+
field: viewModel
|
|
43
|
+
}) : viewModel;
|
|
44
|
+
})
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
if (mapping !== null && mapping !== void 0 && mapping.translator) {
|
|
48
|
+
return mapping.translator({
|
|
49
|
+
section: defaultViewModel,
|
|
50
|
+
context
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return defaultViewModel;
|
|
55
|
+
}
|
|
31
56
|
|
|
32
57
|
export default SectionTranslator;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
function getDefaultFormAction(_ref) {
|
|
2
|
+
let {
|
|
3
|
+
type,
|
|
4
|
+
text,
|
|
5
|
+
isEnabled
|
|
6
|
+
} = _ref;
|
|
7
|
+
const isSubmit = type === "submit";
|
|
8
|
+
return {
|
|
9
|
+
id: isSubmit ? "4000000080010" : "4000000080013",
|
|
10
|
+
name: "FORM ACTION",
|
|
11
|
+
component: "form",
|
|
12
|
+
location: "footer_left_actions",
|
|
13
|
+
uiComponentMapping: {
|
|
14
|
+
id: isSubmit ? "4000000080011" : "4000000080014",
|
|
15
|
+
name: isSubmit ? "Submit Button" : "Cancel Button",
|
|
16
|
+
component: "Button",
|
|
17
|
+
propertiesValueMapping: {
|
|
18
|
+
text: text || (isSubmit ? "Submit" : "Cancel"),
|
|
19
|
+
palette: isSubmit ? "primaryFilled" : "secondary"
|
|
20
|
+
},
|
|
21
|
+
eventMappings: [{
|
|
22
|
+
id: isSubmit ? "4000000080012" : "4000000080015",
|
|
23
|
+
sourceEvent: "BUTTON#CLICKED",
|
|
24
|
+
targetEvent: isSubmit ? "SMART_FORM#SUBMIT_CLICKED" : "SMART_FORM#CANCEL_CLICKED",
|
|
25
|
+
payloadValueMapping: {}
|
|
26
|
+
}]
|
|
27
|
+
},
|
|
28
|
+
modules: ["static_module"],
|
|
29
|
+
conditions: {
|
|
30
|
+
fields: [],
|
|
31
|
+
pattern: ""
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export default function DefaultFormClientActions(props) {
|
|
37
|
+
const {
|
|
38
|
+
submitConfig,
|
|
39
|
+
cancelConfig,
|
|
40
|
+
clientActions = []
|
|
41
|
+
} = props;
|
|
42
|
+
const finalClientActions = [];
|
|
43
|
+
|
|
44
|
+
if (submitConfig !== null && submitConfig !== void 0 && submitConfig.isEnabled) {
|
|
45
|
+
finalClientActions.push(getDefaultFormAction({
|
|
46
|
+
type: "submit",
|
|
47
|
+
...submitConfig
|
|
48
|
+
}));
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if (cancelConfig !== null && cancelConfig !== void 0 && cancelConfig.isEnabled) {
|
|
52
|
+
finalClientActions.push(getDefaultFormAction({
|
|
53
|
+
type: "cancel",
|
|
54
|
+
...cancelConfig
|
|
55
|
+
}));
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return [...finalClientActions, ...clientActions];
|
|
59
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import AbstractUseCase from "./AbstractUseCase";
|
|
2
|
+
|
|
3
|
+
class DeleteFieldUseCase extends AbstractUseCase {
|
|
4
|
+
execute(input) {
|
|
5
|
+
const {
|
|
6
|
+
fieldName,
|
|
7
|
+
dispatch
|
|
8
|
+
} = input;
|
|
9
|
+
const {
|
|
10
|
+
repository,
|
|
11
|
+
presenter
|
|
12
|
+
} = this.dependencies;
|
|
13
|
+
const zformEntitiy = repository.getFormEntity();
|
|
14
|
+
let fieldId = zformEntitiy.getFieldId(fieldName);
|
|
15
|
+
zformEntitiy.deleteField(fieldId);
|
|
16
|
+
let zform = zformEntitiy.toObject();
|
|
17
|
+
presenter.updateFormResponse(zform);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export default DeleteFieldUseCase;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import AbstractUseCase from "./AbstractUseCase";
|
|
2
|
+
|
|
3
|
+
class GetFieldValueUseCase extends AbstractUseCase {
|
|
4
|
+
execute(input) {
|
|
5
|
+
const {
|
|
6
|
+
fieldName,
|
|
7
|
+
callback,
|
|
8
|
+
dispatch
|
|
9
|
+
} = input;
|
|
10
|
+
const {
|
|
11
|
+
repository,
|
|
12
|
+
presenter
|
|
13
|
+
} = this.dependencies;
|
|
14
|
+
const zformEntitiy = repository.getFormEntity();
|
|
15
|
+
let fieldValue = zformEntitiy.getFieldValue(fieldName);
|
|
16
|
+
let zform = zformEntitiy.toObject();
|
|
17
|
+
presenter.updateFormResponse(zform);
|
|
18
|
+
callback === null || callback === void 0 ? void 0 : callback(fieldValue);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export default GetFieldValueUseCase;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import AbstractUseCase from "./AbstractUseCase";
|
|
2
|
+
|
|
3
|
+
class HideFieldUseCase extends AbstractUseCase {
|
|
4
|
+
execute(input) {
|
|
5
|
+
const {
|
|
6
|
+
fieldName
|
|
7
|
+
} = input;
|
|
8
|
+
const {
|
|
9
|
+
repository,
|
|
10
|
+
presenter
|
|
11
|
+
} = this.dependencies;
|
|
12
|
+
const form = repository.getFormEntity();
|
|
13
|
+
form.setFieldVisibility(fieldName, false);
|
|
14
|
+
presenter.updateFormResponse(form.toObject());
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export default HideFieldUseCase;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import AbstractUseCase from "./AbstractUseCase";
|
|
2
|
+
|
|
3
|
+
class HideSectionUseCase extends AbstractUseCase {
|
|
4
|
+
execute(input) {
|
|
5
|
+
const {
|
|
6
|
+
sectionName
|
|
7
|
+
} = input;
|
|
8
|
+
const {
|
|
9
|
+
repository,
|
|
10
|
+
presenter
|
|
11
|
+
} = this.dependencies;
|
|
12
|
+
const form = repository.getFormEntity();
|
|
13
|
+
form.setSectionVisibility(sectionName, false);
|
|
14
|
+
presenter.updateFormResponse(form.toObject());
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export default HideSectionUseCase;
|
|
@@ -2,6 +2,7 @@ import AbstractUseCase from "./AbstractUseCase";
|
|
|
2
2
|
import { ZFORM_MY_LAYOUTS_SUCCESS } from "../../../../bc/zform/Symbol";
|
|
3
3
|
import { DATA_SOURCE_EXECUTE as DATA_BROKER_EXECUTE } from "../../../../bc/zdata-source/Constants";
|
|
4
4
|
import { DATA_SOURCE_SUCCESS as DATA_BROKER_SUCCESS, DATA_SOURCE_NO_CONTENT as DATA_BROKER_NO_CONTENT } from "../../../../bc/zdata-source/Symbols";
|
|
5
|
+
import { CLIENTACTION_BEHAVIOUR_EXECUTE } from "../../../client-actions/bc/zclient-actions/Constants";
|
|
5
6
|
|
|
6
7
|
class InitializeUseCase extends AbstractUseCase {
|
|
7
8
|
execute(input) {
|
|
@@ -10,6 +11,21 @@ class InitializeUseCase extends AbstractUseCase {
|
|
|
10
11
|
} = input;
|
|
11
12
|
const zformEntity = this.dependencies.repository.getFormEntity();
|
|
12
13
|
const context = zformEntity.getContext();
|
|
14
|
+
dispatch({
|
|
15
|
+
type: CLIENTACTION_BEHAVIOUR_EXECUTE,
|
|
16
|
+
payload: {
|
|
17
|
+
actionName: 'getClientActions',
|
|
18
|
+
props: {
|
|
19
|
+
moduleName: 'static_module',
|
|
20
|
+
component: 'smart_form',
|
|
21
|
+
limit: '1',
|
|
22
|
+
from: '12',
|
|
23
|
+
servicePrefix: 'zform',
|
|
24
|
+
orgName: 'orgName'
|
|
25
|
+
},
|
|
26
|
+
apiName: 'clientActions'
|
|
27
|
+
}
|
|
28
|
+
});
|
|
13
29
|
dispatch({
|
|
14
30
|
type: DATA_BROKER_EXECUTE,
|
|
15
31
|
payload: {
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import AbstractUseCase from "./AbstractUseCase";
|
|
2
|
+
import ZField from "../../domain/ZField";
|
|
3
|
+
|
|
4
|
+
class InsertFieldUseCase extends AbstractUseCase {
|
|
5
|
+
execute(input) {
|
|
6
|
+
const {
|
|
7
|
+
sectionName,
|
|
8
|
+
fieldsObj,
|
|
9
|
+
fieldIndex,
|
|
10
|
+
dispatch
|
|
11
|
+
} = input;
|
|
12
|
+
const {
|
|
13
|
+
repository,
|
|
14
|
+
presenter
|
|
15
|
+
} = this.dependencies;
|
|
16
|
+
const zformEntitiy = repository.getFormEntity();
|
|
17
|
+
let sectionId = zformEntitiy.getSectionId({
|
|
18
|
+
sectionName
|
|
19
|
+
});
|
|
20
|
+
let entity = new ZField(fieldsObj);
|
|
21
|
+
zformEntitiy.insertFieldAtPositionInSection(sectionId, entity, fieldIndex);
|
|
22
|
+
let zform = zformEntitiy.toObject();
|
|
23
|
+
presenter.updateFormResponse(zform);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export default InsertFieldUseCase;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import AbstractUseCase from "./AbstractUseCase";
|
|
2
|
+
import { ZFORM_FIELD_VALUE_CHANGE_REQUEST } from "../../../../bc/zform/Symbol";
|
|
3
|
+
|
|
4
|
+
class SetFieldValueUseCase extends AbstractUseCase {
|
|
5
|
+
execute(input) {
|
|
6
|
+
let {
|
|
7
|
+
fieldName,
|
|
8
|
+
newValue,
|
|
9
|
+
dispatch
|
|
10
|
+
} = input; // let { layoutRuleApplier } = this.dependencies
|
|
11
|
+
|
|
12
|
+
let zformEntitiy = this.dependencies.repository.getFormEntity(); // zformEntitiy.setFieldValue(fieldName, newValue, ({ layoutRules, formData }) => {
|
|
13
|
+
// return layoutRuleApplier.applyRules({
|
|
14
|
+
// layoutRules,
|
|
15
|
+
// formData,
|
|
16
|
+
// myForm: zformEntitiy.toObject()
|
|
17
|
+
// })
|
|
18
|
+
// });
|
|
19
|
+
// let zform = zformEntitiy.toObject();
|
|
20
|
+
// // let { fieldResult, sectionResult } = this.dependencies.layoutRuleApplier.applyRules({
|
|
21
|
+
// // layoutRules,
|
|
22
|
+
// // formData: zformEntitiy.getFormData(),
|
|
23
|
+
// // myForm: zform
|
|
24
|
+
// // });
|
|
25
|
+
// // zformEntitiy.applyLayoutRulesResult(sectionResult, fieldResult)
|
|
26
|
+
// // zform = zformEntitiy.toObject();
|
|
27
|
+
// this.dependencies.presenter.updateFormResponse(zform);
|
|
28
|
+
|
|
29
|
+
dispatch({
|
|
30
|
+
type: ZFORM_FIELD_VALUE_CHANGE_REQUEST,
|
|
31
|
+
payload: {
|
|
32
|
+
sectionId: zformEntitiy.getSectionId({
|
|
33
|
+
fieldName
|
|
34
|
+
}),
|
|
35
|
+
fieldName,
|
|
36
|
+
value: newValue
|
|
37
|
+
},
|
|
38
|
+
metaData: {}
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export default SetFieldValueUseCase;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import AbstractUseCase from "./AbstractUseCase";
|
|
2
|
+
import { ZFORM_FIELD_VALUE_CHANGE_REQUEST } from "../../../../bc/zform/Symbol";
|
|
3
|
+
|
|
4
|
+
class SetFieldsValuesUseCase extends AbstractUseCase {
|
|
5
|
+
execute(input) {
|
|
6
|
+
let {
|
|
7
|
+
fieldsValuesObj,
|
|
8
|
+
dispatch
|
|
9
|
+
} = input; // let { layoutRuleApplier } = this.dependencies
|
|
10
|
+
|
|
11
|
+
let zformEntitiy = this.dependencies.repository.getFormEntity(); // zformEntitiy.setFieldValue(fieldName, newValue, ({ layoutRules, formData }) => {
|
|
12
|
+
// return layoutRuleApplier.applyRules({
|
|
13
|
+
// layoutRules,
|
|
14
|
+
// formData,
|
|
15
|
+
// myForm: zformEntitiy.toObject()
|
|
16
|
+
// })
|
|
17
|
+
// });
|
|
18
|
+
// let zform = zformEntitiy.toObject();
|
|
19
|
+
// // let { fieldResult, sectionResult } = this.dependencies.layoutRuleApplier.applyRules({
|
|
20
|
+
// // layoutRules,
|
|
21
|
+
// // formData: zformEntitiy.getFormData(),
|
|
22
|
+
// // myForm: zform
|
|
23
|
+
// // });
|
|
24
|
+
// // zformEntitiy.applyLayoutRulesResult(sectionResult, fieldResult)
|
|
25
|
+
// // zform = zformEntitiy.toObject();
|
|
26
|
+
// this.dependencies.presenter.updateFormResponse(zform);
|
|
27
|
+
// dispatch({
|
|
28
|
+
// type: ZFORM_FIELD_VALUE_CHANGE_REQUEST,
|
|
29
|
+
// payload: { sectionId: zformEntitiy.getSectionId(sectionName), fieldName: '', value: "" },
|
|
30
|
+
// metaData: {}
|
|
31
|
+
// });
|
|
32
|
+
|
|
33
|
+
Object.entries(fieldsValuesObj).forEach(_ref => {
|
|
34
|
+
let [fieldName, value] = _ref;
|
|
35
|
+
dispatch({
|
|
36
|
+
type: ZFORM_FIELD_VALUE_CHANGE_REQUEST,
|
|
37
|
+
payload: {
|
|
38
|
+
sectionId: zformEntitiy.getSectionId({
|
|
39
|
+
fieldName
|
|
40
|
+
}),
|
|
41
|
+
fieldName,
|
|
42
|
+
value
|
|
43
|
+
},
|
|
44
|
+
metaData: {}
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export default SetFieldsValuesUseCase;
|