@zohodesk/library-platform 1.1.6 → 1.1.7-exp.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/es/bc/sdk/ResourceNamesEnum.js +1 -0
- package/es/bc/zform/Properties.js +3 -26
- package/es/bc/zform/Symbol.js +2 -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/index.js +6 -1
- package/es/library/custom-component/adapters/gateways/event-manager/EventManager.js +2 -2
- package/es/library/dot/components/action-location/frameworks/ui/ActionComponentMapping.js +5 -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/cc/action-event-mediator/Properties.js +9 -0
- package/es/platform/client-actions/components/action-event-mediator/frameworks/ui/ActionEventMediatorView.js +3 -1
- 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 +4 -1
- package/es/platform/page/index.js +46 -0
- package/es/platform/sdk/adapters/gateways/Service.js +4 -0
- package/es/platform/sdk/application/interfaces/gateways/AbstractResource.js +52 -1
- package/es/platform/sdk/application/usecases/GetResourcesUseCase.js +15 -0
- package/es/platform/sdk/domain/entities/ResourceManager.js +4 -0
- package/es/platform/sdk/frameworks/Sdk.js +7 -0
- package/es/platform/sdk/frameworks/SdkRegistry.js +9 -0
- package/es/platform/zform/adapters/presenter/FormTranslator.js +90 -46
- package/es/platform/zform/adapters/presenter/translators/SectionTranslator.js +45 -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/ui/EventHandlerFactory.js +37 -15
- package/es/platform/zrecord/adapters/controllers/CreateRecordController.js +5 -1
- package/es/platform/zrecord/applications/usecases/CreateRecordUseCase.js +5 -3
- package/package.json +7 -6
- package/es/library/dot/components/section/adapters/presenter/TransFormState.js +0 -26
|
@@ -1,22 +1,42 @@
|
|
|
1
|
-
/* eslint-disable max-lines-per-function */
|
|
1
|
+
// /* eslint-disable max-lines-per-function */
|
|
2
|
+
import { platformSDK } from "../../../sdk/frameworks/Sdk";
|
|
3
|
+
import ResourceNamesEnum from "../../../../bc/sdk/ResourceNamesEnum";
|
|
2
4
|
export default class FormSdkFactory {
|
|
5
|
+
static getFormSdks(smartForm) {
|
|
6
|
+
return {
|
|
7
|
+
hideSection: sectionName => smartForm.hideSection(sectionName),
|
|
8
|
+
showSection: sectionName => smartForm.showSection(sectionName),
|
|
9
|
+
hideField: fieldName => smartForm.hideField(fieldName),
|
|
10
|
+
showField: fieldName => smartForm.showField(fieldName),
|
|
11
|
+
setFieldValue: (fieldName, newValue) => smartForm.setFieldValue(fieldName, newValue),
|
|
12
|
+
setFieldsValue: fieldsValuesObj => smartForm.setFieldsValue(fieldsValuesObj),
|
|
13
|
+
insertField: input => smartForm.insertField(input),
|
|
14
|
+
deleteField: fieldName => smartForm.deleteField(fieldName),
|
|
15
|
+
updateField: (fieldName, fieldProperties) => smartForm.updateField(fieldName, fieldProperties),
|
|
16
|
+
getFieldValue: fieldName => smartForm.getFieldValue(fieldName),
|
|
17
|
+
submit: () => smartForm.submit()
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
|
|
3
21
|
static create(_ref) {
|
|
4
22
|
let {
|
|
5
|
-
|
|
23
|
+
instanceName
|
|
6
24
|
} = _ref;
|
|
25
|
+
const smartForm = platformSDK[ResourceNamesEnum.SMART_FORM](instanceName);
|
|
26
|
+
const formSdks = FormSdkFactory.getFormSdks(smartForm);
|
|
7
27
|
return {
|
|
8
28
|
zform: {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
29
|
+
hideSection: formSdks.hideSection,
|
|
30
|
+
showSection: formSdks.showSection,
|
|
31
|
+
hideField: formSdks.hideField,
|
|
32
|
+
showField: formSdks.showField,
|
|
33
|
+
setFieldValue: formSdks.setFieldValue,
|
|
34
|
+
setFieldsValue: formSdks.setFieldsValue,
|
|
35
|
+
insertField: formSdks.insertField,
|
|
36
|
+
deleteField: formSdks.deleteField,
|
|
37
|
+
updateField: formSdks.updateField,
|
|
38
|
+
getFieldValue: formSdks.getFieldValue,
|
|
39
|
+
submit: formSdks.submit
|
|
20
40
|
}
|
|
21
41
|
};
|
|
22
42
|
}
|
|
@@ -17,53 +17,11 @@ import UpdateMultipleRecordUseCase from "../../../../zlist/applications/usecases
|
|
|
17
17
|
import GetContextUseCase from "../../../../zlist/applications/usecases/GetContextUseCase";
|
|
18
18
|
import ReOrderUseCase from "../../../../zlist/applications/usecases/ReOrderUseCase";
|
|
19
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";
|
|
22
20
|
export class SmartTableResource extends AbstractResource {
|
|
23
21
|
initialize() {}
|
|
24
22
|
|
|
25
23
|
destroy() {}
|
|
26
24
|
|
|
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
|
-
|
|
67
25
|
getRecordDependencies() {
|
|
68
26
|
const dependencies = {
|
|
69
27
|
repository: new ZRecordRepository(),
|
|
@@ -102,16 +60,6 @@ export class SmartTableResource extends AbstractResource {
|
|
|
102
60
|
return usecase;
|
|
103
61
|
}
|
|
104
62
|
|
|
105
|
-
createCallback() {
|
|
106
|
-
let temp = null;
|
|
107
|
-
return {
|
|
108
|
-
setData: data => {
|
|
109
|
-
temp = data;
|
|
110
|
-
},
|
|
111
|
-
getData: () => temp
|
|
112
|
-
};
|
|
113
|
-
}
|
|
114
|
-
|
|
115
63
|
getRecords() {
|
|
116
64
|
const {
|
|
117
65
|
getData,
|
|
@@ -16,6 +16,7 @@ import ColumnChooserUpdateController from "../adapters/controllers/ColumnChooser
|
|
|
16
16
|
import ColumnChooserOpenedController from "../adapters/controllers/ColumnChooserOpenedController";
|
|
17
17
|
import { platformSDK } from "../../../sdk/frameworks/Sdk";
|
|
18
18
|
import ErrorEventHandlersFactory from "./ErrorEventHandlersFactory";
|
|
19
|
+
import { i18NProviderUtils } from '@zohodesk/i18n';
|
|
19
20
|
const {
|
|
20
21
|
TABLE_LIST_RESIZE_START_REQUESTED,
|
|
21
22
|
TABLE_LIST_RESIZE_MOVE_REQUESTED,
|
|
@@ -34,7 +35,9 @@ function createHandlerWithSdk(handler) {
|
|
|
34
35
|
platformSDK
|
|
35
36
|
}, ListSdkFactory.create({
|
|
36
37
|
instanceName
|
|
37
|
-
})
|
|
38
|
+
}), {
|
|
39
|
+
i18n: i18NProviderUtils.getI18NValue
|
|
40
|
+
});
|
|
38
41
|
};
|
|
39
42
|
}
|
|
40
43
|
|
|
@@ -0,0 +1,46 @@
|
|
|
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
|
+
|
|
3
|
+
import { sdkRegistry } from "../sdk/frameworks/SdkRegistry";
|
|
4
|
+
|
|
5
|
+
class AbstractPageResource {
|
|
6
|
+
constructor() {
|
|
7
|
+
_defineProperty(this, "dependencies", void 0);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
initialize() {// Initialization logic for the page resource
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
updateDependencies(dependencies) {
|
|
14
|
+
this.dependencies = dependencies;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
destroy() {// Cleanup logic for the page resource
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
class PageResource extends AbstractPageResource {
|
|
23
|
+
constructor(instanceName) {
|
|
24
|
+
super();
|
|
25
|
+
this.instanceName = instanceName;
|
|
26
|
+
} // Implement methods to interact with the page resource
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
getInstanceName() {
|
|
30
|
+
return this.instanceName;
|
|
31
|
+
} // Add more methods as needed for page resource management
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function initializePageSdk() {
|
|
37
|
+
sdkRegistry.registerResource({
|
|
38
|
+
resourceName: 'page',
|
|
39
|
+
resource: PageResource
|
|
40
|
+
});
|
|
41
|
+
sdkRegistry.createResourceInstance({
|
|
42
|
+
resourceName: 'page',
|
|
43
|
+
instanceName: 'module'
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
export { PageResource };
|
|
@@ -5,6 +5,7 @@ import { DestructResourceInstanceUseCase } from "../../application/usecases/Dest
|
|
|
5
5
|
import { GetResourceInstanceUseCase } from "../../application/usecases/GetResourceInstanceUseCase";
|
|
6
6
|
import { RegisterResourceUseCase } from "../../application/usecases/RegisterResourceUseCase";
|
|
7
7
|
import { SyncStateWithResourceUseCase } from "../../application/usecases/SyncStateWithResourceUseCase";
|
|
8
|
+
import GetResourcesUseCase from "../../application/usecases/GetResourcesUseCase";
|
|
8
9
|
export class Service {
|
|
9
10
|
constructor(dependencies) {
|
|
10
11
|
_defineProperty(this, "createResourceInstanceUseCase", void 0);
|
|
@@ -17,11 +18,14 @@ export class Service {
|
|
|
17
18
|
|
|
18
19
|
_defineProperty(this, "getResourceInstanceUseCase", void 0);
|
|
19
20
|
|
|
21
|
+
_defineProperty(this, "getResourcesUseCase", void 0);
|
|
22
|
+
|
|
20
23
|
this.createResourceInstanceUseCase = new CreateResourceInstanceUseCase(dependencies);
|
|
21
24
|
this.destructResourceInstanceUseCase = new DestructResourceInstanceUseCase(dependencies);
|
|
22
25
|
this.syncStateWithResourceUseCase = new SyncStateWithResourceUseCase(dependencies);
|
|
23
26
|
this.registerResourceUseCase = new RegisterResourceUseCase(dependencies);
|
|
24
27
|
this.getResourceInstanceUseCase = new GetResourceInstanceUseCase(dependencies);
|
|
28
|
+
this.getResourcesUseCase = new GetResourcesUseCase(dependencies);
|
|
25
29
|
}
|
|
26
30
|
|
|
27
31
|
}
|
|
@@ -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
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { AbstractUseCase } from "./AbstractUseCase";
|
|
2
|
+
|
|
3
|
+
class GetResourcesUseCase extends AbstractUseCase {
|
|
4
|
+
execute() {
|
|
5
|
+
const {
|
|
6
|
+
repository,
|
|
7
|
+
presenter
|
|
8
|
+
} = this.dependencies;
|
|
9
|
+
const resourceManger = repository.getResourceManager();
|
|
10
|
+
presenter.presentData(resourceManger.getResources());
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export default GetResourcesUseCase;
|
|
@@ -15,6 +15,10 @@ export class ResourceManager {
|
|
|
15
15
|
return ((_resourceInstances$re = resourceInstances[resourceName]) === null || _resourceInstances$re === void 0 ? void 0 : _resourceInstances$re[instanceName]) || null;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
+
getResources() {
|
|
19
|
+
return this.resources;
|
|
20
|
+
}
|
|
21
|
+
|
|
18
22
|
createResourceInstance(resourceName, instanceName) {
|
|
19
23
|
const {
|
|
20
24
|
resourceInstances,
|
|
@@ -6,6 +6,13 @@ 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
|
+
});
|
|
9
16
|
}
|
|
10
17
|
|
|
11
18
|
};
|
|
@@ -68,5 +68,14 @@ export class SdkManager {
|
|
|
68
68
|
return this.presentedData;
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
+
getResources() {
|
|
72
|
+
const {
|
|
73
|
+
getResourcesUseCase
|
|
74
|
+
} = this.service;
|
|
75
|
+
getResourcesUseCase.updateDependencies(this.state, this.setPresentedData);
|
|
76
|
+
getResourcesUseCase.execute({});
|
|
77
|
+
return this.presentedData;
|
|
78
|
+
}
|
|
79
|
+
|
|
71
80
|
}
|
|
72
81
|
export const sdkRegistry = new SdkManager();
|
|
@@ -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,51 @@
|
|
|
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
|
+
const defaultViewModel = {
|
|
14
|
+
type: mapping !== null && mapping !== void 0 && mapping.UIComponentName ? mapping.UIComponentName : DefaultFormSectionUIType,
|
|
15
|
+
id: section.id + '',
|
|
16
|
+
name: section.name,
|
|
17
|
+
title: section.i18NLabel,
|
|
18
|
+
description: section.description,
|
|
19
|
+
isCollapsed: section.isCollapsed,
|
|
20
|
+
isVisible: section.isVisible,
|
|
21
|
+
fields: section.fields.map(field => {
|
|
22
|
+
var _componentMapping$fie;
|
|
23
|
+
|
|
24
|
+
const fieldTranslator = FieldTranslators[field.type];
|
|
25
|
+
const {
|
|
26
|
+
UIComponentName,
|
|
27
|
+
translator
|
|
28
|
+
} = (componentMapping === null || componentMapping === void 0 ? void 0 : (_componentMapping$fie = componentMapping.fields) === null || _componentMapping$fie === void 0 ? void 0 : _componentMapping$fie[field.apiName]) || {};
|
|
29
|
+
const type = UIComponentName || fieldTypeToUIType[field.type];
|
|
30
|
+
const viewModel = fieldTranslator({
|
|
31
|
+
field,
|
|
32
|
+
type
|
|
33
|
+
});
|
|
34
|
+
return translator ? translator({
|
|
35
|
+
context,
|
|
36
|
+
field: viewModel
|
|
37
|
+
}) : viewModel;
|
|
38
|
+
})
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
if (mapping !== null && mapping !== void 0 && mapping.translator) {
|
|
42
|
+
return mapping.translator({
|
|
43
|
+
section: defaultViewModel,
|
|
44
|
+
context
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return defaultViewModel;
|
|
49
|
+
}
|
|
31
50
|
|
|
32
51
|
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 {};
|