@zohodesk/library-platform 1.1.9-exp.1 → 1.1.10-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/cc/form-connected/Properties.js +2 -2
- package/es/library/custom-component/applications/interfaces/input/SetRefInputModel.js +1 -0
- package/es/library/custom-component/applications/usecases/MountUseCase copy.js +28 -0
- package/es/library/custom-component/applications/usecases/SetRefUseCase.js +31 -0
- package/es/library/custom-component/domain/entities/ComponentProperties.js +7 -8
- package/es/library/custom-component/domain/entities/Logger.js +40 -10
- package/es/library/dot/components/form/frameworks/ui/FormFallbackView.js +23 -0
- package/es/library/dot/legacy-to-new-arch/button/frameworks/ui/ButtonView.js +1 -1
- package/es/platform/components/form-connected/adapters/resources/SmartFormResources.js +18 -0
- package/es/platform/components/form-connected/frameworks/EventHandlersFactory.js +2 -1
- package/es/platform/components/form-connected/frameworks/FormFallbackView.js +23 -0
- package/es/platform/components/form-connected/frameworks/FormSdkFactory.js +4 -2
- package/es/platform/zdata-source/domain/entities/APITemplate.js +2 -1
- package/es/platform/zform/adapters/controllers/CreateRecordFailedController.js +21 -0
- package/es/platform/zform/adapters/controllers/CreateRecordSuccessController.js +21 -0
- package/es/platform/zform/adapters/gateway/FormRepository.js +2 -0
- package/es/platform/zform/adapters/gateway/Service.js +4 -0
- package/es/platform/zform/adapters/presenter/FormTranslator.js +14 -9
- package/es/platform/zform/adapters/presenter/utils/DefaultClientActions.js +3 -1
- package/es/platform/zform/applications/interfaces/input/CreateRecordFailedUseCaseInputModel.js +1 -0
- package/es/platform/zform/applications/interfaces/input/CreateRecordSuccessUseCaseInputModel.js +1 -0
- package/es/platform/zform/applications/interfaces/input/GetIsFieldValueChangedUseCaseInput.js +1 -0
- package/es/platform/zform/applications/usecases/CreateRecordFailedUseCase.js +25 -0
- package/es/platform/zform/applications/usecases/CreateRecordSuccessUseCase.js +25 -0
- package/es/platform/zform/applications/usecases/FormSubmitUseCase.js +4 -1
- package/es/platform/zform/applications/usecases/GetIsFieldValueChanged.js +35 -0
- package/es/platform/zform/applications/usecases/MyLayoutSuccessUseCase.js +1 -1
- package/es/platform/zform/applications/usecases/SubmitValidationCompletedUseCase.js +2 -0
- package/es/platform/zform/domain/ZField.js +4 -0
- package/es/platform/zform/domain/ZForm.js +7 -0
- package/es/platform/zform/frameworks/ui/EventHandlerFactory.js +11 -25
- package/es/platform/zform/frameworks/ui/ZFormBehaviourFactory.js +1 -0
- package/package.json +1 -1
|
@@ -30,7 +30,7 @@ export default {
|
|
|
30
30
|
type: 'boolean'
|
|
31
31
|
}
|
|
32
32
|
},
|
|
33
|
-
required: ['
|
|
33
|
+
required: ['isEnabled']
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
},
|
|
@@ -47,7 +47,7 @@ export default {
|
|
|
47
47
|
type: 'boolean'
|
|
48
48
|
}
|
|
49
49
|
},
|
|
50
|
-
required: ['
|
|
50
|
+
required: ['isEnabled']
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
53
|
},
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import AbstractUseCase from "./AbstractUseCase";
|
|
2
|
+
|
|
3
|
+
class MountUsecase extends AbstractUseCase {
|
|
4
|
+
execute() {
|
|
5
|
+
const {
|
|
6
|
+
repository,
|
|
7
|
+
presenter,
|
|
8
|
+
eventManager
|
|
9
|
+
} = this.dependencies;
|
|
10
|
+
const component = repository.getComponent();
|
|
11
|
+
const mountAction = component.getMountAction();
|
|
12
|
+
const eventHandlers = component.getEventHandlersWrapper();
|
|
13
|
+
|
|
14
|
+
try {
|
|
15
|
+
eventManager.subscribe(eventHandlers);
|
|
16
|
+
|
|
17
|
+
if (!component.hasBreakingError()) {
|
|
18
|
+
eventManager.dispatch(mountAction);
|
|
19
|
+
}
|
|
20
|
+
} catch (e) {
|
|
21
|
+
component.setError(e);
|
|
22
|
+
presenter.setError(e);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export default MountUsecase;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import AbstractUseCase from "./AbstractUseCase";
|
|
2
|
+
|
|
3
|
+
class SetRefUseCase extends AbstractUseCase {
|
|
4
|
+
execute(_ref) {
|
|
5
|
+
let {
|
|
6
|
+
ref
|
|
7
|
+
} = _ref;
|
|
8
|
+
const {
|
|
9
|
+
repository,
|
|
10
|
+
presenter,
|
|
11
|
+
eventManager
|
|
12
|
+
} = this.dependencies;
|
|
13
|
+
const component = repository.getComponent();
|
|
14
|
+
const eventHandlers = component.getEventHandlersWrapper();
|
|
15
|
+
|
|
16
|
+
try {
|
|
17
|
+
if (eventManager.isDifferentElement(ref)) {
|
|
18
|
+
eventManager.unSubscribe(eventHandlers);
|
|
19
|
+
eventManager.setElement(ref);
|
|
20
|
+
eventManager.subscribe(eventHandlers);
|
|
21
|
+
}
|
|
22
|
+
} catch (e) {
|
|
23
|
+
const error = component.getClassifiedErrorStructure(e);
|
|
24
|
+
component.setError(error);
|
|
25
|
+
presenter.setError(error);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export default SetRefUseCase;
|
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
/* eslint-disable complexity */
|
|
2
2
|
import { ErrorCodes } from "../../../../cc/component/ErrorStructure";
|
|
3
|
-
import Logger from "./Logger";
|
|
4
3
|
export default class ComponentProperties {
|
|
5
4
|
constructor(componentName, properties, behaviours) {
|
|
6
5
|
this.componentName = componentName;
|
|
7
6
|
this.properties = properties;
|
|
8
7
|
this.behaviours = behaviours;
|
|
9
|
-
this.logger = new Logger(componentName);
|
|
10
8
|
this.behavioursProperties = {};
|
|
11
9
|
/* store behaviour properties */
|
|
12
10
|
|
|
13
11
|
this.behaviours.forEach(behaviour => {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
const cloneMap = behaviour.getPropertiesClone();
|
|
13
|
+
this.behavioursProperties = { ...this.behavioursProperties,
|
|
14
|
+
...cloneMap
|
|
15
|
+
};
|
|
17
16
|
});
|
|
18
17
|
}
|
|
19
18
|
|
|
@@ -44,14 +43,13 @@ export default class ComponentProperties {
|
|
|
44
43
|
} = this.validateProperties(jsonValidator, newProps);
|
|
45
44
|
|
|
46
45
|
if (!isValid) {
|
|
47
|
-
|
|
48
|
-
|
|
46
|
+
// console.log({ isValid, componentName: this.componentName, validationResults });
|
|
49
47
|
throw {
|
|
50
48
|
code: ErrorCodes.PROPERTY_VALIDATION_FAILED,
|
|
51
49
|
message: `Properties validation failed for component ${this.componentName}`,
|
|
52
50
|
errorDetails: {
|
|
53
51
|
isBreaking: true,
|
|
54
|
-
validationResults: validationResults.filter(result =>
|
|
52
|
+
validationResults: validationResults.filter(result => result.errors?.length > 0 || result.warnings?.length > 0)
|
|
55
53
|
}
|
|
56
54
|
};
|
|
57
55
|
}
|
|
@@ -82,6 +80,7 @@ export default class ComponentProperties {
|
|
|
82
80
|
params: {}
|
|
83
81
|
}],
|
|
84
82
|
errors: [],
|
|
83
|
+
value: undefined,
|
|
85
84
|
schema: {}
|
|
86
85
|
};
|
|
87
86
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import { ErrorCodes } from "../../../../cc/component/ErrorStructure";
|
|
2
2
|
// const ERROR_TITLE: string = 'color: red; font-weight: bold;';
|
|
3
3
|
const ERROR_PRIMARY = 'color: #FF6F61;font-weight: bold';
|
|
4
4
|
const ERROR_SECONDARY = 'color: #FFA500;font-weight: initial'; // const LOG_TITLE: string = 'color: gray; font-weight: bold;';
|
|
@@ -12,25 +12,55 @@ export default class Logger {
|
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
logPropertiesValidation(validationResults) {
|
|
15
|
-
console.group(`%cProperties Validation: %c${this.componentName}`, ERROR_PRIMARY, ERROR_SECONDARY, validationResults
|
|
16
|
-
validationResults.
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
console.group(`%cProperties Validation: %c${this.componentName}`, ERROR_PRIMARY, ERROR_SECONDARY, validationResults);
|
|
16
|
+
validationResults.forEach(_ref => {
|
|
17
|
+
let {
|
|
18
|
+
key,
|
|
19
|
+
errors,
|
|
20
|
+
warnings,
|
|
21
|
+
value
|
|
22
|
+
} = _ref;
|
|
23
|
+
errors?.forEach(error => {
|
|
24
|
+
this.printResult(key, error, 'error');
|
|
19
25
|
});
|
|
20
|
-
|
|
21
|
-
this.printResult(
|
|
26
|
+
warnings?.forEach(warning => {
|
|
27
|
+
this.printResult(key, warning, 'warning');
|
|
28
|
+
});
|
|
29
|
+
console.log('%cBut, Given is:', 'color: white;font-weight: bold;', {
|
|
30
|
+
[key]: value
|
|
22
31
|
});
|
|
23
32
|
});
|
|
24
33
|
console.groupEnd();
|
|
25
34
|
}
|
|
26
35
|
|
|
27
|
-
|
|
36
|
+
logError(error) {
|
|
37
|
+
console.log('Logging Error in ComponentProperties - logError');
|
|
38
|
+
|
|
39
|
+
if (error.code === ErrorCodes.PROPERTY_VALIDATION_FAILED) {
|
|
40
|
+
this.logPropertiesValidation(error.errorDetails?.validationResults);
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
console.group(`%cError Occurred: %c${this.componentName}`, ERROR_PRIMARY, ERROR_SECONDARY, error);
|
|
45
|
+
console.error(`%cError Code: %c${error.code}`, ERROR_PRIMARY, ERROR_SECONDARY);
|
|
46
|
+
console.error(`%cError Message: %c${error.message}`, ERROR_PRIMARY, ERROR_SECONDARY);
|
|
47
|
+
|
|
48
|
+
if (error.errorDetails?.originalError) {
|
|
49
|
+
console.error(error.errorDetails.originalError);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
console.groupEnd();
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
printResult(key, errorOrWarning, type) {
|
|
56
|
+
const log = type === 'error' ? console.error : console.warn;
|
|
57
|
+
|
|
28
58
|
if (errorOrWarning.dataPath) {
|
|
29
|
-
|
|
59
|
+
log(`Invalid Property %c${key}%c${errorOrWarning.dataPath} %c${errorOrWarning.message}`, ERROR_PRIMARY, ERROR_SECONDARY, 'color: white;');
|
|
30
60
|
return;
|
|
31
61
|
}
|
|
32
62
|
|
|
33
|
-
|
|
63
|
+
log(`Invalid Property %c${key} : %c${errorOrWarning.message}`, ERROR_PRIMARY, 'color: white;');
|
|
34
64
|
}
|
|
35
65
|
|
|
36
66
|
eventNameConsoleStyle(type) {
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import ErrorState from "../../../../legacy-to-new-arch/error-state/frameworks/ui/ErrorState";
|
|
3
|
+
import { ErrorCodes } from "../../../../../../cc/component/ErrorStructure";
|
|
4
|
+
import ErrorTypes from "../../../../../../cc/error-state/ErrorTypes";
|
|
5
|
+
|
|
6
|
+
function FormFallbackView(_ref, ref) {
|
|
7
|
+
let {
|
|
8
|
+
error
|
|
9
|
+
} = _ref;
|
|
10
|
+
const map = {
|
|
11
|
+
[ErrorCodes.API_FAILED]: ErrorTypes.UrlNotFound,
|
|
12
|
+
[ErrorCodes.PROPERTY_VALIDATION_FAILED]: ErrorTypes.OopsSomethingMiss,
|
|
13
|
+
[ErrorCodes.EVENT_HANDLER_FAILED]: ErrorTypes.Inconvenience,
|
|
14
|
+
[ErrorCodes.UNKNOWN_ERROR]: ErrorTypes.Inconvenience
|
|
15
|
+
};
|
|
16
|
+
const errorType = map[error.code] === undefined ? ErrorTypes.Inconvenience : map[error.code];
|
|
17
|
+
return /*#__PURE__*/React.createElement(ErrorState, {
|
|
18
|
+
type: errorType,
|
|
19
|
+
getRef: ref
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export default /*#__PURE__*/React.forwardRef(FormFallbackView);
|
|
@@ -21,6 +21,7 @@ import SetFieldErrorMessageUseCase from "../../../../zform/applications/usecases
|
|
|
21
21
|
import FocusFieldUseCase from "../../../../zform/applications/usecases/FocusFieldUseCase";
|
|
22
22
|
import InsertValidationRuleUseCase from "../../../../zform/applications/usecases/InsertValidationRuleSuccessUseCase";
|
|
23
23
|
import GetFieldErrorMessageUseCase from "../../../../zform/applications/usecases/GetFieldErrorMessageUseCase";
|
|
24
|
+
import GetIsFieldValueChangedUseCase from "../../../../zform/applications/usecases/GetIsFieldValueChanged";
|
|
24
25
|
export class SmartFormResources extends AbstractResource {
|
|
25
26
|
initialize() {}
|
|
26
27
|
|
|
@@ -287,4 +288,21 @@ export class SmartFormResources extends AbstractResource {
|
|
|
287
288
|
});
|
|
288
289
|
}
|
|
289
290
|
|
|
291
|
+
getIsFieldValueChanged() {
|
|
292
|
+
const {
|
|
293
|
+
getData,
|
|
294
|
+
setData
|
|
295
|
+
} = this.createCallback();
|
|
296
|
+
const {
|
|
297
|
+
dispatch
|
|
298
|
+
} = this.dependencies;
|
|
299
|
+
const dependencies = this.getFormDependencies();
|
|
300
|
+
const usecase = this.createUseCase(dependencies, GetIsFieldValueChangedUseCase);
|
|
301
|
+
usecase.execute({
|
|
302
|
+
callback: setData,
|
|
303
|
+
dispatch
|
|
304
|
+
});
|
|
305
|
+
return getData();
|
|
306
|
+
}
|
|
307
|
+
|
|
290
308
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import SmartFormConstants from "../../../../cc/form-connected/ExternalConstants";
|
|
2
2
|
import FormSdkFactory from "./FormSdkFactory";
|
|
3
3
|
import FormConstants from "../../../../cc/form/Constants";
|
|
4
|
-
import { ZFORM_FIELD_BLURRED, ZFORM_FIELD_VALUE_CHANGED, ZFORM_SUBMIT_SUCCESS, ZFORM_SUBMIT_VALIDATION_FAILURE } from "../../../../bc/zform/Symbol";
|
|
4
|
+
import { ZFORM_FIELD_BLURRED, ZFORM_FIELD_VALUE_CHANGED, ZFORM_SUBMIT_FAILURE, ZFORM_SUBMIT_SUCCESS, ZFORM_SUBMIT_VALIDATION_FAILURE } from "../../../../bc/zform/Symbol";
|
|
5
5
|
import { platformSDK_old } from "../../../sdk/frameworks/Sdk";
|
|
6
6
|
const {
|
|
7
7
|
SMART_FORM_FIELD_FOCUSED,
|
|
@@ -56,6 +56,7 @@ export default class EventHandlersFactory {
|
|
|
56
56
|
[FormConstants.FORM_FIELD_FOCUSED]: EventHandlersFactory.createEventMappedHandler(SMART_FORM_FIELD_FOCUSED),
|
|
57
57
|
[ZFORM_FIELD_BLURRED]: EventHandlersFactory.createEventMappedHandler(SMART_FORM_FIELD_BLURRED),
|
|
58
58
|
[ZFORM_SUBMIT_SUCCESS]: EventHandlersFactory.createEventMappedHandler(SMART_FORM_SUBMIT_SUCCESS),
|
|
59
|
+
[ZFORM_SUBMIT_FAILURE]: EventHandlersFactory.createEventMappedHandler(SMART_FORM_SUBMIT_FAILURE),
|
|
59
60
|
[ZFORM_SUBMIT_VALIDATION_FAILURE]: EventHandlersFactory.createEventMappedHandler(SMART_FORM_SUBMIT_FAILURE),
|
|
60
61
|
[ZFORM_FIELD_VALUE_CHANGED]: EventHandlersFactory.createEventMappedHandler(SMART_FORM_FIELD_VALUE_CHANGED)
|
|
61
62
|
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import ErrorState from "../../../../library/dot/legacy-to-new-arch/error-state/frameworks/ui/ErrorState";
|
|
3
|
+
import { ErrorCodes } from "../../../../cc/component/ErrorStructure";
|
|
4
|
+
import ErrorTypes from "../../../../cc/error-state/ErrorTypes";
|
|
5
|
+
|
|
6
|
+
function FormFallbackView(_ref, ref) {
|
|
7
|
+
let {
|
|
8
|
+
error
|
|
9
|
+
} = _ref;
|
|
10
|
+
const map = {
|
|
11
|
+
[ErrorCodes.API_FAILED]: ErrorTypes.UrlNotFound,
|
|
12
|
+
[ErrorCodes.PROPERTY_VALIDATION_FAILED]: ErrorTypes.OopsSomethingMiss,
|
|
13
|
+
[ErrorCodes.EVENT_HANDLER_FAILED]: ErrorTypes.Inconvenience,
|
|
14
|
+
[ErrorCodes.UNKNOWN_ERROR]: ErrorTypes.Inconvenience
|
|
15
|
+
};
|
|
16
|
+
const errorType = map[error.code] === undefined ? ErrorTypes.Inconvenience : map[error.code];
|
|
17
|
+
return /*#__PURE__*/React.createElement(ErrorState, {
|
|
18
|
+
type: errorType,
|
|
19
|
+
getRef: ref
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export default /*#__PURE__*/React.forwardRef(FormFallbackView);
|
|
@@ -14,7 +14,8 @@ export default class FormSdkFactory {
|
|
|
14
14
|
deleteField: fieldName => smartForm.deleteField(fieldName),
|
|
15
15
|
updateField: (fieldName, fieldProperties) => smartForm.updateField(fieldName, fieldProperties),
|
|
16
16
|
getFieldValue: fieldName => smartForm.getFieldValue(fieldName),
|
|
17
|
-
submit: () => smartForm.submit()
|
|
17
|
+
submit: () => smartForm.submit(),
|
|
18
|
+
getIsFieldValueChanged: () => smartForm.getIsFieldValueChanged()
|
|
18
19
|
};
|
|
19
20
|
}
|
|
20
21
|
|
|
@@ -36,7 +37,8 @@ export default class FormSdkFactory {
|
|
|
36
37
|
deleteField: formSdks.deleteField,
|
|
37
38
|
updateField: formSdks.updateField,
|
|
38
39
|
getFieldValue: formSdks.getFieldValue,
|
|
39
|
-
submit: formSdks.submit
|
|
40
|
+
submit: formSdks.submit,
|
|
41
|
+
getIsFieldValueChanged: formSdks.getIsFieldValueChanged
|
|
40
42
|
}
|
|
41
43
|
};
|
|
42
44
|
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import AbstractController from "./AbstractController";
|
|
2
|
+
|
|
3
|
+
class CreateRecordFailedController extends AbstractController {
|
|
4
|
+
handle(event) {
|
|
5
|
+
const {
|
|
6
|
+
createRecordFailedUseCase
|
|
7
|
+
} = this.service;
|
|
8
|
+
const {
|
|
9
|
+
dispatch,
|
|
10
|
+
action
|
|
11
|
+
} = event;
|
|
12
|
+
const payload = action?.payload;
|
|
13
|
+
createRecordFailedUseCase.execute({
|
|
14
|
+
dispatch,
|
|
15
|
+
payload
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export default CreateRecordFailedController;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import AbstractController from "./AbstractController";
|
|
2
|
+
|
|
3
|
+
class CreateRecordSuccessController extends AbstractController {
|
|
4
|
+
handle(event) {
|
|
5
|
+
const {
|
|
6
|
+
createRecordSuccessUseCase
|
|
7
|
+
} = this.service;
|
|
8
|
+
const {
|
|
9
|
+
dispatch,
|
|
10
|
+
action
|
|
11
|
+
} = event;
|
|
12
|
+
const payload = action?.payload;
|
|
13
|
+
createRecordSuccessUseCase.execute({
|
|
14
|
+
dispatch,
|
|
15
|
+
payload
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export default CreateRecordSuccessController;
|
|
@@ -60,6 +60,8 @@ class FormRepository {
|
|
|
60
60
|
isMyFormFetching: zform.isMyFormFetching,
|
|
61
61
|
isDependencyFetching: zform.isDependencyFetching,
|
|
62
62
|
isLayoutRulesFetching: zform.isLayoutRulesFetching,
|
|
63
|
+
focusedFieldName: zform.focusedFieldName,
|
|
64
|
+
isSubmitFetching: zform.isSubmitFetching,
|
|
63
65
|
isValidationRulesFetching: zform.isValidationRulesFetching
|
|
64
66
|
});
|
|
65
67
|
return zformEntitiy; // new ZField()
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import FormSubmitUseCase from "../../applications/usecases/FormSubmitUseCase";
|
|
2
|
+
import CreateRecordSuccessUseCase from "../../applications/usecases/CreateRecordSuccessUseCase";
|
|
3
|
+
import CreateRecordFailedUseCase from "../../applications/usecases/CreateRecordFailedUseCase";
|
|
2
4
|
import InitializeUseCase from "../../applications/usecases/InitializeUseCase";
|
|
3
5
|
import MyLayoutSuccessUseCase from "../../applications/usecases/MyLayoutSuccessUseCase";
|
|
4
6
|
import MyFormSuccessUseCase from "../../applications/usecases/MyFormSuccessUseCase";
|
|
@@ -18,6 +20,8 @@ import LookupFieldSuccessUseCase from "../../applications/usecases/LookupFieldSu
|
|
|
18
20
|
|
|
19
21
|
class Service {
|
|
20
22
|
constructor(dependencies) {
|
|
23
|
+
this.createRecordFailedUseCase = new CreateRecordFailedUseCase(dependencies);
|
|
24
|
+
this.createRecordSuccessUseCase = new CreateRecordSuccessUseCase(dependencies);
|
|
21
25
|
this.formSubmitUseCase = new FormSubmitUseCase(dependencies);
|
|
22
26
|
this.initializeUseCase = new InitializeUseCase(dependencies);
|
|
23
27
|
this.myLayoutSuccessUseCase = new MyLayoutSuccessUseCase(dependencies);
|
|
@@ -26,6 +26,14 @@ export default class FormTranslator {
|
|
|
26
26
|
clientActions,
|
|
27
27
|
isFetching: isClientActionsFetching
|
|
28
28
|
} = zclientAction || {};
|
|
29
|
+
const {
|
|
30
|
+
isMyFormFetching,
|
|
31
|
+
isDependencyFetching,
|
|
32
|
+
isLayoutRulesFetching,
|
|
33
|
+
isValidationRulesFetching,
|
|
34
|
+
isSubmitFetching,
|
|
35
|
+
sections
|
|
36
|
+
} = zform;
|
|
29
37
|
let combinedClientActions = DefaultFormClientActions({
|
|
30
38
|
clientActions,
|
|
31
39
|
submitConfig,
|
|
@@ -33,16 +41,20 @@ export default class FormTranslator {
|
|
|
33
41
|
});
|
|
34
42
|
const mappedClientActions = mapper(combinedClientActions || []);
|
|
35
43
|
const transformedClientActions = {};
|
|
44
|
+
const actionContext = { ...context,
|
|
45
|
+
isSubmitFetching,
|
|
46
|
+
submitStatus: isSubmitFetching ? 'loading' : 'none'
|
|
47
|
+
};
|
|
36
48
|
Object.entries(mappedClientActions).forEach(_ref => {
|
|
37
49
|
let [key, value] = _ref;
|
|
38
50
|
|
|
39
51
|
if (isFooterEnabled && (key === 'footerRightActions' || key === 'footerLeftActions')) {
|
|
40
|
-
let footerActions = ClientActionsTranslator.transform(value,
|
|
52
|
+
let footerActions = ClientActionsTranslator.transform(value, actionContext);
|
|
41
53
|
transformedClientActions[key] = footerActions;
|
|
42
54
|
}
|
|
43
55
|
|
|
44
56
|
if (isHeaderEnabled && (key === 'headerLeftActions' || key === 'headerRightActions')) {
|
|
45
|
-
let headerActions = ClientActionsTranslator.transform(value,
|
|
57
|
+
let headerActions = ClientActionsTranslator.transform(value, actionContext);
|
|
46
58
|
transformedClientActions[key] = headerActions;
|
|
47
59
|
}
|
|
48
60
|
});
|
|
@@ -60,13 +72,6 @@ export default class FormTranslator {
|
|
|
60
72
|
fieldLabelActions,
|
|
61
73
|
fieldActions
|
|
62
74
|
};
|
|
63
|
-
const {
|
|
64
|
-
isMyFormFetching,
|
|
65
|
-
isDependencyFetching,
|
|
66
|
-
isLayoutRulesFetching,
|
|
67
|
-
isValidationRulesFetching,
|
|
68
|
-
sections
|
|
69
|
-
} = zform;
|
|
70
75
|
const isLoading = isMyFormFetching || isDependencyFetching || isLayoutRulesFetching || isValidationRulesFetching;
|
|
71
76
|
let rightPanel = {};
|
|
72
77
|
|
|
@@ -43,7 +43,9 @@ function getDefaultFormAction(_ref) {
|
|
|
43
43
|
name: isSubmit ? 'Submit Button' : 'Cancel Button',
|
|
44
44
|
component: 'Button',
|
|
45
45
|
propertiesValueMapping: {
|
|
46
|
-
|
|
46
|
+
isDisabled: '{{@context.isSubmitFetching}}',
|
|
47
|
+
status: isSubmit ? '{{@context.submitStatus}}' : 'none',
|
|
48
|
+
text: text ? text : isSubmit ? i18NProviderUtils.getI18NValue('crm.button.submit') : i18NProviderUtils.getI18NValue('support.label.cancel'),
|
|
47
49
|
palette: isSubmit ? 'primaryFilled' : 'secondary'
|
|
48
50
|
},
|
|
49
51
|
eventMappings: [{
|
package/es/platform/zform/applications/interfaces/input/CreateRecordFailedUseCaseInputModel.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/es/platform/zform/applications/interfaces/input/CreateRecordSuccessUseCaseInputModel.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import AbstractUseCase from "./AbstractUseCase";
|
|
2
|
+
import { ZFORM_SUBMIT_FAILURE } from "../../../../bc/zform/Symbol";
|
|
3
|
+
|
|
4
|
+
class CreateRecordFailedUseCase extends AbstractUseCase {
|
|
5
|
+
execute(input) {
|
|
6
|
+
const {
|
|
7
|
+
dispatch,
|
|
8
|
+
payload
|
|
9
|
+
} = input;
|
|
10
|
+
const {
|
|
11
|
+
repository,
|
|
12
|
+
presenter
|
|
13
|
+
} = this.dependencies;
|
|
14
|
+
const zFormEntity = repository.getFormEntity();
|
|
15
|
+
zFormEntity.setSubmitFetching(false);
|
|
16
|
+
presenter.updateFormResponse(zFormEntity.toObject());
|
|
17
|
+
dispatch({
|
|
18
|
+
type: ZFORM_SUBMIT_FAILURE,
|
|
19
|
+
payload: payload
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export default CreateRecordFailedUseCase;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import AbstractUseCase from "./AbstractUseCase";
|
|
2
|
+
import { ZFORM_SUBMIT_SUCCESS } from "../../../../bc/zform/Symbol";
|
|
3
|
+
|
|
4
|
+
class CreateRecordSuccessUseCase extends AbstractUseCase {
|
|
5
|
+
execute(input) {
|
|
6
|
+
const {
|
|
7
|
+
dispatch,
|
|
8
|
+
payload
|
|
9
|
+
} = input;
|
|
10
|
+
const {
|
|
11
|
+
repository,
|
|
12
|
+
presenter
|
|
13
|
+
} = this.dependencies;
|
|
14
|
+
const zFormEntity = repository.getFormEntity();
|
|
15
|
+
zFormEntity.setSubmitFetching(false);
|
|
16
|
+
presenter.updateFormResponse(zFormEntity.toObject());
|
|
17
|
+
dispatch({
|
|
18
|
+
type: ZFORM_SUBMIT_SUCCESS,
|
|
19
|
+
payload: payload
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export default CreateRecordSuccessUseCase;
|
|
@@ -8,12 +8,15 @@ class FormSubmitUseCase extends AbstractUseCase {
|
|
|
8
8
|
} = input;
|
|
9
9
|
const {
|
|
10
10
|
repository,
|
|
11
|
-
validator
|
|
11
|
+
validator,
|
|
12
|
+
presenter
|
|
12
13
|
} = this.dependencies;
|
|
13
14
|
const zFormEntity = repository.getFormEntity();
|
|
14
15
|
const validationRules = zFormEntity.getValidateRules();
|
|
15
16
|
const myForm = zFormEntity.toObject();
|
|
16
17
|
const formData = zFormEntity.getFormData();
|
|
18
|
+
zFormEntity.setSubmitFetching(true);
|
|
19
|
+
presenter.updateFormResponse(zFormEntity.toObject());
|
|
17
20
|
validator.validateAsync({
|
|
18
21
|
validationRules,
|
|
19
22
|
formData,
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import AbstractUseCase from "./AbstractUseCase";
|
|
2
|
+
|
|
3
|
+
class GetIsFieldValueChangedUseCase extends AbstractUseCase {
|
|
4
|
+
execute(input) {
|
|
5
|
+
const {
|
|
6
|
+
callback,
|
|
7
|
+
dispatch
|
|
8
|
+
} = input;
|
|
9
|
+
const {
|
|
10
|
+
repository,
|
|
11
|
+
presenter
|
|
12
|
+
} = this.dependencies;
|
|
13
|
+
const zformEntitiy = repository.getFormEntity();
|
|
14
|
+
let allFields = zformEntitiy.getAllFields();
|
|
15
|
+
const isFieldValueChanged = allFields.some(field => {
|
|
16
|
+
const value = field.getValue();
|
|
17
|
+
const defaultValue = field.getDefaultValue();
|
|
18
|
+
const isEmpty = value === null || value === '';
|
|
19
|
+
|
|
20
|
+
if (field.getType() === "Boolean") {
|
|
21
|
+
return value !== defaultValue; // simple compare
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const cond1 = defaultValue && value !== defaultValue;
|
|
25
|
+
const cond2 = !defaultValue && !isEmpty;
|
|
26
|
+
return cond1 || cond2;
|
|
27
|
+
});
|
|
28
|
+
let zform = zformEntitiy.toObject();
|
|
29
|
+
presenter.updateFormResponse(zform);
|
|
30
|
+
callback?.(isFieldValueChanged);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export default GetIsFieldValueChangedUseCase;
|
|
@@ -14,7 +14,7 @@ class MyLayoutSuccessUseCase extends AbstractUseCase {
|
|
|
14
14
|
layouts,
|
|
15
15
|
orgName
|
|
16
16
|
} = input;
|
|
17
|
-
let layoutObject = layouts.find(layout => layout.isDefaultLayout == true); // dispatch({type:ZFORM_MY_FORM_REQUEST,payload:{isFetching:true}})
|
|
17
|
+
let layoutObject = layouts.length == 1 ? layouts[0] : layouts.find(layout => layout.isDefaultLayout == true); // dispatch({type:ZFORM_MY_FORM_REQUEST,payload:{isFetching:true}})
|
|
18
18
|
|
|
19
19
|
const zformEntity = this.dependencies.repository.getFormEntity();
|
|
20
20
|
zformEntity.setLayoutId(layoutObject?.id);
|
|
@@ -23,6 +23,8 @@ class SubmitValidationCompletedUseCase extends AbstractUseCase {
|
|
|
23
23
|
|
|
24
24
|
if (isFormHasError) {
|
|
25
25
|
const errorMessages = zFormEntity.getVisibleFieldsErrorMessages();
|
|
26
|
+
zFormEntity.setSubmitFetching(false);
|
|
27
|
+
presenter.updateFormResponse(zFormEntity.toObject());
|
|
26
28
|
dispatch({
|
|
27
29
|
type: ZFORM_SUBMIT_VALIDATION_FAILURE,
|
|
28
30
|
payload: {
|
|
@@ -23,6 +23,7 @@ export default class ZForm {
|
|
|
23
23
|
isMyFormFetching,
|
|
24
24
|
isDependencyFetching,
|
|
25
25
|
isLayoutRulesFetching,
|
|
26
|
+
isSubmitFetching,
|
|
26
27
|
isValidationRulesFetching
|
|
27
28
|
/*hack end*/
|
|
28
29
|
|
|
@@ -47,6 +48,7 @@ export default class ZForm {
|
|
|
47
48
|
this.isDependencyFetching = isDependencyFetching;
|
|
48
49
|
this.isLayoutRulesFetching = isLayoutRulesFetching;
|
|
49
50
|
this.isValidationRulesFetching = isValidationRulesFetching;
|
|
51
|
+
this.isSubmitFetching = isSubmitFetching;
|
|
50
52
|
/*hack end*/
|
|
51
53
|
}
|
|
52
54
|
|
|
@@ -124,6 +126,10 @@ export default class ZForm {
|
|
|
124
126
|
this.isValidationRulesFetching = isValidationRulesFetching;
|
|
125
127
|
}
|
|
126
128
|
|
|
129
|
+
setSubmitFetching(isSubmitFetching) {
|
|
130
|
+
this.isSubmitFetching = isSubmitFetching;
|
|
131
|
+
}
|
|
132
|
+
|
|
127
133
|
getSectionId(_ref2) {
|
|
128
134
|
let {
|
|
129
135
|
fieldName,
|
|
@@ -580,6 +586,7 @@ export default class ZForm {
|
|
|
580
586
|
isMyFormFetching: this.isMyFormFetching,
|
|
581
587
|
isDependencyFetching: this.isDependencyFetching,
|
|
582
588
|
isLayoutRulesFetching: this.isLayoutRulesFetching,
|
|
589
|
+
isSubmitFetching: this.isSubmitFetching,
|
|
583
590
|
isValidationRulesFetching: this.isValidationRulesFetching
|
|
584
591
|
/*hack end*/
|
|
585
592
|
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { ZFORM_SUBMIT } from "../../../../bc/zform/Constants";
|
|
2
2
|
import FormSubmitController from "../../adapters/controllers/FormSubmitController";
|
|
3
|
+
import CreateRecordSuccessController from "../../adapters/controllers/CreateRecordSuccessController";
|
|
4
|
+
import CreateRecordFailedController from "../../adapters/controllers/CreateRecordFailedController";
|
|
3
5
|
import FormRepository from "../../adapters/gateway/FormRepository";
|
|
4
6
|
import FormPresenter from "../../adapters/presenter/FormPresenter";
|
|
5
7
|
import Service from "../../adapters/gateway/Service";
|
|
6
8
|
import LifeCycleEvents from "../../../../cc/component/LifeCycleEventsEnum";
|
|
7
9
|
import InitializeController from "../../adapters/controllers/IntializeController";
|
|
8
|
-
import { ZFORM_DEPENDENCY_MAPPINGS_REQUEST, ZFORM_DEPENDENCY_MAPPINGS_SUCCESS, ZFORM_FIELD_VALUE_CHANGE_REQUEST, ZFORM_MY_FORM_REQUEST, ZFORM_MY_FORM_SUCCESS, ZFORM_MY_LAYOUTS_SUCCESS, ZFORM_SET_FIELD_ERROR_MESSAGE,
|
|
10
|
+
import { ZFORM_DEPENDENCY_MAPPINGS_REQUEST, ZFORM_DEPENDENCY_MAPPINGS_SUCCESS, ZFORM_FIELD_VALUE_CHANGE_REQUEST, ZFORM_MY_FORM_REQUEST, ZFORM_MY_FORM_SUCCESS, ZFORM_MY_LAYOUTS_SUCCESS, ZFORM_SET_FIELD_ERROR_MESSAGE, ZFORM_SUBMIT_VALIDATION_COMPLETED, ZFORM_VALIDATE_FIELD_REQUEST, ZFORM_VALIDATION_RULES_REQUEST, ZFORM_VALIDATION_RULES_SUCCESS, ZFORM_VALIDATION_RULES_EXECUTION_RESULT, ZFORM_LOOKUP_FIELD_SUCCESS } from "../../../../bc/zform/Symbol";
|
|
9
11
|
import LookupFieldController from "../../adapters/controllers/LookupFieldController";
|
|
10
12
|
import MyLayoutSuccessController from "../../adapters/controllers/MyLayoutSuccessController";
|
|
11
13
|
import MyFormSuccessController from "../../adapters/controllers/MyFromSuccessController";
|
|
@@ -41,6 +43,8 @@ class EventHandlersFactory {
|
|
|
41
43
|
validator,
|
|
42
44
|
layoutRuleApplier
|
|
43
45
|
});
|
|
46
|
+
const createRecordSuccessController = new CreateRecordSuccessController(service);
|
|
47
|
+
const createRecordFailedController = new CreateRecordFailedController(service);
|
|
44
48
|
const initializeController = new InitializeController(service);
|
|
45
49
|
const myLayoutSuccessController = new MyLayoutSuccessController(service);
|
|
46
50
|
const myFormRequestController = new MyFormRequestController(service);
|
|
@@ -62,26 +66,8 @@ class EventHandlersFactory {
|
|
|
62
66
|
return {
|
|
63
67
|
[LifeCycleEvents.MOUNT]: initializeController.handle,
|
|
64
68
|
[ZFORM_MY_LAYOUTS_SUCCESS]: myLayoutSuccessController.handle,
|
|
65
|
-
[RECORD_EXECUTE_SUCCESS_CALLBACK]:
|
|
66
|
-
|
|
67
|
-
action,
|
|
68
|
-
dispatch
|
|
69
|
-
} = _ref;
|
|
70
|
-
dispatch({
|
|
71
|
-
type: ZFORM_SUBMIT_SUCCESS,
|
|
72
|
-
payload: action.payload
|
|
73
|
-
});
|
|
74
|
-
},
|
|
75
|
-
[RECORD_EXECUTE_FAIL_CALLBACK]: _ref2 => {
|
|
76
|
-
let {
|
|
77
|
-
action,
|
|
78
|
-
dispatch
|
|
79
|
-
} = _ref2;
|
|
80
|
-
dispatch({
|
|
81
|
-
type: 'SMART_FORM#SUBMIT_FAILED',
|
|
82
|
-
payload: action.payload
|
|
83
|
-
});
|
|
84
|
-
},
|
|
69
|
+
[RECORD_EXECUTE_SUCCESS_CALLBACK]: createRecordSuccessController.handle,
|
|
70
|
+
[RECORD_EXECUTE_FAIL_CALLBACK]: createRecordFailedController.handle,
|
|
85
71
|
[ZFORM_MY_FORM_REQUEST]: myFormRequestController.handle,
|
|
86
72
|
[ZFORM_MY_FORM_SUCCESS]: myFormSuccessController.handle,
|
|
87
73
|
[ZFORM_DEPENDENCY_MAPPINGS_REQUEST]: dependenciesRequestController.handle,
|
|
@@ -95,11 +81,11 @@ class EventHandlersFactory {
|
|
|
95
81
|
[ZFORM_VALIDATE_FIELD_REQUEST]: validateFieldRequestController.handle,
|
|
96
82
|
[SmartFormConstants.SMART_FORM_SUBMIT_CLICKED]: formSubmitController.handle,
|
|
97
83
|
[ZFORM_SUBMIT]: formSubmitController.handle,
|
|
98
|
-
[FormConstants.FORM_SUBMIT]:
|
|
84
|
+
[FormConstants.FORM_SUBMIT]: _ref => {
|
|
99
85
|
let {
|
|
100
86
|
action,
|
|
101
87
|
dispatch
|
|
102
|
-
} =
|
|
88
|
+
} = _ref;
|
|
103
89
|
dispatch({
|
|
104
90
|
type: ZFORM_SUBMIT
|
|
105
91
|
});
|
|
@@ -107,11 +93,11 @@ class EventHandlersFactory {
|
|
|
107
93
|
[FormConstants.FORM_FIELD_BLURRED]: fieldBlurController.handle,
|
|
108
94
|
[ZFORM_VALIDATION_RULES_EXECUTION_RESULT]: validationRulesExecutionResultController.handle,
|
|
109
95
|
[ZFORM_SUBMIT_VALIDATION_COMPLETED]: submitValidationCompletedController.handle,
|
|
110
|
-
[FormConstants.FORM_FIELD_VALUE_CHANGE_REQUEST]:
|
|
96
|
+
[FormConstants.FORM_FIELD_VALUE_CHANGE_REQUEST]: _ref2 => {
|
|
111
97
|
let {
|
|
112
98
|
action,
|
|
113
99
|
dispatch
|
|
114
|
-
} =
|
|
100
|
+
} = _ref2;
|
|
115
101
|
const {
|
|
116
102
|
sectionId,
|
|
117
103
|
fieldName,
|