@zohodesk/library-platform 1.1.7 → 1.1.8

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.
Files changed (55) hide show
  1. package/es/bc/sdk/ResourceNamesEnum.js +1 -0
  2. package/es/bc/zform/Symbol.js +1 -0
  3. package/es/bc/zlist/Constants.js +3 -1
  4. package/es/bc/zrecord/Constants.js +1 -0
  5. package/es/cc/form/Properties.js +54 -0
  6. package/es/cc/form-connected/Constants.js +8 -0
  7. package/es/cc/form-connected/Properties.js +52 -0
  8. package/es/cc/table-connected/Properties.js +8 -0
  9. package/es/cc/table-connected/constants/Events.js +1 -0
  10. package/es/library/dot/components/action-location/usecases/interactors/PropertiesChangeUseCase.js +1 -1
  11. package/es/library/dot/components/form/adapters/presenter/TransformState.js +38 -25
  12. package/es/library/dot/components/form/frameworks/ui/FormView.js +11 -5
  13. package/es/library/dot/components/section/frameworks/ui/SectionView.js +1 -1
  14. package/es/platform/client-actions/bc/zclient-actions/SdkContract.js +35 -0
  15. package/es/platform/client-actions/behaviour/zclient-actions/adapters/resources/ClientActionResource.js +105 -0
  16. package/es/platform/client-actions/behaviour/zclient-actions/applications/interfaces/IClientActionResource.js +1 -0
  17. package/es/platform/client-actions/behaviour/zclient-actions/applications/interfaces/input/GetClientActionLocationInputModel.js +1 -0
  18. package/es/platform/client-actions/behaviour/zclient-actions/applications/interfaces/input/GetClientActionUIComponentPropertiesInputModel.js +1 -0
  19. package/es/platform/client-actions/behaviour/zclient-actions/applications/interfaces/input/GetClientActionsInputModel.js +1 -0
  20. package/es/platform/client-actions/behaviour/zclient-actions/applications/interfaces/input/UpdateClientActionUIComponentPropertiesInputModel.js +1 -0
  21. package/es/platform/client-actions/behaviour/zclient-actions/applications/usecases/GetClientActionLocationUseCase.js +20 -0
  22. package/es/platform/client-actions/behaviour/zclient-actions/applications/usecases/GetClientActionUIComponentPropertiesUseCase.js +20 -0
  23. package/es/platform/client-actions/behaviour/zclient-actions/applications/usecases/GetClientActionsUseCase.js +18 -0
  24. package/es/platform/client-actions/behaviour/zclient-actions/applications/usecases/UpdateClientActionUIComponentPropertiesUseCase.js +32 -0
  25. package/es/platform/client-actions/behaviour/zclient-actions/domain/entities/ClientAction.js +12 -0
  26. package/es/platform/client-actions/behaviour/zclient-actions/domain/entities/ClientActionManager.js +45 -0
  27. package/es/platform/client-actions/behaviour/zclient-actions/domain/entities/UIComponentMapping.js +10 -0
  28. package/es/platform/client-actions/behaviour/zclient-actions/frameworks/sdk/ClientActionsSDKFactory.js +29 -0
  29. package/es/platform/client-actions/cc/action-event-mediator/Properties.js +9 -0
  30. package/es/platform/client-actions/components/action-event-mediator/applications/usecases/PropertiesChangeUseCase.js +1 -1
  31. package/es/platform/client-actions/components/action-event-mediator/domain/entities/ActionEventMediatorEntity.js +7 -3
  32. package/es/platform/client-actions/components/action-event-mediator/frameworks/ui/ActionEventMediatorView.js +3 -1
  33. package/es/platform/client-actions/components/dynamic-component/frameworks/ui/DynamicActionComponentView.js +4 -2
  34. package/es/platform/client-actions/components/row-actions-renderer/frameworks/ui/RowActionsRendererView.js +4 -1
  35. package/es/platform/components/form-connected/frameworks/EventHandlersFactory.js +3 -2
  36. package/es/platform/components/form-connected/frameworks/FormConnectedFactory.js +6 -5
  37. package/es/platform/components/form-connected/frameworks/FormConnectedView.js +14 -2
  38. package/es/platform/components/table-connected/frameworks/EventHandlersFactory.js +15 -1
  39. package/es/platform/components/table-connected/frameworks/TableConnectedFactory.js +6 -1
  40. package/es/platform/data-source/http-template/getClientActions.js +2 -2
  41. package/es/platform/sdk/frameworks/Sdk.js +7 -0
  42. package/es/platform/zform/adapters/presenter/FormTranslator.js +60 -3
  43. package/es/platform/zform/adapters/presenter/translators/SectionTranslator.js +7 -1
  44. package/es/platform/zform/adapters/presenter/utils/DefaultClientActions.js +59 -0
  45. package/es/platform/zform/applications/usecases/InitializeUseCase.js +16 -0
  46. package/es/platform/zform/frameworks/layout-rules/calculateLayoutRulesResult.js +1 -1
  47. package/es/platform/zform/frameworks/layout-rules/runSingleFieldCondition.js +1 -1
  48. package/es/platform/zform/frameworks/layout-rules/validator.js +0 -1
  49. package/es/platform/zform/frameworks/ui/EventHandlerFactory.js +37 -15
  50. package/es/platform/zlist/adapters/presenters/TableTranslator.js +3 -2
  51. package/es/platform/zlist/applications/usecases/RecordSuccessCallbackUsecase.js +4 -1
  52. package/es/platform/zlist/domain/entities/List.js +9 -3
  53. package/es/platform/zrecord/adapters/controllers/SetRecordsController.js +7 -3
  54. package/es/platform/zrecord/applications/usecases/SetRecordsUseCase.js +11 -1
  55. package/package.json +2 -1
