@zohodesk/library-platform 1.1.6 → 1.1.7-exp.2

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 (124) hide show
  1. package/es/bc/sdk/ResourceNamesEnum.js +2 -0
  2. package/es/bc/zform/Properties.js +3 -26
  3. package/es/bc/zform/Symbol.js +2 -0
  4. package/es/bc/zlist/Constants.js +3 -1
  5. package/es/bc/zrecord/Constants.js +1 -0
  6. package/es/cc/breadcrumb/Constants.js +7 -0
  7. package/es/cc/breadcrumb/Events.js +14 -0
  8. package/es/cc/breadcrumb/Properties.js +35 -0
  9. package/es/cc/breadcrumb/index.js +3 -0
  10. package/es/cc/fields/field/FormDefaultUIType.js +37 -0
  11. package/es/cc/fields/index.js +2 -1
  12. package/es/cc/form/Properties.js +54 -0
  13. package/es/cc/form-connected/Constants.js +8 -0
  14. package/es/cc/form-connected/Properties.js +95 -1
  15. package/es/cc/form-connected/SdkContract.js +159 -0
  16. package/es/cc/icon-button/Constants.js +7 -0
  17. package/es/cc/icon-button/Events.js +5 -0
  18. package/es/cc/icon-button/Properties.js +86 -0
  19. package/es/cc/icon-button/index.js +3 -0
  20. package/es/cc/index.js +1 -0
  21. package/es/cc/section/Properties.js +25 -0
  22. package/es/cc/table-connected/Properties.js +8 -0
  23. package/es/cc/table-connected/constants/Events.js +1 -0
  24. package/es/index.js +6 -1
  25. package/es/library/dot/components/action-location/frameworks/ui/ActionComponentMapping.js +5 -1
  26. package/es/library/dot/components/action-location/usecases/interactors/PropertiesChangeUseCase.js +1 -1
  27. package/es/library/dot/components/form/adapters/presenter/TransformState.js +70 -3
  28. package/es/library/dot/components/form/frameworks/ui/DefaultComponentRegister.js +28 -0
  29. package/es/library/dot/components/form/frameworks/ui/Form.js +2 -0
  30. package/es/library/dot/components/form/frameworks/ui/FormView.js +47 -26
  31. package/es/library/dot/components/form/frameworks/ui/css/Form.module.css +8 -4
  32. package/es/library/dot/components/form/frameworks/ui/sub-components/Sections.js +9 -9
  33. package/es/library/dot/components/section/frameworks/ui/RenderField.js +19 -0
  34. package/es/library/dot/components/section/frameworks/ui/Section.js +13 -4
  35. package/es/library/dot/components/section/frameworks/ui/SectionView.js +7 -28
  36. package/es/library/dot/components/table-list/frameworks/ui/css/TableList.module.css +72 -40
  37. package/es/library/dot/components/table-list/frameworks/ui/sub-components/Header.js +7 -13
  38. package/es/library/dot/components/table-list/frameworks/ui/sub-components/row/Row.js +2 -2
  39. package/es/library/dot/legacy-to-new-arch/breadcrumb/frameworks/ui/Breadcrumb.js +12 -0
  40. package/es/library/dot/legacy-to-new-arch/breadcrumb/frameworks/ui/BreadcrumbView.js +47 -0
  41. package/es/library/dot/legacy-to-new-arch/breadcrumb/frameworks/ui/css/Breadcrumb.module.css +19 -0
  42. package/es/library/dot/legacy-to-new-arch/breadcrumb/frameworks/ui/sub-components/BreadcrumbItem.js +58 -0
  43. package/es/library/dot/legacy-to-new-arch/icon-button/frameworks/ui/IconButton.js +12 -0
  44. package/es/library/dot/legacy-to-new-arch/icon-button/frameworks/ui/IconButtonView.js +43 -0
  45. package/es/platform/client-actions/bc/zclient-actions/SdkContract.js +35 -0
  46. package/es/platform/client-actions/behaviour/zclient-actions/adapters/resources/ClientActionResource.js +105 -0
  47. package/es/platform/client-actions/behaviour/zclient-actions/applications/interfaces/IClientActionResource.js +1 -0
  48. package/es/platform/client-actions/behaviour/zclient-actions/applications/interfaces/input/GetClientActionLocationInputModel.js +1 -0
  49. package/es/platform/client-actions/behaviour/zclient-actions/applications/interfaces/input/GetClientActionUIComponentPropertiesInputModel.js +1 -0
  50. package/es/platform/client-actions/behaviour/zclient-actions/applications/interfaces/input/GetClientActionsInputModel.js +1 -0
  51. package/es/platform/client-actions/behaviour/zclient-actions/applications/interfaces/input/UpdateClientActionUIComponentPropertiesInputModel.js +1 -0
  52. package/es/platform/client-actions/behaviour/zclient-actions/applications/usecases/GetClientActionLocationUseCase.js +20 -0
  53. package/es/platform/client-actions/behaviour/zclient-actions/applications/usecases/GetClientActionUIComponentPropertiesUseCase.js +20 -0
  54. package/es/platform/client-actions/behaviour/zclient-actions/applications/usecases/GetClientActionsUseCase.js +18 -0
  55. package/es/platform/client-actions/behaviour/zclient-actions/applications/usecases/UpdateClientActionUIComponentPropertiesUseCase.js +32 -0
  56. package/es/platform/client-actions/behaviour/zclient-actions/domain/entities/ClientAction.js +12 -0
  57. package/es/platform/client-actions/behaviour/zclient-actions/domain/entities/ClientActionManager.js +45 -0
  58. package/es/platform/client-actions/behaviour/zclient-actions/domain/entities/UIComponentMapping.js +10 -0
  59. package/es/platform/client-actions/behaviour/zclient-actions/frameworks/sdk/ClientActionsSDKFactory.js +29 -0
  60. package/es/platform/client-actions/cc/action-event-mediator/Properties.js +9 -0
  61. package/es/platform/client-actions/components/action-event-mediator/applications/usecases/PropertiesChangeUseCase.js +1 -1
  62. package/es/platform/client-actions/components/action-event-mediator/domain/entities/ActionEventMediatorEntity.js +7 -3
  63. package/es/platform/client-actions/components/action-event-mediator/frameworks/ui/ActionEventMediatorView.js +3 -1
  64. package/es/platform/client-actions/components/dynamic-component/frameworks/ui/DynamicActionComponentView.js +4 -2
  65. package/es/platform/client-actions/components/row-actions-renderer/frameworks/ui/RowActionsRenderer.module.css +4 -0
  66. package/es/platform/client-actions/components/row-actions-renderer/frameworks/ui/RowActionsRendererView.js +5 -2
  67. package/es/platform/components/form-connected/adapters/resources/SmartFormResources.js +210 -0
  68. package/es/platform/components/form-connected/application/interfaces/ISmartFormResources.js +1 -0
  69. package/es/platform/components/form-connected/frameworks/EventHandlersFactory.js +16 -8
  70. package/es/platform/components/form-connected/frameworks/FormConnectedFactory.js +27 -3
  71. package/es/platform/components/form-connected/frameworks/FormConnectedView.js +14 -2
  72. package/es/platform/components/form-connected/frameworks/FormSdkFactory.js +33 -13
  73. package/es/platform/components/table-connected/adapters/resources/SmartTableResource.js +0 -52
  74. package/es/platform/components/table-connected/frameworks/EventHandlersFactory.js +15 -1
  75. package/es/platform/components/table-connected/frameworks/TableConnectedFactory.js +6 -1
  76. package/es/platform/data-source/http-template/getClientActions.js +2 -2
  77. package/es/platform/sdk/application/interfaces/gateways/AbstractResource.js +52 -1
  78. package/es/platform/sdk/frameworks/Sdk.js +14 -0
  79. package/es/platform/zform/adapters/presenter/FormTranslator.js +90 -46
  80. package/es/platform/zform/adapters/presenter/translators/SectionTranslator.js +51 -26
  81. package/es/platform/zform/adapters/presenter/translators/interfaces/ComponentMapping.js +1 -0
  82. package/es/platform/zform/adapters/presenter/translators/interfaces/FieldContract.js +1 -0
  83. package/es/platform/zform/adapters/presenter/translators/interfaces/FormTranslatorState.js +1 -0
  84. package/es/platform/zform/adapters/presenter/translators/interfaces/SectionContract.js +1 -0
  85. package/es/platform/zform/adapters/presenter/utils/DefaultClientActions.js +59 -0
  86. package/es/platform/zform/applications/interfaces/input/DeleteFieldUseCaseInput.js +1 -0
  87. package/es/platform/zform/applications/interfaces/input/GetFieldValueUseCaseInput.js +1 -0
  88. package/es/platform/zform/applications/interfaces/input/HideFieldUseCaseInput.js +1 -0
  89. package/es/platform/zform/applications/interfaces/input/HideSectionUseCaseInput.js +1 -0
  90. package/es/platform/zform/applications/interfaces/input/InsertFieldUseCaseInput.js +1 -0
  91. package/es/platform/zform/applications/interfaces/input/SetFieldValueUseCaseInput.js +1 -0
  92. package/es/platform/zform/applications/interfaces/input/SetFieldsValuesUseCaseInput.js +1 -0
  93. package/es/platform/zform/applications/interfaces/input/ShowFieldUseCaseInput.js +1 -0
  94. package/es/platform/zform/applications/interfaces/input/ShowSectionUseCaseInput.js +1 -0
  95. package/es/platform/zform/applications/interfaces/input/SubmitUseCaseInput.js +1 -0
  96. package/es/platform/zform/applications/interfaces/input/UpdateFieldUseCaseInput.js +1 -0
  97. package/es/platform/zform/applications/usecases/DeleteFieldUseCase.js +22 -0
  98. package/es/platform/zform/applications/usecases/GetFieldValueUseCase.js +23 -0
  99. package/es/platform/zform/applications/usecases/HideFieldUseCase.js +19 -0
  100. package/es/platform/zform/applications/usecases/HideSectionUseCase.js +19 -0
  101. package/es/platform/zform/applications/usecases/InitializeUseCase.js +16 -0
  102. package/es/platform/zform/applications/usecases/InsertFieldUseCase.js +28 -0
  103. package/es/platform/zform/applications/usecases/SetFieldValueUseCase.js +44 -0
  104. package/es/platform/zform/applications/usecases/SetFieldsValuesUseCase.js +51 -0
  105. package/es/platform/zform/applications/usecases/ShowFieldUseCase.js +19 -0
  106. package/es/platform/zform/applications/usecases/ShowSectionUseCase.js +19 -0
  107. package/es/platform/zform/applications/usecases/SubmitUseCase.js +29 -0
  108. package/es/platform/zform/applications/usecases/UpdateFieldUseCase.js +22 -0
  109. package/es/platform/zform/domain/ZField.js +14 -0
  110. package/es/platform/zform/domain/ZForm.js +85 -3
  111. package/es/platform/zform/domain/ZSection.js +6 -0
  112. package/es/platform/zform/frameworks/layout-rules/calculateLayoutRulesResult.js +1 -1
  113. package/es/platform/zform/frameworks/layout-rules/runSingleFieldCondition.js +1 -1
  114. package/es/platform/zform/frameworks/layout-rules/validator.js +0 -1
  115. package/es/platform/zform/frameworks/ui/EventHandlerFactory.js +37 -15
  116. package/es/platform/zlist/adapters/presenters/TableTranslator.js +3 -2
  117. package/es/platform/zlist/applications/usecases/RecordSuccessCallbackUsecase.js +4 -1
  118. package/es/platform/zlist/domain/entities/List.js +9 -3
  119. package/es/platform/zrecord/adapters/controllers/CreateRecordController.js +5 -1
  120. package/es/platform/zrecord/adapters/controllers/SetRecordsController.js +7 -3
  121. package/es/platform/zrecord/applications/usecases/CreateRecordUseCase.js +5 -3
  122. package/es/platform/zrecord/applications/usecases/SetRecordsUseCase.js +11 -1
  123. package/package.json +8 -6
  124. package/es/library/dot/components/section/adapters/presenter/TransFormState.js +0 -26
