@topconsultnpm/sdkui-react-beta 6.6.0 → 6.6.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/lib/components/base/TMContextMenu.d.ts +20 -21
- package/lib/components/base/TMContextMenu.js +101 -48
- package/lib/components/base/TMContextMenuOLD.d.ts +26 -0
- package/lib/components/base/TMContextMenuOLD.js +56 -0
- package/lib/components/base/TMListView.d.ts +22 -21
- package/lib/components/base/TMListView.js +245 -282
- package/lib/components/base/TMListViewOLD.d.ts +24 -0
- package/lib/components/base/TMListViewOLD.js +321 -0
- package/lib/components/choosers/TMDynDataListItemChooser.d.ts +37 -0
- package/lib/components/choosers/TMDynDataListItemChooser.js +128 -0
- package/lib/components/editors/TMTextArea.js +1 -1
- package/lib/components/editors/TMTextBox.js +2 -2
- package/lib/components/index.d.ts +4 -2
- package/lib/components/index.js +4 -2
- package/lib/components/query/TMQueryEditor.d.ts +38 -2
- package/lib/components/query/TMQueryEditor.js +189 -178
- package/lib/components/query/TMQueryResult.d.ts +4 -2
- package/lib/components/query/TMQueryResult.js +8 -9
- package/lib/components/query/TMQueryResultForm.d.ts +33 -0
- package/lib/components/query/TMQueryResultForm.js +362 -0
- package/lib/components/sidebar/TMHeader.d.ts +3 -1
- package/lib/components/sidebar/TMHeader.js +22 -106
- package/lib/components/viewers/TMTidViewer.js +1 -1
- package/lib/helper/SDKUI_Localizator.d.ts +3 -1
- package/lib/helper/SDKUI_Localizator.js +27 -7
- package/package.json +2 -2
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import React, { useEffect, useState } from 'react';
|
|
3
|
+
import styled from 'styled-components';
|
|
4
|
+
import { Colors, FontSize } from '../../utils/theme';
|
|
5
|
+
import { getColor } from '../../helper/helpers';
|
|
6
|
+
import { IconCloseCircle, IconDown, IconInsertAbove, IconInsertBelow, IconSearch, IconUp } from '../../helper';
|
|
7
|
+
const StyledContainer = styled.div `
|
|
8
|
+
z-index: -1;
|
|
9
|
+
border: 1px solid;
|
|
10
|
+
border-color: ${props => getColor(props.$color)} ;
|
|
11
|
+
overflow: auto;
|
|
12
|
+
max-height: ${props => props.$maxHight};
|
|
13
|
+
`;
|
|
14
|
+
const StyledListViewWrapper = styled.div `
|
|
15
|
+
display: flex;
|
|
16
|
+
flex-direction: column;
|
|
17
|
+
justify-content: flex-start;
|
|
18
|
+
align-items: flex-start;
|
|
19
|
+
font-size: ${props => props.$fontSize} ;
|
|
20
|
+
`;
|
|
21
|
+
const StyledListItemContainer = styled.div `
|
|
22
|
+
display: flex;
|
|
23
|
+
width: 100%;
|
|
24
|
+
flex-direction: row;
|
|
25
|
+
justify-content: space-between;
|
|
26
|
+
align-items: center;
|
|
27
|
+
padding: 5px;
|
|
28
|
+
background-color: ${props => !props.$isSelected ? props.$index % 2 === 0 ? 'white' : Colors.colore_sul_primary : Colors.secondary};
|
|
29
|
+
font-size: ${props => props.$fontSize};
|
|
30
|
+
color: ${props => !props.$isSelected ? Colors.primary : 'white'};
|
|
31
|
+
z-index: 1;
|
|
32
|
+
`;
|
|
33
|
+
const StyledLsitItemCheck = styled.input `
|
|
34
|
+
margin-right: 5px;
|
|
35
|
+
cursor: pointer;
|
|
36
|
+
`;
|
|
37
|
+
const StyledListItem = styled.li `
|
|
38
|
+
padding: 3px;
|
|
39
|
+
list-style: none;
|
|
40
|
+
text-decoration: none;
|
|
41
|
+
color: ${props => props.$color};
|
|
42
|
+
`;
|
|
43
|
+
const StyledListViewItemDetails = styled.div `
|
|
44
|
+
display: flex;
|
|
45
|
+
flex-direction: column;
|
|
46
|
+
align-items: flex-start;
|
|
47
|
+
justify-content: flex-start;
|
|
48
|
+
padding: 5px;
|
|
49
|
+
background-color: ${Colors.contenitore_su_colore_primary};
|
|
50
|
+
color: white;
|
|
51
|
+
width: 100%;
|
|
52
|
+
`;
|
|
53
|
+
const StyledDetailsToggleButton = styled.button `
|
|
54
|
+
border: none;
|
|
55
|
+
background-color: transparent;
|
|
56
|
+
cursor: pointer;
|
|
57
|
+
color: ${props => props.$isSelected ? 'white' : Colors.primary};
|
|
58
|
+
`;
|
|
59
|
+
const StyledListViewSearchContainer = styled.div `
|
|
60
|
+
position: sticky;
|
|
61
|
+
padding: 5px;
|
|
62
|
+
top: 0px;
|
|
63
|
+
display: flex;
|
|
64
|
+
flex-direction: row;
|
|
65
|
+
align-items: center;
|
|
66
|
+
justify-content: flex-start;
|
|
67
|
+
padding-bottom: 5px;
|
|
68
|
+
border-bottom: 1px solid ${props => getColor(props.$color)};
|
|
69
|
+
background-color: ${props => getColor(props.$color)};
|
|
70
|
+
z-index: 100;
|
|
71
|
+
`;
|
|
72
|
+
const StyledSelectOptionCheckBox = styled.input `
|
|
73
|
+
margin-right: 5px;
|
|
74
|
+
margin-left: 2px;
|
|
75
|
+
cursor: pointer;
|
|
76
|
+
width: 20px;
|
|
77
|
+
height: 20px;
|
|
78
|
+
`;
|
|
79
|
+
const StyledListViewSearchInput = styled.input `
|
|
80
|
+
width: 100%;
|
|
81
|
+
padding: 3px 10px;
|
|
82
|
+
border-radius: 5px;
|
|
83
|
+
border-width: 1px ;
|
|
84
|
+
border-color: ${props => getColor(props.$color)};
|
|
85
|
+
border-style: solid;
|
|
86
|
+
color: ${props => getColor(props.$color)};
|
|
87
|
+
&::placeholder{
|
|
88
|
+
color: ${props => getColor(props.$color)};
|
|
89
|
+
}
|
|
90
|
+
&:focus{
|
|
91
|
+
outline: none;
|
|
92
|
+
background-color: #fbf5ca;
|
|
93
|
+
}
|
|
94
|
+
`;
|
|
95
|
+
const StyledListViewSearchIcon = styled.button `
|
|
96
|
+
background-color: transparent;
|
|
97
|
+
border: none;
|
|
98
|
+
cursor: ${props => props.$isSearch ? 'pointer' : 'default'};
|
|
99
|
+
color: ${props => getColor(props.$color)};
|
|
100
|
+
position: absolute;
|
|
101
|
+
right: 10px;
|
|
102
|
+
top: 10px;
|
|
103
|
+
&:focus{
|
|
104
|
+
outline: ${props => !props.$isSearch && 'none'};
|
|
105
|
+
}
|
|
106
|
+
`;
|
|
107
|
+
const StyledListViewFooter = styled.div `
|
|
108
|
+
z-index: 100;
|
|
109
|
+
position: sticky;
|
|
110
|
+
bottom: 0px;
|
|
111
|
+
width: 100%;
|
|
112
|
+
padding: 5px;
|
|
113
|
+
background-color: ${props => getColor(props.$color)};
|
|
114
|
+
color: white;
|
|
115
|
+
font-size: 1rem;
|
|
116
|
+
`;
|
|
117
|
+
const StyledShowHideDetailsButton = styled.button `
|
|
118
|
+
background-color: transparent;
|
|
119
|
+
border: none;
|
|
120
|
+
margin-right: 10px;
|
|
121
|
+
/* color: ${props => getColor(props.$color)}; */
|
|
122
|
+
color: white;
|
|
123
|
+
cursor: pointer;
|
|
124
|
+
transform: translateY(1.5px);
|
|
125
|
+
`;
|
|
126
|
+
const TMListViewOLD = ({ maxHeight = '100%', selectedValues = [], color = 'primary', footer = false, header = false, customItemDetails, customListViewItem, hasItemDetails = false, detailsFields, dataSource, displayField, searchable, elementStyle, selectedListItems, multipleSelect = false, fontSize = FontSize.defaultFontSize }) => {
|
|
127
|
+
const [focusedItem, setFocusedItem] = useState(undefined);
|
|
128
|
+
const [selectedItems, setSelectedItems] = useState([]);
|
|
129
|
+
const [detailRequestItems, setDetailRequestItems] = useState([]);
|
|
130
|
+
const [currentDetailsFields, setCurrentDetailsField] = useState(detailsFields);
|
|
131
|
+
const [searchValue, setSearchValue] = useState('');
|
|
132
|
+
const [currentDataSource, setCurrentDataSource] = useState([]);
|
|
133
|
+
const [usedFields, setUsedFields] = useState([]);
|
|
134
|
+
useEffect(() => {
|
|
135
|
+
if (!selectedValues.fieldName) {
|
|
136
|
+
setSelectedItems(selectedValues);
|
|
137
|
+
}
|
|
138
|
+
else {
|
|
139
|
+
let data = [];
|
|
140
|
+
for (let value of selectedValues.fieldValues) {
|
|
141
|
+
for (let d of currentDataSource) {
|
|
142
|
+
if (value === d[selectedValues.fieldName]) {
|
|
143
|
+
data.push(d);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
setSelectedItems(data);
|
|
148
|
+
}
|
|
149
|
+
}, [currentDataSource]);
|
|
150
|
+
useEffect(() => { selectedListItems && selectedListItems(selectedItems); }, [selectedItems]);
|
|
151
|
+
useEffect(() => {
|
|
152
|
+
const selectByKey = (e) => { if (e.code === 'Space' && focusedItem) {
|
|
153
|
+
onListItemClick();
|
|
154
|
+
} };
|
|
155
|
+
window.addEventListener('keyup', selectByKey);
|
|
156
|
+
return () => window.removeEventListener('keyup', selectByKey);
|
|
157
|
+
}, [focusedItem, selectedItems]);
|
|
158
|
+
useEffect(() => {
|
|
159
|
+
let arr = [];
|
|
160
|
+
if (customListViewItem) {
|
|
161
|
+
for (let key of Object.keys(customListViewItem.props)) {
|
|
162
|
+
arr.push(customListViewItem.props[key]);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
else {
|
|
166
|
+
arr.push(displayField);
|
|
167
|
+
}
|
|
168
|
+
if (customItemDetails) {
|
|
169
|
+
for (let key of Object.keys(customItemDetails.props)) {
|
|
170
|
+
arr.push(customItemDetails.props[key]);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
else if (currentDetailsFields) {
|
|
174
|
+
for (let field of currentDetailsFields) {
|
|
175
|
+
arr.push(field);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
setUsedFields(arr);
|
|
179
|
+
}, [customItemDetails, customListViewItem, displayField, detailsFields]);
|
|
180
|
+
useEffect(() => {
|
|
181
|
+
if (hasItemDetails) {
|
|
182
|
+
let keys = Object.keys(dataSource[0]);
|
|
183
|
+
if (!displayField) {
|
|
184
|
+
let detailsKeys = keys.filter(key => key !== displayField);
|
|
185
|
+
if (!detailsFields) {
|
|
186
|
+
setCurrentDetailsField(detailsKeys);
|
|
187
|
+
}
|
|
188
|
+
else {
|
|
189
|
+
setCurrentDetailsField(detailsFields);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
else {
|
|
193
|
+
if (!detailsFields) {
|
|
194
|
+
setCurrentDetailsField(keys);
|
|
195
|
+
}
|
|
196
|
+
else {
|
|
197
|
+
setCurrentDetailsField(detailsFields);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
}, [hasItemDetails, detailsFields, displayField]);
|
|
202
|
+
useEffect(() => {
|
|
203
|
+
if (searchable) {
|
|
204
|
+
if (searchValue.length > 0) {
|
|
205
|
+
filter(dataSource, searchValue);
|
|
206
|
+
}
|
|
207
|
+
else {
|
|
208
|
+
setCurrentDataSource(dataSource);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
else {
|
|
212
|
+
setCurrentDataSource(dataSource);
|
|
213
|
+
}
|
|
214
|
+
}, [dataSource, searchValue, searchable]);
|
|
215
|
+
const showHideDetails = () => {
|
|
216
|
+
if (detailRequestItems.length > 0) {
|
|
217
|
+
setDetailRequestItems([]);
|
|
218
|
+
}
|
|
219
|
+
else {
|
|
220
|
+
setDetailRequestItems(currentDataSource);
|
|
221
|
+
}
|
|
222
|
+
};
|
|
223
|
+
const filter = (dataSource, value) => {
|
|
224
|
+
let arr = [];
|
|
225
|
+
for (let data of dataSource) {
|
|
226
|
+
if (typeof data === 'string') {
|
|
227
|
+
setCurrentDataSource(dataSource.filter(item => item.toString().toLowerCase().includes(value.toLowerCase())));
|
|
228
|
+
}
|
|
229
|
+
else {
|
|
230
|
+
for (let key of usedFields) {
|
|
231
|
+
if (data[key].toString().toLowerCase().includes(value.toLowerCase())) {
|
|
232
|
+
if (!arr.includes(data)) {
|
|
233
|
+
arr.push(data);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
;
|
|
238
|
+
setCurrentDataSource(arr);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
};
|
|
242
|
+
const onListItemClick = () => {
|
|
243
|
+
if (multipleSelect) {
|
|
244
|
+
if (!hasItem(selectedItems, focusedItem)) {
|
|
245
|
+
setSelectedItems(prev => [...prev, focusedItem]);
|
|
246
|
+
}
|
|
247
|
+
else {
|
|
248
|
+
(setSelectedItems(selectedItems.filter(item => JSON.stringify(item) !== JSON.stringify(focusedItem))));
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
else {
|
|
252
|
+
setSelectedItems([]);
|
|
253
|
+
setSelectedItems(prev => [...prev, focusedItem]);
|
|
254
|
+
}
|
|
255
|
+
};
|
|
256
|
+
const onCheckClick = () => { if (hasItem(selectedItems, focusedItem)) {
|
|
257
|
+
setSelectedItems(selectedItems.filter(item => JSON.stringify(item) !== JSON.stringify(focusedItem)));
|
|
258
|
+
} };
|
|
259
|
+
const detailsToggle = (e) => {
|
|
260
|
+
if (detailRequestItems.includes(focusedItem)) {
|
|
261
|
+
setDetailRequestItems(detailRequestItems.filter(item => item !== focusedItem));
|
|
262
|
+
}
|
|
263
|
+
else {
|
|
264
|
+
setDetailRequestItems(prev => [...prev, focusedItem]);
|
|
265
|
+
}
|
|
266
|
+
};
|
|
267
|
+
const obj = (data, type) => {
|
|
268
|
+
let object = {};
|
|
269
|
+
switch (type) {
|
|
270
|
+
case 'item':
|
|
271
|
+
for (let key of Object.keys(customListViewItem?.props)) {
|
|
272
|
+
object[key] = data[customListViewItem?.props[key]];
|
|
273
|
+
}
|
|
274
|
+
break;
|
|
275
|
+
case 'details':
|
|
276
|
+
for (let key of Object.keys(customItemDetails?.props)) {
|
|
277
|
+
object[key] = data[customItemDetails?.props[key]];
|
|
278
|
+
}
|
|
279
|
+
break;
|
|
280
|
+
}
|
|
281
|
+
return object;
|
|
282
|
+
};
|
|
283
|
+
const hasItem = (arr, el) => {
|
|
284
|
+
let bool = false;
|
|
285
|
+
for (let item of arr) {
|
|
286
|
+
if (typeof item === 'string') {
|
|
287
|
+
if (item === el) {
|
|
288
|
+
bool = true;
|
|
289
|
+
break;
|
|
290
|
+
}
|
|
291
|
+
else {
|
|
292
|
+
bool = false;
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
else {
|
|
296
|
+
if (JSON.stringify(item) == JSON.stringify(el)) {
|
|
297
|
+
bool = true;
|
|
298
|
+
break;
|
|
299
|
+
}
|
|
300
|
+
else {
|
|
301
|
+
bool = false;
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
return bool;
|
|
306
|
+
};
|
|
307
|
+
const selectDeselectAll = () => { if (selectedItems.length > 0) {
|
|
308
|
+
setSelectedItems([]);
|
|
309
|
+
}
|
|
310
|
+
else {
|
|
311
|
+
setSelectedItems(currentDataSource);
|
|
312
|
+
} };
|
|
313
|
+
const renderedList = () => {
|
|
314
|
+
return (currentDataSource?.map((d, index) => (_jsxs(StyledListViewWrapper, { "$fontSize": fontSize, children: [_jsxs(StyledListItemContainer, { "$isFocused": focusedItem === d, "$isSelected": hasItem(selectedItems, d), "$fontSize": fontSize, tabIndex: 0, "$index": index, onFocus: () => setFocusedItem(d), children: [_jsxs("div", { style: { display: 'flex', flexDirection: 'row', justifyContent: 'flex-start', alignItems: 'center', width: '100%' }, onClick: onListItemClick, children: [multipleSelect && _jsx(StyledLsitItemCheck, { checked: hasItem(selectedItems, d), onChange: onCheckClick, tabIndex: -1, type: "checkbox" }), !customListViewItem ? _jsx(StyledListItem, { "$color": color, children: displayField ? d[displayField] : d }) : React.cloneElement(customListViewItem, obj(d, 'item'))] }), hasItemDetails && _jsx(StyledDetailsToggleButton, { "$isSelected": hasItem(selectedItems, d), onClick: (e) => detailsToggle(e), children: detailRequestItems.includes(d) ? _jsx(IconUp, {}) : _jsx(IconDown, {}) })] }), detailRequestItems.includes(d) && _jsxs(StyledListViewItemDetails, { children: [" ", !customItemDetails ? currentDetailsFields.map((detail, index) => (_jsxs("div", { children: [detail, ": ", d[detail]] }, index))) : React.cloneElement(customItemDetails, obj(d, 'details')), " "] })] }, index))));
|
|
315
|
+
};
|
|
316
|
+
const renderedHeader = () => {
|
|
317
|
+
return (_jsxs(StyledListViewSearchContainer, { "$color": color, children: [multipleSelect && _jsx(StyledSelectOptionCheckBox, { "$color": color, "$fontsize": fontSize, type: 'checkbox', checked: selectedItems.length > 0, onChange: selectDeselectAll }), hasItemDetails && _jsx(StyledShowHideDetailsButton, { "$color": color, onClick: showHideDetails, children: detailRequestItems.length > 0 ? _jsx(IconInsertBelow, {}) : _jsx(IconInsertAbove, {}) }), searchable && _jsx(StyledListViewSearchInput, { "$color": color, value: searchValue, onChange: (e) => setSearchValue(e.target.value), placeholder: 'search' }), searchable && _jsx(StyledListViewSearchIcon, { onClick: () => searchValue.length > 0 && setSearchValue(''), "$isSearch": searchValue.length > 0, "$color": color, children: searchValue.length > 0 ? _jsx(IconCloseCircle, {}) : _jsx(IconSearch, {}) })] }));
|
|
318
|
+
};
|
|
319
|
+
return (_jsx("div", { style: elementStyle, children: _jsxs(StyledContainer, { "$maxHight": maxHeight, "$color": color, children: [" ", (searchable || multipleSelect) && renderedHeader(), " ", _jsx("ul", { children: renderedList() }), " ", multipleSelect && footer && _jsxs(StyledListViewFooter, { "$color": color, children: ["Selected items: ", selectedItems.length, " | Visible items: ", currentDataSource.length] })] }) }));
|
|
320
|
+
};
|
|
321
|
+
export default TMListViewOLD;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { DataListItemDescriptor, QueryDescriptor, DynamicDataListDescriptor, SearchResultDescriptor, MetadataDescriptor, LayoutModes } from '@topconsultnpm/sdk-ts-beta';
|
|
3
|
+
import { ITMChooserProps, ITMChooserFormProps } from '../../ts';
|
|
4
|
+
interface ITMDynDataListItemChooserProps extends ITMChooserProps {
|
|
5
|
+
/** TID della lista dati da gestire */
|
|
6
|
+
tid: number | undefined;
|
|
7
|
+
/** metadato della lista dati dinamica da gestire */
|
|
8
|
+
md: MetadataDescriptor | undefined;
|
|
9
|
+
/** Contesto di utilizzo */
|
|
10
|
+
layoutMode?: LayoutModes;
|
|
11
|
+
/** Contiene i values selezionati */
|
|
12
|
+
values?: string[];
|
|
13
|
+
/** Visualizza il bordo */
|
|
14
|
+
showBorder?: boolean;
|
|
15
|
+
/** Se presente, visualizza il bottone Pulisci ed esegue */
|
|
16
|
+
hasClear?: boolean;
|
|
17
|
+
/** Se presente, sono i parametri da passare alla query per recuperare il dataSource */
|
|
18
|
+
queryParamsDynDataList?: string[];
|
|
19
|
+
/** Indica quali liste dati dinamiche aggiornare in cascata */
|
|
20
|
+
onCascadeRefreshDynDataLists?: (dynDataListsToBeRefreshed: DynDataListsToBeRefreshed[]) => void;
|
|
21
|
+
}
|
|
22
|
+
export declare const IsParametricQuery: (qd: QueryDescriptor | undefined) => boolean;
|
|
23
|
+
export type DynDataListsToBeRefreshed = {
|
|
24
|
+
mid: number | undefined;
|
|
25
|
+
queryParams: string[];
|
|
26
|
+
midStarter: number | undefined;
|
|
27
|
+
};
|
|
28
|
+
declare const TMDynDataListItemChooser: React.FunctionComponent<ITMDynDataListItemChooserProps>;
|
|
29
|
+
export default TMDynDataListItemChooser;
|
|
30
|
+
interface ITMDynDataListItemChooserFormProps extends ITMChooserFormProps<DataListItemDescriptor> {
|
|
31
|
+
TID: number | undefined;
|
|
32
|
+
MID: number | undefined;
|
|
33
|
+
layoutMode?: LayoutModes;
|
|
34
|
+
dynDL?: DynamicDataListDescriptor;
|
|
35
|
+
searchResult?: SearchResultDescriptor;
|
|
36
|
+
}
|
|
37
|
+
export declare const TMDynDataListItemChooserForm: React.FunctionComponent<ITMDynDataListItemChooserFormProps>;
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useState } from 'react';
|
|
3
|
+
import { DataColumnTypes, SDK_Localizator, DataListCacheService, SDK_Globals, LayoutModes } from '@topconsultnpm/sdk-ts-beta';
|
|
4
|
+
import { Column } from 'devextreme-react/cjs/data-grid';
|
|
5
|
+
import { IconDetails, IconSearch, getDataColumnName, Globalization, SDKUI_Localizator, searchResultDescriptorToSimpleArray } from '../../helper';
|
|
6
|
+
import { StyledDivHorizontal } from '../base/Styled';
|
|
7
|
+
import { TMExceptionBoxManager } from '../base/TMPopUp';
|
|
8
|
+
import TMSpinner from '../base/TMSpinner';
|
|
9
|
+
import TMSummary from '../editors/TMSummary';
|
|
10
|
+
import TMChooserForm from '../forms/TMChooserForm';
|
|
11
|
+
//TODO: Spostare in SDK QueryEngine
|
|
12
|
+
export const IsParametricQuery = (qd) => {
|
|
13
|
+
if (qd == undefined)
|
|
14
|
+
return false;
|
|
15
|
+
if (qd.where == undefined)
|
|
16
|
+
return false;
|
|
17
|
+
let qp = "{@QueryParam";
|
|
18
|
+
for (const wi of qd.where) {
|
|
19
|
+
if (wi.value1?.includes(qp))
|
|
20
|
+
return true;
|
|
21
|
+
if (wi.value2?.includes(qp))
|
|
22
|
+
return true;
|
|
23
|
+
}
|
|
24
|
+
return false;
|
|
25
|
+
};
|
|
26
|
+
const TMDynDataListItemChooser = ({ tid, md, layoutMode = LayoutModes.None, queryParamsDynDataList, backgroundColor, showBorder = true, elementStyle, allowMultipleSelection, values, isModifiedWhen, label, placeHolder, validationItems = [], onValueChanged, onCascadeRefreshDynDataLists, hasClear }) => {
|
|
27
|
+
const [showChooser, setShowChooser] = useState(false);
|
|
28
|
+
const [dynDl, setDynDl] = useState();
|
|
29
|
+
const [dataSource, setDataSource] = useState();
|
|
30
|
+
useEffect(() => {
|
|
31
|
+
let d = md?.dynDL_Cfgs?.[0];
|
|
32
|
+
if (md?.dynDL_IsMultiCfg == 1) {
|
|
33
|
+
switch (layoutMode) {
|
|
34
|
+
case LayoutModes.None:
|
|
35
|
+
case LayoutModes.Update:
|
|
36
|
+
d = md?.dynDL_Cfgs?.[1];
|
|
37
|
+
break;
|
|
38
|
+
default:
|
|
39
|
+
d = md?.dynDL_Cfgs?.[0];
|
|
40
|
+
break;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
setDynDl(d);
|
|
44
|
+
// if (IsParametricQuery(d?.qd) && (queryParamsDynDataList?.length ?? 0) <= 0) return;
|
|
45
|
+
if (!IsParametricQuery(d?.qd) && !dataSource)
|
|
46
|
+
loadData().then((result) => { setDataSource(result); }).catch((err) => { TMExceptionBoxManager.show({ exception: err }); });
|
|
47
|
+
}, [md]);
|
|
48
|
+
useEffect(() => {
|
|
49
|
+
if (!IsParametricQuery(dynDl?.qd))
|
|
50
|
+
return;
|
|
51
|
+
if ((queryParamsDynDataList?.length ?? 0) <= 0) {
|
|
52
|
+
setDataSource(undefined);
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
loadData().then((result) => {
|
|
56
|
+
setDataSource(result);
|
|
57
|
+
if (values && values.length > 0) {
|
|
58
|
+
let description = result?.dtdResult?.rows?.filter(o => o[dynDl?.selectItemForValue ?? 0] == values?.[0])?.[0]?.[dynDl?.selectItemForDescription ?? 0];
|
|
59
|
+
if (!description)
|
|
60
|
+
onValueChanged?.(undefined);
|
|
61
|
+
}
|
|
62
|
+
}).catch((err) => { TMExceptionBoxManager.show({ exception: err }); });
|
|
63
|
+
}, [queryParamsDynDataList]);
|
|
64
|
+
const loadData = async () => {
|
|
65
|
+
return await SDK_Globals.tmSession?.NewSearchEngine().GetDynDataListValuesAsync(tid, md?.id, layoutMode, queryParamsDynDataList ?? []);
|
|
66
|
+
};
|
|
67
|
+
const renderTemplate = () => {
|
|
68
|
+
return (_jsxs(StyledDivHorizontal, { style: { minWidth: '125px' }, children: [placeHolder && (!values || values.length <= 0) && _jsx("p", { children: placeHolder }), values && values.length > 0 && dynDl && dataSource && _jsxs(StyledDivHorizontal, { children: [_jsx(IconDetails, {}), _jsx("p", { style: { marginLeft: '5px' }, children: dataSource.dtdResult?.rows?.filter(o => o[dynDl.selectItemForValue ?? 0] == values?.[0])?.[0]?.[dynDl.selectItemForDescription ?? 0] })] }), values && values.length > 1 && _jsx("p", { style: { marginLeft: '10px' }, children: `(+${values.length - 1} ${values.length == 2 ? 'altro' : 'altri'})` })] }));
|
|
69
|
+
};
|
|
70
|
+
return (_jsxs(_Fragment, { children: [_jsx(TMSummary, { backgroundColor: backgroundColor, showBorder: showBorder, iconEditButton: _jsx(IconSearch, {}), onEditorClick: () => setShowChooser(true), elementStyle: elementStyle, isModifiedWhen: isModifiedWhen, label: label, template: renderTemplate(), onClearClick: hasClear ? () => { onValueChanged?.([]); } : undefined, validationItems: validationItems }), showChooser &&
|
|
71
|
+
_jsx(TMDynDataListItemChooserForm, { TID: tid, MID: md?.id, dynDL: dynDl, allowMultipleSelection: allowMultipleSelection, searchResult: dataSource, selectedIDs: values, onClose: () => setShowChooser(false), onChoose: (IDs) => {
|
|
72
|
+
onValueChanged?.(IDs);
|
|
73
|
+
if (!dynDl)
|
|
74
|
+
return;
|
|
75
|
+
if (!dynDl.onValueChanged_DynDataListsToBeRefreshed)
|
|
76
|
+
return;
|
|
77
|
+
let row = dataSource?.dtdResult?.rows?.filter(o => o[dynDl.selectItemForValue ?? 0] == IDs?.[0]);
|
|
78
|
+
if (!row)
|
|
79
|
+
return;
|
|
80
|
+
let toBeRefreshed = [];
|
|
81
|
+
for (const t of dynDl.onValueChanged_DynDataListsToBeRefreshed) {
|
|
82
|
+
let mid = t.item1;
|
|
83
|
+
let queryParams = [];
|
|
84
|
+
if ((t.item2 ?? 0) >= 0)
|
|
85
|
+
queryParams.push(row[0][t.item2 ?? 0]);
|
|
86
|
+
if ((t.item3 ?? 0) >= 0)
|
|
87
|
+
queryParams.push(row[0][t.item3 ?? 0]);
|
|
88
|
+
if ((t.item4 ?? 0) >= 0)
|
|
89
|
+
queryParams.push(row[0][t.item4 ?? 0]);
|
|
90
|
+
if ((t.item5 ?? 0) >= 0)
|
|
91
|
+
queryParams.push(row[0][t.item5 ?? 0]);
|
|
92
|
+
toBeRefreshed.push({ mid: mid, queryParams: queryParams, midStarter: md?.id });
|
|
93
|
+
}
|
|
94
|
+
onCascadeRefreshDynDataLists?.(toBeRefreshed);
|
|
95
|
+
} })] }));
|
|
96
|
+
};
|
|
97
|
+
export default TMDynDataListItemChooser;
|
|
98
|
+
export const TMDynDataListItemChooserForm = (props) => {
|
|
99
|
+
// const renderDataGridColumns = [
|
|
100
|
+
// <Column key={0} dataField={"value"} caption={SDKUI_Localizator.Value} />,
|
|
101
|
+
// <Column key={1} dataField={"name"} caption={SDKUI_Localizator.Description} />
|
|
102
|
+
// ]
|
|
103
|
+
const renderDataGridColumns = props.searchResult?.dtdResult?.columns?.map((col, index) => {
|
|
104
|
+
let keyField = getDataColumnName(props.searchResult?.fromTID, col);
|
|
105
|
+
const isVisible = col.extendedProperties?.["Visibility"] != "Hidden";
|
|
106
|
+
const dataType = () => {
|
|
107
|
+
switch (col.dataType) {
|
|
108
|
+
case DataColumnTypes.DateTime: return "datetime";
|
|
109
|
+
case DataColumnTypes.Bool: return "boolean";
|
|
110
|
+
case DataColumnTypes.Number: return "number";
|
|
111
|
+
default: return "string";
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
return (_jsx(Column, { dataField: keyField, caption: col.caption, visible: isVisible, dataType: dataType(), format: col.dataType === DataColumnTypes.DateTime ? Globalization.getDateDisplayFormat() : "" }, col.caption + index.toString()));
|
|
115
|
+
});
|
|
116
|
+
const keyValue = props.searchResult ? getDataColumnName(props.searchResult?.fromTID, props.searchResult?.dtdResult?.columns?.[props.dynDL?.selectItemForValue ?? 0]) : '';
|
|
117
|
+
const getItems = async (refreshCache) => {
|
|
118
|
+
if (!props.searchResult)
|
|
119
|
+
return [];
|
|
120
|
+
if (refreshCache)
|
|
121
|
+
DataListCacheService.RemoveAll();
|
|
122
|
+
TMSpinner.show({ description: `${SDKUI_Localizator.Loading} - ${SDK_Localizator.DataList} ...` });
|
|
123
|
+
let result = await SDK_Globals.tmSession?.NewSearchEngine().GetDynDataListValuesAsync(props.TID, props.MID, props.layoutMode, []);
|
|
124
|
+
TMSpinner.hide();
|
|
125
|
+
return result ? searchResultDescriptorToSimpleArray(result) ?? [] : [];
|
|
126
|
+
};
|
|
127
|
+
return (_jsx(TMChooserForm, { title: SDK_Localizator.DataLists, allowMultipleSelection: props.allowMultipleSelection, width: props.width, height: props.height, keyName: keyValue ?? '', showDefaultColumns: false, hasShowId: false, columns: renderDataGridColumns, selectedIDs: props.selectedIDs, cellRenderIcon: () => { return (_jsx(IconDetails, {})); }, dataSource: searchResultDescriptorToSimpleArray(props.searchResult) ?? [], getItems: getItems, onClose: props.onClose, onChoose: (IDs) => props.onChoose?.(IDs) }));
|
|
128
|
+
};
|
|
@@ -3,7 +3,7 @@ import { useState, useEffect, useRef } from 'react';
|
|
|
3
3
|
import { StyledEditorButtonIcon, StyledEditorContainer, StyledEditorIcon, StyledEditorLabel, StyledTextareaEditor } from './TMEditorStyled';
|
|
4
4
|
import { FontSize } from '../../utils/theme';
|
|
5
5
|
import { useWindowWidth } from '../../helper';
|
|
6
|
-
import TMContextMenu, { useContextMenu } from '../base/
|
|
6
|
+
import TMContextMenu, { useContextMenu } from '../base/TMContextMenuOLD';
|
|
7
7
|
import { TMExceptionBoxManager } from '../base/TMPopUp';
|
|
8
8
|
import TMLayoutContainer, { TMLayoutItem } from '../base/TMLayout';
|
|
9
9
|
import TMVilViewer from '../base/TMVilViewer';
|
|
@@ -4,7 +4,7 @@ import styled from 'styled-components';
|
|
|
4
4
|
import { StyledEditor, StyledEditorButtonIcon, StyledEditorContainer, StyledEditorIcon, StyledEditorLabel, editorColorManager } from './TMEditorStyled';
|
|
5
5
|
import { FontSize, TMColors } from '../../utils/theme';
|
|
6
6
|
import { IconHide, IconShow, useWindowWidth } from '../../helper';
|
|
7
|
-
import TMContextMenu, { useContextMenu } from '../base/
|
|
7
|
+
import TMContextMenu, { useContextMenu } from '../base/TMContextMenuOLD';
|
|
8
8
|
import ShowAlert from '../base/TMAlert';
|
|
9
9
|
import { TMExceptionBoxManager } from '../base/TMPopUp';
|
|
10
10
|
import TMLayoutContainer, { TMLayoutItem } from '../base/TMLayout';
|
|
@@ -91,7 +91,7 @@ const TMTextBox = ({ autoFocus, maxLength, precision, scale, validationItems = [
|
|
|
91
91
|
if (maxValue)
|
|
92
92
|
return maxValue;
|
|
93
93
|
// if (precision && (!scale || scale == 0)) return Number("9".repeat(precision ?? 0));
|
|
94
|
-
console.log(Number("9".repeat((precision ?? 0) - (scale ?? 0)) + '.' + "9".repeat(scale ?? 0)));
|
|
94
|
+
// console.log(Number("9".repeat((precision ?? 0) - (scale ?? 0)) + '.' + "9".repeat(scale ?? 0)));
|
|
95
95
|
if (precision || scale)
|
|
96
96
|
return Number("9".repeat((precision ?? 0) - (scale ?? 0)) + '.' + "9".repeat(scale ?? 0));
|
|
97
97
|
return Number(curValue);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export { default as ShowAlert } from './base/TMAlert';
|
|
2
2
|
export { default as TMButton } from './base/TMButton';
|
|
3
3
|
export { default as TMClosableList } from './base/TMClosableList';
|
|
4
|
-
export * from './base/
|
|
4
|
+
export * from './base/TMContextMenuOLD';
|
|
5
5
|
export { default as TMDropDownMenu } from './base/TMDropDownMenu';
|
|
6
|
-
export { default as
|
|
6
|
+
export { default as TMListViewOLD } from './base/TMListViewOLD';
|
|
7
7
|
export { default as TMList } from './base/TMList';
|
|
8
8
|
export { default as TMModal } from './base/TMModal';
|
|
9
9
|
export * from './base/TMPopUp';
|
|
@@ -24,11 +24,13 @@ export { default as TMRadioButton } from './editors/TMRadioButton';
|
|
|
24
24
|
export { default as TMDateBox } from './editors/TMDateBox';
|
|
25
25
|
export { editorColorManager } from './editors/TMEditorStyled';
|
|
26
26
|
export * from './choosers/TMDataListItemChooser';
|
|
27
|
+
export * from './choosers/TMDynDataListItemChooser';
|
|
27
28
|
export * from './choosers/TMDcmtTypeChooser';
|
|
28
29
|
export * from './choosers/TMMetadataChooser';
|
|
29
30
|
export * from './choosers/TMUserChooser';
|
|
30
31
|
export { default as TMValidationItemsList } from './grids/TMValidationItemsList';
|
|
31
32
|
export * from './query/TMQueryEditor';
|
|
33
|
+
export * from './query/TMQueryResultForm';
|
|
32
34
|
export * from './base/TMTab';
|
|
33
35
|
export { default as TMHeader } from "./sidebar/TMHeader";
|
|
34
36
|
export { default as TMSidebar } from "./sidebar/TMSidebar";
|
package/lib/components/index.js
CHANGED
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
export { default as ShowAlert } from './base/TMAlert';
|
|
4
4
|
export { default as TMButton } from './base/TMButton';
|
|
5
5
|
export { default as TMClosableList } from './base/TMClosableList';
|
|
6
|
-
export * from './base/
|
|
6
|
+
export * from './base/TMContextMenuOLD';
|
|
7
7
|
export { default as TMDropDownMenu } from './base/TMDropDownMenu';
|
|
8
|
-
export { default as
|
|
8
|
+
export { default as TMListViewOLD } from './base/TMListViewOLD';
|
|
9
9
|
export { default as TMList } from './base/TMList';
|
|
10
10
|
export { default as TMModal } from './base/TMModal';
|
|
11
11
|
export * from './base/TMPopUp';
|
|
@@ -28,6 +28,7 @@ export { default as TMDateBox } from './editors/TMDateBox';
|
|
|
28
28
|
export { editorColorManager } from './editors/TMEditorStyled';
|
|
29
29
|
// choosers
|
|
30
30
|
export * from './choosers/TMDataListItemChooser';
|
|
31
|
+
export * from './choosers/TMDynDataListItemChooser';
|
|
31
32
|
export * from './choosers/TMDcmtTypeChooser';
|
|
32
33
|
export * from './choosers/TMMetadataChooser';
|
|
33
34
|
export * from './choosers/TMUserChooser';
|
|
@@ -35,6 +36,7 @@ export * from './choosers/TMUserChooser';
|
|
|
35
36
|
export { default as TMValidationItemsList } from './grids/TMValidationItemsList';
|
|
36
37
|
//query
|
|
37
38
|
export * from './query/TMQueryEditor';
|
|
39
|
+
export * from './query/TMQueryResultForm';
|
|
38
40
|
//tab
|
|
39
41
|
export * from './base/TMTab';
|
|
40
42
|
// others
|
|
@@ -1,6 +1,28 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { QueryDescriptor, ValidationItem } from '@topconsultnpm/sdk-ts-beta';
|
|
2
|
+
import { MetadataDescriptor, QueryDescriptor, ValidationItem } from '@topconsultnpm/sdk-ts-beta';
|
|
3
3
|
import { ITMApplyFormProps, FormModes } from '../../ts';
|
|
4
|
+
import { DynDataListsToBeRefreshed } from '../choosers/TMDynDataListItemChooser';
|
|
5
|
+
export declare const StyledRowItem: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
6
|
+
export declare const StyledItemWrapper: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {
|
|
7
|
+
$borderRadius?: string;
|
|
8
|
+
}>> & string;
|
|
9
|
+
export declare const StyledAccordionItemContainer: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
10
|
+
export declare const StyledAccordionItemContent: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {
|
|
11
|
+
$disabled?: boolean;
|
|
12
|
+
}>> & string;
|
|
13
|
+
export declare const colorValue = "rgba(224,224,224,.5)";
|
|
14
|
+
export declare const colorBrackets = "rgba(209,52,56,.3)";
|
|
15
|
+
export declare const colorOperator = "rgba(16,124,16,.3)";
|
|
16
|
+
export declare const color1 = "#F5DD9C";
|
|
17
|
+
export declare const color2 = "rgba(15,108,189,.3)";
|
|
18
|
+
export declare const color3 = "rgb(199, 236, 172)";
|
|
19
|
+
export declare const color4 = "rgb(223, 204, 251)";
|
|
20
|
+
export declare const color5 = "rgb(249, 181, 114)";
|
|
21
|
+
export declare const color6 = "rgb(170, 215, 217)";
|
|
22
|
+
export declare const color7 = "rgb(243, 208, 215)";
|
|
23
|
+
export declare const color8 = "rgb(236, 202, 156)";
|
|
24
|
+
export declare const color9 = "rgb(137, 185, 173)";
|
|
25
|
+
export declare const colorX = "rgb(246, 245, 242)";
|
|
4
26
|
export declare enum Descriptors {
|
|
5
27
|
Query = 3
|
|
6
28
|
}
|
|
@@ -14,7 +36,7 @@ export declare function useOrchApplyForm<T>(d: Descriptors, formMode: FormModes,
|
|
|
14
36
|
applyData: () => void;
|
|
15
37
|
};
|
|
16
38
|
interface ITMQueryEditor extends ITMApplyFormProps<QueryDescriptor> {
|
|
17
|
-
|
|
39
|
+
runQdImmediately?: boolean;
|
|
18
40
|
validateSelect?: boolean;
|
|
19
41
|
validateOrderBy?: boolean;
|
|
20
42
|
showDistinct?: boolean;
|
|
@@ -22,6 +44,20 @@ interface ITMQueryEditor extends ITMApplyFormProps<QueryDescriptor> {
|
|
|
22
44
|
borderRadius?: string;
|
|
23
45
|
searchText?: string;
|
|
24
46
|
onFromTIDChanged?: (tid: number) => void;
|
|
47
|
+
onQDChanged?: (qd: QueryDescriptor) => void;
|
|
25
48
|
}
|
|
26
49
|
declare const TMQueryEditor: React.FunctionComponent<ITMQueryEditor>;
|
|
27
50
|
export default TMQueryEditor;
|
|
51
|
+
export declare const TMQdWhereItemValueEditor: ({ tid, value, queryParamsDynDataList, containerElement, allowMultipleSelection, autoFocus, numberOfOperands, md, onValueChanged, onValueChange, onCascadeRefreshDynDataLists }: {
|
|
52
|
+
tid: number | undefined;
|
|
53
|
+
value: string | undefined;
|
|
54
|
+
queryParamsDynDataList?: string[];
|
|
55
|
+
allowMultipleSelection: boolean;
|
|
56
|
+
numberOfOperands: number;
|
|
57
|
+
autoFocus: boolean;
|
|
58
|
+
containerElement: Element | undefined;
|
|
59
|
+
md: MetadataDescriptor | undefined;
|
|
60
|
+
onValueChanged?: (value: any) => void;
|
|
61
|
+
onValueChange?: (value: any) => void;
|
|
62
|
+
onCascadeRefreshDynDataLists?: (dynDataListsToBeRefreshed: DynDataListsToBeRefreshed[]) => void;
|
|
63
|
+
}) => import("react/jsx-runtime").JSX.Element;
|