@@ -1,6 +1,7 @@
1
1
  var ResourceNamesEnum = /*#__PURE__*/function (ResourceNamesEnum) {
2
2
  ResourceNamesEnum["SMART_TABLE"] = "smartTable";
3
3
  ResourceNamesEnum["SMART_FORM"] = "smartForm";
4
+ ResourceNamesEnum["CLIENT_ACTION"] = "clientAction";
4
5
  return ResourceNamesEnum;
5
6
  }(ResourceNamesEnum || {});
6
7
 
@@ -23,4 +23,5 @@ export const ZFORM_VALIDATION_ERROR = 'ZFORM#VALIDATION_ERROR';
23
23
  export const ZFORM_VALIDATION_SUCCESS = 'ZFORM#VALIDATION_SUCCESS';
24
24
  export const ZFORM_VALIDATE_SUBMIT_FIELD_HAS_ERROR_MESSAGE = 'ZFORM#VALIDATE_SUBMIT_FIELD_HAS_ERROR_MESSAGE';
25
25
  export const ZFORM_SUBMIT_SUCCESS = 'ZFORM#SUBMIT_SUCCESS';
26
+ export const ZFORM_SUBMIT_FAILURE = 'ZFORM#SUBMIT_FAILURE';
26
27
  export const ZFORM_ERROR = 'ZFORM#ERROR';
@@ -14,4 +14,6 @@ export const ZLIST_INITIAL_AVAILABLE_FIELDS_FETCH_FAILED = 'ZLIST#INITIAL_AVAILA
14
14
  export const ZLIST_INITIAL_SELECTED_FIELDS_FETCH_FAILED = 'ZLIST#INITIAL_SELECTED_FIELDS_FETCH_FAILED';
15
15
  export const ZLIST_INITIAL_RECORDS_FETCH_FAILED = 'ZLIST#INITIAL_RECORDS_FETCH_FAILED';
16
16
  export const ZLIST_INITIAL_CLIENT_ACTIONS_FETCH_FAILED = 'ZLIST#INITIAL_CLIENT_ACTIONS_FETCH_FAILED';
