@zohodesk/library-platform 1.1.6-temp-1 → 1.1.7
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/Symbol.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/index.js +2 -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/section/Properties.js +9 -0
- package/es/cc/switch/Properties.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 +32 -2
- package/es/library/dot/components/form/frameworks/ui/sub-components/Sections.js +4 -2
- package/es/library/dot/components/section/frameworks/ui/SectionView.js +3 -5
- 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 +1 -1
- 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/library/dot/legacy-to-new-arch/switch/frameworks/ui/SwitchView.js +5 -5
- package/es/library/dot/legacy-to-new-arch/table-field-components/switch-field/frameworks/ui/SwitchFieldView.js +1 -0
- 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 +1 -1
- 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 +13 -6
- package/es/platform/components/form-connected/frameworks/FormConnectedFactory.js +27 -4
- 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/sdk/application/interfaces/gateways/AbstractResource.js +52 -1
- package/es/platform/sdk/frameworks/Sdk.js +7 -0
- package/es/platform/zform/adapters/presenter/translators/SectionTranslator.js +13 -3
- 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/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/zrecord/adapters/controllers/CreateRecordController.js +5 -1
- package/es/platform/zrecord/applications/usecases/CreateRecordUseCase.js +5 -3
- package/package.json +18 -19
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import ZFormRepository from "../../../../zform/adapters/gateway/FormRepository";
|
|
2
|
+
import ZFormPresenter from "../../../../zform/adapters/presenter/FormPresenter";
|
|
3
|
+
import ZFormValidator from "../../../../zform/frameworks/validation-rules/Validator";
|
|
4
|
+
import ZFormLayoutRuleApplier from "../../../../zform/frameworks/layout-rules/LayoutRuleApplier";
|
|
5
|
+
import HideSectionUseCase from "../../../../zform/applications/usecases/HideSectionUseCase";
|
|
6
|
+
import ShowSectionUseCase from "../../../../zform/applications/usecases/ShowSectionUseCase";
|
|
7
|
+
import ShowFieldUseCase from "../../../../zform/applications/usecases/ShowFieldUseCase";
|
|
8
|
+
import HideFieldUseCase from "../../../../zform/applications/usecases/HideFieldUseCase";
|
|
9
|
+
import SetFieldValueUseCase from "../../../../zform/applications/usecases/SetFieldValueUseCase";
|
|
10
|
+
import SetFieldsValuesUseCase from "../../../../zform/applications/usecases/SetFieldsValuesUseCase";
|
|
11
|
+
import InsertFieldUseCase from "../../../../zform/applications/usecases/InsertFieldUseCase";
|
|
12
|
+
import DeleteFieldUseCase from "../../../../zform/applications/usecases/DeleteFieldUseCase";
|
|
13
|
+
import UpdateFieldUseCase from "../../../../zform/applications/usecases/UpdateFieldUseCase";
|
|
14
|
+
import GetFieldValueUseCase from "../../../../zform/applications/usecases/GetFieldValueUseCase";
|
|
15
|
+
import SubmitUseCase from "../../../../zform/applications/usecases/SubmitUseCase";
|
|
16
|
+
import { AbstractResource } from "../../../../sdk/application/interfaces/gateways/AbstractResource";
|
|
17
|
+
import { SdkContracts } from "../../../../../cc/form-connected/SdkContract"; // hack
|
|
18
|
+
|
|
19
|
+
import { validations as defaultFieldValidations } from "../../../../../library/behaviours/field-validation/frameworks/utils/FormBasicValidationAdaptor";
|
|
20
|
+
export class SmartFormResources extends AbstractResource {
|
|
21
|
+
initialize() {}
|
|
22
|
+
|
|
23
|
+
destroy() {}
|
|
24
|
+
|
|
25
|
+
createUseCase(dependencies, UseCaseClass) {
|
|
26
|
+
var _usecase$updateDepend, _usecase$updateDepend2;
|
|
27
|
+
|
|
28
|
+
const {
|
|
29
|
+
state,
|
|
30
|
+
updateState
|
|
31
|
+
} = this.dependencies;
|
|
32
|
+
const usecase = new UseCaseClass(dependencies);
|
|
33
|
+
(_usecase$updateDepend = usecase.updateDependencies) === null || _usecase$updateDepend === void 0 ? void 0 : _usecase$updateDepend.call(usecase, state, updateState);
|
|
34
|
+
(_usecase$updateDepend2 = usecase.updateDependency) === null || _usecase$updateDepend2 === void 0 ? void 0 : _usecase$updateDepend2.call(usecase, state, updateState);
|
|
35
|
+
return usecase;
|
|
36
|
+
} // private getFormDependencies(): ZFormUseCaseDependencies {
|
|
37
|
+
// const dependencies: ZFormUseCaseDependencies = {
|
|
38
|
+
// repository: new ZFormRepository(),
|
|
39
|
+
// presenter: new ZFormPresenter(),
|
|
40
|
+
// validator: new ZFormValidator(),
|
|
41
|
+
// layoutRuleApplier: new ZFormLayoutRuleApplier()
|
|
42
|
+
// };
|
|
43
|
+
// return dependencies;
|
|
44
|
+
// }
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
getFormDependencies() {
|
|
48
|
+
const dependencies = {
|
|
49
|
+
repository: new ZFormRepository(),
|
|
50
|
+
presenter: new ZFormPresenter(),
|
|
51
|
+
validator: new ZFormValidator(defaultFieldValidations),
|
|
52
|
+
// Hack Need to pass customValidators
|
|
53
|
+
layoutRuleApplier: new ZFormLayoutRuleApplier()
|
|
54
|
+
};
|
|
55
|
+
return dependencies;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
hideSection(sectionName) {
|
|
59
|
+
this.validateInput('hideSection', {
|
|
60
|
+
sectionName
|
|
61
|
+
}, SdkContracts.hideSectionInputMeta);
|
|
62
|
+
const dependencies = this.getFormDependencies();
|
|
63
|
+
const usecase = this.createUseCase(dependencies, HideSectionUseCase);
|
|
64
|
+
usecase.execute({
|
|
65
|
+
sectionName
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
showSection(sectionName) {
|
|
70
|
+
this.validateInput('showSection', {
|
|
71
|
+
sectionName
|
|
72
|
+
}, SdkContracts.showSectionInputMeta);
|
|
73
|
+
const dependencies = this.getFormDependencies();
|
|
74
|
+
const usecase = this.createUseCase(dependencies, ShowSectionUseCase);
|
|
75
|
+
usecase.execute({
|
|
76
|
+
sectionName
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
hideField(fieldName) {
|
|
81
|
+
this.validateInput('hideField', {
|
|
82
|
+
fieldName
|
|
83
|
+
}, SdkContracts.hideFieldInputMeta);
|
|
84
|
+
const dependencies = this.getFormDependencies();
|
|
85
|
+
const usecase = this.createUseCase(dependencies, HideFieldUseCase);
|
|
86
|
+
usecase.execute({
|
|
87
|
+
fieldName
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
showField(fieldName) {
|
|
92
|
+
this.validateInput('showField', {
|
|
93
|
+
fieldName
|
|
94
|
+
}, SdkContracts.showFieldInputMeta);
|
|
95
|
+
const dependencies = this.getFormDependencies();
|
|
96
|
+
const usecase = this.createUseCase(dependencies, ShowFieldUseCase);
|
|
97
|
+
usecase.execute({
|
|
98
|
+
fieldName
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
setFieldValue(fieldName, newValue) {
|
|
103
|
+
this.validateInput('setFieldValue', {
|
|
104
|
+
fieldName,
|
|
105
|
+
newValue
|
|
106
|
+
}, SdkContracts.setFieldValueInputMeta);
|
|
107
|
+
const {
|
|
108
|
+
dispatch
|
|
109
|
+
} = this.dependencies;
|
|
110
|
+
const dependencies = this.getFormDependencies();
|
|
111
|
+
const usecase = this.createUseCase(dependencies, SetFieldValueUseCase);
|
|
112
|
+
usecase.execute({
|
|
113
|
+
fieldName,
|
|
114
|
+
newValue,
|
|
115
|
+
dispatch
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
setFieldsValue(fieldsValuesObj) {
|
|
120
|
+
this.validateInput('setFieldsValue', {
|
|
121
|
+
fieldsValuesObj
|
|
122
|
+
}, SdkContracts.setFieldsValueInputMeta);
|
|
123
|
+
const {
|
|
124
|
+
dispatch
|
|
125
|
+
} = this.dependencies;
|
|
126
|
+
const dependencies = this.getFormDependencies();
|
|
127
|
+
const usecase = this.createUseCase(dependencies, SetFieldsValuesUseCase);
|
|
128
|
+
usecase.execute({
|
|
129
|
+
fieldsValuesObj,
|
|
130
|
+
dispatch
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
insertField(input) {
|
|
135
|
+
this.validateInput('insertField', input, SdkContracts.insertFieldInputMeta);
|
|
136
|
+
const {
|
|
137
|
+
dispatch
|
|
138
|
+
} = this.dependencies;
|
|
139
|
+
const dependencies = this.getFormDependencies();
|
|
140
|
+
const usecase = this.createUseCase(dependencies, InsertFieldUseCase);
|
|
141
|
+
usecase.execute({ ...input,
|
|
142
|
+
dispatch
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
deleteField(fieldName) {
|
|
147
|
+
this.validateInput('deleteField', {
|
|
148
|
+
fieldName
|
|
149
|
+
}, SdkContracts.deleteFieldInputMeta);
|
|
150
|
+
const {
|
|
151
|
+
dispatch
|
|
152
|
+
} = this.dependencies;
|
|
153
|
+
const dependencies = this.getFormDependencies();
|
|
154
|
+
const usecase = this.createUseCase(dependencies, DeleteFieldUseCase);
|
|
155
|
+
usecase.execute({
|
|
156
|
+
fieldName,
|
|
157
|
+
dispatch
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
updateField(fieldName, fieldProperties) {
|
|
162
|
+
this.validateInput('updateField', {
|
|
163
|
+
fieldName,
|
|
164
|
+
fieldProperties
|
|
165
|
+
}, SdkContracts.updateFieldInputMeta);
|
|
166
|
+
const {
|
|
167
|
+
dispatch
|
|
168
|
+
} = this.dependencies;
|
|
169
|
+
const dependencies = this.getFormDependencies();
|
|
170
|
+
const usecase = this.createUseCase(dependencies, UpdateFieldUseCase);
|
|
171
|
+
usecase.execute({
|
|
172
|
+
fieldName,
|
|
173
|
+
fieldProperties,
|
|
174
|
+
dispatch
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
getFieldValue(fieldName) {
|
|
179
|
+
const {
|
|
180
|
+
getData,
|
|
181
|
+
setData
|
|
182
|
+
} = this.createCallback();
|
|
183
|
+
this.validateInput('getFieldValue', {
|
|
184
|
+
fieldName
|
|
185
|
+
}, SdkContracts.getFieldValueInputMeta);
|
|
186
|
+
const {
|
|
187
|
+
dispatch
|
|
188
|
+
} = this.dependencies;
|
|
189
|
+
const dependencies = this.getFormDependencies();
|
|
190
|
+
const usecase = this.createUseCase(dependencies, GetFieldValueUseCase);
|
|
191
|
+
usecase.execute({
|
|
192
|
+
fieldName,
|
|
193
|
+
callback: setData,
|
|
194
|
+
dispatch
|
|
195
|
+
});
|
|
196
|
+
return getData();
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
submit() {
|
|
200
|
+
const {
|
|
201
|
+
dispatch
|
|
202
|
+
} = this.dependencies;
|
|
203
|
+
const dependencies = this.getFormDependencies();
|
|
204
|
+
const usecase = this.createUseCase(dependencies, SubmitUseCase);
|
|
205
|
+
usecase.execute({
|
|
206
|
+
dispatch
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -2,21 +2,28 @@ import SmartFormConstants from "../../../../cc/form-connected/Constants";
|
|
|
2
2
|
import FormSdkFactory from "./FormSdkFactory";
|
|
3
3
|
import FormConstants from "../../../../cc/form/Constants";
|
|
4
4
|
import { ZFORM_FIELD_VALUE_CHANGED } from "../../../../bc/zform/Symbol";
|
|
5
|
+
import { platformSDK } from "../../../sdk/frameworks/Sdk";
|
|
5
6
|
const {
|
|
6
7
|
SMART_FORM_FIELD_FOCUSED,
|
|
7
8
|
SMART_FORM_FIELD_BLURRED,
|
|
8
9
|
SMART_FORM_FIELD_VALUE_CHANGED
|
|
9
|
-
} = SmartFormConstants;
|
|
10
|
+
} = SmartFormConstants; // function createHandlerWithSdk(handler) {
|
|
11
|
+
// return input => {
|
|
12
|
+
// const { state, dispatch } = input;
|
|
13
|
+
// handler(input, FormSdkFactory.create({ state, dispatch }));
|
|
14
|
+
// };
|
|
15
|
+
// }
|
|
10
16
|
|
|
11
17
|
function createHandlerWithSdk(handler) {
|
|
12
18
|
return input => {
|
|
13
19
|
const {
|
|
14
|
-
state
|
|
15
|
-
dispatch
|
|
20
|
+
state
|
|
16
21
|
} = input;
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
22
|
+
const instanceName = state.properties.instanceName;
|
|
23
|
+
handler({ ...input,
|
|
24
|
+
platformSDK
|
|
25
|
+
}, FormSdkFactory.create({
|
|
26
|
+
instanceName
|
|
20
27
|
}));
|
|
21
28
|
};
|
|
22
29
|
}
|
|
@@ -2,29 +2,52 @@ import Properties from "../../../../cc/form-connected/Properties";
|
|
|
2
2
|
import { createCustomComponent } from "../../../../library/custom-component";
|
|
3
3
|
import ZHttpBehaviourFactory from "../../../zhttp/frameworks/ZHttpBehaviourFactory";
|
|
4
4
|
import RecordBehaviourFactory from "../../../zrecord/frameworks/RecordBehaviourFactory";
|
|
5
|
-
import FormConnectedView from "./FormConnectedView";
|
|
6
|
-
|
|
5
|
+
import FormConnectedView from "./FormConnectedView"; // import defaultDataBroker from '@platform/data-source';
|
|
6
|
+
|
|
7
|
+
import defaultDataSource from "../../../data-source";
|
|
7
8
|
import DataBrokerBehaviourFactory from "../../../zdata-source/frameworks/DataBrokerBehaviourFactory";
|
|
8
9
|
import FormTranslator from "../../../zform/adapters/presenter/FormTranslator";
|
|
9
10
|
import ZFormBehaviourFactory from "../../../zform/frameworks/ui/ZFormBehaviourFactory";
|
|
10
11
|
import FieldValidationBehaviourFactory from "../../../../library/behaviours/field-validation/frameworks/ui/FieldValidationBehaviourFactory";
|
|
11
12
|
import EventHandlersfactory from "./EventHandlersFactory";
|
|
13
|
+
import SdkBehaviourFactory from "../../../sdk-behaviour/frameworks/SdkBehaviourFactory";
|
|
14
|
+
import ResourceNamesEnum from "../../../../bc/sdk/ResourceNamesEnum";
|
|
15
|
+
import { sdkRegistry } from "../../../sdk/frameworks/SdkRegistry";
|
|
16
|
+
import { SmartFormResources } from "../adapters/resources/SmartFormResources";
|
|
17
|
+
sdkRegistry.registerResource({
|
|
18
|
+
resourceName: ResourceNamesEnum.SMART_FORM,
|
|
19
|
+
resource: SmartFormResources
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
function combineDataSourceWithDefault(dataSource) {
|
|
23
|
+
return { ...defaultDataSource,
|
|
24
|
+
...dataSource,
|
|
25
|
+
httpTemplates: { ...defaultDataSource.httpTemplates,
|
|
26
|
+
...(dataSource === null || dataSource === void 0 ? void 0 : dataSource.httpTemplates)
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
12
31
|
export default class FormConnectedFactory {
|
|
13
32
|
static create(_ref) {
|
|
14
33
|
let {
|
|
15
34
|
name,
|
|
16
35
|
customValidators,
|
|
17
|
-
dataBroker =
|
|
36
|
+
dataBroker = defaultDataSource,
|
|
37
|
+
dataSource,
|
|
18
38
|
eventHandlers = {},
|
|
19
39
|
View = FormConnectedView
|
|
20
40
|
} = _ref;
|
|
41
|
+
|
|
42
|
+
const _dataSource = combineDataSourceWithDefault(dataBroker ? dataBroker : dataSource);
|
|
43
|
+
|
|
21
44
|
return createCustomComponent({
|
|
22
45
|
name: name,
|
|
23
46
|
View: View,
|
|
24
47
|
properties: Properties,
|
|
25
48
|
eventHandlers: EventHandlersfactory.create(eventHandlers),
|
|
26
49
|
transformState: FormTranslator.transformState,
|
|
27
|
-
behaviours: [ZHttpBehaviourFactory.create(), DataBrokerBehaviourFactory.create(), RecordBehaviourFactory.create(
|
|
50
|
+
behaviours: [SdkBehaviourFactory.create([ResourceNamesEnum.SMART_FORM]), ZHttpBehaviourFactory.create(), DataBrokerBehaviourFactory.create(), RecordBehaviourFactory.create(_dataSource.httpTemplates), FieldValidationBehaviourFactory.create(), ZFormBehaviourFactory.create({
|
|
28
51
|
customValidators
|
|
29
52
|
})]
|
|
30
53
|
});
|
|
@@ -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,
|
|
@@ -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,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
|
};
|
|
@@ -2,12 +2,14 @@ import { DefaultFormSectionUIType, fieldTypeToUIType } from "../../../../../cc/f
|
|
|
2
2
|
import * as FieldTranslators from "./fields";
|
|
3
3
|
|
|
4
4
|
function SectionTranslator(_ref) {
|
|
5
|
+
var _componentMapping$sec;
|
|
6
|
+
|
|
5
7
|
let {
|
|
6
8
|
section,
|
|
7
9
|
componentMapping,
|
|
8
10
|
context
|
|
9
11
|
} = _ref;
|
|
10
|
-
const mapping = componentMapping.sections[section.name];
|
|
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];
|
|
11
13
|
const defaultViewModel = {
|
|
12
14
|
type: mapping !== null && mapping !== void 0 && mapping.UIComponentName ? mapping.UIComponentName : DefaultFormSectionUIType,
|
|
13
15
|
id: section.id + '',
|
|
@@ -20,11 +22,19 @@ function SectionTranslator(_ref) {
|
|
|
20
22
|
var _componentMapping$fie;
|
|
21
23
|
|
|
22
24
|
const fieldTranslator = FieldTranslators[field.type];
|
|
23
|
-
const
|
|
24
|
-
|
|
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({
|
|
25
31
|
field,
|
|
26
32
|
type
|
|
27
33
|
});
|
|
34
|
+
return translator ? translator({
|
|
35
|
+
context,
|
|
36
|
+
field: viewModel
|
|
37
|
+
}) : viewModel;
|
|
28
38
|
})
|
|
29
39
|
};
|
|
30
40
|
|
|
@@ -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;
|