@@ -1,22 +1,16 @@
1
1
  import React from 'react';
2
2
  import TableHeader from '@zohodesk-private/desk-components/es/table/TableHeader/TableHeader';
3
- import TableHeadFirstNode from '@zohodesk-private/desk-components/es/table/TableHeadFirstNode/TableHeadFirstNode'; // import TableHeaderRow from '@zohodesk-private/desk-components/es/table/TableHeader/TableHeaderRow';
4
-
5
- const TableHeaderRow = _ref => {
6
- let {
7
- children
8
- } = _ref;
9
- return /*#__PURE__*/React.createElement(React.Fragment, null, children);
10
- };
11
-
3
+ import TableHeadFirstNode from '@zohodesk-private/desk-components/es/table/TableHeadFirstNode/TableHeadFirstNode';
4
+ import TableHeaderRow from '@zohodesk-private/desk-components/es/table/TableHeader/TableHeaderRow';
12
5
  import MassAction from "./header/MassAction";
13
6
  import Headers from "./header/Headers";
14
7
  import ActionColumn from "./header/ActionColumn";
15
8
  import ResizerExtraSpace from "./header/ResizerExtraSpace";
16
- import getHeaderClasses from "./../../utils/getHeaderClasses";
9
+ import getHeaderClasses from "./../../utils/getHeaderClasses"; // @ts-ignore
10
+
17
11
  import style from "./../css/TableList.module.css";
