@bit.rhplus/ag-grid 0.0.41 → 0.0.42
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/Aggregations.js +343 -343
- package/BulkEdit/BulkEditButton.jsx +187 -187
- package/BulkEdit/BulkEditModule.jsx +68 -0
- package/BulkEdit/index.js +10 -9
- package/BulkEdit/utils.js +10 -8
- package/dist/BulkEdit/BulkEditModule.d.ts +10 -0
- package/dist/BulkEdit/BulkEditModule.js +28 -0
- package/dist/BulkEdit/BulkEditModule.js.map +1 -0
- package/dist/BulkEdit/index.d.ts +1 -0
- package/dist/BulkEdit/index.js +1 -0
- package/dist/BulkEdit/index.js.map +1 -1
- package/dist/BulkEdit/utils.js +11 -9
- package/dist/BulkEdit/utils.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/index.jsx +2 -1
- package/package.json +5 -4
- /package/dist/{preview-1760475768249.js → preview-1760621011908.js} +0 -0
|
@@ -1,187 +1,187 @@
|
|
|
1
|
-
/* eslint-disable */
|
|
2
|
-
import React, { useState, useRef, useEffect } from 'react';
|
|
3
|
-
import { Button, Tooltip } from 'antd';
|
|
4
|
-
import { EditOutlined } from '@ant-design/icons';
|
|
5
|
-
import BulkEditPopover from './BulkEditPopover';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Floating button komponenta pro bulk edit
|
|
9
|
-
* @param {Object} props
|
|
10
|
-
* @param {boolean} props.visible - Viditelnost buttonu
|
|
11
|
-
* @param {Object} props.position - Pozice buttonu {x, y}
|
|
12
|
-
* @param {Object} props.range - AG Grid cell range
|
|
13
|
-
* @param {Object} props.column - AG Grid column objekt
|
|
14
|
-
* @param {number} props.cellCount - Počet buněk k editaci
|
|
15
|
-
* @param {Object} props.editPopover - State popoveru
|
|
16
|
-
* @param {Function} props.onOpenPopover - Handler pro otevření popoveru
|
|
17
|
-
* @param {Function} props.onValueChange - Handler pro změnu hodnoty
|
|
18
|
-
* @param {Function} props.onSubmit - Handler pro submit
|
|
19
|
-
* @param {Function} props.onCancel - Handler pro cancel
|
|
20
|
-
*/
|
|
21
|
-
const BulkEditButton = ({
|
|
22
|
-
visible,
|
|
23
|
-
position,
|
|
24
|
-
range,
|
|
25
|
-
column,
|
|
26
|
-
cellCount,
|
|
27
|
-
editPopover,
|
|
28
|
-
onOpenPopover,
|
|
29
|
-
onValueChange,
|
|
30
|
-
onSubmit,
|
|
31
|
-
onCancel,
|
|
32
|
-
}) => {
|
|
33
|
-
const [popoverVisible, setPopoverVisible] = useState(false);
|
|
34
|
-
const [popoverPosition, setPopoverPosition] = useState(null);
|
|
35
|
-
const buttonRef = useRef(null);
|
|
36
|
-
const popoverRef = useRef(null);
|
|
37
|
-
|
|
38
|
-
// Sync local popover state s parent editPopover state
|
|
39
|
-
useEffect(() => {
|
|
40
|
-
setPopoverVisible(editPopover.visible);
|
|
41
|
-
}, [editPopover.visible]);
|
|
42
|
-
|
|
43
|
-
// Viewport-aware positioning pro popover
|
|
44
|
-
useEffect(() => {
|
|
45
|
-
if (popoverVisible && popoverRef.current && position) {
|
|
46
|
-
requestAnimationFrame(() => {
|
|
47
|
-
const popoverRect = popoverRef.current.getBoundingClientRect();
|
|
48
|
-
const viewportWidth = window.innerWidth;
|
|
49
|
-
const viewportHeight = window.innerHeight;
|
|
50
|
-
const MARGIN = 10;
|
|
51
|
-
|
|
52
|
-
let top = position.y + 35;
|
|
53
|
-
let left = position.x;
|
|
54
|
-
|
|
55
|
-
if (left + popoverRect.width > viewportWidth - MARGIN) {
|
|
56
|
-
left = viewportWidth - popoverRect.width - MARGIN;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
if (left < MARGIN) {
|
|
60
|
-
left = MARGIN;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
if (top + popoverRect.height > viewportHeight - MARGIN) {
|
|
64
|
-
top = position.y - popoverRect.height - 5;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
if (top < MARGIN) {
|
|
68
|
-
top = MARGIN;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
setPopoverPosition({ top, left });
|
|
72
|
-
});
|
|
73
|
-
} else {
|
|
74
|
-
setPopoverPosition(null);
|
|
75
|
-
}
|
|
76
|
-
}, [popoverVisible, position]);
|
|
77
|
-
|
|
78
|
-
if (!visible) return null;
|
|
79
|
-
|
|
80
|
-
const colDef = column?.getColDef();
|
|
81
|
-
const fieldName = colDef?.headerName || colDef?.field || 'Sloupec';
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* Handler pro kliknutí na button
|
|
85
|
-
*/
|
|
86
|
-
const handleButtonClick = (e) => {
|
|
87
|
-
e.stopPropagation();
|
|
88
|
-
if (!popoverVisible) {
|
|
89
|
-
setPopoverVisible(true);
|
|
90
|
-
onOpenPopover();
|
|
91
|
-
}
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* Handler pro kliknutí mimo popover (close)
|
|
96
|
-
*/
|
|
97
|
-
const handleClickOutside = (e) => {
|
|
98
|
-
if (
|
|
99
|
-
popoverVisible &&
|
|
100
|
-
popoverRef.current &&
|
|
101
|
-
!popoverRef.current.contains(e.target) &&
|
|
102
|
-
buttonRef.current &&
|
|
103
|
-
!buttonRef.current.contains(e.target)
|
|
104
|
-
) {
|
|
105
|
-
onCancel();
|
|
106
|
-
}
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
// Click outside listener
|
|
110
|
-
useEffect(() => {
|
|
111
|
-
if (popoverVisible) {
|
|
112
|
-
document.addEventListener('mousedown', handleClickOutside);
|
|
113
|
-
return () => {
|
|
114
|
-
document.removeEventListener('mousedown', handleClickOutside);
|
|
115
|
-
};
|
|
116
|
-
}
|
|
117
|
-
}, [popoverVisible]);
|
|
118
|
-
|
|
119
|
-
const tooltipTitle = `Hromadně změnit ${cellCount} ${
|
|
120
|
-
cellCount === 1 ? 'buňku' : cellCount < 5 ? 'buňky' : 'buněk'
|
|
121
|
-
} v "${fieldName}"`;
|
|
122
|
-
|
|
123
|
-
return (
|
|
124
|
-
<>
|
|
125
|
-
{/* Floating Button */}
|
|
126
|
-
<div
|
|
127
|
-
ref={buttonRef}
|
|
128
|
-
style={{
|
|
129
|
-
position: 'fixed',
|
|
130
|
-
top: position?.y || 0,
|
|
131
|
-
left: position?.x || 0,
|
|
132
|
-
zIndex: 9999,
|
|
133
|
-
pointerEvents: 'auto',
|
|
134
|
-
}}
|
|
135
|
-
>
|
|
136
|
-
<Tooltip
|
|
137
|
-
title={tooltipTitle}
|
|
138
|
-
placement="top"
|
|
139
|
-
getPopupContainer={() => document.body}
|
|
140
|
-
zIndex={10001}
|
|
141
|
-
>
|
|
142
|
-
<Button
|
|
143
|
-
type="primary"
|
|
144
|
-
shape="circle"
|
|
145
|
-
icon={<EditOutlined />}
|
|
146
|
-
size="small"
|
|
147
|
-
onClick={handleButtonClick}
|
|
148
|
-
style={{
|
|
149
|
-
boxShadow: '0 2px 8px rgba(0,0,0,0.15)',
|
|
150
|
-
}}
|
|
151
|
-
/>
|
|
152
|
-
</Tooltip>
|
|
153
|
-
</div>
|
|
154
|
-
|
|
155
|
-
{/* Popover */}
|
|
156
|
-
{popoverVisible && (
|
|
157
|
-
<div
|
|
158
|
-
ref={popoverRef}
|
|
159
|
-
style={{
|
|
160
|
-
position: 'fixed',
|
|
161
|
-
top: popoverPosition?.top ?? (position?.y || 0) + 35,
|
|
162
|
-
left: popoverPosition?.left ?? (position?.x || 0),
|
|
163
|
-
zIndex: 10000,
|
|
164
|
-
pointerEvents: 'auto',
|
|
165
|
-
opacity: popoverPosition ? 1 : 0,
|
|
166
|
-
transition: 'opacity 0.1s ease-in-out',
|
|
167
|
-
}}
|
|
168
|
-
>
|
|
169
|
-
<BulkEditPopover
|
|
170
|
-
visible={editPopover.visible}
|
|
171
|
-
value={editPopover.value}
|
|
172
|
-
loading={editPopover.loading}
|
|
173
|
-
error={editPopover.error}
|
|
174
|
-
column={column}
|
|
175
|
-
range={range}
|
|
176
|
-
cellCount={cellCount}
|
|
177
|
-
onValueChange={onValueChange}
|
|
178
|
-
onSubmit={onSubmit}
|
|
179
|
-
onCancel={onCancel}
|
|
180
|
-
/>
|
|
181
|
-
</div>
|
|
182
|
-
)}
|
|
183
|
-
</>
|
|
184
|
-
);
|
|
185
|
-
};
|
|
186
|
-
|
|
187
|
-
export default BulkEditButton;
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
import React, { useState, useRef, useEffect } from 'react';
|
|
3
|
+
import { Button, Tooltip } from 'antd';
|
|
4
|
+
import { EditOutlined } from '@ant-design/icons';
|
|
5
|
+
import BulkEditPopover from './BulkEditPopover';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Floating button komponenta pro bulk edit
|
|
9
|
+
* @param {Object} props
|
|
10
|
+
* @param {boolean} props.visible - Viditelnost buttonu
|
|
11
|
+
* @param {Object} props.position - Pozice buttonu {x, y}
|
|
12
|
+
* @param {Object} props.range - AG Grid cell range
|
|
13
|
+
* @param {Object} props.column - AG Grid column objekt
|
|
14
|
+
* @param {number} props.cellCount - Počet buněk k editaci
|
|
15
|
+
* @param {Object} props.editPopover - State popoveru
|
|
16
|
+
* @param {Function} props.onOpenPopover - Handler pro otevření popoveru
|
|
17
|
+
* @param {Function} props.onValueChange - Handler pro změnu hodnoty
|
|
18
|
+
* @param {Function} props.onSubmit - Handler pro submit
|
|
19
|
+
* @param {Function} props.onCancel - Handler pro cancel
|
|
20
|
+
*/
|
|
21
|
+
const BulkEditButton = ({
|
|
22
|
+
visible,
|
|
23
|
+
position,
|
|
24
|
+
range,
|
|
25
|
+
column,
|
|
26
|
+
cellCount,
|
|
27
|
+
editPopover,
|
|
28
|
+
onOpenPopover,
|
|
29
|
+
onValueChange,
|
|
30
|
+
onSubmit,
|
|
31
|
+
onCancel,
|
|
32
|
+
}) => {
|
|
33
|
+
const [popoverVisible, setPopoverVisible] = useState(false);
|
|
34
|
+
const [popoverPosition, setPopoverPosition] = useState(null);
|
|
35
|
+
const buttonRef = useRef(null);
|
|
36
|
+
const popoverRef = useRef(null);
|
|
37
|
+
|
|
38
|
+
// Sync local popover state s parent editPopover state
|
|
39
|
+
useEffect(() => {
|
|
40
|
+
setPopoverVisible(editPopover.visible);
|
|
41
|
+
}, [editPopover.visible]);
|
|
42
|
+
|
|
43
|
+
// Viewport-aware positioning pro popover
|
|
44
|
+
useEffect(() => {
|
|
45
|
+
if (popoverVisible && popoverRef.current && position) {
|
|
46
|
+
requestAnimationFrame(() => {
|
|
47
|
+
const popoverRect = popoverRef.current.getBoundingClientRect();
|
|
48
|
+
const viewportWidth = window.innerWidth;
|
|
49
|
+
const viewportHeight = window.innerHeight;
|
|
50
|
+
const MARGIN = 10;
|
|
51
|
+
|
|
52
|
+
let top = position.y + 35;
|
|
53
|
+
let left = position.x;
|
|
54
|
+
|
|
55
|
+
if (left + popoverRect.width > viewportWidth - MARGIN) {
|
|
56
|
+
left = viewportWidth - popoverRect.width - MARGIN;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (left < MARGIN) {
|
|
60
|
+
left = MARGIN;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (top + popoverRect.height > viewportHeight - MARGIN) {
|
|
64
|
+
top = position.y - popoverRect.height - 5;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if (top < MARGIN) {
|
|
68
|
+
top = MARGIN;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
setPopoverPosition({ top, left });
|
|
72
|
+
});
|
|
73
|
+
} else {
|
|
74
|
+
setPopoverPosition(null);
|
|
75
|
+
}
|
|
76
|
+
}, [popoverVisible, position]);
|
|
77
|
+
|
|
78
|
+
if (!visible) return null;
|
|
79
|
+
|
|
80
|
+
const colDef = column?.getColDef();
|
|
81
|
+
const fieldName = colDef?.headerName || colDef?.field || 'Sloupec';
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Handler pro kliknutí na button
|
|
85
|
+
*/
|
|
86
|
+
const handleButtonClick = (e) => {
|
|
87
|
+
e.stopPropagation();
|
|
88
|
+
if (!popoverVisible) {
|
|
89
|
+
setPopoverVisible(true);
|
|
90
|
+
onOpenPopover();
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Handler pro kliknutí mimo popover (close)
|
|
96
|
+
*/
|
|
97
|
+
const handleClickOutside = (e) => {
|
|
98
|
+
if (
|
|
99
|
+
popoverVisible &&
|
|
100
|
+
popoverRef.current &&
|
|
101
|
+
!popoverRef.current.contains(e.target) &&
|
|
102
|
+
buttonRef.current &&
|
|
103
|
+
!buttonRef.current.contains(e.target)
|
|
104
|
+
) {
|
|
105
|
+
onCancel();
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
// Click outside listener
|
|
110
|
+
useEffect(() => {
|
|
111
|
+
if (popoverVisible) {
|
|
112
|
+
document.addEventListener('mousedown', handleClickOutside);
|
|
113
|
+
return () => {
|
|
114
|
+
document.removeEventListener('mousedown', handleClickOutside);
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
}, [popoverVisible]);
|
|
118
|
+
|
|
119
|
+
const tooltipTitle = `Hromadně změnit ${cellCount} ${
|
|
120
|
+
cellCount === 1 ? 'buňku' : cellCount < 5 ? 'buňky' : 'buněk'
|
|
121
|
+
} v "${fieldName}"`;
|
|
122
|
+
|
|
123
|
+
return (
|
|
124
|
+
<>
|
|
125
|
+
{/* Floating Button */}
|
|
126
|
+
<div
|
|
127
|
+
ref={buttonRef}
|
|
128
|
+
style={{
|
|
129
|
+
position: 'fixed',
|
|
130
|
+
top: position?.y || 0,
|
|
131
|
+
left: position?.x || 0,
|
|
132
|
+
zIndex: 9999,
|
|
133
|
+
pointerEvents: 'auto',
|
|
134
|
+
}}
|
|
135
|
+
>
|
|
136
|
+
<Tooltip
|
|
137
|
+
title={tooltipTitle}
|
|
138
|
+
placement="top"
|
|
139
|
+
getPopupContainer={() => document.body}
|
|
140
|
+
zIndex={10001}
|
|
141
|
+
>
|
|
142
|
+
<Button
|
|
143
|
+
type="primary"
|
|
144
|
+
shape="circle"
|
|
145
|
+
icon={<EditOutlined />}
|
|
146
|
+
size="small"
|
|
147
|
+
onClick={handleButtonClick}
|
|
148
|
+
style={{
|
|
149
|
+
boxShadow: '0 2px 8px rgba(0,0,0,0.15)',
|
|
150
|
+
}}
|
|
151
|
+
/>
|
|
152
|
+
</Tooltip>
|
|
153
|
+
</div>
|
|
154
|
+
|
|
155
|
+
{/* Popover */}
|
|
156
|
+
{popoverVisible && (
|
|
157
|
+
<div
|
|
158
|
+
ref={popoverRef}
|
|
159
|
+
style={{
|
|
160
|
+
position: 'fixed',
|
|
161
|
+
top: popoverPosition?.top ?? (position?.y || 0) + 35,
|
|
162
|
+
left: popoverPosition?.left ?? (position?.x || 0),
|
|
163
|
+
zIndex: 10000,
|
|
164
|
+
pointerEvents: 'auto',
|
|
165
|
+
opacity: popoverPosition ? 1 : 0,
|
|
166
|
+
transition: 'opacity 0.1s ease-in-out',
|
|
167
|
+
}}
|
|
168
|
+
>
|
|
169
|
+
<BulkEditPopover
|
|
170
|
+
visible={editPopover.visible}
|
|
171
|
+
value={editPopover.value}
|
|
172
|
+
loading={editPopover.loading}
|
|
173
|
+
error={editPopover.error}
|
|
174
|
+
column={column}
|
|
175
|
+
range={range}
|
|
176
|
+
cellCount={cellCount}
|
|
177
|
+
onValueChange={onValueChange}
|
|
178
|
+
onSubmit={onSubmit}
|
|
179
|
+
onCancel={onCancel}
|
|
180
|
+
/>
|
|
181
|
+
</div>
|
|
182
|
+
)}
|
|
183
|
+
</>
|
|
184
|
+
);
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
export default BulkEditButton;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
import React, { useRef, useEffect } from 'react';
|
|
3
|
+
import { Button, Space } from 'antd';
|
|
4
|
+
import ModuleDropdownList from '@bit.rhplus/ui2.module-dropdown-list';
|
|
5
|
+
|
|
6
|
+
const BulkEditModule = ({
|
|
7
|
+
value,
|
|
8
|
+
onChange,
|
|
9
|
+
onSubmit,
|
|
10
|
+
onCancel,
|
|
11
|
+
loading,
|
|
12
|
+
moduleDefinition,
|
|
13
|
+
placeholder = 'Vyberte hodnotu...',
|
|
14
|
+
}) => {
|
|
15
|
+
const moduleRef = useRef(null);
|
|
16
|
+
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
if (moduleRef.current) {
|
|
19
|
+
setTimeout(() => {
|
|
20
|
+
moduleRef.current?.focus();
|
|
21
|
+
}, 100);
|
|
22
|
+
}
|
|
23
|
+
}, []);
|
|
24
|
+
|
|
25
|
+
const handleKeyDown = (e) => {
|
|
26
|
+
if (e.key === 'Enter' && !loading) {
|
|
27
|
+
e.preventDefault();
|
|
28
|
+
onSubmit(value);
|
|
29
|
+
} else if (e.key === 'Escape') {
|
|
30
|
+
e.preventDefault();
|
|
31
|
+
onCancel();
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
return (
|
|
36
|
+
<>
|
|
37
|
+
<div style={{ marginBottom: '12px' }} onClick={(e) => e.stopPropagation()}>
|
|
38
|
+
<ModuleDropdownList
|
|
39
|
+
ref={moduleRef}
|
|
40
|
+
value={value}
|
|
41
|
+
onChange={onChange}
|
|
42
|
+
moduleDefinition={moduleDefinition}
|
|
43
|
+
placeholder={placeholder}
|
|
44
|
+
disabled={loading}
|
|
45
|
+
style={{ width: '100%' }}
|
|
46
|
+
onKeyDown={handleKeyDown}
|
|
47
|
+
displayMode="full"
|
|
48
|
+
/>
|
|
49
|
+
</div>
|
|
50
|
+
|
|
51
|
+
<Space style={{ width: '100%', justifyContent: 'flex-end' }}>
|
|
52
|
+
<Button size="small" onClick={onCancel} disabled={loading}>
|
|
53
|
+
Zrušit
|
|
54
|
+
</Button>
|
|
55
|
+
<Button
|
|
56
|
+
type="primary"
|
|
57
|
+
size="small"
|
|
58
|
+
onClick={() => onSubmit(value)}
|
|
59
|
+
loading={loading}
|
|
60
|
+
>
|
|
61
|
+
Použít
|
|
62
|
+
</Button>
|
|
63
|
+
</Space>
|
|
64
|
+
</>
|
|
65
|
+
);
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
export default BulkEditModule;
|
package/BulkEdit/index.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
/* eslint-disable */
|
|
2
|
-
export { useBulkCellEdit } from './useBulkCellEdit';
|
|
3
|
-
export { default as BulkEditButton } from './BulkEditButton';
|
|
4
|
-
export { default as BulkEditPopover } from './BulkEditPopover';
|
|
5
|
-
export { default as BulkEditSelect } from './BulkEditSelect';
|
|
6
|
-
export { default as BulkEditDatePicker } from './BulkEditDatePicker';
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
export { useBulkCellEdit } from './useBulkCellEdit';
|
|
3
|
+
export { default as BulkEditButton } from './BulkEditButton';
|
|
4
|
+
export { default as BulkEditPopover } from './BulkEditPopover';
|
|
5
|
+
export { default as BulkEditSelect } from './BulkEditSelect';
|
|
6
|
+
export { default as BulkEditDatePicker } from './BulkEditDatePicker';
|
|
7
|
+
export { default as BulkEditModule } from './BulkEditModule';
|
|
8
|
+
|
|
9
|
+
export * from './utils';
|
|
10
|
+
|
package/BulkEdit/utils.js
CHANGED
|
@@ -388,7 +388,11 @@ export const applyBulkChangesWithApi = async (
|
|
|
388
388
|
|
|
389
389
|
// Sestavit request podle bulkEditApi konfigurace
|
|
390
390
|
let requestData;
|
|
391
|
-
|
|
391
|
+
// mapRequest má přednost před lookup
|
|
392
|
+
if (bulkEditApi.mapRequest) {
|
|
393
|
+
// Custom mapRequest funkce
|
|
394
|
+
requestData = await bulkEditApi.mapRequest(ids, newValue, field, rows, fetchDataUIAsync, accessToken);
|
|
395
|
+
} else if (bulkEditApi.lookup) {
|
|
392
396
|
// Lookup pattern - automaticky vytvořit PATCH request
|
|
393
397
|
requestData = {
|
|
394
398
|
ids,
|
|
@@ -398,9 +402,6 @@ export const applyBulkChangesWithApi = async (
|
|
|
398
402
|
value: newValue
|
|
399
403
|
}]
|
|
400
404
|
};
|
|
401
|
-
} else if (bulkEditApi.mapRequest) {
|
|
402
|
-
// Custom mapRequest funkce
|
|
403
|
-
requestData = bulkEditApi.mapRequest(ids, newValue, field, rows);
|
|
404
405
|
} else {
|
|
405
406
|
// Fallback default
|
|
406
407
|
requestData = {
|
|
@@ -419,7 +420,11 @@ export const applyBulkChangesWithApi = async (
|
|
|
419
420
|
if (response.success) {
|
|
420
421
|
// Update grid - použít data z response nebo lokálně
|
|
421
422
|
let updatedData;
|
|
422
|
-
|
|
423
|
+
|
|
424
|
+
// Pokud existuje mapResponse, má přednost před automatickým lookup patternem
|
|
425
|
+
if (bulkEditApi.mapResponse) {
|
|
426
|
+
updatedData = await bulkEditApi.mapResponse(response.data, ids, rows, field, newValue, bulkEditApi, fetchDataUIAsync, accessToken);
|
|
427
|
+
} else if (bulkEditApi.lookup) {
|
|
423
428
|
// Lookup pattern - najít objekt v lookupData a aktualizovat rows
|
|
424
429
|
let selectedItem = null;
|
|
425
430
|
|
|
@@ -443,9 +448,6 @@ export const applyBulkChangesWithApi = async (
|
|
|
443
448
|
}
|
|
444
449
|
return row;
|
|
445
450
|
});
|
|
446
|
-
} else if (bulkEditApi.mapResponse) {
|
|
447
|
-
|
|
448
|
-
updatedData = bulkEditApi.mapResponse(response.data, ids, rows, field);
|
|
449
451
|
// } else if (response.data?.records) {
|
|
450
452
|
// // Mapovat response records (id + value) na existující rows
|
|
451
453
|
// Custom mapResponse funkce// updatedData = rows.map(row => {
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export default BulkEditModule;
|
|
2
|
+
declare function BulkEditModule({ value, onChange, onSubmit, onCancel, loading, moduleDefinition, placeholder, }: {
|
|
3
|
+
value: any;
|
|
4
|
+
onChange: any;
|
|
5
|
+
onSubmit: any;
|
|
6
|
+
onCancel: any;
|
|
7
|
+
loading: any;
|
|
8
|
+
moduleDefinition: any;
|
|
9
|
+
placeholder?: string | undefined;
|
|
10
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
import React, { useRef, useEffect } from 'react';
|
|
4
|
+
import { Button, Space } from 'antd';
|
|
5
|
+
import ModuleDropdownList from '@bit.rhplus/ui2.module-dropdown-list';
|
|
6
|
+
const BulkEditModule = ({ value, onChange, onSubmit, onCancel, loading, moduleDefinition, placeholder = 'Vyberte hodnotu...', }) => {
|
|
7
|
+
const moduleRef = useRef(null);
|
|
8
|
+
useEffect(() => {
|
|
9
|
+
if (moduleRef.current) {
|
|
10
|
+
setTimeout(() => {
|
|
11
|
+
moduleRef.current?.focus();
|
|
12
|
+
}, 100);
|
|
13
|
+
}
|
|
14
|
+
}, []);
|
|
15
|
+
const handleKeyDown = (e) => {
|
|
16
|
+
if (e.key === 'Enter' && !loading) {
|
|
17
|
+
e.preventDefault();
|
|
18
|
+
onSubmit(value);
|
|
19
|
+
}
|
|
20
|
+
else if (e.key === 'Escape') {
|
|
21
|
+
e.preventDefault();
|
|
22
|
+
onCancel();
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
return (_jsxs(_Fragment, { children: [_jsx("div", { style: { marginBottom: '12px' }, onClick: (e) => e.stopPropagation(), children: _jsx(ModuleDropdownList, { ref: moduleRef, value: value, onChange: onChange, moduleDefinition: moduleDefinition, placeholder: placeholder, disabled: loading, style: { width: '100%' }, onKeyDown: handleKeyDown, displayMode: "full" }) }), _jsxs(Space, { style: { width: '100%', justifyContent: 'flex-end' }, children: [_jsx(Button, { size: "small", onClick: onCancel, disabled: loading, children: "Zru\u0161it" }), _jsx(Button, { type: "primary", size: "small", onClick: () => onSubmit(value), loading: loading, children: "Pou\u017E\u00EDt" })] })] }));
|
|
26
|
+
};
|
|
27
|
+
export default BulkEditModule;
|
|
28
|
+
//# sourceMappingURL=BulkEditModule.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BulkEditModule.js","sourceRoot":"","sources":["../../BulkEdit/BulkEditModule.jsx"],"names":[],"mappings":";AAAA,oBAAoB;AACpB,OAAO,KAAK,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,kBAAkB,MAAM,sCAAsC,CAAC;AAEtE,MAAM,cAAc,GAAG,CAAC,EACtB,KAAK,EACL,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,OAAO,EACP,gBAAgB,EAChB,WAAW,GAAG,oBAAoB,GACnC,EAAE,EAAE;IACH,MAAM,SAAS,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;IAE/B,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,SAAS,CAAC,OAAO,EAAE,CAAC;YACtB,UAAU,CAAC,GAAG,EAAE;gBACd,SAAS,CAAC,OAAO,EAAE,KAAK,EAAE,CAAC;YAC7B,CAAC,EAAE,GAAG,CAAC,CAAC;QACV,CAAC;IACH,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,MAAM,aAAa,GAAG,CAAC,CAAC,EAAE,EAAE;QAC1B,IAAI,CAAC,CAAC,GAAG,KAAK,OAAO,IAAI,CAAC,OAAO,EAAE,CAAC;YAClC,CAAC,CAAC,cAAc,EAAE,CAAC;YACnB,QAAQ,CAAC,KAAK,CAAC,CAAC;QAClB,CAAC;aAAM,IAAI,CAAC,CAAC,GAAG,KAAK,QAAQ,EAAE,CAAC;YAC9B,CAAC,CAAC,cAAc,EAAE,CAAC;YACnB,QAAQ,EAAE,CAAC;QACb,CAAC;IACH,CAAC,CAAC;IAEF,OAAO,CACL,8BACE,cAAK,KAAK,EAAE,EAAE,YAAY,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,eAAe,EAAE,YACvE,KAAC,kBAAkB,IACjB,GAAG,EAAE,SAAS,EACd,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,QAAQ,EAClB,gBAAgB,EAAE,gBAAgB,EAClC,WAAW,EAAE,WAAW,EACxB,QAAQ,EAAE,OAAO,EACjB,KAAK,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,EACxB,SAAS,EAAE,aAAa,EACxB,WAAW,EAAC,MAAM,GAClB,GACE,EAEN,MAAC,KAAK,IAAC,KAAK,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,UAAU,EAAE,aACzD,KAAC,MAAM,IAAC,IAAI,EAAC,OAAO,EAAC,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,4BAEhD,EACT,KAAC,MAAM,IACL,IAAI,EAAC,SAAS,EACd,IAAI,EAAC,OAAO,EACZ,OAAO,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,EAC9B,OAAO,EAAE,OAAO,iCAGT,IACH,IACP,CACJ,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,cAAc,CAAC"}
|
package/dist/BulkEdit/index.d.ts
CHANGED
|
@@ -3,4 +3,5 @@ export { default as BulkEditButton } from "./BulkEditButton";
|
|
|
3
3
|
export { default as BulkEditPopover } from "./BulkEditPopover";
|
|
4
4
|
export { default as BulkEditSelect } from "./BulkEditSelect";
|
|
5
5
|
export { default as BulkEditDatePicker } from "./BulkEditDatePicker";
|
|
6
|
+
export { default as BulkEditModule } from "./BulkEditModule";
|
|
6
7
|
export * from "./utils";
|
package/dist/BulkEdit/index.js
CHANGED
|
@@ -4,5 +4,6 @@ export { default as BulkEditButton } from './BulkEditButton';
|
|
|
4
4
|
export { default as BulkEditPopover } from './BulkEditPopover';
|
|
5
5
|
export { default as BulkEditSelect } from './BulkEditSelect';
|
|
6
6
|
export { default as BulkEditDatePicker } from './BulkEditDatePicker';
|
|
7
|
+
export { default as BulkEditModule } from './BulkEditModule';
|
|
7
8
|
export * from './utils';
|
|
8
9
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../BulkEdit/index.js"],"names":[],"mappings":"AAAA,oBAAoB;AACpB,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../BulkEdit/index.js"],"names":[],"mappings":"AAAA,oBAAoB;AACpB,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AACrE,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAE7D,cAAc,SAAS,CAAC"}
|
package/dist/BulkEdit/utils.js
CHANGED
|
@@ -341,7 +341,12 @@ export const applyBulkChangesWithApi = async (range, newValue, gridApi, bulkEdit
|
|
|
341
341
|
}
|
|
342
342
|
// Sestavit request podle bulkEditApi konfigurace
|
|
343
343
|
let requestData;
|
|
344
|
-
|
|
344
|
+
// mapRequest má přednost před lookup
|
|
345
|
+
if (bulkEditApi.mapRequest) {
|
|
346
|
+
// Custom mapRequest funkce
|
|
347
|
+
requestData = await bulkEditApi.mapRequest(ids, newValue, field, rows, fetchDataUIAsync, accessToken);
|
|
348
|
+
}
|
|
349
|
+
else if (bulkEditApi.lookup) {
|
|
345
350
|
// Lookup pattern - automaticky vytvořit PATCH request
|
|
346
351
|
requestData = {
|
|
347
352
|
ids,
|
|
@@ -352,10 +357,6 @@ export const applyBulkChangesWithApi = async (range, newValue, gridApi, bulkEdit
|
|
|
352
357
|
}]
|
|
353
358
|
};
|
|
354
359
|
}
|
|
355
|
-
else if (bulkEditApi.mapRequest) {
|
|
356
|
-
// Custom mapRequest funkce
|
|
357
|
-
requestData = bulkEditApi.mapRequest(ids, newValue, field, rows);
|
|
358
|
-
}
|
|
359
360
|
else {
|
|
360
361
|
// Fallback default
|
|
361
362
|
requestData = {
|
|
@@ -368,7 +369,11 @@ export const applyBulkChangesWithApi = async (range, newValue, gridApi, bulkEdit
|
|
|
368
369
|
if (response.success) {
|
|
369
370
|
// Update grid - použít data z response nebo lokálně
|
|
370
371
|
let updatedData;
|
|
371
|
-
|
|
372
|
+
// Pokud existuje mapResponse, má přednost před automatickým lookup patternem
|
|
373
|
+
if (bulkEditApi.mapResponse) {
|
|
374
|
+
updatedData = await bulkEditApi.mapResponse(response.data, ids, rows, field, newValue, bulkEditApi, fetchDataUIAsync, accessToken);
|
|
375
|
+
}
|
|
376
|
+
else if (bulkEditApi.lookup) {
|
|
372
377
|
// Lookup pattern - najít objekt v lookupData a aktualizovat rows
|
|
373
378
|
let selectedItem = null;
|
|
374
379
|
// Pokud je newValue prázdné ("" nebo null), nastavit selectedItem na null
|
|
@@ -389,9 +394,6 @@ export const applyBulkChangesWithApi = async (range, newValue, gridApi, bulkEdit
|
|
|
389
394
|
}
|
|
390
395
|
return row;
|
|
391
396
|
});
|
|
392
|
-
}
|
|
393
|
-
else if (bulkEditApi.mapResponse) {
|
|
394
|
-
updatedData = bulkEditApi.mapResponse(response.data, ids, rows, field);
|
|
395
397
|
// } else if (response.data?.records) {
|
|
396
398
|
// // Mapovat response records (id + value) na existující rows
|
|
397
399
|
// Custom mapResponse funkce// updatedData = rows.map(row => {
|