@zohodesk/library-platform 1.1.13 → 1.2.0
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/.DS_Store +0 -0
- package/es/bc/column-chooser/EventHandlers.js +1 -2
- package/es/bc/zform/Properties.js +20 -0
- package/es/bc/zform/Symbol.js +3 -0
- package/es/bc/zrecord/Constants.js +2 -0
- package/es/cc/action-band/Properties.js +37 -0
- package/es/cc/action-band/constants/ExternalConstants.js +3 -1
- package/es/cc/component/LifeCycleEventsEnum.js +1 -0
- package/es/cc/fields/currency/Properties.js +9 -0
- package/es/cc/fields/decimal/Properties.js +9 -0
- package/es/cc/fields/email/Properties.js +9 -0
- package/es/cc/fields/lookup/Properties.js +10 -26
- package/es/cc/fields/multi-line/Properties.js +1 -0
- package/es/cc/fields/number/Properties.js +10 -1
- package/es/cc/fields/phone/Properties.js +9 -0
- package/es/cc/fields/text/Properties.js +2 -2
- package/es/cc/fields/url/Properties.js +9 -0
- package/es/cc/table-column-chooser/Constants.js +2 -1
- package/es/cc/table-connected/SdkContract.js +22 -0
- package/es/cc/text/Properties.js +100 -0
- package/es/cc/textbox/Properties.js +1 -1
- package/es/index.js +1 -0
- package/es/library/behaviours/clip-wrap/applications/usecases/ClipWrapUpdateUseCase.js +19 -0
- package/es/library/behaviours/search/adapters/controllers/UpdatePropertiesController.js +9 -4
- package/es/library/custom-component/adapters/gateways/event-manager/EventManager.js +4 -3
- package/es/library/custom-component/applications/usecases/DispatchUseCase.js +1 -0
- package/es/library/custom-component/applications/usecases/InitializeUseCase.js +1 -0
- package/es/library/custom-component/applications/usecases/MountUseCase.js +1 -0
- package/es/library/custom-component/applications/usecases/SetRefUseCase.js +7 -0
- package/es/library/custom-component/applications/usecases/UnmountUseCase.js +1 -0
- package/es/library/custom-component/applications/usecases/UpdatePropertyUseCase.js +1 -0
- package/es/library/custom-component/domain/entities/Component.js +1 -0
- package/es/library/custom-component/domain/entities/Logger.js +4 -9
- package/es/library/dot/components/form-fields/currency/frameworks/ui/CurrencyView.js +2 -0
- package/es/library/dot/components/form-fields/decimal/frameworks/ui/DecimalView.js +2 -0
- package/es/library/dot/components/form-fields/email/frameworks/ui/Email.js +1 -1
- package/es/library/dot/components/form-fields/email/frameworks/ui/EmailView.js +2 -0
- package/es/library/dot/components/form-fields/number/frameworks/ui/NumberView.js +2 -0
- package/es/library/dot/components/form-fields/phone/frameworks/ui/PhoneView.js +2 -0
- package/es/library/dot/components/form-fields/textarea/frameworks/ui/TextArea.js +1 -1
- package/es/library/dot/components/form-fields/textarea/frameworks/ui/TextAreaView.js +4 -2
- package/es/library/dot/components/form-fields/textbox/frameworks/ui/TextBoxView.js +2 -0
- package/es/library/dot/components/form-fields/url/frameworks/ui/UrlView.js +2 -0
- package/es/library/dot/components/table-list/frameworks/ui/sub-components/header/HeaderData.js +1 -1
- package/es/library/dot/legacy-to-new-arch/table-field-components/text-field/frameworks/ui/TextFieldView.js +20 -0
- package/es/library/dot/legacy-to-new-arch/text/frameworks/ui/Text.js +2 -2
- package/es/library/dot/legacy-to-new-arch/text/frameworks/ui/TextView.js +22 -1
- package/es/platform/.DS_Store +0 -0
- package/es/platform/app-context-behaviour/adapters/controllers/AbstractController.js +9 -0
- package/es/platform/app-context-behaviour/adapters/controllers/UpdatePropertiesController.js +32 -0
- package/es/platform/app-context-behaviour/adapters/gateway/Repository.js +22 -0
- package/es/platform/app-context-behaviour/adapters/gateway/Service.js +10 -0
- package/es/platform/app-context-behaviour/adapters/presenter/Presenter.js +16 -0
- package/es/platform/app-context-behaviour/applications/interfaces/UseCaseDependencies.js +1 -0
- package/es/platform/app-context-behaviour/applications/interfaces/gateways/IRepository.js +1 -0
- package/es/platform/app-context-behaviour/applications/interfaces/gateways/IService.js +1 -0
- package/es/platform/app-context-behaviour/applications/interfaces/input/UpdatePropertiesInputModel.js +1 -0
- package/es/platform/app-context-behaviour/applications/interfaces/output/BehaviourOutputModel.js +1 -0
- package/es/platform/app-context-behaviour/applications/interfaces/output/IPresenter.js +1 -0
- package/es/platform/app-context-behaviour/applications/usecases/AbstractUseCase.js +17 -0
- package/es/platform/app-context-behaviour/applications/usecases/UpdatePropertiesUsecase.js +25 -0
- package/es/platform/app-context-behaviour/domain/entities/AppContext.js +44 -0
- package/es/platform/app-context-behaviour/domain/entities/interfaces/IAppContext.js +1 -0
- package/es/platform/app-context-behaviour/frameworks/AppContextBehaviourFactory.js +2 -2
- package/es/platform/app-context-behaviour/frameworks/EventHandlerFactory.js +22 -0
- package/es/platform/column-chooser/adapters/controllers/ColumnChooserOpenController.js +14 -6
- package/es/platform/column-chooser/adapters/controllers/ColumnChooserUpdateController.js +22 -0
- package/es/platform/column-chooser/adapters/gateways/Repository.js +12 -1
- package/es/platform/column-chooser/adapters/gateways/Service.js +2 -0
- package/es/platform/column-chooser/applications/interfaces/input/ColumnChooserUpdateInput.js +1 -0
- package/es/platform/column-chooser/applications/usecases/ColumnChooserSaveUseCase.js +8 -1
- package/es/platform/column-chooser/applications/usecases/ColumnChooserUpdateUseCase.js +35 -0
- package/es/platform/column-chooser/domain/entities/ColumnChooserImp.js +6 -0
- package/es/platform/column-chooser/frameworks/EventHandlersFactory.js +6 -4
- package/es/platform/components/smart-action-band/adapters/presenters/ActionBandTranslator.js +64 -5
- package/es/platform/components/smart-action-band/adapters/presenters/utils/DefaultClientActions.js +32 -0
- package/es/platform/components/smart-action-band/frameworks/EventHandlersFactory.js +42 -1
- package/es/platform/components/smart-action-band/frameworks/SmartActionBandFactory.js +4 -1
- package/es/platform/components/table-connected/adapters/resources/SmartTableResource.js +52 -0
- package/es/platform/components/table-connected/frameworks/EventHandlersFactory.js +1 -7
- package/es/platform/components/table-connected/frameworks/ListSdkFactory.js +4 -2
- package/es/platform/data-source/http-template/fetchLookupFields.js +0 -6
- package/es/platform/data-source/http-template/getSingleRecord.js +51 -0
- package/es/platform/data-source/index.js +2 -0
- package/es/platform/data-source/utils/validation-rules/FieldConditions.js +1 -1
- package/es/platform/sdk-behaviour/adapters/controllers/InitializeController.js +7 -2
- package/es/platform/sdk-behaviour/applications/usecases/CreateResourceInstanceUseCase.js +10 -1
- package/es/platform/zform/adapters/controllers/GetInitialRecordSuccessController.js +31 -0
- package/es/platform/zform/adapters/gateway/FormRepository.js +10 -2
- package/es/platform/zform/adapters/gateway/Service.js +2 -0
- package/es/platform/zform/adapters/presenter/FormTranslator.js +9 -0
- package/es/platform/zform/adapters/presenter/translators/fields/CurrencyFieldTranslator.js +1 -0
- package/es/platform/zform/adapters/presenter/translators/fields/DecimalFieldTranslator.js +1 -0
- package/es/platform/zform/adapters/presenter/translators/fields/EmailFieldTranslator.js +1 -0
- package/es/platform/zform/adapters/presenter/translators/fields/LookUpFieldTranslator.js +11 -7
- package/es/platform/zform/adapters/presenter/translators/fields/NumberFieldTranslator.js +1 -0
- package/es/platform/zform/adapters/presenter/translators/fields/PhoneFieldTranslator.js +1 -0
- package/es/platform/zform/adapters/presenter/translators/fields/TextAreaFieldTranslator.js +1 -0
- package/es/platform/zform/adapters/presenter/translators/fields/TextFieldTranslator.js +1 -0
- package/es/platform/zform/adapters/presenter/translators/fields/URLFieldTranslator.js +1 -0
- package/es/platform/zform/adapters/presenter/utils/sanitizeHtmlString.js +2 -2
- package/es/platform/zform/applications/interfaces/input/GetInitialRecordSuccessUseCaseInputModel.js +1 -0
- package/es/platform/zform/applications/usecases/GetInitialRecordSuccessUseCase.js +132 -0
- package/es/platform/zform/applications/usecases/InitializeUseCase.js +54 -30
- package/es/platform/zform/applications/usecases/LookupFieldSuccessUseCase.js +5 -0
- package/es/platform/zform/applications/usecases/MyFormSuccessUseCase.js +12 -11
- package/es/platform/zform/applications/usecases/SubmitValidationCompletedUseCase.js +21 -8
- package/es/platform/zform/domain/ZField.js +7 -5
- package/es/platform/zform/domain/ZForm.js +97 -20
- package/es/platform/zform/frameworks/ui/EventHandlerFactory.js +23 -5
- package/es/platform/zform/frameworks/ui/ZFormBehaviourFactory.js +2 -0
- package/es/platform/zrecord/adapters/controllers/UpdateRecordController.js +30 -0
- package/es/platform/zrecord/adapters/gateways/Service.js +2 -0
- package/es/platform/zrecord/applications/interfaces/input/UpdateRecordInputModel.js +0 -0
- package/es/platform/zrecord/applications/usecases/UpdateRecordUseCase.js +30 -0
- package/es/platform/zrecord/frameworks/ActionsHandlersFactory.js +4 -1
- package/package.json +8 -11
- package/es/platform/components/table-connected/adapters/controllers/ColumnChooserOpenedController.js +0 -28
- package/es/platform/components/table-connected/adapters/controllers/ColumnChooserUpdateController.js +0 -31
|
@@ -6,19 +6,23 @@ const LookUpFieldTranslator = _ref => {
|
|
|
6
6
|
uiConfig
|
|
7
7
|
} = _ref;
|
|
8
8
|
const fieldModified = {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
value: field.value || '',
|
|
9
|
+
// Need to check if value is an object or string (ID)
|
|
10
|
+
value: field.value ? field.value instanceof Object ? field.value.id : field.value : '',
|
|
12
11
|
//state.behaviours.zform.values[field.apiName],
|
|
13
12
|
name: field.apiName,
|
|
14
13
|
...fieldPreModified,
|
|
14
|
+
uiConfig: uiConfig,
|
|
15
|
+
type: type,
|
|
16
|
+
fieldType: field.type,
|
|
15
17
|
id: field.id,
|
|
16
18
|
label: field.i18NLabel,
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
// visibility: field.isVisible,
|
|
19
|
+
apiName: field.apiName,
|
|
20
|
+
errorMessage: field.errorMessage,
|
|
20
21
|
isVisible: field.isVisible,
|
|
21
|
-
|
|
22
|
+
readonly: field.isReadOnly,
|
|
23
|
+
required: field.isMandatory,
|
|
24
|
+
isCustomField: field.isCustomField,
|
|
25
|
+
maxLength: field.maxLength,
|
|
22
26
|
lookup: field.lookup
|
|
23
27
|
};
|
|
24
28
|
return fieldModified;
|
|
@@ -16,6 +16,7 @@ const NumberFieldTranslator = _ref => {
|
|
|
16
16
|
label: field.i18NLabel,
|
|
17
17
|
// ePHI: field.isPHI, //field.ePHI,
|
|
18
18
|
required: field.isMandatory,
|
|
19
|
+
maxLength: field.maxLength,
|
|
19
20
|
readonly: field.isReadOnly,
|
|
20
21
|
// visibility: field.isVisible,
|
|
21
22
|
isVisible: field.isVisible,
|
|
@@ -16,6 +16,7 @@ const PhoneFieldTranslator = _ref => {
|
|
|
16
16
|
label: field.i18NLabel,
|
|
17
17
|
// ePHI: field.isPHI, //field.ePHI,
|
|
18
18
|
required: field.isMandatory,
|
|
19
|
+
maxLength: field.maxLength,
|
|
19
20
|
readonly: field.isReadOnly,
|
|
20
21
|
isVisible: field.isVisible,
|
|
21
22
|
errorMessage: field.errorMessage || ''
|
|
@@ -16,6 +16,7 @@ const TextAreaFieldTranslator = _ref => {
|
|
|
16
16
|
label: field.i18NLabel,
|
|
17
17
|
required: field.isMandatory,
|
|
18
18
|
readonly: field.isReadOnly,
|
|
19
|
+
maxLength: field.maxLength,
|
|
19
20
|
// visibility: field.isVisible,
|
|
20
21
|
isVisible: field.isVisible,
|
|
21
22
|
errorMessage: field.errorMessage || ''
|
|
@@ -17,6 +17,7 @@ const TextFieldTranslator = _ref => {
|
|
|
17
17
|
// ePHI: field.isPHI, //field.ePHI,
|
|
18
18
|
required: field.isMandatory,
|
|
19
19
|
readonly: field.isReadOnly,
|
|
20
|
+
maxLength: field.maxLength,
|
|
20
21
|
// visibility: field.isVisible,
|
|
21
22
|
isVisible: field.isVisible,
|
|
22
23
|
errorMessage: field.errorMessage || ''
|
|
@@ -16,6 +16,7 @@ const URLFieldTranslator = _ref => {
|
|
|
16
16
|
label: field.i18NLabel,
|
|
17
17
|
// ePHI: field.isPHI, //field.ePHI,
|
|
18
18
|
required: field.isMandatory,
|
|
19
|
+
maxLength: field.maxLength,
|
|
19
20
|
readonly: field.isReadOnly,
|
|
20
21
|
// visibility: field.isVisible,
|
|
21
22
|
isVisible: field.isVisible,
|
package/es/platform/zform/applications/interfaces/input/GetInitialRecordSuccessUseCaseInputModel.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import AbstractUseCase from "./AbstractUseCase";
|
|
2
|
+
import { ZFORM_API_FAILURE, ZFORM_DEPENDENCY_MAPPINGS_SUCCESS, ZFORM_LAYOUT_RULES_SUCCESS, ZFORM_MY_FORM_SUCCESS } from "../../../../bc/zform/Symbol";
|
|
3
|
+
import { DATA_SOURCE_EXECUTE as DATA_BROKER_EXECUTE } from "../../../../bc/zdata-source/Constants";
|
|
4
|
+
import { DATA_SOURCE_SUCCESS, DATA_SOURCE_NO_CONTENT, DATA_SOURCE_FAILURE } from "../../../../bc/zdata-source/Symbols";
|
|
5
|
+
|
|
6
|
+
class GetInitialRecordSuccessUseCase extends AbstractUseCase {
|
|
7
|
+
execute(input) {
|
|
8
|
+
const {
|
|
9
|
+
disableValidationRule,
|
|
10
|
+
disableLayoutRule,
|
|
11
|
+
disableDependencyMapping
|
|
12
|
+
} = input;
|
|
13
|
+
const {
|
|
14
|
+
dispatch,
|
|
15
|
+
record
|
|
16
|
+
} = input;
|
|
17
|
+
const zformEntity = this.dependencies.repository.getFormEntity();
|
|
18
|
+
zformEntity.setInitialRecord(record);
|
|
19
|
+
const context = { ...zformEntity.getContext(),
|
|
20
|
+
layoutId: zformEntity.getLayoutId()
|
|
21
|
+
};
|
|
22
|
+
dispatch({
|
|
23
|
+
type: DATA_BROKER_EXECUTE,
|
|
24
|
+
payload: {
|
|
25
|
+
actionName: "getMyForm",
|
|
26
|
+
props: context
|
|
27
|
+
},
|
|
28
|
+
metaData: {
|
|
29
|
+
actionName: "getMyForm",
|
|
30
|
+
//hack
|
|
31
|
+
initialRecordData: record,
|
|
32
|
+
// Store record data here for later use
|
|
33
|
+
[DATA_SOURCE_NO_CONTENT]: {
|
|
34
|
+
type: ZFORM_MY_FORM_SUCCESS,
|
|
35
|
+
metaData: {
|
|
36
|
+
actionName: "getMyForm",
|
|
37
|
+
initialRecordData: record
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
//hack
|
|
41
|
+
[DATA_SOURCE_FAILURE]: {
|
|
42
|
+
type: ZFORM_API_FAILURE,
|
|
43
|
+
metaData: {
|
|
44
|
+
actionName: 'getMyForm'
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
[DATA_SOURCE_SUCCESS]: {
|
|
48
|
+
type: ZFORM_MY_FORM_SUCCESS,
|
|
49
|
+
metaData: {
|
|
50
|
+
actionName: "getMyForm",
|
|
51
|
+
initialRecordData: record
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
if (!disableDependencyMapping) {
|
|
58
|
+
dispatch({
|
|
59
|
+
type: DATA_BROKER_EXECUTE,
|
|
60
|
+
payload: {
|
|
61
|
+
actionName: "getDependencyMappings",
|
|
62
|
+
props: context
|
|
63
|
+
},
|
|
64
|
+
metaData: {
|
|
65
|
+
actionName: "getDependencyMappings",
|
|
66
|
+
//hack
|
|
67
|
+
[DATA_SOURCE_SUCCESS]: {
|
|
68
|
+
type: ZFORM_DEPENDENCY_MAPPINGS_SUCCESS,
|
|
69
|
+
metaData: {
|
|
70
|
+
actionName: "getDependencyMappings"
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
[DATA_SOURCE_FAILURE]: {
|
|
74
|
+
type: ZFORM_API_FAILURE,
|
|
75
|
+
metaData: {
|
|
76
|
+
actionName: 'getDependencyMappings'
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
[DATA_SOURCE_NO_CONTENT]: {
|
|
80
|
+
type: ZFORM_DEPENDENCY_MAPPINGS_SUCCESS,
|
|
81
|
+
metaData: {
|
|
82
|
+
actionName: "getDependencyMappings"
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
} else {
|
|
88
|
+
zformEntity.setDependencyFetching(false);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
if (!disableLayoutRule) {
|
|
92
|
+
dispatch({
|
|
93
|
+
type: DATA_BROKER_EXECUTE,
|
|
94
|
+
payload: {
|
|
95
|
+
actionName: "getLayoutRules",
|
|
96
|
+
props: { ...context,
|
|
97
|
+
activeRulesOnly: true
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
metaData: {
|
|
101
|
+
actionName: "getLayoutRules",
|
|
102
|
+
//hack
|
|
103
|
+
[DATA_SOURCE_NO_CONTENT]: {
|
|
104
|
+
type: ZFORM_LAYOUT_RULES_SUCCESS,
|
|
105
|
+
metaData: {
|
|
106
|
+
actionName: "getLayoutRules"
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
[DATA_SOURCE_FAILURE]: {
|
|
110
|
+
type: ZFORM_API_FAILURE,
|
|
111
|
+
metaData: {
|
|
112
|
+
actionName: 'getLayoutRules'
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
[DATA_SOURCE_SUCCESS]: {
|
|
116
|
+
type: ZFORM_LAYOUT_RULES_SUCCESS,
|
|
117
|
+
metaData: {
|
|
118
|
+
actionName: "getLayoutRules"
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
} else {
|
|
124
|
+
zformEntity.setLayoutRulesFetching(false);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
this.dependencies.presenter.updateFormResponse(zformEntity.toObject());
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export default GetInitialRecordSuccessUseCase;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import AbstractUseCase from "./AbstractUseCase";
|
|
2
|
-
import { ZFORM_API_FAILURE, ZFORM_MY_LAYOUTS_SUCCESS } from "../../../../bc/zform/Symbol";
|
|
2
|
+
import { ZFORM_API_FAILURE, ZFORM_INITIAL_RECORD_SUCCESS, ZFORM_MY_LAYOUTS_SUCCESS } from "../../../../bc/zform/Symbol";
|
|
3
3
|
import { DATA_SOURCE_EXECUTE } from "../../../../bc/zdata-source/Constants";
|
|
4
|
-
import { DATA_SOURCE_SUCCESS, DATA_SOURCE_NO_CONTENT, DATA_SOURCE_FAILURE } from "../../../../bc/zdata-source/Symbols";
|
|
5
4
|
import { CLIENTACTION_BEHAVIOUR_EXECUTE } from "../../../client-actions/bc/zclient-actions/Constants";
|
|
6
5
|
import { ZFormApiActionName } from "../../../../bc/zform/Constants";
|
|
7
6
|
import { CLIENTSCRIPT_FETCH } from "../../../client-scripts/bc/zclient-scripts-fetch/Constants";
|
|
7
|
+
import { RecordApiActionName } from "../../../../bc/zrecord/Constants";
|
|
8
|
+
import { ACA_ERROR_OCCURRED, ErrorCodes } from "../../../../cc/component/ErrorStructure";
|
|
8
9
|
|
|
9
10
|
class InitializeUseCase extends AbstractUseCase {
|
|
10
11
|
execute(input) {
|
|
@@ -48,38 +49,61 @@ class InitializeUseCase extends AbstractUseCase {
|
|
|
48
49
|
});
|
|
49
50
|
}
|
|
50
51
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
52
|
+
if (zformEntity.isEditMode()) {
|
|
53
|
+
const recordId = zformEntity.getRecordId();
|
|
54
|
+
|
|
55
|
+
if (!recordId) {
|
|
56
|
+
const errorStructure = {
|
|
57
|
+
code: ErrorCodes.PROPERTY_VALIDATION_FAILED,
|
|
58
|
+
message: 'Record ID is required for Edit Mode',
|
|
59
|
+
errorDetails: {
|
|
60
|
+
validationResults: [{
|
|
61
|
+
key: 'recordId',
|
|
62
|
+
errors: [{
|
|
63
|
+
message: 'Record ID is required for Edit Mode'
|
|
64
|
+
}],
|
|
65
|
+
value: recordId
|
|
66
|
+
}],
|
|
67
|
+
isBreaking: true
|
|
67
68
|
}
|
|
69
|
+
};
|
|
70
|
+
dispatch({
|
|
71
|
+
type: ACA_ERROR_OCCURRED,
|
|
72
|
+
payload: errorStructure
|
|
73
|
+
});
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
dispatch({
|
|
78
|
+
type: DATA_SOURCE_EXECUTE,
|
|
79
|
+
payload: {
|
|
80
|
+
actionName: RecordApiActionName.GET_SINGLE_RECORD,
|
|
81
|
+
props: context
|
|
68
82
|
},
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
83
|
+
metaData: zformEntity.getDataSourceMetaData({
|
|
84
|
+
actionName: RecordApiActionName.GET_SINGLE_RECORD,
|
|
85
|
+
successEvent: ZFORM_INITIAL_RECORD_SUCCESS,
|
|
86
|
+
failureEvent: ZFORM_API_FAILURE
|
|
87
|
+
})
|
|
88
|
+
});
|
|
89
|
+
} else {
|
|
90
|
+
dispatch({
|
|
91
|
+
type: DATA_SOURCE_EXECUTE,
|
|
92
|
+
payload: {
|
|
93
|
+
actionName: ZFormApiActionName.getMyLayouts,
|
|
94
|
+
props: { ...context,
|
|
95
|
+
from: 1,
|
|
96
|
+
limit: 50
|
|
73
97
|
}
|
|
74
98
|
},
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
}
|
|
99
|
+
metaData: zformEntity.getDataSourceMetaData({
|
|
100
|
+
actionName: ZFormApiActionName.getMyLayouts,
|
|
101
|
+
//hack
|
|
102
|
+
successEvent: ZFORM_MY_LAYOUTS_SUCCESS,
|
|
103
|
+
failureEvent: ZFORM_API_FAILURE
|
|
104
|
+
})
|
|
105
|
+
});
|
|
106
|
+
}
|
|
83
107
|
}
|
|
84
108
|
|
|
85
109
|
}
|
|
@@ -11,6 +11,11 @@ class LookUpFieldSuccessUseCase extends AbstractUseCase {
|
|
|
11
11
|
dispatch,
|
|
12
12
|
fieldMetadataResponse
|
|
13
13
|
} = input;
|
|
14
|
+
|
|
15
|
+
if (!fieldMetadataResponse || !fieldMetadataResponse.data || fieldMetadataResponse.data.length === 0) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
|
|
14
19
|
const {
|
|
15
20
|
data
|
|
16
21
|
} = fieldMetadataResponse;
|
|
@@ -21,14 +21,17 @@ class MyFormSuccessUseCase extends AbstractUseCase {
|
|
|
21
21
|
sections
|
|
22
22
|
} = myForm;
|
|
23
23
|
const zFormEntity = repository.getFormEntity();
|
|
24
|
+
const layoutId = zFormEntity.getLayoutId();
|
|
25
|
+
const initialRecord = zFormEntity.getInitialRecord();
|
|
24
26
|
const context = { ...zFormEntity.getContext(),
|
|
25
|
-
layoutId:
|
|
27
|
+
layoutId: layoutId
|
|
26
28
|
};
|
|
27
29
|
const lookupFields = sections.flatMap(section => section.fields.filter(field => field.type === 'LookUp'));
|
|
28
30
|
const sectionEntities = sections.map(section => {
|
|
29
31
|
const fields = section.fields.map(field => {
|
|
32
|
+
const recordValue = initialRecord ? field.isCustomField ? initialRecord.cf[field.apiName] : initialRecord[field.apiName] : undefined;
|
|
30
33
|
const entity = new ZField(field);
|
|
31
|
-
entity.decideDefaultValue();
|
|
34
|
+
entity.decideDefaultValue(recordValue);
|
|
32
35
|
return entity;
|
|
33
36
|
});
|
|
34
37
|
const sectionWithFields = { ...section,
|
|
@@ -63,24 +66,22 @@ class MyFormSuccessUseCase extends AbstractUseCase {
|
|
|
63
66
|
type: DATA_SOURCE_EXECUTE,
|
|
64
67
|
payload: {
|
|
65
68
|
actionName: 'fetchLookupFields',
|
|
66
|
-
props:
|
|
67
|
-
}
|
|
69
|
+
props: context
|
|
68
70
|
},
|
|
69
71
|
metaData: {
|
|
70
72
|
actionName: 'fetchLookupFields',
|
|
71
|
-
//hack
|
|
72
73
|
[DATA_SOURCE_NO_CONTENT]: {
|
|
73
74
|
type: ZFORM_LOOKUP_FIELD_SUCCESS,
|
|
74
75
|
metaData: {
|
|
75
76
|
actionName: 'fetchLookupFields'
|
|
76
77
|
}
|
|
77
78
|
},
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
79
|
+
[DATA_SOURCE_FAILURE]: {
|
|
80
|
+
type: ZFORM_API_FAILURE,
|
|
81
|
+
metaData: {
|
|
82
|
+
actionName: 'fetchLookupFields'
|
|
83
|
+
}
|
|
84
|
+
},
|
|
84
85
|
[DATA_SOURCE_SUCCESS]: {
|
|
85
86
|
type: ZFORM_LOOKUP_FIELD_SUCCESS,
|
|
86
87
|
metaData: {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CREATE_RECORD } from "../../../../bc/zrecord/Constants";
|
|
1
|
+
import { CREATE_RECORD, UPDATE_RECORD } from "../../../../bc/zrecord/Constants";
|
|
2
2
|
import AbstractUseCase from "./AbstractUseCase";
|
|
3
3
|
import { ZFORM_ERROR, ZFORM_VALIDATION_SUCCESS, ZFORM_SUBMIT_VALIDATION_FAILURE } from "../../../../bc/zform/Symbol";
|
|
4
4
|
|
|
@@ -43,6 +43,7 @@ class SubmitValidationCompletedUseCase extends AbstractUseCase {
|
|
|
43
43
|
const moduleName = zFormEntity.getModuleName();
|
|
44
44
|
const record = zFormEntity.getVisibleFieldsAsRecord();
|
|
45
45
|
const visibleFieldsData = zFormEntity.getVisibleFieldsData();
|
|
46
|
+
const isEditMode = zFormEntity.isEditMode();
|
|
46
47
|
dispatch({
|
|
47
48
|
type: ZFORM_VALIDATION_SUCCESS,
|
|
48
49
|
payload: {
|
|
@@ -52,13 +53,25 @@ class SubmitValidationCompletedUseCase extends AbstractUseCase {
|
|
|
52
53
|
});
|
|
53
54
|
|
|
54
55
|
if (!disableCreateRecord) {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
56
|
+
if (isEditMode) {
|
|
57
|
+
const recordId = zFormEntity.getRecordId();
|
|
58
|
+
dispatch({
|
|
59
|
+
type: UPDATE_RECORD,
|
|
60
|
+
payload: {
|
|
61
|
+
record,
|
|
62
|
+
moduleName,
|
|
63
|
+
recordId
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
} else {
|
|
67
|
+
dispatch({
|
|
68
|
+
type: CREATE_RECORD,
|
|
69
|
+
payload: {
|
|
70
|
+
record,
|
|
71
|
+
moduleName
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
}
|
|
62
75
|
}
|
|
63
76
|
}
|
|
64
77
|
}
|
|
@@ -79,18 +79,20 @@ export default class ZField {
|
|
|
79
79
|
return defaultValue;
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
-
decideDefaultValue() {
|
|
82
|
+
decideDefaultValue(_defaultValue) {
|
|
83
|
+
const defaultValue = _defaultValue !== undefined ? _defaultValue : this.defaultValue;
|
|
84
|
+
|
|
83
85
|
switch (this.type) {
|
|
84
86
|
case 'Boolean':
|
|
85
|
-
this.value = this.decideValueForBoolean(
|
|
87
|
+
this.value = this.decideValueForBoolean(defaultValue);
|
|
86
88
|
break;
|
|
87
89
|
|
|
88
90
|
case 'Multiselect':
|
|
89
|
-
this.value = this.decideValueForMultiselect(
|
|
91
|
+
this.value = this.decideValueForMultiselect(defaultValue);
|
|
90
92
|
break;
|
|
91
93
|
|
|
92
94
|
default:
|
|
93
|
-
this.value =
|
|
95
|
+
this.value = defaultValue === undefined ? '' : defaultValue;
|
|
94
96
|
}
|
|
95
97
|
}
|
|
96
98
|
|
|
@@ -184,7 +186,7 @@ export default class ZField {
|
|
|
184
186
|
isEncryptedField: this.isEncryptedField,
|
|
185
187
|
id: this.id,
|
|
186
188
|
isRemovable: this.isRemovable,
|
|
187
|
-
maxLength: this.maxLength,
|
|
189
|
+
maxLength: Number(this.maxLength) > 0 ? Number(this.maxLength) : this.maxLength,
|
|
188
190
|
isMandatory: this.isMandatory,
|
|
189
191
|
value: this.value,
|
|
190
192
|
errorMessage: this.errorMessage,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ErrorCodes } from "../../../cc/component/ErrorStructure";
|
|
2
2
|
import { ZFormApiActionName } from "../../../bc/zform/Constants";
|
|
3
|
-
import {
|
|
3
|
+
import { DATA_SOURCE_SUCCESS, DATA_SOURCE_NO_CONTENT, DATA_SOURCE_FAILURE } from "../../../bc/zdata-source/Symbols";
|
|
4
|
+
import { RecordApiActionName } from "../../../bc/zrecord/Constants";
|
|
4
5
|
export default class ZForm {
|
|
5
6
|
/*hack*/
|
|
6
7
|
|
|
@@ -21,6 +22,10 @@ export default class ZForm {
|
|
|
21
22
|
dependencyMappings,
|
|
22
23
|
context,
|
|
23
24
|
focusedFieldName,
|
|
25
|
+
layoutId,
|
|
26
|
+
mode,
|
|
27
|
+
recordId,
|
|
28
|
+
initialRecordData,
|
|
24
29
|
|
|
25
30
|
/*hack*/
|
|
26
31
|
isMyFormFetching,
|
|
@@ -45,6 +50,10 @@ export default class ZForm {
|
|
|
45
50
|
this.dependencyMappings = dependencyMappings;
|
|
46
51
|
this.context = context;
|
|
47
52
|
this.focusedFieldName = focusedFieldName || null;
|
|
53
|
+
this.layoutId = layoutId;
|
|
54
|
+
this.initialRecordData = initialRecordData;
|
|
55
|
+
this.mode = mode;
|
|
56
|
+
this.recordId = recordId;
|
|
48
57
|
/*hack*/
|
|
49
58
|
|
|
50
59
|
this.isMyFormFetching = isMyFormFetching;
|
|
@@ -81,14 +90,64 @@ export default class ZForm {
|
|
|
81
90
|
orgName,
|
|
82
91
|
servicePrefix
|
|
83
92
|
} = this.context;
|
|
84
|
-
|
|
93
|
+
const recordId = this.getRecordId();
|
|
94
|
+
const formValues = this.getVisibleFieldsData();
|
|
95
|
+
const context = {
|
|
85
96
|
module,
|
|
86
97
|
departmentId: departmentId,
|
|
87
98
|
orgName,
|
|
99
|
+
mode: this.mode,
|
|
100
|
+
formValues,
|
|
101
|
+
record: this.initialRecordData,
|
|
88
102
|
...this.context,
|
|
89
103
|
servicePrefix: servicePrefix || 'supportapi/zd' // FIX: servicePrefix defaultValue should be available from properties
|
|
90
104
|
|
|
91
105
|
};
|
|
106
|
+
|
|
107
|
+
if (recordId) {
|
|
108
|
+
context.recordId = recordId;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
return context;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
getRecordId() {
|
|
115
|
+
return this.recordId;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
isEditMode() {
|
|
119
|
+
return this.mode === 'edit';
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
getDataSourceMetaData(_ref2) {
|
|
123
|
+
let {
|
|
124
|
+
actionName,
|
|
125
|
+
successEvent,
|
|
126
|
+
failureEvent,
|
|
127
|
+
extras
|
|
128
|
+
} = _ref2;
|
|
129
|
+
return {
|
|
130
|
+
actionName,
|
|
131
|
+
//hack
|
|
132
|
+
[DATA_SOURCE_NO_CONTENT]: {
|
|
133
|
+
type: successEvent,
|
|
134
|
+
metaData: { ...extras,
|
|
135
|
+
actionName
|
|
136
|
+
}
|
|
137
|
+
},
|
|
138
|
+
[DATA_SOURCE_FAILURE]: {
|
|
139
|
+
type: failureEvent,
|
|
140
|
+
metaData: { ...extras,
|
|
141
|
+
actionName
|
|
142
|
+
}
|
|
143
|
+
},
|
|
144
|
+
[DATA_SOURCE_SUCCESS]: {
|
|
145
|
+
type: successEvent,
|
|
146
|
+
metaData: { ...extras,
|
|
147
|
+
actionName
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
};
|
|
92
151
|
}
|
|
93
152
|
|
|
94
153
|
setFormProperties(properties, layoutRuleHelper) {
|
|
@@ -137,6 +196,10 @@ export default class ZForm {
|
|
|
137
196
|
let isBreaking = false; // Set error state based on the failed action
|
|
138
197
|
|
|
139
198
|
switch (actionName) {
|
|
199
|
+
case RecordApiActionName.GET_SINGLE_RECORD:
|
|
200
|
+
isBreaking = true;
|
|
201
|
+
break;
|
|
202
|
+
|
|
140
203
|
case ZFormApiActionName.getMyForm:
|
|
141
204
|
this.setMyFormFetching(false);
|
|
142
205
|
isBreaking = true;
|
|
@@ -170,34 +233,23 @@ export default class ZForm {
|
|
|
170
233
|
}
|
|
171
234
|
|
|
172
235
|
constructApiErrorEvent(error, actionName, isBreaking) {
|
|
173
|
-
if (error.code === ZHttpErrorCode.ApiError) {
|
|
174
|
-
return {
|
|
175
|
-
code: ErrorCodes.API_FAILED,
|
|
176
|
-
message: 'Api call failed for action: ' + actionName,
|
|
177
|
-
errorDetails: {
|
|
178
|
-
isBreaking,
|
|
179
|
-
originalError: error,
|
|
180
|
-
actionName
|
|
181
|
-
}
|
|
182
|
-
};
|
|
183
|
-
}
|
|
184
|
-
|
|
185
236
|
return {
|
|
186
|
-
code: ErrorCodes.
|
|
187
|
-
message:
|
|
237
|
+
code: ErrorCodes.API_FAILED,
|
|
238
|
+
message: error.message,
|
|
188
239
|
errorDetails: {
|
|
189
240
|
isBreaking,
|
|
190
|
-
|
|
191
|
-
actionName
|
|
241
|
+
message: 'Api call failed for action: ' + actionName,
|
|
242
|
+
actionName,
|
|
243
|
+
originalError: error
|
|
192
244
|
}
|
|
193
245
|
};
|
|
194
246
|
}
|
|
195
247
|
|
|
196
|
-
getSectionId(
|
|
248
|
+
getSectionId(_ref3) {
|
|
197
249
|
let {
|
|
198
250
|
fieldName,
|
|
199
251
|
sectionName
|
|
200
|
-
} =
|
|
252
|
+
} = _ref3;
|
|
201
253
|
|
|
202
254
|
if (sectionName) {
|
|
203
255
|
for (let section of this.sections) {
|
|
@@ -482,6 +534,27 @@ export default class ZForm {
|
|
|
482
534
|
}
|
|
483
535
|
}
|
|
484
536
|
|
|
537
|
+
setInitialRecord(recordData) {
|
|
538
|
+
this.initialRecordData = recordData;
|
|
539
|
+
const layoutId = recordData.layout.id;
|
|
540
|
+
this.setLayoutId(layoutId); // if (recordData && recordData.data && recordData.data.length > 0) {
|
|
541
|
+
// const record = recordData.data[0];
|
|
542
|
+
// // Populate form fields with record data
|
|
543
|
+
// Object.keys(record).forEach(fieldApiName => {
|
|
544
|
+
// if (fieldApiName !== 'id') { // Skip ID field
|
|
545
|
+
// const field = this.getFieldByApiName(fieldApiName);
|
|
546
|
+
// if (field) {
|
|
547
|
+
// field.setValue(record[fieldApiName]);
|
|
548
|
+
// }
|
|
549
|
+
// }
|
|
550
|
+
// });
|
|
551
|
+
// }
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
getInitialRecord() {
|
|
555
|
+
return this.initialRecordData;
|
|
556
|
+
}
|
|
557
|
+
|
|
485
558
|
getFieldErrorMessage(fieldApiName) {
|
|
486
559
|
const field = this.getFieldByApiName(fieldApiName);
|
|
487
560
|
return field ? field.getErrorMessage() : undefined;
|
|
@@ -627,6 +700,7 @@ export default class ZForm {
|
|
|
627
700
|
}
|
|
628
701
|
|
|
629
702
|
toObject() {
|
|
703
|
+
const formValues = this.getVisibleFieldsData();
|
|
630
704
|
return {
|
|
631
705
|
modifiedTime: this.modifiedTime,
|
|
632
706
|
isStandardLayout: this.isStandardLayout,
|
|
@@ -642,8 +716,11 @@ export default class ZForm {
|
|
|
642
716
|
dependencyMappings: this.dependencyMappings.map(dm => dm.toObject()),
|
|
643
717
|
focusedFieldName: this.focusedFieldName,
|
|
644
718
|
layoutId: this.layoutId,
|
|
719
|
+
mode: this.mode,
|
|
720
|
+
initialRecordData: this.initialRecordData,
|
|
645
721
|
|
|
646
722
|
/*hack*/
|
|
723
|
+
formValues,
|
|
647
724
|
isMyFormFetching: this.isMyFormFetching,
|
|
648
725
|
isDependencyFetching: this.isDependencyFetching,
|
|
649
726
|
isLayoutRulesFetching: this.isLayoutRulesFetching,
|