18
12
 
19
- function Header(_ref2) {
13
+ function Header(_ref) {
20
14
  let {
21
15
  isReorderEnabled,
22
16
  isSelectionEnabled,
@@ -31,7 +25,7 @@ function Header(_ref2) {
31
25
  rowActionsColumnWidth,
32
26
  headers,
33
27
  dispatch
34
- } = _ref2;
28
+ } = _ref;
35
29
 
36
30
  if (headers.length <= 0) {
37
31
  return null;
@@ -44,7 +38,7 @@ function Header(_ref2) {
44
38
  });
45
39
  return /*#__PURE__*/React.createElement(TableHeader, {
46
40
  $flag_isColumnsFlexible: isFlexibleColumns,
47
- $flag_padding: !isSelectionEnabled && !isReorderEnabled,
41
+ $flag_padding: false,
48
42
  $flag_hasHighlighter: isKeyboardControlsEnabled,
49
43
  customStyle: {
50
44
  tableHeader: `${style.header} ${style[headerClasses]}`
@@ -49,7 +49,7 @@ function RowView(_ref, ref) {
49
49
  key: id,
50
50
  ref: ref,
51
51
  testId: id,
52
- $flag_padding: !isSelectionEnabled && !isReorderEnabled,
52
+ $flag_padding: false,
53
53
  $flag_active: isSelected,
54
54
  $flag_hasHighlighter: isKeyboardControlsEnabled,
55
55
  $flag_isHighlighted: isFocussed,
@@ -60,7 +60,7 @@ function RowView(_ref, ref) {
60
60
  }
61
61
  }),
62
62
  customStyle: {
63
- tableList: isSelectionEnabled || isReorderEnabled ? style.row : '',
63
+ tableList: style.row,
64
64
  $pointer: style[`rowCursor_${cursor}`]
65
65
  }
66
66
  }, renderReorderer({
@@ -0,0 +1,12 @@
1
+ import { createCustomComponent } from "../../../../../custom-component";
2
+ import BreadcrumbProperties from "../../../../../../cc/breadcrumb/Properties";
3
+ import BreadcrumbEvents from "../../../../../../cc/breadcrumb/Events";
4
+ import BreadcrumbView from "./BreadcrumbView";
5
+ let Breadcrumb = createCustomComponent({
6
+ name: "Breadcrumb",
7
+ View: BreadcrumbView,
8
+ properties: BreadcrumbProperties,
9
+ events: BreadcrumbEvents,
10
+ eventHandlers: {}
11
+ });
12
+ export default Breadcrumb;
@@ -0,0 +1,47 @@
1
+ import React from "react";
2
+ import Separator from "@zohodesk/dot/es/Separator/Separator";
3
+ import BreadcrumbItem from "./sub-components/BreadcrumbItem"; // @ts-ignore
4
+
5
+ import style from "./css/Breadcrumb.module.css";
6
+
7
+ function BreadcrumbView(_ref, ref) {
8
+ let {
9
+ state,
10
+ helpers
11
+ } = _ref;
12
+ const {
13
+ dispatch
14
+ } = helpers;
15
+ const {
16
+ items
17
+ } = state.properties;
18
+ return /*#__PURE__*/React.createElement("div", {
19
+ ref: ref,
20
+ className: style.wrapper
21
+ }, /*#__PURE__*/React.createElement(Separator, {
22
+ type: "slash",
23
+ shrink: true,
24
+ customClass: {
25
+ customSeparator: style.separator
26
+ }
27
+ }, items.map(_ref2 => {
28
+ let {
29
+ id,
30
+ text,
31
+ isLink,
32
+ iconName,
33
+ isActive
34
+ } = _ref2;
35
+ return /*#__PURE__*/React.createElement(BreadcrumbItem, {
36
+ key: id,
37
+ id: id,
38
+ text: text,
39
+ isLink: isLink,
40
+ iconName: iconName,
41
+ isActive: isActive,
42
+ dispatch: dispatch
43
+ });
44
+ })));
45
+ }
46
+
47
+ export default BreadcrumbView;
@@ -0,0 +1,19 @@
1
+ .wrapper, .itemContainer {
2
+ max-width: 100%
3
+ }
4
+
5
+ .itemContainer {
6
+ column-gap: var(--zd_size4) ;
7
+ }
8
+
9
+ .separator {
10
+ --separator_fontSize: 14px;
11
+ margin: 0 var(--zd_size10) ;
12
+ }
13
+
14
+ .buttonStyle {
15
+ --button_font_size: 14px;
16
+ --button_padding: 0px;
17
+ --button_letter_spacing: 0px;
18
+ max-width: 100% ;
19
+ }
@@ -0,0 +1,58 @@
1
+ import React from "react";
2
+ import Icon from "@zohodesk/icons/es/Icon";
3
+ import Flex from "@zohodesk/layout/es/Flex/Flex";
4
+ import Typography from "@zohodesk/components/es/Typography/Typography";
5
+ import Button from "@zohodesk/components/es/Button/Button";
6
+ import BreadcrumbConstants from "../../../../../../../cc/breadcrumb/Constants"; // @ts-ignore
7
+
8
+ import style from "./../css/Breadcrumb.module.css";
9
+
10
+ function BreadcrumbItem(_ref) {
11
+ let {
12
+ id,
13
+ text,
14
+ isLink,
15
+ iconName,
16
+ iconSize = '14',
17
+ isActive,
18
+ dispatch
19
+ } = _ref;
20
+
21
+ const renderTitle = (text, isLink, isActive) => {
22
+ return isLink ? /*#__PURE__*/React.createElement(Button, {
23
+ text: text,
24
+ title: text,
25
+ palette: 'plainPrimary',
26
+ isBold: false,
27
+ customClass: {
28
+ customButton: style.buttonStyle
29
+ }
30
+ }) : /*#__PURE__*/React.createElement(Typography, {
31
+ $ui_size: isActive ? '16' : '14',
32
+ $ui_weight: isActive ? 'semibold' : 'regular',
33
+ $flag_dotted: true,
34
+ $i18n_dataTitle: text,
35
+ $ui_tagName: 'span'
36
+ }, text);
37
+ };
38
+
39
+ const renderIcon = (iconName, iconSize) => /*#__PURE__*/React.createElement(Icon, {
40
+ name: iconName,
41
+ size: iconSize
42
+ });
43
+
44
+ return /*#__PURE__*/React.createElement(Flex, {
45
+ key: id,
46
+ $ui_displayMode: "inline",
47
+ $ui_alignItems: "center",
48
+ $ui_className: style.itemContainer,
49
+ $event_onClick: () => dispatch({
50
+ type: BreadcrumbConstants.BREADCRUMB_ITEM_CLICKED,
51
+ payload: {
52
+ id
53
+ }
54
+ })
55
+ }, !isLink && iconName && renderIcon(iconName, iconSize), renderTitle(text, isLink, isActive));
56
+ }
57
+
58
+ export default BreadcrumbItem;
@@ -0,0 +1,12 @@
1
+ import { createCustomComponent } from "../../../../../custom-component";
2
+ import IconButtonProperties from "../../../../../../cc/icon-button/Properties";
3
+ import IconButtonEvents from "../../../../../../cc/icon-button/Events";
4
+ import IconButtonView from "./IconButtonView";
5
+ let IconButton = createCustomComponent({
6
+ name: "IconButton",
7
+ View: IconButtonView,
8
+ properties: IconButtonProperties,
9
+ events: IconButtonEvents,
10
+ eventHandlers: {}
11
+ });
12
+ export default IconButton;
@@ -0,0 +1,43 @@
1
+ import React from "react";
2
+ import IconButton from '@zohodesk/dot/es/IconButton/IconButton';
3
+ import IconButtonConstants from "../../../../../../cc/icon-button/Constants";
4
+
5
+ function IconButtonView(_ref, ref) {
6
+ let {
7
+ state,
8
+ helpers
9
+ } = _ref;
10
+ const {
11
+ dispatch
12
+ } = helpers;
13
+ const {
14
+ palette,
15
+ iconSize,
16
+ size,
17
+ iconName,
18
+ isActive,
19
+ isDisabled,
20
+ hoverType,
21
+ title,
22
+ isBold
23
+ } = state.properties;
24
+ return /*#__PURE__*/React.createElement(IconButton, {
25
+ eleRef: ref,
26
+ palette: palette,
27
+ iconSize: iconSize,
28
+ size: size,
29
+ iconName: iconName,
30
+ isActive: isActive,
31
+ isDisabled: isDisabled,
32
+ hoverType: hoverType,
33
+ title: title,
34
+ isBold: isBold,
35
+ onClick: () => {
36
+ dispatch({
37
+ type: IconButtonConstants.ICON_BUTTON_CLICKED
38
+ });
39
+ }
40
+ });
41
+ }
42
+
43
+ export default IconButtonView;
@@ -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 {
@@ -23,6 +23,16 @@ export default class UIComponentMapping {
23
23
  this.eventMappings = new EventMappings(uiComponentMappingObj.eventMappings);
24
24
  }
25
25
 
26
+ getPropertiesValueMapping() {
27
+ return this.propertiesValueMapping;
28
+ }
29
+
30
+ updatePropertiesValueMapping(newProperties) {
31
+ this.propertiesValueMapping = { ...this.propertiesValueMapping,
32
+ ...newProperties
33
+ };
34
+ }
35
+
26
36
  toObject() {
27
37
  return {
28
38
  id: this.id,
@@ -0,0 +1,29 @@
1
+ import ResourceNamesEnum from "../../../../../../bc/sdk/ResourceNamesEnum";
2
+ import { platformSDK } from "../../../../../sdk/frameworks/Sdk";
3
+ export default class ClientActionsSDKFactory {
4
+ static getClientActionSDK(clientActionResource) {
5
+ return {
6
+ getLocation: id => clientActionResource.getLocation(id),
7
+ getUIComponentProperties: id => clientActionResource.getUIComponentProperties(id),
8
+ getClientActions: () => clientActionResource.getClientActions(),
9
+ updateUIComponentProperties: (id, newComponentProperties) => clientActionResource.updateUIComponentProperties(id, newComponentProperties)
10
+ };
11
+ }
12
+
13
+ static create(_ref) {
14
+ let {
15
+ instanceName
16
+ } = _ref;
17
+ const clientActionResource = platformSDK[ResourceNamesEnum.CLIENT_ACTION](instanceName);
18
+ const clientActionSDK = ClientActionsSDKFactory.getClientActionSDK(clientActionResource);
19
+ return {
20
+ clientAction: {
21
+ getLocation: clientActionSDK.getLocation,
22
+ getUIComponentProperties: clientActionSDK.getUIComponentProperties,
23
+ getClientActions: clientActionSDK.getClientActions,
24
+ updateUIComponentProperties: clientActionSDK.updateUIComponentProperties
25
+ }
26
+ };
27
+ }
28
+
29
+ }
@@ -6,6 +6,15 @@ export const actionsSchema = {
6
6
  items: actionSchema
7
7
  };
8
8
  export default {
9
+ testId: {
10
+ required: false,
11
+ typeMetadata: {
12
+ schema: {
13
+ type: 'string'
14
+ }
15
+ },
16
+ defaultValue: ''
17
+ },
9
18
  actions: {
10
19
  required: true,
11
20
  typeMetadata: {
@@ -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.updateActionEventMediator(actionLocation.toObject());
15
15
  }
16
16