@zohodesk/library-platform 1.1.3-exp.1 → 1.1.3-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.
- package/README.md +3 -3
- package/es/bc/zlist/Constants.js +3 -1
- package/es/bc/zrecord/Constants.js +3 -1
- package/es/cc/table-connected/Properties.js +16 -0
- package/es/cc/table-list/Constants.js +4 -0
- package/es/cc/table-list/Properties.js +16 -0
- package/es/cc/table-list/row/Properties.js +35 -0
- package/es/index.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 +8 -0
- package/es/library/dot/components/table-list/frameworks/hooks/useTableRowReorder.js +93 -0
- package/es/library/dot/components/table-list/frameworks/ui/TableListView.js +67 -6
- package/es/library/dot/components/table-list/frameworks/ui/css/TableList.module.css +145 -2
- package/es/library/dot/components/table-list/frameworks/ui/sub-components/Header.js +22 -4
- package/es/library/dot/components/table-list/frameworks/ui/sub-components/Rows.js +22 -9
- package/es/library/dot/components/table-list/frameworks/ui/sub-components/header/MassAction.js +19 -2
- package/es/library/dot/components/table-list/frameworks/ui/sub-components/row/Row.js +55 -10
- package/es/library/dot/components/table-list/frameworks/ui/sub-components/row/RowSelection.js +10 -0
- package/es/library/dot/components/table-list/frameworks/utils/reOrder.js +76 -0
- package/es/platform/client-actions/translators/client-actions-translator/index.js +5 -2
- package/es/platform/client-actions/translators/condition-resolver/field-evaluators/GetResolvedContextFieldValue.js +3 -2
- package/es/platform/client-actions/translators/context-resolver/index.js +1 -4
- package/es/platform/components/form-connected/frameworks/FormConnectedFactory.js +33 -0
- package/es/{desk-frameworks → platform/components}/form-connected/frameworks/FormConnectedView.js +1 -1
- package/es/{desk-frameworks → platform/components}/form-connected/frameworks/FormSdkFactory.js +3 -14
- package/es/platform/components/table-connected/adapters/controllers/ColumnChooserOpenedController.js +28 -0
- package/es/{desk-frameworks → platform/components}/table-connected/adapters/controllers/ColumnChooserUpdateController.js +5 -5
- package/es/platform/components/table-connected/adapters/controllers/ReOrderFinishController.js +21 -0
- package/es/{desk-frameworks → platform/components}/table-connected/adapters/controllers/ResizeByMouseController.js +1 -1
- package/es/{desk-frameworks → platform/components}/table-connected/adapters/controllers/ResizeEndController.js +1 -1
- package/es/{desk-frameworks → platform/components}/table-connected/adapters/controllers/ResizeFinishController.js +1 -1
- package/es/{desk-frameworks → platform/components}/table-connected/adapters/controllers/ResizeStartController.js +2 -2
- package/es/{desk-frameworks → platform/components}/table-connected/adapters/controllers/ScrollController.js +1 -1
- package/es/{desk-frameworks/table-connected/frameworks → platform/components/table-connected/adapters}/resources/SmartTableResource.js +35 -17
- package/es/{desk-frameworks → platform/components}/table-connected/frameworks/EventHandlersFactory.js +20 -17
- package/es/platform/components/table-connected/frameworks/ListSdkFactory.js +57 -0
- package/es/platform/components/table-connected/frameworks/TableConnectedFactory.js +76 -0
- package/es/{desk-frameworks → platform/components}/table-connected/frameworks/TableConnectedView.js +5 -3
- package/es/platform/data-source/http-template/reOrderRecord.js +44 -0
- package/es/platform/data-source/index.js +2 -0
- package/es/platform/sdk/{frameworks → application/interfaces/gateways}/AbstractResource.js +1 -4
- package/es/platform/sdk/domain/entities/ResourceManager.js +1 -1
- package/es/platform/sdk/frameworks/Sdk.js +1 -1
- 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 +7 -0
- package/es/platform/zlist/adapters/gateways/Service.js +8 -0
- package/es/platform/zlist/adapters/presenters/TableTranslator.js +5 -1
- package/es/platform/zlist/adapters/presenters/translators/ColumnTranslator.js +9 -10
- package/es/platform/zlist/adapters/presenters/utils/DefaultClientActions.js +1 -1
- package/es/platform/zlist/applications/interfaces/input/ReOrderRecordUseCaseInput.js +1 -0
- 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/RecordSuccessCallbackUsecase.js +24 -3
- package/es/platform/zlist/domain/entities/List.js +66 -2
- package/es/platform/zlist/frameworks/EventHandlersFactory.js +7 -3
- package/es/platform/zlist/frameworks/ZListBehaviourFactory.js +2 -1
- package/es/platform/zrecord/domain/entities/GetReOrderRecordsStrategy.js +40 -0
- package/es/platform/zrecord/domain/entities/RecordsManager.js +3 -1
- package/package.json +6 -4
- package/es/desk-frameworks/form-connected/frameworks/FormConnectedFactory.js +0 -33
- package/es/desk-frameworks/table-connected/adapters/controllers/ColumnChooserOpenedController.js +0 -36
- package/es/desk-frameworks/table-connected/frameworks/ListSdkFactory.js +0 -57
- package/es/desk-frameworks/table-connected/frameworks/TableConnectedFactory.js +0 -64
- /package/es/{desk-frameworks → platform/components}/form-connected/frameworks/EventHandlersFactory.js +0 -0
- /package/es/{desk-frameworks → platform/components}/form-connected/frameworks/FormConnected.js +0 -0
- /package/es/{desk-frameworks → platform/components}/index.js +0 -0
- /package/es/{desk-frameworks → platform/components}/table-connected/adapters/controllers/AbstractController.js +0 -0
- /package/es/{desk-frameworks/table-connected/frameworks/resources → platform/components/table-connected/application/interfaces}/ISmartTableResource.js +0 -0
- /package/es/{desk-frameworks → platform/components}/table-connected/frameworks/TableConnected.js +0 -0
|
@@ -1,24 +1,34 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import Row from "./row/Row";
|
|
3
|
+
import { SortableElement } from 'react-sortable-hoc';
|
|
4
|
+
const SortableRow = SortableElement(props => /*#__PURE__*/React.createElement(Row, { ...props
|
|
5
|
+
}));
|
|
3
6
|
|
|
4
|
-
|
|
7
|
+
const Rows = _ref => {
|
|
5
8
|
let {
|
|
6
9
|
headers,
|
|
7
10
|
rows,
|
|
8
11
|
isFlexibleColumns,
|
|
12
|
+
isReorderEnabled,
|
|
9
13
|
isSelectionEnabled,
|
|
10
14
|
rowCursor,
|
|
11
15
|
hasRowActions,
|
|
12
16
|
rowActionsColumnWidth,
|
|
13
|
-
isKeyboardControlsEnabled
|
|
17
|
+
isKeyboardControlsEnabled,
|
|
18
|
+
dropIndicator
|
|
14
19
|
} = _ref;
|
|
15
|
-
return rows.map((row, index) =>
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
+
return rows.map((row, index) => {
|
|
21
|
+
const isDroppable = dropIndicator.index !== null ? dropIndicator.index === index ? true : false : false;
|
|
22
|
+
const dropPosition = dropIndicator.position;
|
|
23
|
+
return /*#__PURE__*/React.createElement(SortableRow, {
|
|
24
|
+
key: `${row.id}`,
|
|
25
|
+
index: index,
|
|
26
|
+
...getRowProps(row, headers, isFlexibleColumns, isReorderEnabled, isSelectionEnabled, rowCursor, hasRowActions, rowActionsColumnWidth, isKeyboardControlsEnabled, isDroppable, dropPosition)
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
};
|
|
20
30
|
|
|
21
|
-
function getRowProps(row, headers, isFlexibleColumns, isSelectionEnabled, rowCursor, hasRowActions, rowActionsColumnWidth, isKeyboardControlsEnabled) {
|
|
31
|
+
function getRowProps(row, headers, isFlexibleColumns, isReorderEnabled, isSelectionEnabled, rowCursor, hasRowActions, rowActionsColumnWidth, isKeyboardControlsEnabled, isDroppable, dropPosition) {
|
|
22
32
|
const {
|
|
23
33
|
id,
|
|
24
34
|
columns,
|
|
@@ -38,11 +48,14 @@ function getRowProps(row, headers, isFlexibleColumns, isSelectionEnabled, rowCur
|
|
|
38
48
|
isFocussed,
|
|
39
49
|
selectionTooltip,
|
|
40
50
|
isFlexibleColumns,
|
|
51
|
+
isReorderEnabled,
|
|
41
52
|
isSelectionEnabled,
|
|
42
53
|
cursor: rowCursor,
|
|
43
54
|
hasActions: hasRowActions,
|
|
44
55
|
isKeyboardControlsEnabled,
|
|
45
|
-
rowActionsColumnWidth
|
|
56
|
+
rowActionsColumnWidth,
|
|
57
|
+
isDroppable,
|
|
58
|
+
dropPosition
|
|
46
59
|
};
|
|
47
60
|
}
|
|
48
61
|
|
package/es/library/dot/components/table-list/frameworks/ui/sub-components/header/MassAction.js
CHANGED
|
@@ -2,10 +2,13 @@ import React from 'react';
|
|
|
2
2
|
import TableHeadFirstNode from '@zohodesk-private/desk-components/es/table/TableHeadFirstNode/TableHeadFirstNode';
|
|
3
3
|
import TableHeading from '@zohodesk-private/desk-components/es/table/TableHeading/TableHeading';
|
|
4
4
|
import ActionEventMediator from "../../../../../../../../platform/client-actions/components/action-event-mediator/frameworks/ui/ActionEventMediator";
|
|
5
|
+
import style from "./../../../ui/css/TableList.module.css";
|
|
5
6
|
|
|
6
7
|
function MassAction(_ref) {
|
|
7
8
|
let {
|
|
8
9
|
isSelectionEnabled,
|
|
10
|
+
isReorderEnabled,
|
|
11
|
+
isKeyboardControlsEnabled,
|
|
9
12
|
actions
|
|
10
13
|
} = _ref;
|
|
11
14
|
|
|
@@ -13,14 +16,28 @@ function MassAction(_ref) {
|
|
|
13
16
|
return null;
|
|
14
17
|
}
|
|
15
18
|
|
|
19
|
+
const customPropsContainer = isReorderEnabled && isSelectionEnabled ? {
|
|
20
|
+
$data_width: 56
|
|
21
|
+
} : {};
|
|
22
|
+
|
|
16
23
|
if (!actions || actions.length === 0) {
|
|
17
|
-
return /*#__PURE__*/React.createElement(TableHeadFirstNode,
|
|
24
|
+
return /*#__PURE__*/React.createElement(TableHeadFirstNode, {
|
|
25
|
+
customStyle: {
|
|
26
|
+
container: isReorderEnabled && isSelectionEnabled ? `${style.offsetLeft24} ${style.paddingRight24}` : isKeyboardControlsEnabled && isSelectionEnabled ? `${style.offsetLeft8} ${style.paddingRight16}` : isKeyboardControlsEnabled ? style.offsetLeft8 : style.offsetLeft0
|
|
27
|
+
},
|
|
28
|
+
$customProps_container: customPropsContainer
|
|
29
|
+
}, /*#__PURE__*/React.createElement(TableHeading, {
|
|
18
30
|
$i18n_text: "M/A",
|
|
19
31
|
$i18n_tooltip: "Mass Action"
|
|
20
32
|
}));
|
|
21
33
|
}
|
|
22
34
|
|
|
23
|
-
return /*#__PURE__*/React.createElement(TableHeadFirstNode,
|
|
35
|
+
return /*#__PURE__*/React.createElement(TableHeadFirstNode, {
|
|
36
|
+
customStyle: {
|
|
37
|
+
container: isReorderEnabled && isSelectionEnabled ? `${style.offsetLeft24} ${style.paddingRight24}` : isKeyboardControlsEnabled && isSelectionEnabled ? `${style.offsetLeft8} ${style.paddingRight16}` : isKeyboardControlsEnabled ? style.offsetLeft8 : style.offsetLeft0
|
|
38
|
+
},
|
|
39
|
+
$customProps_container: customPropsContainer
|
|
40
|
+
}, /*#__PURE__*/React.createElement(ActionEventMediator, {
|
|
24
41
|
actions: actions
|
|
25
42
|
}));
|
|
26
43
|
}
|
|
@@ -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,15 @@ 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
|
|
28
33
|
} = state.properties;
|
|
29
34
|
const {
|
|
30
35
|
id,
|
|
@@ -39,11 +44,11 @@ function RowView(_ref, ref) {
|
|
|
39
44
|
type,
|
|
40
45
|
actions
|
|
41
46
|
} = rowActionLocation;
|
|
42
|
-
return /*#__PURE__*/React.createElement(TableRow, {
|
|
47
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(TableRow, {
|
|
43
48
|
key: id,
|
|
44
49
|
ref: ref,
|
|
45
50
|
testId: id,
|
|
46
|
-
$flag_padding: !isSelectionEnabled,
|
|
51
|
+
$flag_padding: !isSelectionEnabled && !isReorderEnabled,
|
|
47
52
|
$flag_active: isSelected,
|
|
48
53
|
$flag_hasHighlighter: isKeyboardControlsEnabled,
|
|
49
54
|
$flag_isHighlighted: isFocussed,
|
|
@@ -56,8 +61,14 @@ function RowView(_ref, ref) {
|
|
|
56
61
|
customStyle: {
|
|
57
62
|
$pointer: style[`rowCursor_${cursor}`]
|
|
58
63
|
}
|
|
59
|
-
},
|
|
64
|
+
}, renderReorderer({
|
|
65
|
+
isSelectionEnabled,
|
|
66
|
+
isReorderEnabled,
|
|
67
|
+
isKeyboardControlsEnabled
|
|
68
|
+
}), renderRowSelection({
|
|
60
69
|
isSelectionEnabled,
|
|
70
|
+
isReorderEnabled,
|
|
71
|
+
isKeyboardControlsEnabled,
|
|
61
72
|
id,
|
|
62
73
|
selectionTooltip,
|
|
63
74
|
isSelected,
|
|
@@ -71,12 +82,16 @@ function RowView(_ref, ref) {
|
|
|
71
82
|
columnWidth: rowActionsColumnWidth,
|
|
72
83
|
type,
|
|
73
84
|
actions
|
|
74
|
-
})
|
|
85
|
+
}), isDroppable && /*#__PURE__*/React.createElement("div", {
|
|
86
|
+
className: `${style.rowDropIndicator} ${dropPosition === 'downward' && style.dropIndicatorTop} ${dropPosition === 'upward' && style.dropIndicatorBottom}`
|
|
87
|
+
})));
|
|
75
88
|
}
|
|
76
89
|
|
|
77
90
|
function renderRowSelection(_ref2) {
|
|
78
91
|
let {
|
|
79
92
|
isSelectionEnabled,
|
|
93
|
+
isReorderEnabled,
|
|
94
|
+
isKeyboardControlsEnabled,
|
|
80
95
|
id,
|
|
81
96
|
selectionTooltip,
|
|
82
97
|
isSelected,
|
|
@@ -85,6 +100,8 @@ function renderRowSelection(_ref2) {
|
|
|
85
100
|
} = _ref2;
|
|
86
101
|
return /*#__PURE__*/React.createElement(RowSelection, {
|
|
87
102
|
isSelectionEnabled: isSelectionEnabled,
|
|
103
|
+
isReorderEnabled: isReorderEnabled,
|
|
104
|
+
isKeyboardControlsEnabled: isKeyboardControlsEnabled,
|
|
88
105
|
id: id,
|
|
89
106
|
tooltip: selectionTooltip,
|
|
90
107
|
selected: isSelected,
|
|
@@ -93,24 +110,52 @@ function renderRowSelection(_ref2) {
|
|
|
93
110
|
});
|
|
94
111
|
}
|
|
95
112
|
|
|
96
|
-
function
|
|
113
|
+
function renderReorderer(_ref3) {
|
|
114
|
+
let {
|
|
115
|
+
isSelectionEnabled,
|
|
116
|
+
isReorderEnabled,
|
|
117
|
+
isKeyboardControlsEnabled
|
|
118
|
+
} = _ref3;
|
|
119
|
+
const DragHandler = SortableHandle(_ref4 => {
|
|
120
|
+
let {
|
|
121
|
+
isSelectionEnabled,
|
|
122
|
+
isReorderEnabled,
|
|
123
|
+
isKeyboardControlsEnabled
|
|
124
|
+
} = _ref4;
|
|
125
|
+
return /*#__PURE__*/React.createElement("td", {
|
|
126
|
+
tabIndex: 0,
|
|
127
|
+
className: `${style.dragHandleWrapper} ${isKeyboardControlsEnabled && isSelectionEnabled && !isReorderEnabled ? style.paddingRight16 : isKeyboardControlsEnabled ? `${style.offsetLeft8} ${style.paddingLeft0} ${style.paddingRight8}` : `${style.offsetLeft0} ${style.paddingLeft8}`}`
|
|
128
|
+
}, /*#__PURE__*/React.createElement(DragHandle, {
|
|
129
|
+
customStyle: {
|
|
130
|
+
container: `${style.dragHandleContainer} `
|
|
131
|
+
}
|
|
132
|
+
}));
|
|
133
|
+
});
|
|
134
|
+
return isReorderEnabled ? /*#__PURE__*/React.createElement(DragHandler, {
|
|
135
|
+
isSelectionEnabled: isSelectionEnabled,
|
|
136
|
+
isReorderEnabled: isReorderEnabled,
|
|
137
|
+
isKeyboardControlsEnabled: isKeyboardControlsEnabled
|
|
138
|
+
}) : null;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
function renderColumns(_ref5) {
|
|
97
142
|
let {
|
|
98
143
|
columns,
|
|
99
144
|
isFlexibleColumns
|
|
100
|
-
} =
|
|
145
|
+
} = _ref5;
|
|
101
146
|
return /*#__PURE__*/React.createElement(Columns, {
|
|
102
147
|
data: columns,
|
|
103
148
|
isFlexibleColumns: isFlexibleColumns
|
|
104
149
|
});
|
|
105
150
|
}
|
|
106
151
|
|
|
107
|
-
function renderRowActions(
|
|
152
|
+
function renderRowActions(_ref6) {
|
|
108
153
|
let {
|
|
109
154
|
hasActions,
|
|
110
155
|
columnWidth,
|
|
111
156
|
actions,
|
|
112
157
|
type
|
|
113
|
-
} =
|
|
158
|
+
} = _ref6;
|
|
114
159
|
return /*#__PURE__*/React.createElement(RowActions, {
|
|
115
160
|
hasActions: hasActions,
|
|
116
161
|
columnWidth: columnWidth,
|
package/es/library/dot/components/table-list/frameworks/ui/sub-components/row/RowSelection.js
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import TableListSelect from '@zohodesk-private/desk-components/es/table/TableListSelect/TableListSelect';
|
|
3
3
|
import { TableListConstants } from "../../../../../../../../cc/table-list";
|
|
4
|
+
import style from "./../../css/TableList.module.css";
|
|
4
5
|
|
|
5
6
|
function RowSelection(_ref) {
|
|
6
7
|
let {
|
|
7
8
|
isSelectionEnabled,
|
|
9
|
+
isReorderEnabled,
|
|
10
|
+
isKeyboardControlsEnabled,
|
|
8
11
|
id,
|
|
9
12
|
tooltip,
|
|
10
13
|
selected,
|
|
@@ -16,10 +19,17 @@ function RowSelection(_ref) {
|
|
|
16
19
|
return null;
|
|
17
20
|
}
|
|
18
21
|
|
|
22
|
+
const customPropsContainer = isReorderEnabled && isSelectionEnabled ? {
|
|
23
|
+
$data_width: 56
|
|
24
|
+
} : {};
|
|
19
25
|
return /*#__PURE__*/React.createElement(TableListSelect, {
|
|
20
26
|
$data_id: id,
|
|
21
27
|
$i18n_tooltip: tooltip,
|
|
22
28
|
$flag_checked: selected,
|
|
29
|
+
customStyle: {
|
|
30
|
+
container: isReorderEnabled && isSelectionEnabled ? `${style.offsetLeft24} ${style.paddingRight24}` : isKeyboardControlsEnabled && isSelectionEnabled ? `${style.paddingRight16} ${style.offsetLeft8}` : isKeyboardControlsEnabled ? style.offsetLeft8 : style.offsetLeft0
|
|
31
|
+
},
|
|
32
|
+
$customProps_container: customPropsContainer,
|
|
23
33
|
$flag_disabled: !selectable,
|
|
24
34
|
$event_onChange: (_, event) => dispatch({
|
|
25
35
|
type: TableListConstants.TABLE_LIST_TOGGLE_ITEM_SELECTION,
|
|
@@ -0,0 +1,76 @@
|
|
|
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 setTableUserSelect(ref, value) {
|
|
27
|
+
if (ref.current) {
|
|
28
|
+
ref.current.style.userSelect = value;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
export function adjustHelperElementPosition(ref, draggingClass) {
|
|
32
|
+
if (ref.current) {
|
|
33
|
+
const TableScrollLeft = ref.current.scrollLeft;
|
|
34
|
+
const helperElement = ref.current.querySelector(`.${draggingClass}`);
|
|
35
|
+
|
|
36
|
+
if (helperElement) {
|
|
37
|
+
const helperLeft = parseCssNumberWithUnit(helperElement.style.left);
|
|
38
|
+
|
|
39
|
+
if (helperLeft && helperLeft.unit === 'px') {
|
|
40
|
+
helperElement.style.left = `${helperLeft.number + TableScrollLeft}px`;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
export function getDropIndicator(_ref) {
|
|
46
|
+
let {
|
|
47
|
+
index,
|
|
48
|
+
oldIndex,
|
|
49
|
+
newIndex,
|
|
50
|
+
rowsLength
|
|
51
|
+
} = _ref;
|
|
52
|
+
const isMovingDown = newIndex > oldIndex;
|
|
53
|
+
let dropIndex, normalizedDropIndex, dropPosition;
|
|
54
|
+
|
|
55
|
+
if (isMovingDown) {
|
|
56
|
+
dropIndex = newIndex < index ? newIndex : newIndex + 1;
|
|
57
|
+
} else {
|
|
58
|
+
dropIndex = newIndex <= index ? newIndex - 1 : newIndex;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
normalizedDropIndex = dropIndex;
|
|
62
|
+
dropPosition = isMovingDown ? 'downward' : 'upward';
|
|
63
|
+
|
|
64
|
+
if (dropIndex < 0) {
|
|
65
|
+
normalizedDropIndex = 0;
|
|
66
|
+
dropPosition = 'downward';
|
|
67
|
+
} else if (dropIndex >= rowsLength) {
|
|
68
|
+
normalizedDropIndex = rowsLength - 1;
|
|
69
|
+
dropPosition = 'upward';
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return {
|
|
73
|
+
index: normalizedDropIndex,
|
|
74
|
+
position: dropPosition
|
|
75
|
+
};
|
|
76
|
+
}
|
|
@@ -20,8 +20,11 @@ export default class ClientActionsTranslator {
|
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
static transform(actions, context) {
|
|
23
|
-
const
|
|
24
|
-
|
|
23
|
+
const replacementContext = {
|
|
24
|
+
"@context": context
|
|
25
|
+
};
|
|
26
|
+
const resolvedActions = ActionContextResolver.resolveActions(actions, replacementContext);
|
|
27
|
+
const evaluatedActions = resolvedActions.filter(action => ConditionResolver.evaluateCondition(action.conditions, replacementContext, action.id));
|
|
25
28
|
const finalTransformedActions = evaluatedActions.map(action => this.transformToActionViewModel(action));
|
|
26
29
|
return finalTransformedActions;
|
|
27
30
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import TemplateResolver from "../../../template-resolver";
|
|
1
2
|
export function getResolvedContextFieldValue(context, field) {
|
|
2
|
-
if (field.includes(
|
|
3
|
-
let value =
|
|
3
|
+
if (field.includes('.')) {
|
|
4
|
+
let value = TemplateResolver.replaceContextVariables(field, context);
|
|
4
5
|
return value;
|
|
5
6
|
}
|
|
6
7
|
|
|
@@ -45,10 +45,7 @@ export class ActionContextResolver {
|
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
static resolveActions(actions, context) {
|
|
48
|
-
|
|
49
|
-
"@context": context
|
|
50
|
-
};
|
|
51
|
-
return actions ? actions.map(action => this.resolveAction(action, replacementContext)) : [];
|
|
48
|
+
return actions ? actions.map(action => this.resolveAction(action, context)) : [];
|
|
52
49
|
}
|
|
53
50
|
|
|
54
51
|
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import Properties from "../../../../cc/form-connected/Properties";
|
|
2
|
+
import { createCustomComponent } from "../../../../library/custom-component";
|
|
3
|
+
import ZHttpBehaviourFactory from "../../../zhttp/frameworks/ZHttpBehaviourFactory";
|
|
4
|
+
import RecordBehaviourFactory from "../../../zrecord/frameworks/RecordBehaviourFactory";
|
|
5
|
+
import FormConnectedView from "./FormConnectedView";
|
|
6
|
+
import defaultDataBroker from "../../../data-source";
|
|
7
|
+
import DataBrokerBehaviourFactory from "../../../zdata-source/frameworks/DataBrokerBehaviourFactory";
|
|
8
|
+
import FormTranslator from "../../../zform/adapters/presenter/FormTranslator";
|
|
9
|
+
import ZFormBehaviourFactory from "../../../zform/frameworks/ui/ZFormBehaviourFactory";
|
|
10
|
+
import FieldValidationBehaviourFactory from "../../../../library/behaviours/field-validation/frameworks/ui/FieldValidationBehaviourFactory";
|
|
11
|
+
import EventHandlersfactory from "./EventHandlersFactory";
|
|
12
|
+
export default class FormConnectedFactory {
|
|
13
|
+
static create(_ref) {
|
|
14
|
+
let {
|
|
15
|
+
name,
|
|
16
|
+
customValidators,
|
|
17
|
+
dataBroker = defaultDataBroker,
|
|
18
|
+
eventHandlers = {},
|
|
19
|
+
View = FormConnectedView
|
|
20
|
+
} = _ref;
|
|
21
|
+
return createCustomComponent({
|
|
22
|
+
name: name,
|
|
23
|
+
View: View,
|
|
24
|
+
properties: Properties,
|
|
25
|
+
eventHandlers: EventHandlersfactory.create(eventHandlers),
|
|
26
|
+
transformState: FormTranslator.transformState,
|
|
27
|
+
behaviours: [ZHttpBehaviourFactory.create(), DataBrokerBehaviourFactory.create(), RecordBehaviourFactory.create(dataBroker.httpTemplates), FieldValidationBehaviourFactory.create(), ZFormBehaviourFactory.create({
|
|
28
|
+
customValidators
|
|
29
|
+
})]
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
}
|
package/es/{desk-frameworks → platform/components}/form-connected/frameworks/FormSdkFactory.js
RENAMED
|
@@ -2,8 +2,7 @@
|
|
|
2
2
|
export default class FormSdkFactory {
|
|
3
3
|
static create(_ref) {
|
|
4
4
|
let {
|
|
5
|
-
state
|
|
6
|
-
dispatch
|
|
5
|
+
state
|
|
7
6
|
} = _ref;
|
|
8
7
|
return {
|
|
9
8
|
zform: {
|
|
@@ -12,21 +11,11 @@ export default class FormSdkFactory {
|
|
|
12
11
|
},
|
|
13
12
|
getFieldValue: name => {
|
|
14
13
|
let field = state.behaviours.zform.sections.flatMap(section => section.fields).find(field => field.name === name);
|
|
15
|
-
|
|
16
|
-
if (field) {
|
|
17
|
-
return field.value;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
return null;
|
|
14
|
+
return field ? field.value : null;
|
|
21
15
|
},
|
|
22
16
|
getFieldValidationResult: name => {
|
|
23
17
|
let field = state.behaviours.zform.sections.flatMap(section => section.fields).find(field => field.name === name);
|
|
24
|
-
|
|
25
|
-
if (field) {
|
|
26
|
-
return field.errorMessage;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
return null;
|
|
18
|
+
return field ? field.errorMessage : null;
|
|
30
19
|
}
|
|
31
20
|
}
|
|
32
21
|
};
|
package/es/platform/components/table-connected/adapters/controllers/ColumnChooserOpenedController.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import AbstractController from "./AbstractController";
|
|
2
|
+
import { COLUMN_CHOOSER_BEHAVIOUR_OPENED } from "../../../../../bc/column-chooser/Constants";
|
|
3
|
+
export default class ColumnChooserOpenedController extends AbstractController {
|
|
4
|
+
handle(event) {
|
|
5
|
+
const state = event.state;
|
|
6
|
+
const {
|
|
7
|
+
zfield
|
|
8
|
+
} = state.behaviours;
|
|
9
|
+
const {
|
|
10
|
+
fields: availableFields,
|
|
11
|
+
selectedFields
|
|
12
|
+
} = zfield;
|
|
13
|
+
const columnChooserOptionsOrder = selectedFields;
|
|
14
|
+
availableFields.forEach(field => {
|
|
15
|
+
if (!selectedFields.includes(field.name)) {
|
|
16
|
+
columnChooserOptionsOrder.push(field.name);
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
event.dispatch({
|
|
20
|
+
type: COLUMN_CHOOSER_BEHAVIOUR_OPENED,
|
|
21
|
+
payload: {
|
|
22
|
+
order: columnChooserOptionsOrder,
|
|
23
|
+
selectedArray: selectedFields
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
}
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import AbstractController from "./AbstractController";
|
|
2
|
-
import { FIELD_EXECUTE } from "
|
|
2
|
+
import { FIELD_EXECUTE } from "../../../../../bc/zfield/Constants";
|
|
3
3
|
export default class ColumnChooserUpdateController extends AbstractController {
|
|
4
4
|
handle(event) {
|
|
5
5
|
const {
|
|
6
|
-
state
|
|
6
|
+
state,
|
|
7
|
+
dispatch
|
|
7
8
|
} = event;
|
|
8
9
|
const {
|
|
9
10
|
context
|
|
10
11
|
} = state.properties;
|
|
11
12
|
const fields = event.action.payload.selectedArray;
|
|
12
|
-
|
|
13
|
+
dispatch({
|
|
13
14
|
type: FIELD_EXECUTE,
|
|
14
15
|
payload: {
|
|
15
16
|
actionName: 'updateSelectedFields',
|
|
@@ -18,8 +19,7 @@ export default class ColumnChooserUpdateController extends AbstractController {
|
|
|
18
19
|
},
|
|
19
20
|
apiName: 'updateSelectedFields'
|
|
20
21
|
}
|
|
21
|
-
};
|
|
22
|
-
event.dispatch(action);
|
|
22
|
+
});
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
}
|
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
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RESIZE_MOUSE } from "
|
|
1
|
+
import { RESIZE_MOUSE } from "../../../../../bc/table-column-resizer/Constants";
|
|
2
2
|
import AbstractController from "./AbstractController";
|
|
3
3
|
export default class ResizeByMouseController extends AbstractController {
|
|
4
4
|
handle(event) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RESIZE_ENDED } from "
|
|
1
|
+
import { RESIZE_ENDED } from "../../../../../bc/table-column-resizer/Constants";
|
|
2
2
|
import AbstractController from "./AbstractController";
|
|
3
3
|
export default class ResizeEndController extends AbstractController {
|
|
4
4
|
handle(event) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { STORE_REQUESTED } from "
|
|
1
|
+
import { STORE_REQUESTED } from "../../../../../bc/local-storage/Constants";
|
|
2
2
|
import AbstractController from "./AbstractController";
|
|
3
3
|
export class ResizeFinishController extends AbstractController {
|
|
4
4
|
handle(event) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RESIZE_STARTED } from "
|
|
1
|
+
import { RESIZE_STARTED } from "../../../../../bc/table-column-resizer/Constants";
|
|
2
2
|
import AbstractController from "./AbstractController";
|
|
3
3
|
export default class ResizeStartController extends AbstractController {
|
|
4
4
|
handle(event) {
|
|
@@ -11,7 +11,7 @@ export default class ResizeStartController extends AbstractController {
|
|
|
11
11
|
mouseEvent
|
|
12
12
|
} = event.action.payload;
|
|
13
13
|
const mouseX = mouseEvent.clientX;
|
|
14
|
-
const lineClientRect = lineElement.getBoundingClientRect(); // HACK: calculate the initial position of the line element because of lineElement will not be read form entity because of clean architecture.
|
|
14
|
+
const lineClientRect = lineElement.getBoundingClientRect(); // HACK: calculate the initial position of the line element because of lineElement will not be read form entity because of clean architecture.
|
|
15
15
|
// lineElement is not part of the entity, it is part of the view.
|
|
16
16
|
// Note: the reason for this (lineClientRect.width / 2) is , Even line is 2 or 3 px thick we need to take center position.
|
|
17
17
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RESIZE_SCROLL } from "
|
|
1
|
+
import { RESIZE_SCROLL } from "../../../../../bc/table-column-resizer/Constants";
|
|
2
2
|
import AbstractController from "./AbstractController";
|
|
3
3
|
export default class ScrollController extends AbstractController {
|
|
4
4
|
handle(event) {
|