17
- export const ZLIST_FETCH_MORE_RECORDS_FAILED = 'ZLIST#FETCH_MORE_RECORDS_FAILED';
17
+ export const ZLIST_FETCH_MORE_RECORDS_FAILED = 'ZLIST#FETCH_MORE_RECORDS_FAILED';
18
+ export const ZLIST_RECORD_REORDER_SUCCEEDED = 'ZLIST#RECORD_REORDER_SUCCEEDED';
19
+ export const CLIENT_ACTION_TABLE_LIST_COMPONENT_NAME = 'TableList';
@@ -14,6 +14,7 @@ export const RECORD_LOCAL_UPDATE = 'RECORD#LOCAL_UPDATE';
14
14
  export const RECORD_LOCAL_MULTIPLE_DELETE = 'RECORD#LOCAL_MULTIPLE_DELETE';
15
15
  export const APPEND_RECORDS = 'RECORD#APPEND_RECORDS';
16
16
  export const SET_RECORDS = 'RECORD#SET_RECORDS';
17
+ export const SET_RECORDS_SUCCESS = 'RECORD#SET_RECORDS_SUCCESS';
17
18
  export const CREATE_RECORD = 'RECORD#CREATE_RECORD';
18
19
  export class RecordApiActionName {}
19
20
 
@@ -1,6 +1,60 @@
1
1
  import PropertiesConverter from "../component/properties/PropertiesConverter";
2
2
  import SectionProperties from "../section/Properties";
