@zohodesk/library-platform 1.1.3-exp.3 → 1.1.3-exp.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/bc/zhttp/Errors.js +14 -0
- package/es/bc/zhttp/index.js +3 -1
- package/es/bc/zlist/Constants.js +8 -1
- package/es/bc/zlist/Events.js +140 -0
- package/es/bc/zlist/index.js +2 -1
- package/es/bc/zrecord/Constants.js +3 -1
- package/es/cc/component/FallbackView.js +1 -0
- package/es/cc/fields/currency/Model.js +2 -0
- package/es/cc/fields/field/Properties.js +1 -1
- package/es/cc/fields/formula/Model.js +5 -0
- package/es/cc/index.js +1 -0
- package/es/cc/link/Properties.js +0 -1
- package/es/cc/table-connected/ErrorEventType.js +32 -0
- package/es/cc/table-connected/Events.js +96 -0
- package/es/cc/table-connected/Properties.js +16 -0
- package/es/cc/table-connected/SdkContract.js +120 -0
- package/es/cc/table-connected/constants/Events.js +2 -0
- package/es/cc/table-connected/index.js +3 -1
- package/es/cc/table-list/Constants.js +4 -0
- package/es/cc/table-list/Properties.js +25 -0
- package/es/cc/table-list/row/Properties.js +44 -0
- package/es/index.js +2 -1
- package/es/library/custom-component/adapters/gateways/event-manager/EventManager.js +116 -4
- package/es/library/custom-component/applications/interfaces/gateways/ISchemaValidator.js +1 -0
- package/es/library/custom-component/applications/usecases/InitializeUseCase.js +3 -2
- package/es/library/custom-component/applications/usecases/UpdatePropertyUseCase.js +3 -2
- package/es/library/custom-component/domain/entities/Component.js +16 -3
- package/es/library/custom-component/domain/entities/Properties.js +19 -1
- package/es/library/custom-component/frameworks/json-schema-validator/Validator.js +36 -1
- package/es/library/custom-component/frameworks/ui/CreateCustomComponent.js +23 -11
- package/es/library/custom-component/frameworks/ui/DependencyFactory.js +4 -3
- package/es/library/dot/components/table-list/frameworks/hooks/useDropIndicator.js +8 -0
- package/es/library/dot/components/table-list/frameworks/hooks/useRowData.js +15 -0
- package/es/library/dot/components/table-list/frameworks/hooks/useTableRowReorder.js +105 -0
- package/es/library/dot/components/table-list/frameworks/ui/TableListView.js +85 -15
- package/es/library/dot/components/table-list/frameworks/ui/css/TableList.module.css +240 -1
- package/es/library/dot/components/table-list/frameworks/ui/sub-components/Header.js +28 -4
- package/es/library/dot/components/table-list/frameworks/ui/sub-components/Rows.js +25 -9
- package/es/library/dot/components/table-list/frameworks/ui/sub-components/header/MassAction.js +11 -2
- package/es/library/dot/components/table-list/frameworks/ui/sub-components/row/Row.js +50 -8
- package/es/library/dot/components/table-list/frameworks/ui/sub-components/row/RowSelection.js +6 -1
- package/es/library/dot/components/table-list/frameworks/utils/getHeaderClasses.js +37 -0
- package/es/library/dot/components/table-list/frameworks/utils/getTableListClassName.js +37 -0
- package/es/library/dot/components/table-list/frameworks/utils/reOrder.js +90 -0
- package/es/library/dot/legacy-to-new-arch/text-area/frameworks/ui/TextAreaView.js +1 -1
- package/es/platform/client-actions/components/action-event-mediator/frameworks/ui/ClientActionsAdapter.js +96 -0
- package/es/platform/client-actions/components/action-event-mediator/frameworks/ui/EventHandlersFactory.js +11 -3
- package/es/platform/client-actions/template-resolver/index.js +1 -0
- package/es/platform/client-actions/translators/context-resolver/index.js +6 -6
- package/es/platform/components/table-connected/adapters/controllers/ColumnChooserOpenedController.js +1 -1
- package/es/platform/components/table-connected/adapters/controllers/ReOrderFinishController.js +21 -0
- package/es/platform/components/table-connected/adapters/resources/ErrorPrinter.js +20 -0
- package/es/platform/components/table-connected/adapters/resources/SmartTableResource.js +85 -0
- package/es/platform/components/table-connected/frameworks/ErrorEventHandlersFactory.js +126 -0
- package/es/platform/components/table-connected/frameworks/EventHandlersFactory.js +39 -3
- package/es/platform/components/table-connected/frameworks/ListSdkFactory.js +4 -2
- package/es/platform/components/table-connected/frameworks/TableConnectedFactory.js +2 -0
- package/es/platform/components/table-connected/frameworks/TableConnectedView.js +8 -2
- package/es/platform/data-source/http-template/reOrderRecord.js +44 -0
- package/es/platform/data-source/index.js +2 -0
- package/es/platform/sdk/application/interfaces/gateways/AbstractResource.js +1 -2
- package/es/platform/sdk/domain/entities/ResourceManager.js +1 -1
- package/es/platform/zdata-source/domain/entities/DataSource.js +18 -12
- package/es/platform/zfield/domain/entities/fields-manager/FieldsManager.js +7 -1
- package/es/platform/zform/adapters/presenter/FormTranslator.js +6 -127
- package/es/platform/zform/adapters/presenter/translators/SectionTranslator.js +32 -0
- package/es/platform/zform/adapters/presenter/translators/fields/BooleanFieldTranslator.js +20 -0
- package/es/platform/zform/adapters/presenter/translators/fields/CurrencyFieldTranslator.js +29 -0
- package/es/platform/zform/adapters/presenter/translators/fields/DateFieldTranslator.js +20 -0
- package/es/platform/zform/adapters/presenter/translators/fields/DateTimeFieldTranslator.js +21 -0
- package/es/platform/zform/adapters/presenter/translators/fields/DecimalFieldTranslator.js +29 -0
- package/es/platform/zform/adapters/presenter/translators/fields/EmailFieldTranslator.js +30 -0
- package/es/platform/zform/adapters/presenter/translators/fields/LookUpFieldTranslator.js +30 -0
- package/es/platform/zform/adapters/presenter/translators/fields/MultiselectFieldTranslator.js +29 -0
- package/es/platform/zform/adapters/presenter/translators/fields/NumberFieldTranslator.js +30 -0
- package/es/platform/zform/adapters/presenter/translators/fields/PercentageFieldTranslator.js +30 -0
- package/es/platform/zform/adapters/presenter/translators/fields/PhoneFieldTranslator.js +29 -0
- package/es/platform/zform/adapters/presenter/translators/fields/PicklistFieldTranslator.js +29 -0
- package/es/platform/zform/adapters/presenter/translators/fields/TextAreaFieldTranslator.js +30 -0
- package/es/platform/zform/adapters/presenter/translators/fields/TextFieldTranslator.js +27 -0
- package/es/platform/zform/adapters/presenter/translators/fields/URLFieldTranslator.js +30 -0
- package/es/platform/zform/adapters/presenter/translators/fields/index.js +15 -0
- package/es/platform/zform/applications/usecases/MyFormSuccessUseCase.js +3 -1
- package/es/platform/zform/domain/ZField.js +61 -16
- package/es/platform/zform/domain/ZSection.js +20 -7
- package/es/platform/zhttp/applications/usecases/FetchUseCase.js +111 -66
- package/es/platform/zlist/adapters/controllers/FieldExecuteFailedController.js +25 -0
- package/es/platform/zlist/adapters/controllers/ReOrderController.js +25 -0
- package/es/platform/zlist/adapters/controllers/ReOrderFailedController.js +26 -0
- package/es/platform/zlist/adapters/gateways/Repository.js +12 -2
- package/es/platform/zlist/adapters/gateways/Service.js +8 -0
- package/es/platform/zlist/adapters/presenters/TableTranslator.js +15 -4
- package/es/platform/zlist/adapters/presenters/translators/ColumnTranslator.js +11 -12
- package/es/platform/zlist/adapters/presenters/translators/EmptyViewModel.js +2 -1
- package/es/platform/zlist/adapters/presenters/translators/Header.js +3 -2
- package/es/platform/zlist/adapters/presenters/translators/HeadersTranslator.js +3 -2
- package/es/platform/zlist/adapters/presenters/translators/fields/CurrencyFieldTranslator.js +1 -0
- package/es/platform/zlist/adapters/presenters/translators/fields/FormulaFieldTranslator.js +3 -0
- package/es/platform/zlist/adapters/presenters/utils/DefaultClientActions.js +1 -1
- package/es/platform/zlist/applications/entities-factory/ListFactory.js +3 -2
- package/es/platform/zlist/applications/interfaces/input/ReOrderRecordUseCaseInput.js +1 -0
- package/es/platform/zlist/applications/usecases/FetchMoreUseCase.js +1 -1
- package/es/platform/zlist/applications/usecases/ReOrderFailedUseCase.js +22 -0
- package/es/platform/zlist/applications/usecases/ReOrderUseCase.js +25 -0
- package/es/platform/zlist/applications/usecases/RecordExecuteFailedUseCase.js +3 -2
- package/es/platform/zlist/applications/usecases/RecordSuccessCallbackUsecase.js +24 -3
- package/es/platform/zlist/domain/entities/List.js +61 -48
- package/es/platform/zlist/domain/entities/ListErrorState.js +167 -0
- package/es/platform/zlist/frameworks/EventHandlersFactory.js +13 -3
- package/es/platform/zlist/frameworks/ZListBehaviourFactory.js +6 -0
- package/es/platform/zrecord/domain/entities/GetReOrderRecordsStrategy.js +40 -0
- package/es/platform/zrecord/domain/entities/RecordsManager.js +3 -1
- package/package.json +6 -3
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import TableRow from '@zohodesk-private/desk-components/es/table/TableList/TableList';
|
|
3
|
+
import DragHandle from '@zohodesk-private/desk-components/es/DragHandle/DragHandle';
|
|
3
4
|
import RowSelection from "./RowSelection";
|
|
4
5
|
import Columns from "./Columns";
|
|
5
6
|
import RowActions from "./RowActions";
|
|
6
7
|
import { createCustomComponent } from "../../../../../../../custom-component";
|
|
7
8
|
import { RowEventHandlersFactory } from "./RowEventHandlersFactory";
|
|
8
9
|
import TableRowProperties from "../../../../../../../../cc/table-list/row/Properties";
|
|
9
|
-
import TableRowConstants from "../../../../../../../../cc/table-list/row/Constants";
|
|
10
|
+
import TableRowConstants from "../../../../../../../../cc/table-list/row/Constants";
|
|
11
|
+
import { SortableHandle } from 'react-sortable-hoc'; // @ts-ignore
|
|
10
12
|
|
|
11
13
|
import style from "../../css/TableList.module.css";
|
|
12
14
|
|
|
@@ -19,12 +21,16 @@ function RowView(_ref, ref) {
|
|
|
19
21
|
dispatch
|
|
20
22
|
} = helpers;
|
|
21
23
|
const {
|
|
24
|
+
isReorderEnabled,
|
|
22
25
|
isSelectionEnabled,
|
|
23
26
|
isSelected,
|
|
24
27
|
isSelectable,
|
|
25
28
|
isKeyboardControlsEnabled,
|
|
26
29
|
isFocussed,
|
|
27
|
-
selectionTooltip
|
|
30
|
+
selectionTooltip,
|
|
31
|
+
isDroppable,
|
|
32
|
+
dropPosition,
|
|
33
|
+
isReOrderLoading
|
|
28
34
|
} = state.properties;
|
|
29
35
|
const {
|
|
30
36
|
id,
|
|
@@ -43,7 +49,7 @@ function RowView(_ref, ref) {
|
|
|
43
49
|
key: id,
|
|
44
50
|
ref: ref,
|
|
45
51
|
testId: id,
|
|
46
|
-
$flag_padding: !isSelectionEnabled,
|
|
52
|
+
$flag_padding: !isSelectionEnabled && !isReorderEnabled,
|
|
47
53
|
$flag_active: isSelected,
|
|
48
54
|
$flag_hasHighlighter: isKeyboardControlsEnabled,
|
|
49
55
|
$flag_isHighlighted: isFocussed,
|
|
@@ -54,9 +60,13 @@ function RowView(_ref, ref) {
|
|
|
54
60
|
}
|
|
55
61
|
}),
|
|
56
62
|
customStyle: {
|
|
63
|
+
tableList: isSelectionEnabled || isReorderEnabled ? style.row : '',
|
|
57
64
|
$pointer: style[`rowCursor_${cursor}`]
|
|
58
65
|
}
|
|
59
|
-
},
|
|
66
|
+
}, renderReorderer({
|
|
67
|
+
isReorderEnabled,
|
|
68
|
+
isReOrderLoading
|
|
69
|
+
}), renderRowSelection({
|
|
60
70
|
isSelectionEnabled,
|
|
61
71
|
id,
|
|
62
72
|
selectionTooltip,
|
|
@@ -71,6 +81,8 @@ function RowView(_ref, ref) {
|
|
|
71
81
|
columnWidth: rowActionsColumnWidth,
|
|
72
82
|
type,
|
|
73
83
|
actions
|
|
84
|
+
}), isDroppable && /*#__PURE__*/React.createElement("div", {
|
|
85
|
+
className: `${style.rowDropIndicator} ${dropPosition === 'downward' && style.dropIndicatorTop} ${dropPosition === 'upward' && style.dropIndicatorBottom}`
|
|
74
86
|
}));
|
|
75
87
|
}
|
|
76
88
|
|
|
@@ -93,24 +105,54 @@ function renderRowSelection(_ref2) {
|
|
|
93
105
|
});
|
|
94
106
|
}
|
|
95
107
|
|
|
96
|
-
|
|
108
|
+
const DragHandler = SortableHandle(_ref3 => {
|
|
109
|
+
let {
|
|
110
|
+
isDisabled
|
|
111
|
+
} = _ref3;
|
|
112
|
+
return /*#__PURE__*/React.createElement(DragHandle, {
|
|
113
|
+
isDisabled: isDisabled,
|
|
114
|
+
customStyle: {
|
|
115
|
+
container: style.dragHandleContainer
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
function renderReorderer(_ref4) {
|
|
121
|
+
let {
|
|
122
|
+
isReorderEnabled,
|
|
123
|
+
isReOrderLoading
|
|
124
|
+
} = _ref4;
|
|
125
|
+
|
|
126
|
+
if (!isReorderEnabled) {
|
|
127
|
+
return null;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
return /*#__PURE__*/React.createElement("td", {
|
|
131
|
+
tabIndex: 0,
|
|
132
|
+
className: style.dragHandleWrapper
|
|
133
|
+
}, /*#__PURE__*/React.createElement(DragHandler, {
|
|
134
|
+
isDisabled: isReOrderLoading
|
|
135
|
+
}));
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
function renderColumns(_ref5) {
|
|
97
139
|
let {
|
|
98
140
|
columns,
|
|
99
141
|
isFlexibleColumns
|
|
100
|
-
} =
|
|
142
|
+
} = _ref5;
|
|
101
143
|
return /*#__PURE__*/React.createElement(Columns, {
|
|
102
144
|
data: columns,
|
|
103
145
|
isFlexibleColumns: isFlexibleColumns
|
|
104
146
|
});
|
|
105
147
|
}
|
|
106
148
|
|
|
107
|
-
function renderRowActions(
|
|
149
|
+
function renderRowActions(_ref6) {
|
|
108
150
|
let {
|
|
109
151
|
hasActions,
|
|
110
152
|
columnWidth,
|
|
111
153
|
actions,
|
|
112
154
|
type
|
|
113
|
-
} =
|
|
155
|
+
} = _ref6;
|
|
114
156
|
return /*#__PURE__*/React.createElement(RowActions, {
|
|
115
157
|
hasActions: hasActions,
|
|
116
158
|
columnWidth: columnWidth,
|
package/es/library/dot/components/table-list/frameworks/ui/sub-components/row/RowSelection.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import TableListSelect from '@zohodesk-private/desk-components/es/table/TableListSelect/TableListSelect';
|
|
3
|
-
import { TableListConstants } from "../../../../../../../../cc/table-list";
|
|
3
|
+
import { TableListConstants } from "../../../../../../../../cc/table-list"; // @ts-ignore
|
|
4
|
+
|
|
5
|
+
import style from "./../../css/TableList.module.css";
|
|
4
6
|
|
|
5
7
|
function RowSelection(_ref) {
|
|
6
8
|
let {
|
|
@@ -20,6 +22,9 @@ function RowSelection(_ref) {
|
|
|
20
22
|
$data_id: id,
|
|
21
23
|
$i18n_tooltip: tooltip,
|
|
22
24
|
$flag_checked: selected,
|
|
25
|
+
customStyle: {
|
|
26
|
+
container: style.tableListSelectContainer
|
|
27
|
+
},
|
|
23
28
|
$flag_disabled: !selectable,
|
|
24
29
|
$event_onChange: (_, event) => dispatch({
|
|
25
30
|
type: TableListConstants.TABLE_LIST_TOGGLE_ITEM_SELECTION,
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export default function getTableListHeaderClassName(_ref) {
|
|
2
|
+
let {
|
|
3
|
+
isKeyboardControlsEnabled,
|
|
4
|
+
isReorderEnabled,
|
|
5
|
+
isSelectionEnabled
|
|
6
|
+
} = _ref;
|
|
7
|
+
|
|
8
|
+
if (isKeyboardControlsEnabled && isReorderEnabled && isSelectionEnabled) {
|
|
9
|
+
return 'tableListHeader-kbdReorderSelection';
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
if (isKeyboardControlsEnabled && isReorderEnabled && !isSelectionEnabled) {
|
|
13
|
+
return 'tableListHeader-kbdReorder';
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
if (isKeyboardControlsEnabled && isSelectionEnabled && !isReorderEnabled) {
|
|
17
|
+
return 'tableListHeader-kbdSelection';
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
if (isKeyboardControlsEnabled && !isReorderEnabled && !isSelectionEnabled) {
|
|
21
|
+
return 'tableListHeader-kbd';
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (isReorderEnabled && isSelectionEnabled && !isKeyboardControlsEnabled) {
|
|
25
|
+
return 'tableListHeader-reorderSelection';
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (isReorderEnabled && !isSelectionEnabled && !isKeyboardControlsEnabled) {
|
|
29
|
+
return 'tableListHeader-reorder';
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (isSelectionEnabled && !isReorderEnabled && !isKeyboardControlsEnabled) {
|
|
33
|
+
return 'tableListHeader-selection';
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return 'tableListHeader';
|
|
37
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export default function getTableListClassName(_ref) {
|
|
2
|
+
let {
|
|
3
|
+
isKeyboardControlsEnabled,
|
|
4
|
+
isReorderEnabled,
|
|
5
|
+
isSelectionEnabled
|
|
6
|
+
} = _ref;
|
|
7
|
+
|
|
8
|
+
if (isKeyboardControlsEnabled && isReorderEnabled && isSelectionEnabled) {
|
|
9
|
+
return 'tableListRow-kbdReorderSelection';
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
if (isKeyboardControlsEnabled && isReorderEnabled && !isSelectionEnabled) {
|
|
13
|
+
return 'tableListRow-kbdReorder';
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
if (isKeyboardControlsEnabled && isSelectionEnabled && !isReorderEnabled) {
|
|
17
|
+
return 'tableListRow-kbdSelection';
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
if (isKeyboardControlsEnabled && !isReorderEnabled && !isSelectionEnabled) {
|
|
21
|
+
return 'tableListRow-kbd';
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (isReorderEnabled && isSelectionEnabled && !isKeyboardControlsEnabled) {
|
|
25
|
+
return 'tableListRow-reorderSelection';
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (isReorderEnabled && !isSelectionEnabled && !isKeyboardControlsEnabled) {
|
|
29
|
+
return 'tableListRow-reorder';
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (isSelectionEnabled && !isReorderEnabled && !isKeyboardControlsEnabled) {
|
|
33
|
+
return 'tableListRow-selection';
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return 'tableListRow';
|
|
37
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
function reorderImmutableArray(arr, fromIndex, toIndex) {
|
|
2
|
+
const start = fromIndex < 0 ? arr.length + fromIndex : fromIndex;
|
|
3
|
+
|
|
4
|
+
if (start >= 0 && start < arr.length) {
|
|
5
|
+
const end = toIndex < 0 ? arr.length + toIndex : toIndex;
|
|
6
|
+
const [item] = arr.splice(start, 1);
|
|
7
|
+
arr.splice(end, 0, item);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function reorderArray(arr, fromIndex, toIndex) {
|
|
12
|
+
const copy = [...arr];
|
|
13
|
+
reorderImmutableArray(copy, fromIndex, toIndex);
|
|
14
|
+
return copy;
|
|
15
|
+
}
|
|
16
|
+
export function parseCssNumberWithUnit(value) {
|
|
17
|
+
if (typeof value !== "string") return null;
|
|
18
|
+
const regex = /^(-?\d+(\.\d+)?)([a-z%]*)$/i;
|
|
19
|
+
const match = value.trim().match(regex);
|
|
20
|
+
if (!match) return null;
|
|
21
|
+
return {
|
|
22
|
+
number: parseFloat(match[1]),
|
|
23
|
+
unit: match[3] || ""
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
export function setTableInteractionClass(ref, className, add) {
|
|
27
|
+
if (ref.current) {
|
|
28
|
+
if (add && !ref.current.classList.contains(className)) {
|
|
29
|
+
ref.current.classList.add(className);
|
|
30
|
+
} else if (!add && ref.current.classList.contains(className)) {
|
|
31
|
+
ref.current.classList.remove(className);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
export function adjustHelperElementPosition(ref, draggingClass) {
|
|
36
|
+
if (ref.current) {
|
|
37
|
+
const TableScrollLeft = ref.current.scrollLeft;
|
|
38
|
+
const helperElement = ref.current.querySelector(`.${draggingClass}`);
|
|
39
|
+
|
|
40
|
+
if (helperElement) {
|
|
41
|
+
const helperLeft = parseCssNumberWithUnit(helperElement.style.left);
|
|
42
|
+
|
|
43
|
+
if (helperLeft && helperLeft.unit === 'px') {
|
|
44
|
+
helperElement.style.left = `${helperLeft.number + TableScrollLeft}px`;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
helperElement.scrollLeft = TableScrollLeft;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
export function getDropIndicator(_ref) {
|
|
52
|
+
let {
|
|
53
|
+
index,
|
|
54
|
+
oldIndex,
|
|
55
|
+
newIndex,
|
|
56
|
+
rowsLength
|
|
57
|
+
} = _ref;
|
|
58
|
+
const isMovingDown = newIndex > oldIndex;
|
|
59
|
+
let dropIndex, normalizedDropIndex, dropPosition;
|
|
60
|
+
|
|
61
|
+
if (index === newIndex && newIndex === 0) {
|
|
62
|
+
normalizedDropIndex = 1;
|
|
63
|
+
dropPosition = 'downward';
|
|
64
|
+
} else if (index === newIndex && newIndex === rowsLength - 1) {
|
|
65
|
+
normalizedDropIndex = rowsLength - 2;
|
|
66
|
+
dropPosition = 'upward';
|
|
67
|
+
} else {
|
|
68
|
+
if (isMovingDown) {
|
|
69
|
+
dropIndex = newIndex < index ? newIndex : newIndex + 1;
|
|
70
|
+
} else {
|
|
71
|
+
dropIndex = newIndex <= index ? newIndex - 1 : newIndex;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
normalizedDropIndex = dropIndex;
|
|
75
|
+
dropPosition = isMovingDown ? 'downward' : 'upward';
|
|
76
|
+
|
|
77
|
+
if (dropIndex < 0) {
|
|
78
|
+
normalizedDropIndex = 0;
|
|
79
|
+
dropPosition = 'downward';
|
|
80
|
+
} else if (dropIndex >= rowsLength) {
|
|
81
|
+
normalizedDropIndex = rowsLength - 1;
|
|
82
|
+
dropPosition = 'upward';
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
return {
|
|
87
|
+
index: normalizedDropIndex,
|
|
88
|
+
position: dropPosition
|
|
89
|
+
};
|
|
90
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { createCustomComponent } from "../../../../../../library/custom-component";
|
|
2
|
+
import ActionEventMediatorProperties from "../../../../cc/action-event-mediator/Properties";
|
|
3
|
+
import EventHandlersFactory from "./EventHandlersFactory";
|
|
4
|
+
import ActionEventMediatorView from "./ActionEventMediatorView"; // import ClientActionsSDKFactory from '../../../../behaviour/zclient-actions/frameworks/sdk/ClientActionsSDKFactory'; TODO: Add support for returning clientActionsSDK factory when client actions SDK is merged to V2
|
|
5
|
+
|
|
6
|
+
import ClientActionsBehaviourFactory from "../../../../behaviour/zclient-actions/frameworks/ClientActionsBehaviourFactory";
|
|
7
|
+
import getClientActions from "../../../../../data-source/http-template/getClientActions";
|
|
8
|
+
import ClientActionsTranslator from "../../../../translators/client-actions-translator";
|
|
9
|
+
import FetchGateWay from "../../../../../zhttp/adapters/gateway/FetchGateWay";
|
|
10
|
+
import APITemplate from "../../../../../zdata-source/domain/entities/APITemplate";
|
|
11
|
+
import TemplateHelpers from "../../../../../zdata-source/adapters/gateways/TemplateHelpers";
|
|
12
|
+
;
|
|
13
|
+
const windowWrapper = window;
|
|
14
|
+
const ClientActionsAdapterUtils = {
|
|
15
|
+
getClientActionsAPIDetails(args) {
|
|
16
|
+
const apiTemplate = new APITemplate(getClientActions, new TemplateHelpers());
|
|
17
|
+
args.servicePrefix = 'supportapi/zd';
|
|
18
|
+
args.orgName = windowWrapper.currentOrg.portalName;
|
|
19
|
+
const apiDetails = apiTemplate.getApiDetails(args);
|
|
20
|
+
apiDetails.options = {
|
|
21
|
+
headers: {
|
|
22
|
+
orgId: windowWrapper.currentOrg.id
|
|
23
|
+
},
|
|
24
|
+
method: apiDetails.method
|
|
25
|
+
};
|
|
26
|
+
return apiDetails;
|
|
27
|
+
},
|
|
28
|
+
|
|
29
|
+
transform(input) {
|
|
30
|
+
return ClientActionsTranslator.transform(input, {
|
|
31
|
+
departmentName: windowWrapper.currentDepartment.sanitizedName,
|
|
32
|
+
orgId: windowWrapper.currentOrg.id,
|
|
33
|
+
orgName: windowWrapper.currentOrg.portalName,
|
|
34
|
+
servicePrefix: 'supportapi/zd'
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
};
|
|
39
|
+
const ClientActionsAdapter = {
|
|
40
|
+
createEventHandler(clientScript) {
|
|
41
|
+
return event => {
|
|
42
|
+
let response = {
|
|
43
|
+
event: event,
|
|
44
|
+
sdk: {}
|
|
45
|
+
}; // response.sdks.clientActions = ClientActionsSDKFactory.create({ TODO: Add support for returning clientActionsSDK factory when client actions SDK is merged to V2
|
|
46
|
+
// state: event.state,
|
|
47
|
+
// dispatch: event.dispatch
|
|
48
|
+
// });
|
|
49
|
+
|
|
50
|
+
clientScript(response);
|
|
51
|
+
};
|
|
52
|
+
},
|
|
53
|
+
|
|
54
|
+
createActionToEventHandlers(clientScripts) {
|
|
55
|
+
const actionEventHandlers = {};
|
|
56
|
+
Object.keys(clientScripts).map(targetEvent => {
|
|
57
|
+
const clientScript = clientScripts[targetEvent];
|
|
58
|
+
actionEventHandlers[targetEvent] = ClientActionsAdapter.createEventHandler(clientScript);
|
|
59
|
+
});
|
|
60
|
+
return actionEventHandlers;
|
|
61
|
+
},
|
|
62
|
+
|
|
63
|
+
fetchClientActions(args) {
|
|
64
|
+
const apiDetails = ClientActionsAdapterUtils.getClientActionsAPIDetails(args);
|
|
65
|
+
const fetchGateway = new FetchGateWay(window.fetch.bind(window));
|
|
66
|
+
return fetchGateway.fetch(apiDetails.url, apiDetails.options).then(response => {
|
|
67
|
+
return response.json();
|
|
68
|
+
}).then(response => {
|
|
69
|
+
if (response.errorCode) {
|
|
70
|
+
return Promise.reject(response);
|
|
71
|
+
} else {
|
|
72
|
+
const actions = ClientActionsAdapterUtils.transform(response);
|
|
73
|
+
return Promise.resolve(actions);
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
},
|
|
77
|
+
|
|
78
|
+
getClientActionComponent: clientScripts => {
|
|
79
|
+
return createCustomComponent({
|
|
80
|
+
name: 'ClientActionsAdapter',
|
|
81
|
+
properties: ActionEventMediatorProperties,
|
|
82
|
+
setInitialState: () => ({
|
|
83
|
+
handlers: {}
|
|
84
|
+
}),
|
|
85
|
+
eventHandlers: { ...EventHandlersFactory.createClientActionsAdapterEventHandlers(),
|
|
86
|
+
...ClientActionsAdapter.createActionToEventHandlers(clientScripts)
|
|
87
|
+
},
|
|
88
|
+
behaviours: [ClientActionsBehaviourFactory.create({
|
|
89
|
+
getClientActions: getClientActions
|
|
90
|
+
})],
|
|
91
|
+
View: ActionEventMediatorView
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
export const getClientActionsAdapter = ClientActionsAdapter.getClientActionComponent;
|
|
96
|
+
export const fetchClientActions = ClientActionsAdapter.fetchClientActions;
|
|
@@ -9,6 +9,14 @@ import PropertiesChangeController from "../../adapters/controllers/PropertiesCha
|
|
|
9
9
|
import LifeCycleEvents from "../../../../../../cc/component/LifeCycleEventsEnum";
|
|
10
10
|
export default class EventHandlersFactory {
|
|
11
11
|
static create() {
|
|
12
|
+
return EventHandlersFactory.createClientActionsLifeCycleEventHandlers('ActionEventMediator');
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
static createClientActionsAdapterEventHandlers() {
|
|
16
|
+
return EventHandlersFactory.createClientActionsLifeCycleEventHandlers('ClientActionsAdapter');
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
static createClientActionsLifeCycleEventHandlers(componentName) {
|
|
12
20
|
const repository = new Repository();
|
|
13
21
|
const presenter = new Presenter();
|
|
14
22
|
const dependencies = {
|
|
@@ -22,9 +30,9 @@ export default class EventHandlersFactory {
|
|
|
22
30
|
const unmountController = new UnmountController(destroyUseCase);
|
|
23
31
|
const propertiesChangeController = new PropertiesChangeController(propertiesChangeUseCase);
|
|
24
32
|
return {
|
|
25
|
-
[
|
|
26
|
-
[
|
|
27
|
-
[
|
|
33
|
+
[`${componentName}#${LifeCycleEvents.MOUNT}`]: initializeController.handle,
|
|
34
|
+
[`${componentName}#${LifeCycleEvents.UPDATE_PROPERTIES}`]: propertiesChangeController.handle,
|
|
35
|
+
[`${componentName}#${LifeCycleEvents.UN_MOUNT}`]: unmountController.handle
|
|
28
36
|
};
|
|
29
37
|
}
|
|
30
38
|
|
|
@@ -4,7 +4,7 @@ export class ActionContextResolver {
|
|
|
4
4
|
|
|
5
5
|
static resolveContextInEventMappingPayload(eventMapping, context) {
|
|
6
6
|
return { ...eventMapping,
|
|
7
|
-
payloadValueMapping: TemplateResolver.replaceContextVariablesInObject(eventMapping.
|
|
7
|
+
payloadValueMapping: TemplateResolver.replaceContextVariablesInObject(eventMapping.payloadValueMapping, context)
|
|
8
8
|
};
|
|
9
9
|
}
|
|
10
10
|
|
|
@@ -14,9 +14,9 @@ export class ActionContextResolver {
|
|
|
14
14
|
pattern
|
|
15
15
|
} = condition;
|
|
16
16
|
const resolvedFields = fields.map(field => {
|
|
17
|
-
const resolvedValue = TemplateResolver.replaceContextVariables(field.value.join(
|
|
17
|
+
const resolvedValue = TemplateResolver.replaceContextVariables(field.value.join(','), templateContext);
|
|
18
18
|
return { ...field,
|
|
19
|
-
value: resolvedValue.split(
|
|
19
|
+
value: resolvedValue.split(',')
|
|
20
20
|
};
|
|
21
21
|
});
|
|
22
22
|
return { ...condition,
|
|
@@ -31,10 +31,10 @@ export class ActionContextResolver {
|
|
|
31
31
|
|
|
32
32
|
static resolveAction(action, context) {
|
|
33
33
|
const eventMappings = action.uiComponentMapping.eventMappings;
|
|
34
|
-
const conditions = action.
|
|
34
|
+
const conditions = action.conditions;
|
|
35
35
|
const resolvedEventMappings = eventMappings.map(eventMapping => this.resolveContextInEventMappingPayload(eventMapping, context));
|
|
36
|
-
const resolvedProperty = this.resolveContextInProperties(action.uiComponentMapping.
|
|
37
|
-
const resolveConditionValues = this.resolveConditionValueContext(conditions, context);
|
|
36
|
+
const resolvedProperty = this.resolveContextInProperties(action.uiComponentMapping.propertiesValueMapping, context);
|
|
37
|
+
const resolveConditionValues = conditions ? this.resolveConditionValueContext(conditions, context) : conditions;
|
|
38
38
|
return { ...action,
|
|
39
39
|
conditions: resolveConditionValues,
|
|
40
40
|
uiComponentMapping: { ...action.uiComponentMapping,
|
package/es/platform/components/table-connected/adapters/controllers/ColumnChooserOpenedController.js
CHANGED
|
@@ -10,7 +10,7 @@ export default class ColumnChooserOpenedController extends AbstractController {
|
|
|
10
10
|
fields: availableFields,
|
|
11
11
|
selectedFields
|
|
12
12
|
} = zfield;
|
|
13
|
-
const columnChooserOptionsOrder = selectedFields;
|
|
13
|
+
const columnChooserOptionsOrder = [...selectedFields];
|
|
14
14
|
availableFields.forEach(field => {
|
|
15
15
|
if (!selectedFields.includes(field.name)) {
|
|
16
16
|
columnChooserOptionsOrder.push(field.name);
|
package/es/platform/components/table-connected/adapters/controllers/ReOrderFinishController.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import AbstractController from "./AbstractController";
|
|
2
|
+
import { ZLIST_RECORD_REORDER } from "../../../../../bc/zlist/Constants";
|
|
3
|
+
export class ReOrderFinishController extends AbstractController {
|
|
4
|
+
handle(event) {
|
|
5
|
+
const {
|
|
6
|
+
dispatch
|
|
7
|
+
} = event;
|
|
8
|
+
const {
|
|
9
|
+
oldIndex,
|
|
10
|
+
newIndex
|
|
11
|
+
} = event.action.payload;
|
|
12
|
+
dispatch({
|
|
13
|
+
type: ZLIST_RECORD_REORDER,
|
|
14
|
+
payload: {
|
|
15
|
+
oldIndex,
|
|
16
|
+
newIndex
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export default class ErrorPrinter {
|
|
2
|
+
static printError(error) {
|
|
3
|
+
console.error('Error occurred:', error);
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
static displaySchemaErrors(title, errors) {
|
|
7
|
+
let dataName = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '(root)';
|
|
8
|
+
console.group(title.msg, ...title.styles);
|
|
9
|
+
errors.forEach((_ref, i) => {
|
|
10
|
+
let {
|
|
11
|
+
dataPath,
|
|
12
|
+
keyword,
|
|
13
|
+
message
|
|
14
|
+
} = _ref;
|
|
15
|
+
console.error(`%c${i + 1}. %c${dataName + dataPath}%c → ${keyword} ${message}`, 'color: initial;', 'color: #FF6F61; font-weight: bold;', 'color: #FFA500;');
|
|
16
|
+
});
|
|
17
|
+
console.groupEnd();
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
}
|