3
3
  export default {
4
+ isHeaderEnabled: {
5
+ required: false,
6
+ defaultValue: true,
7
+ typeMetadata: {
8
+ schema: {
9
+ type: 'boolean'
10
+ }
11
+ }
12
+ },
13
+ isFooterEnabled: {
14
+ required: false,
15
+ defaultValue: true,
16
+ typeMetadata: {
17
+ schema: {
18
+ type: 'boolean'
19
+ }
20
+ }
21
+ },
22
+ headerLeftActions: {
23
+ required: false,
24
+ defaultValue: [],
25
+ typeMetadata: {
26
+ schema: {
27
+ type: 'array'
28
+ }
29
+ }
30
+ },
31
+ headerRightActions: {
32
+ required: false,
33
+ defaultValue: [],
34
+ typeMetadata: {
35
+ schema: {
36
+ type: 'array'
37
+ }
38
+ }
39
+ },
40
+ footerLeftActions: {
41
+ required: false,
42
+ defaultValue: [],
43
+ typeMetadata: {
44
+ schema: {
45
+ type: 'array'
46
+ }
47
+ }
48
+ },
49
+ footerRightActions: {
50
+ required: false,
51
+ defaultValue: [],
52
+ typeMetadata: {
53
+ schema: {
54
+ type: 'array'
55
+ }
56
+ }
57
+ },
4
58
  sections: {
5
59
  required: false,
6
60
  typeMetadata: {
@@ -10,4 +10,12 @@ _defineProperty(SmartFormConstants, "SMART_FORM_FIELD_VALUE_CHANGED", 'SMART_FOR
10
10
 
11
11
  _defineProperty(SmartFormConstants, "SMART_FORM_SUBMIT", 'SMART_FORM#SUBMIT');
12
12
 
13
+ _defineProperty(SmartFormConstants, "SMART_FORM_SUBMIT_CLICKED", 'SMART_FORM#SUBMIT_CLICKED');
14
+
15
+ _defineProperty(SmartFormConstants, "SMART_FORM_CANCEL_CLICKED", 'SMART_FORM#CANCEL_CLICKED');
16
+
17
+ _defineProperty(SmartFormConstants, "SMART_FORM_SUBMIT_SUCCESS", 'SMART_FORM#SUBMIT_SUCCESS');
18
+
19
+ _defineProperty(SmartFormConstants, "SMART_FORM_SUBMIT_FAILURE", 'SMART_FORM#SUBMIT_FAILED');
20
+
13
21
  export default SmartFormConstants;
@@ -1,4 +1,56 @@
1
1
  export default {
2
+ isHeaderEnabled: {
3
+ required: false,
4
+ defaultValue: true,
5
+ typeMetadata: {
6
+ schema: {
7
+ type: 'boolean'
8
+ }
9
+ }
10
+ },
11
+ isFooterEnabled: {
12
+ required: false,
13
+ defaultValue: true,
14
+ typeMetadata: {
15
+ schema: {
16
+ type: 'boolean'
17
+ }
18
+ }
19
+ },
20
+ submitConfig: {
21
+ required: false,
22
+ typeMetadata: {
23
+ schema: {
24
+ type: 'object',
25
+ properties: {
26
+ text: {
27
+ type: 'string'
28
+ },
29
+ isEnabled: {
30
+ type: 'boolean'
31
+ }
32
+ },
33
+ required: ['text', 'isEnabled']
34
+ }
35
+ }
36
+ },
37
+ cancelConfig: {
38
+ required: false,
39
+ typeMetadata: {
40
+ schema: {
41
+ type: 'object',
42
+ properties: {
43
+ text: {
44
+ type: 'string'
45
+ },
46
+ isEnabled: {
47
+ type: 'boolean'
48
+ }
49
+ },
50
+ required: ['text', 'isEnabled']
51
+ }
52
+ }
53
+ },
2
54
  componentMapping: {
3
55
  required: false,
4
56
  defaultValue: {
@@ -10,6 +10,14 @@ export default {
10
10
  schema: {
11
11
  type: 'object',
12
12
  properties: {
13
+ rowActions: {
14
+ type: 'object',
15
+ additionalProperties: {
16
+ width: {
17
+ type: 'string'
18
+ }
19
+ }
20
+ },
13
21
  fields: {
14
22
  type: 'object',
15
23
  additionalProperties: {
@@ -1,5 +1,6 @@
1
1
  export const ERROR_OCCURRED = 'SMART_TABLE#ERROR_OCCURRED';
2
2
  export default {
3
+ REORDER_SUCCESS: 'SMART_TABLE#REORDER_SUCCEED',
3
4
  DELETE_RECORDS_SUCCESS: 'SMART_TABLE#RECORD_DELETED',
4
5
  UPDATE_RECORDS_SUCCESS: 'SMART_TABLE#RECORD_UPDATED',
5
6
  SORT: 'SMART_TABLE#SORT',
@@ -10,7 +10,7 @@ export default class PropertiesChangeUseCase extends AbstractUseCase {
10
10
  currentActions,
11
11
  previousActions
12
12
  } = input;
13
- actionLocation.processActionsChange(currentActions, previousActions);
13
+ actionLocation.processActionsChange(previousActions, currentActions);
14
14
  presenter.updateActionLocation(actionLocation.toObject());
15
15
  }
16
16
 
@@ -32,28 +32,33 @@ function updateFieldValues(_ref) {
32
32
  fields
33
33
  };
34
34
  });
35
- }
35
+ } // const footerLeftActions = [{
36
+ // component: 'Button',
37
+ // location: 'footer_left_actions',
38
+ // properties: {
39
+ // text: 'Submit',
40
+ // palette: 'primaryFilled'
41
+ // },
42
+ // eventMappings: [
43
+ // {
44
+ // payloadValueMapping: {},
45
+ // sourceEvent: "BUTTON#CLICKED",
46
+ // id: "1234567890",
47
+ // targetEvent: "FORM#SUBMIT"
48
+ // }
49
+ // ]
50
+ // },
51
+ // {
52
+ // component: 'Button',
53
+ // location: 'footer_left_actions',
54
+ // properties: {
55
+ // text: 'Cancel',
56
+ // palette: 'secondary'
57
+ // },
58
+ // eventMappings: []
59
+ // }];
60
+
36
61
 
37
- const footerLeftActions = [{
38
- component: 'Button',
39
- properties: {
40
- text: 'Submit',
41
- palette: 'primaryFilled'
42
- },
43
- eventMappings: [{
44
- payloadValueMapping: {},
45
- sourceEvent: "BUTTON#CLICKED",
46
- id: "1234567890",
47
- targetEvent: "FORM#SUBMIT"
48
- }]
49
- }, {
50
- component: 'Button',
51
- properties: {
52
- text: 'Cancel',
53
- palette: 'secondary'
54
- },
55
- eventMappings: []
56
- }];
57
62
  const headerLeftActions = [{
58
63
  component: 'Breadcrumb',
59
64
  properties: {
@@ -89,7 +94,13 @@ export function TransformState(state) {
89
94
  sections,
90
95
  isLoading,
91
96
  values,
92
- errorMessages
97
+ errorMessages,
98
+ isHeaderEnabled,
99
+ isFooterEnabled,
100
+ headerLeftActions,
101
+ headerRightActions,
102
+ footerLeftActions,
103
+ footerRightActions
93
104
  } = state.properties; // const { values, errorMessages } = state.behaviours.form;
94
105
 
95
106
  const updatedSections = updateFieldValues({
@@ -100,12 +111,14 @@ export function TransformState(state) {
100
111
  return { ...state,
101
112
  // properties: { ...state.properties, sections: updatedSections }
102
113
  viewModel: {
114
+ isHeaderEnabled,
115
+ isFooterEnabled,
103
116
  sections: updatedSections,
104
117
  isLoading,
105
- headerLeftActions: headerLeftActions,
106
- headerRightActions: headerRightActions,
118
+ headerLeftActions,
119
+ headerRightActions,
107
120
  footerLeftActions,
108
- footerRightActions: []
121
+ footerRightActions
109
122
  }
110
123
  };
111
124
  }
@@ -22,7 +22,9 @@ function FormView(_ref, ref) {
22
22
  headerLeftActions,
23
23
  headerRightActions,
24
24
  footerLeftActions,
25
- footerRightActions
25
+ footerRightActions,
26
+ isHeaderEnabled,
27
+ isFooterEnabled
26
28
  } = state.viewModel;
27
29
  return /*#__PURE__*/React.createElement(Flex, {
28
30
  $ui_tagName: "form",
@@ -30,7 +32,9 @@ function FormView(_ref, ref) {
30
32
  $ui_direction: "column",
31
33
  $flag_fullsize: true,
32
34
  ref: ref
33
- }, /*#__PURE__*/React.createElement(FormHeader, {
35
+ }, isHeaderEnabled && /*#__PURE__*/React.createElement(FormHeader, {
36
+ customId: "formHeader",
37
+ testId: "formHeader",
34
38
  $render_leftElement: headerLeftActions.length > 0 ? /*#__PURE__*/React.createElement(ActionEventMediator, {
35
39
  actions: headerLeftActions,
36
40
  gap: ActionViewGap.MEDIUM
@@ -45,14 +49,16 @@ function FormView(_ref, ref) {
45
49
  $flag_childrenWrapper: true
46
50
  }, isLoading ? /*#__PURE__*/React.createElement(Loader, null) : /*#__PURE__*/React.createElement(SectionsWrapper, null, /*#__PURE__*/React.createElement(Sections, {
47
51
  sections: sections
48
- }))), /*#__PURE__*/React.createElement(FormAction, {
52
+ }))), isFooterEnabled && /*#__PURE__*/React.createElement(FormAction, {
49
53
  size: "small",
50
54
  paddingLeftSize: "xmedium",
51
55
  paddingRightClass: style.footer
52
- }, /*#__PURE__*/React.createElement(LeftSide, null, /*#__PURE__*/React.createElement(ActionEventMediator, {
56
+ }, /*#__PURE__*/React.createElement(LeftSide, null, footerLeftActions.length > 0 && /*#__PURE__*/React.createElement(ActionEventMediator, {
57
+ testId: "formFooter_leftActions",
53
58
  actions: footerLeftActions,
54
59
  gap: ActionViewGap.LARGE
55
- })), /*#__PURE__*/React.createElement(RightSide, null, /*#__PURE__*/React.createElement(ActionEventMediator, {
60
+ })), /*#__PURE__*/React.createElement(RightSide, null, footerRightActions.length > 0 && /*#__PURE__*/React.createElement(ActionEventMediator, {
61
+ testId: "formFooter_rightActions",
56
62
  actions: footerRightActions,
57
63
  gap: ActionViewGap.LARGE
58
64
  }))));
@@ -24,7 +24,7 @@ function SectionView(_ref, ref) {
24
24
  }
25
25
  }, !isCollapsed && /*#__PURE__*/React.createElement(FieldsLayout, {
26
26
  $flag_topSpace: !!title || !!description
27
- }, fields.filter(field => field.isVisible).map((field, index) => renderField(field, index))));
27
+ }, fields.filter(field => field.isVisible).map(field => renderField(field, field.name || field.apiName))));
28
28
  }
29
29
 
30
30
  export default SectionView;
@@ -0,0 +1,35 @@
1
+ export const SdkContracts = {
2
+ getLocationMeta: {
3
+ type: 'object',
4
+ properties: {
5
+ clientActionId: {
6
+ type: 'string',
7
+ minLength: 1
8
+ }
9
+ },
10
+ required: ['clientActionId']
11
+ },
12
+ getComponentPropertiesMeta: {
13
+ type: 'object',
14
+ properties: {
15
+ clientActionId: {
16
+ type: 'string',
17
+ minLength: 1
18
+ }
19
+ },
20
+ required: ['clientActionId']
21
+ },
22
+ updateComponentPropertiesMeta: {
23
+ type: 'object',
24
+ properties: {
25
+ clientActionId: {
26
+ type: 'string',
27
+ minLength: 1
28
+ },
29
+ newComponentProperties: {
30
+ type: 'object'
31
+ }
32
+ },
33
+ required: ['clientActionId', 'newComponentProperties']
34
+ }
35
+ };
@@ -0,0 +1,105 @@
1
+ import { AbstractResource } from "../../../../../sdk/application/interfaces/gateways/AbstractResource";
2
+ import Repository from "../gateways/Repository";
3
+ import Presenter from "../presenters/Presenter";
4
+ import GetClientActionLocationUseCase from "../../applications/usecases/GetClientActionLocationUseCase";
5
+ import GetClientActionUIComponentPropertiesUseCase from "../../applications/usecases/GetClientActionUIComponentPropertiesUseCase";
6
+ import UpdateClientActionUIComponentPropertiesUseCase from "../../applications/usecases/UpdateClientActionUIComponentPropertiesUseCase";
7
+ import GetClientActionsUseCase from "../../applications/usecases/GetClientActionsUseCase";
8
+ import { SdkContracts } from "../../../../bc/zclient-actions/SdkContract";
9
+ export class ClientActionResource extends AbstractResource {
10
+ initialize() {}
11
+
12
+ destroy() {}
13
+
14
+ getClientActionDependencies() {
15
+ const dependencies = {
16
+ repository: new Repository(),
17
+ presenter: new Presenter()
18
+ };
19
+ return dependencies;
20
+ }
21
+
22
+ createUseCase(dependencies, UseCaseClass) {
23
+ var _usecase$updateDepend, _usecase$updateDepend2;
24
+
25
+ const {
26
+ state,
27
+ updateState
28
+ } = this.dependencies;
29
+ const usecase = new UseCaseClass(dependencies);
30
+ (_usecase$updateDepend = usecase.updateDependency) === null || _usecase$updateDepend === void 0 ? void 0 : _usecase$updateDepend.call(usecase, state, updateState);
31
+ (_usecase$updateDepend2 = usecase.updateDependencies) === null || _usecase$updateDepend2 === void 0 ? void 0 : _usecase$updateDepend2.call(usecase, state, updateState);
32
+ return usecase;
33
+ }
34
+
35
+ getLocation(id) {
36
+ this.validateInput('getLocation', {
37
+ clientActionId: id
38
+ }, SdkContracts.getLocationMeta);
39
+ const {
40
+ getData,
41
+ setData
42
+ } = this.createCallback();
43
+ const dependencies = this.getClientActionDependencies();
44
+ const useCase = this.createUseCase(dependencies, GetClientActionLocationUseCase);
45
+ useCase.execute({
46
+ id,
47
+ callback: setData
48
+ });
49
+ return getData();
50
+ }
51
+
52
+ getUIComponentProperties(id) {
53
+ this.validateInput('getUIComponentProperties', {
54
+ clientActionId: id
55
+ }, SdkContracts.getComponentPropertiesMeta);
56
+ const {
57
+ getData,
58
+ setData
59
+ } = this.createCallback();
60
+ const dependencies = this.getClientActionDependencies();
61
+ const useCase = this.createUseCase(dependencies, GetClientActionUIComponentPropertiesUseCase);
62
+ useCase.execute({
63
+ id,
64
+ callback: setData
65
+ });
66
+ return getData();
67
+ }
68
+
69
+ getClientActions() {
70
+ const {
71
+ getData,
72
+ setData
73
+ } = this.createCallback();
74
+ const dependencies = this.getClientActionDependencies();
75
+ const useCase = this.createUseCase(dependencies, GetClientActionsUseCase);
76
+ useCase.execute({
77
+ callback: setData
78
+ });
79
+ return getData();
80
+ }
81
+
82
+ updateUIComponentProperties(id, newComponentProperties) {
83
+ this.validateInput('updateUIComponentProperties', {
84
+ clientActionId: id,
85
+ newComponentProperties
86
+ }, SdkContracts.updateComponentPropertiesMeta);
87
+ const {
88
+ getData,
89
+ setData
90
+ } = this.createCallback();
91
+ const dependencies = this.getClientActionDependencies();
92
+ const {
93
+ dispatch
94
+ } = this.dependencies;
95
+ const useCase = this.createUseCase(dependencies, UpdateClientActionUIComponentPropertiesUseCase);
96
+ useCase.execute({
97
+ id,
98
+ newComponentProperties,
99
+ dispatch,
100
+ callback: setData
101
+ });
102
+ return getData();
103
+ }
104
+
105
+ }
@@ -0,0 +1,20 @@
1
+ import AbstractUseCase from "./AbstractUseCase";
2
+
3
+ class GetClientActionLocationUseCase extends AbstractUseCase {
4
+ execute(_ref) {
5
+ let {
6
+ id,
7
+ callback
8
+ } = _ref;
9
+ const {
10
+ repository
11
+ } = this.dependencies;
12
+ const clientActionManager = repository.getClientActionsManagerEntity();
13
+ clientActionManager.validateClientActionId(id);
14
+ const clientAction = clientActionManager.getClientAction(id);
15
+ callback === null || callback === void 0 ? void 0 : callback(clientAction.getLocation());
16
+ }
17
+
18
+ }
19
+
20
+ export default GetClientActionLocationUseCase;
@@ -0,0 +1,20 @@
1
+ import AbstractUseCase from "./AbstractUseCase";
2
+
3
+ class GetClientActionUIComponentPropertiesUseCase extends AbstractUseCase {
4
+ execute(_ref) {
5
+ let {
6
+ id,
7
+ callback
8
+ } = _ref;
9
+ const {
10
+ repository
11
+ } = this.dependencies;
12
+ const clientActionManager = repository.getClientActionsManagerEntity();
13
+ clientActionManager.validateClientActionId(id);
14
+ const clientAction = clientActionManager.getClientAction(id);
15
+ callback === null || callback === void 0 ? void 0 : callback(clientAction.getUIComponentProperties());
16
+ }
17
+
18
+ }
19
+
20
+ export default GetClientActionUIComponentPropertiesUseCase;
@@ -0,0 +1,18 @@
1
+ import AbstractUseCase from "./AbstractUseCase";
2
+
3
+ class GetClientActionsUseCase extends AbstractUseCase {
4
+ execute(_ref) {
5
+ let {
6
+ callback
7
+ } = _ref;
8
+ const {
9
+ repository
10
+ } = this.dependencies;
11
+ const clientActionManager = repository.getClientActionsManagerEntity();
12
+ const clientActions = clientActionManager.getClientActionModels();
13
+ callback === null || callback === void 0 ? void 0 : callback(clientActions);
14
+ }
15
+
16
+ }
17
+
18
+ export default GetClientActionsUseCase;
@@ -0,0 +1,32 @@
1
+ import AbstractUseCase from "./AbstractUseCase";
2
+ import { SET_CLIENTACTIONS } from "../../../../bc/zclient-actions/Constants";
3
+
4
+ class UpdateClientActionUIComponentPropertiesUseCase extends AbstractUseCase {
5
+ execute(_ref) {
6
+ let {
7
+ id,
8
+ newComponentProperties,
9
+ dispatch,
10
+ callback
11
+ } = _ref;
12
+ const {
13
+ repository
14
+ } = this.dependencies;
15
+ const clientActionManager = repository.getClientActionsManagerEntity();
16
+ clientActionManager.validateClientActionId(id);
17
+ const {
18
+ updatedClientAction,
19
+ updatedClientActions
20
+ } = clientActionManager.updateClientActionComponentProperties(id, newComponentProperties);
21
+ dispatch({
22
+ type: SET_CLIENTACTIONS,
23
+ payload: {
24
+ clientActions: updatedClientActions
25
+ }
26
+ });
27
+ callback === null || callback === void 0 ? void 0 : callback(updatedClientAction.getUIComponentProperties());
28
+ }
29
+
30
+ }
31
+
32
+ export default UpdateClientActionUIComponentPropertiesUseCase;
@@ -41,6 +41,18 @@ export default class ClientAction {
41
41
  this.conditionMeta = clientActionObj.conditions;
42
42
  }
43
43
 
44
+ getLocation() {
45
+ return this.location;
46
+ }
47
+
48
+ getUIComponentProperties() {
49
+ return this.uiComponentMapping.getPropertiesValueMapping();
50
+ }
51
+
52
+ updateUIComponentProperties(newProperties) {
53
+ this.uiComponentMapping.updatePropertiesValueMapping(newProperties);
54
+ }
55
+
44
56
  toObject() {
45
57
  return {
46
58
  id: this.id,
@@ -114,6 +114,32 @@ export default class ClientActionManager {
114
114
  this.clientActions.setIsFetching(false);
115
115
  }
116
116
 
117
+ getClientAction(id) {
118
+ return this.clientActions.getClientAction(id);
119
+ }
120
+
121
+ getClientActionModels() {
122
+ const clientActionModels = this.clientActions.toObject();
123
+ return clientActionModels.data;
124
+ }
125
+
126
+ updateClientActionComponentProperties(id, newComponentProperties) {
127
+ const clientActions = this.getClientActionModels();
128
+ const updatedClientAction = this.getClientAction(id);
129
+ updatedClientAction.updateUIComponentProperties(newComponentProperties);
130
+ const updatedClientActions = clientActions.map(clientAction => {
131
+ if (clientAction.id === updatedClientAction.getId()) {
132
+ return updatedClientAction.toObject();
133
+ }
134
+
135
+ return clientAction;
136
+ });
137
+ return {
138
+ updatedClientAction,
139
+ updatedClientActions
140
+ };
141
+ }
142
+
117
143
  setClientActions(clientActions) {
118
144
  this.clientActions.setClientActions(clientActions);
119
145
  }
@@ -130,6 +156,25 @@ export default class ClientActionManager {
130
156
  return apiName === 'clientActions';
131
157
  }
132
158
 
159
+ validateClientActionId(id) {
160
+ const isValidClientActionIdFormat = id !== '' && id !== null && !isNaN(Number(id)) && typeof id === 'string';
161
+
162
+ if (!isValidClientActionIdFormat) {
163
+ throw new Error(`ClientActionResource: Invalid value '${id}' passed as client action id.`);
164
+ }
165
+
166
+ this.doesClientActionExist(id);
167
+ }
168
+
169
+ doesClientActionExist(id) {
170
+ const clientActions = this.getClientActionModels();
171
+ const doesClientActionExist = clientActions.find(clientAction => clientAction.id === id);
172
+
173
+ if (doesClientActionExist === undefined) {
174
+ throw new Error(`ClientActionResource: No client action exists for the ID '${id}'.`);
175
+ }
176
+ }
177
+
133
178
  toObject() {
134
179
  const clientActionsObj = this.clientActions.toObject();
135
180
  return {