@topconsultnpm/sdkui-react-beta 6.12.42 → 6.12.44
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/features/archive/TMArchive.d.ts +6 -0
- package/lib/components/features/archive/TMArchive.js +57 -0
- package/lib/components/{query → features/documents}/TMBatchUpdateForm.d.ts +1 -1
- package/lib/components/{query → features/documents}/TMBatchUpdateForm.js +18 -18
- package/lib/components/{query → features/documents}/TMDcmtBlog.js +4 -4
- package/lib/components/{query → features/documents}/TMDcmtForm.d.ts +2 -2
- package/lib/components/{query → features/documents}/TMDcmtForm.js +22 -22
- package/lib/components/{query → features/documents}/TMDcmtIcon.js +2 -2
- package/lib/components/{query → features/documents}/TMDcmtPreview.d.ts +1 -1
- package/lib/components/{query → features/documents}/TMDcmtPreview.js +14 -14
- package/lib/components/{query → features/documents}/TMFileUploader.d.ts +1 -1
- package/lib/components/{query → features/documents}/TMFileUploader.js +10 -10
- package/lib/components/{query → features/documents}/TMMasterDetailDcmts.d.ts +3 -7
- package/lib/components/{query → features/documents}/TMMasterDetailDcmts.js +20 -20
- package/lib/components/features/search/TMSavedQueryForm.d.ts +9 -0
- package/lib/components/features/search/TMSavedQueryForm.js +41 -0
- package/lib/components/features/search/TMSavedQuerySelector.d.ts +16 -0
- package/lib/components/features/search/TMSavedQuerySelector.js +143 -0
- package/lib/components/features/search/TMSearch.d.ts +10 -0
- package/lib/components/features/search/TMSearch.js +188 -0
- package/lib/components/features/search/TMSearchQueryEditor.d.ts +15 -0
- package/lib/components/features/search/TMSearchQueryEditor.js +365 -0
- package/lib/components/features/search/TMSearchQueryPanel.d.ts +20 -0
- package/lib/components/features/search/TMSearchQueryPanel.js +296 -0
- package/lib/components/{search → features/search}/TMSearchResult.d.ts +2 -6
- package/lib/components/{search → features/search}/TMSearchResult.js +31 -31
- package/lib/components/{search → features/search}/TMSearchResultsMenuItems.d.ts +2 -2
- package/lib/components/{search → features/search}/TMSearchResultsMenuItems.js +5 -5
- package/lib/components/features/search/TMTreeSelector.d.ts +9 -0
- package/lib/components/features/search/TMTreeSelector.js +125 -0
- package/lib/components/{query → features/workflow}/TMWorkflowPopup.d.ts +1 -1
- package/lib/components/{query → features/workflow}/TMWorkflowPopup.js +8 -8
- package/lib/components/grids/TMBlogsUtils.d.ts +2 -1
- package/lib/components/grids/TMRecentsManager.d.ts +11 -0
- package/lib/components/grids/TMRecentsManager.js +45 -0
- package/lib/components/index.d.ts +5 -2
- package/lib/components/index.js +8 -2
- package/lib/components/query/TMQueryEditor.js +5 -8
- package/lib/helper/Enum_Localizator.d.ts +2 -1
- package/lib/helper/Enum_Localizator.js +9 -1
- package/lib/helper/SDKUI_Localizator.d.ts +9 -0
- package/lib/helper/SDKUI_Localizator.js +90 -0
- package/lib/ts/types.d.ts +11 -0
- package/package.json +2 -2
- package/lib/components/query/TMQueryResult.d.ts +0 -10
- package/lib/components/query/TMQueryResult.js +0 -42
- package/lib/components/query/TMQueryResultForm.d.ts +0 -17
- package/lib/components/query/TMQueryResultForm.js +0 -318
- /package/lib/components/{query → features/documents}/TMDcmtBlog.d.ts +0 -0
- /package/lib/components/{query → features/documents}/TMDcmtIcon.d.ts +0 -0
@@ -0,0 +1,188 @@
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
2
|
+
import { useCallback, useEffect, useState } from 'react';
|
3
|
+
import { SavedQueryCacheService, SDK_Globals, DcmtTypeListCacheService, SDK_Localizator, LocalStorageService } from '@topconsultnpm/sdk-ts-beta';
|
4
|
+
import TMSavedQuerySelector from './TMSavedQuerySelector';
|
5
|
+
import TMTreeSelector from './TMTreeSelector';
|
6
|
+
import { TabPanel, Item } from 'devextreme-react/tab-panel';
|
7
|
+
import TMSearchQueryPanel, { refreshLastSearch } from './TMSearchQueryPanel';
|
8
|
+
import { getSysAllDcmtsSQD, IconDataList, IconProgressReady, IconSavedQuery, IconTree, SDKUI_Globals, SDKUI_Localizator } from '../../../helper';
|
9
|
+
import TMLayoutContainer, { TMLayoutItem, TMSplitterLayout } from '../../base/TMLayout';
|
10
|
+
import TMToolbarCard from '../../base/TMToolbarCard';
|
11
|
+
import TMSearchResult from './TMSearchResult';
|
12
|
+
import TMRecentsManager from '../../grids/TMRecentsManager';
|
13
|
+
import { SearchResultContext } from '../../../ts';
|
14
|
+
import { useDeviceType, DeviceType } from '../../base/TMDeviceProvider';
|
15
|
+
var TMSearchViews;
|
16
|
+
(function (TMSearchViews) {
|
17
|
+
TMSearchViews[TMSearchViews["None"] = 0] = "None";
|
18
|
+
TMSearchViews[TMSearchViews["Result"] = 1] = "Result";
|
19
|
+
})(TMSearchViews || (TMSearchViews = {}));
|
20
|
+
const TMSearch = ({ inputTID, inputSqdID, onRefreshAfterAddDcmtToFavs, onTaskCreateRequest }) => {
|
21
|
+
const [allSQDs, setAllSQDs] = useState([]);
|
22
|
+
const [filteredByTIDSQDs, setFilteredByTIDSQDs] = useState([]);
|
23
|
+
const [currentSQD, setCurrentSQD] = useState();
|
24
|
+
const [currentTID, setCurrentTID] = useState(0);
|
25
|
+
const [currentMruTID, setCurrentMruTID] = useState(0);
|
26
|
+
const [fromDTD, setFromDTD] = useState();
|
27
|
+
const [searchResult, setSearchResult] = useState([]);
|
28
|
+
const [mruTIDs, setMruTIDs] = useState([]);
|
29
|
+
const [currentSearchView, setCurrentSearchView] = useState(TMSearchViews.None);
|
30
|
+
const [showDistinctValuesPanel, setShowDistinctValuesPanel] = useState(false);
|
31
|
+
const [showTreesPanel, setShowTreesPanel] = useState(true);
|
32
|
+
const [showRecentsPanel, setShowRecentsPanel] = useState(true);
|
33
|
+
const [showSavedQueryPanel, setShowSavedQueryPanel] = useState(true);
|
34
|
+
const [currentSQDMode, setCurrentSQDMode] = useState(1);
|
35
|
+
const [focusedTidMid, setFocusedTidMid] = useState();
|
36
|
+
const [lastQdSearched, setLastQdSearched] = useState();
|
37
|
+
const deviceType = useDeviceType();
|
38
|
+
useEffect(() => {
|
39
|
+
setMruTIDs(LocalStorageService.getItem(`SEARCHPAGE_MRU_TIDS_${SDK_Globals.tmSession?.SessionDescr?.archiveID}_${SDK_Globals.tmSession?.SessionDescr?.userID}`) ?? []);
|
40
|
+
loadDataSQDsAsync(false);
|
41
|
+
}, []);
|
42
|
+
useEffect(() => {
|
43
|
+
if (!inputTID)
|
44
|
+
return;
|
45
|
+
setCurrentTID(inputTID);
|
46
|
+
}, [inputTID]);
|
47
|
+
useEffect(() => {
|
48
|
+
if (inputSqdID) {
|
49
|
+
SavedQueryCacheService.GetAsync(inputSqdID).then(async (resultSqd) => {
|
50
|
+
await setSQDAsync(resultSqd);
|
51
|
+
});
|
52
|
+
}
|
53
|
+
}, [inputSqdID]);
|
54
|
+
useEffect(() => {
|
55
|
+
if (!currentTID || currentTID <= 0) {
|
56
|
+
setSearchResult([]);
|
57
|
+
return;
|
58
|
+
}
|
59
|
+
DcmtTypeListCacheService.GetAsync(currentTID).then(async (dtd) => {
|
60
|
+
setFromDTD(dtd);
|
61
|
+
let sqds = await getSQDsByTIDAsync(currentTID, allSQDs) ?? [];
|
62
|
+
setFilteredByTIDSQDs(sqds);
|
63
|
+
setCurrentSQDMode(0);
|
64
|
+
await setDefaultSQDAsync(sqds);
|
65
|
+
});
|
66
|
+
}, [currentTID]);
|
67
|
+
useEffect(() => {
|
68
|
+
if (currentSQD && currentSQD.masterTID != currentTID) {
|
69
|
+
DcmtTypeListCacheService.GetAsync(currentSQD.masterTID).then(async (dtd) => {
|
70
|
+
setFromDTD(dtd);
|
71
|
+
let sqds = await getSQDsByTIDAsync(currentSQD.masterTID, allSQDs) ?? [];
|
72
|
+
setFilteredByTIDSQDs(sqds);
|
73
|
+
setCurrentSQDMode(0);
|
74
|
+
});
|
75
|
+
}
|
76
|
+
}, [currentSQD]);
|
77
|
+
const loadDataSQDsAsync = async (refreshCache, curTID) => {
|
78
|
+
if (refreshCache) {
|
79
|
+
SavedQueryCacheService.RemoveAll();
|
80
|
+
SavedQueryCacheService.Remove();
|
81
|
+
}
|
82
|
+
let sqdCache = await SavedQueryCacheService.GetAllAsync() ?? [];
|
83
|
+
setAllSQDs(sqdCache);
|
84
|
+
let sqds = await getSQDsByTIDAsync(curTID ?? currentTID, allSQDs) ?? [];
|
85
|
+
setFilteredByTIDSQDs(sqds);
|
86
|
+
setCurrentSQDMode(0);
|
87
|
+
};
|
88
|
+
const getSQDsByTIDAsync = async (tid, allSQDList) => {
|
89
|
+
if (!tid)
|
90
|
+
return;
|
91
|
+
let sqds = allSQDList ? allSQDList.slice() : allSQDs.slice();
|
92
|
+
sqds = sqds.filter(o => o.masterTID == tid);
|
93
|
+
sqds.unshift(await getSysAllDcmtsSQD(tid, false));
|
94
|
+
return sqds;
|
95
|
+
};
|
96
|
+
const setDefaultSQDAsync = async (sqds) => {
|
97
|
+
let defaultSQD = sqds.find(o => o.isDefault == 1);
|
98
|
+
defaultSQD ??= sqds.find(o => o.id == 1);
|
99
|
+
if (defaultSQD)
|
100
|
+
defaultSQD.isDefault = 1;
|
101
|
+
if (defaultSQD) {
|
102
|
+
await setSQDAsync(defaultSQD);
|
103
|
+
}
|
104
|
+
};
|
105
|
+
const setSQDAsync = async (sqd) => {
|
106
|
+
let newSqd = (sqd?.id == 1) ? sqd : await SavedQueryCacheService.GetAsync(sqd?.id);
|
107
|
+
setCurrentSQD(newSqd);
|
108
|
+
if (!newSqd?.masterTID)
|
109
|
+
return;
|
110
|
+
if (newSqd?.masterTID !== currentTID)
|
111
|
+
setCurrentTID(0);
|
112
|
+
if (mruTIDs.includes(newSqd.masterTID))
|
113
|
+
setCurrentMruTID(newSqd.masterTID);
|
114
|
+
else
|
115
|
+
setCurrentMruTID(0);
|
116
|
+
};
|
117
|
+
const onSQDItemClick = useCallback(async (sqd, setSqdAsync) => {
|
118
|
+
await setSqdAsync(sqd);
|
119
|
+
}, []);
|
120
|
+
const onSQDDeleted = useCallback(async (sqd, sqdToBeSet, setSqdAsync) => {
|
121
|
+
await loadDataSQDsAsync(true, sqd.masterTID);
|
122
|
+
if (sqdToBeSet)
|
123
|
+
await setSqdAsync?.(sqdToBeSet);
|
124
|
+
}, []);
|
125
|
+
const rightSidebarItems = [
|
126
|
+
{ icon: _jsx(IconTree, {}), id: 'trees', visibleName: 'Alberi', isActive: showTreesPanel, visible: true },
|
127
|
+
{ icon: _jsx(IconProgressReady, {}), id: 'recents', visibleName: 'Recenti', isActive: showRecentsPanel, visible: true, },
|
128
|
+
{ icon: _jsx(IconSavedQuery, {}), id: 'savedquery', visibleName: 'Ricerche rapide', isActive: showSavedQueryPanel, visible: true },
|
129
|
+
{ icon: _jsx(IconDataList, {}), id: 'DistinctValues', visibleName: 'Valori distiniti', isActive: showDistinctValuesPanel, disabled: !focusedTidMid, visible: true }
|
130
|
+
];
|
131
|
+
const rightSidebarItemClickHandler = (item) => {
|
132
|
+
switch (item.toLowerCase()) {
|
133
|
+
case 'trees':
|
134
|
+
setShowTreesPanel(!showTreesPanel);
|
135
|
+
break;
|
136
|
+
case 'recents':
|
137
|
+
setShowRecentsPanel(!showRecentsPanel);
|
138
|
+
break;
|
139
|
+
case 'savedquery':
|
140
|
+
setShowSavedQueryPanel(!showSavedQueryPanel);
|
141
|
+
break;
|
142
|
+
case 'distinctvalues':
|
143
|
+
setShowDistinctValuesPanel(!showDistinctValuesPanel);
|
144
|
+
break;
|
145
|
+
default: break;
|
146
|
+
}
|
147
|
+
};
|
148
|
+
return (_jsxs(TMLayoutContainer, { direction: 'vertical', children: [_jsx("div", { style: { position: (currentSearchView === TMSearchViews.None) ? 'relative' : 'absolute', left: (currentSearchView === TMSearchViews.None) ? '0px' : '-9999px', top: (currentSearchView === TMSearchViews.None) ? '0px' : '-9999px', visibility: (currentSearchView === TMSearchViews.None) ? 'visible' : 'hidden', display: "flex", flexDirection: "column", height: "100%", width: '100%' }, children: _jsxs(TMSplitterLayout, { direction: 'horizontal', showSeparator: deviceType !== DeviceType.MOBILE && showTreesPanel, separatorSize: 8, separatorColor: 'transparent', separatorActiveColor: 'transparent', min: ['0', '0'], start: (deviceType === DeviceType.MOBILE) ? ['100%', '0%'] : showTreesPanel ? [SDKUI_Globals.userAppSettings?.searchSettings?.filterPageSettings?.treePanel?.size ?? '50px', '80%'] : ['0%', '100%'], children: [deviceType !== DeviceType.MOBILE && _jsx(TMTreeSelector, { onClose: () => setShowTreesPanel(false), onSelectedTIDChanged: (tid) => {
|
149
|
+
setCurrentTID(tid);
|
150
|
+
if (tid && mruTIDs.includes(tid))
|
151
|
+
setCurrentMruTID(tid);
|
152
|
+
else
|
153
|
+
setCurrentMruTID(0);
|
154
|
+
} }), _jsxs(TMSplitterLayout, { direction: 'horizontal', showSeparator: deviceType !== DeviceType.MOBILE && showSavedQueryPanel && !showDistinctValuesPanel, separatorSize: 8, separatorColor: 'transparent', separatorActiveColor: 'transparent', min: ['0', '0'], start: (deviceType === DeviceType.MOBILE || showDistinctValuesPanel) ? ['100%', '0%'] : ((showSavedQueryPanel) ? ['70%', '30%'] : ['100%', '0%']), children: [_jsx(TMLayoutItem, { children: _jsxs(TMSplitterLayout, { direction: 'horizontal', showSeparator: deviceType !== DeviceType.MOBILE && showRecentsPanel, separatorSize: 8, separatorColor: 'transparent', separatorActiveColor: 'transparent', min: ['0', '0'], start: deviceType === DeviceType.DESKTOP ? (showRecentsPanel ? ['30%', '70%'] : ['0%', '100%']) : (currentTID ? ['0%', '100%'] : ['100%', '0%']), children: [_jsx(TMToolbarCard, { title: "Scorciatoie", totalItems: mruTIDs.length, onClose: () => setShowRecentsPanel(false), children: _jsx(TMRecentsManager, { mruTIDs: mruTIDs, currentMruTID: currentMruTID, deviceType: deviceType, onSelectedTID: (tid) => { setCurrentMruTID(tid); setCurrentTID(tid); }, onDeletedTID: (tid) => {
|
155
|
+
let newMruTIDS = mruTIDs.slice();
|
156
|
+
let index = newMruTIDS.findIndex(o => o == tid);
|
157
|
+
if (index >= 0)
|
158
|
+
newMruTIDS.splice(index, 1);
|
159
|
+
LocalStorageService.setItem(`SEARCHPAGE_MRU_TIDS_${SDK_Globals.tmSession?.SessionDescr?.archiveID}_${SDK_Globals.tmSession?.SessionDescr?.userID}`, newMruTIDS.filter(tid => tid != undefined && tid != null));
|
160
|
+
setMruTIDs(newMruTIDS);
|
161
|
+
} }) }), _jsx(TMSearchQueryPanel, { fromDTD: fromDTD, SQD: currentSQD, isOpenDistinctValuesPanel: showDistinctValuesPanel, rightSidebarItems: rightSidebarItems, onFocusedMetadataChanged: setFocusedTidMid, onRightSidebarItemClick: rightSidebarItemClickHandler, onCloseDistinctValuesPanel: () => setShowDistinctValuesPanel(false), onSearchCompleted: (searchResult, qd) => {
|
162
|
+
setSearchResult(searchResult);
|
163
|
+
setLastQdSearched(qd);
|
164
|
+
setCurrentSearchView(TMSearchViews.Result);
|
165
|
+
// Salvataggio ultimi 10 TIDs
|
166
|
+
let fromTID = searchResult?.[0].fromTID;
|
167
|
+
let newMruTIDS = mruTIDs.slice();
|
168
|
+
let index = newMruTIDS.findIndex(o => o == fromTID);
|
169
|
+
if (index >= 0)
|
170
|
+
newMruTIDS.splice(index, 1);
|
171
|
+
if (newMruTIDS.length >= 10)
|
172
|
+
newMruTIDS.splice(0, 1);
|
173
|
+
newMruTIDS.push(fromTID);
|
174
|
+
setMruTIDs(newMruTIDS);
|
175
|
+
setCurrentMruTID(fromTID);
|
176
|
+
LocalStorageService.setItem(`SEARCHPAGE_MRU_TIDS_${SDK_Globals.tmSession?.SessionDescr?.archiveID}_${SDK_Globals.tmSession?.SessionDescr?.userID}`, newMruTIDS.filter(tid => tid != undefined && tid != null));
|
177
|
+
}, onSqdSaved: async (newSqd) => {
|
178
|
+
await loadDataSQDsAsync(true, newSqd.masterTID);
|
179
|
+
await setSQDAsync(newSqd);
|
180
|
+
} })] }) }), _jsx(TMLayoutItem, { children: _jsx(TMToolbarCard, { title: SDK_Localizator.SavedQueries, onClose: () => setShowSavedQueryPanel(false), children: _jsxs(TabPanel, { width: "100%", height: "100%", showNavButtons: true, repaintChangesOnly: true, selectedIndex: currentSQDMode, onSelectedIndexChange: (index) => setCurrentSQDMode(index), children: [(currentTID || currentSQD) ? _jsx(Item, { title: fromDTD?.nameLoc, children: _jsx(TMSavedQuerySelector, { allowShowSearch: false, items: filteredByTIDSQDs, selectedId: currentSQD?.id, onRefreshData: () => loadDataSQDsAsync(true), onItemClick: (sqd) => onSQDItemClick(sqd, setSQDAsync), onDeleted: (sqd) => onSQDDeleted(sqd, sqd.id == currentSQD?.id ? filteredByTIDSQDs.find(o => o.id == 1) : currentSQD, setSQDAsync) }) }) : _jsx(_Fragment, {}), _jsx(Item, { title: SDKUI_Localizator.Alls2, children: _jsx(TMSavedQuerySelector, { allowShowSearch: true, items: allSQDs, manageDefault: false,
|
181
|
+
// selectedId={currentSQD?.id}
|
182
|
+
onItemClick: (sqd) => onSQDItemClick(sqd, setSQDAsync), onDeleted: (sqd) => onSQDDeleted(sqd, sqd.id == currentSQD?.id ? undefined : currentSQD, setSQDAsync) }) })] }) }) })] })] }) }, 'div-1'), _jsx("div", { style: { position: (currentSearchView === TMSearchViews.Result) ? 'relative' : 'absolute', left: (currentSearchView === TMSearchViews.Result) ? '0px' : '-9999px', top: (currentSearchView === TMSearchViews.Result) ? '0px' : '-9999px', visibility: (currentSearchView === TMSearchViews.Result) ? 'visible' : 'hidden', display: "flex", flexDirection: "column", height: "100%", width: '100%' }, children: searchResult.length > 0 &&
|
183
|
+
_jsx(TMSearchResult, { context: SearchResultContext.METADATA_SEARCH, searchResults: searchResult, onRefreshAfterAddDcmtToFavs: onRefreshAfterAddDcmtToFavs, onRefreshSearchAsync: async () => {
|
184
|
+
// setSearchResult([]);
|
185
|
+
setSearchResult(await refreshLastSearch(lastQdSearched) ?? []);
|
186
|
+
}, onTaskCreateRequest: onTaskCreateRequest, onClose: () => { setCurrentSearchView(TMSearchViews.None); } }) }, 'div-2')] }));
|
187
|
+
};
|
188
|
+
export default TMSearch;
|
@@ -0,0 +1,15 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { DcmtTypeDescriptor, QueryDescriptor } from '@topconsultnpm/sdk-ts-beta';
|
3
|
+
import { TID_MID } from '../../../ts';
|
4
|
+
interface ITMSearchQueryEditorProps {
|
5
|
+
qd: QueryDescriptor | undefined;
|
6
|
+
fromDTD?: DcmtTypeDescriptor;
|
7
|
+
dcmtTypesList?: DcmtTypeDescriptor[];
|
8
|
+
showAdvancedMenu?: boolean;
|
9
|
+
showAllMdWhere?: boolean;
|
10
|
+
isOpenDistinctValuesPanel: boolean;
|
11
|
+
onQdChanged?: (qd: QueryDescriptor) => void;
|
12
|
+
onFocusedMetadataChanged?: (tid_mid: TID_MID | undefined) => void;
|
13
|
+
}
|
14
|
+
declare const TMSearchQueryEditor: React.FunctionComponent<ITMSearchQueryEditorProps>;
|
15
|
+
export default TMSearchQueryEditor;
|
@@ -0,0 +1,365 @@
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
2
|
+
import React, { useEffect, useState } from 'react';
|
3
|
+
import { LayoutModes, DcmtTypeListCacheService, PlatformObjectValidator, MetadataDataTypes, QueryOperators, DataListCacheService, MetadataDataDomains, SDK_Localizator, UserListCacheService } from '@topconsultnpm/sdk-ts-beta';
|
4
|
+
import styled from 'styled-components';
|
5
|
+
import { LocalizeQueryOperators, getDefaultOperator, SDKUI_Localizator, IconUndo, IconPencil, IconDataList, IconFunction, IconMenuVertical, IconClearButton, displayMetadataValue } from '../../../helper';
|
6
|
+
import { TMColors } from '../../../utils/theme';
|
7
|
+
import { StyledDivHorizontal } from '../../base/Styled';
|
8
|
+
import TMButton from '../../base/TMButton';
|
9
|
+
import { useDeviceType, DeviceType } from '../../base/TMDeviceProvider';
|
10
|
+
import TMDropDownMenu from '../../base/TMDropDownMenu';
|
11
|
+
import TMSpinner from '../../base/TMSpinner';
|
12
|
+
import { FormulaHelper } from '../../editors/TMFormulaEditor';
|
13
|
+
import TMMetadataEditor, { useMetadataEditableList } from '../../editors/TMMetadataEditor';
|
14
|
+
import { colorOperator, StyledItemWrapper, StyledRowItem } from '../../query/TMQueryEditor';
|
15
|
+
import { TMMidViewer } from '../../viewers/TMMidViewer';
|
16
|
+
const StyledMetadataListItem = styled.div `
|
17
|
+
padding: 5px;
|
18
|
+
border-radius: 8px;
|
19
|
+
height: max-content;
|
20
|
+
width: 100%;
|
21
|
+
/* box-shadow: 1px 1px 7px rgba(0,0,0,0.15); */
|
22
|
+
/* font-size: ${(props) => props.$isSelected ? '1.2rem' : '1rem'}; */
|
23
|
+
background: ${(props) => props.$isSelected ? props.$selectedColor : props.$backgroundColor};
|
24
|
+
|
25
|
+
&:hover {
|
26
|
+
background: ${(props) => props.$isSelected ? props.$selectedColor : props.$hoverColor};
|
27
|
+
cursor: pointer;
|
28
|
+
}
|
29
|
+
`;
|
30
|
+
const TMSearchQueryEditor = ({ qd, fromDTD, dcmtTypesList = [], isOpenDistinctValuesPanel, showAdvancedMenu, showAllMdWhere, onQdChanged, onFocusedMetadataChanged }) => {
|
31
|
+
const [dynDataListsToBeRefreshed, setDynDataListsToBeRefreshed] = useState([]);
|
32
|
+
const [showDistinctValuesPanel, setShowDistinctValuesPanel] = useState(false);
|
33
|
+
const [currentEditingMID, setCurrentEditingMID] = useState(0);
|
34
|
+
const [isEditableList, addOrRemoveEditableList] = useMetadataEditableList();
|
35
|
+
const [focusedTidMid, setFocusedTidMid] = useState();
|
36
|
+
const deviceType = useDeviceType();
|
37
|
+
let initialMaxItems = deviceType === DeviceType.MOBILE ? 8 : 12;
|
38
|
+
useEffect(() => { setShowDistinctValuesPanel(isOpenDistinctValuesPanel); }, [isOpenDistinctValuesPanel]);
|
39
|
+
useEffect(() => {
|
40
|
+
onFocusedMetadataChanged?.(focusedTidMid);
|
41
|
+
}, [focusedTidMid]);
|
42
|
+
const handleMetadataSelection = (tid, mid) => {
|
43
|
+
if (currentEditingMID !== mid)
|
44
|
+
setCurrentEditingMID(mid);
|
45
|
+
if (mid !== focusedTidMid?.mid)
|
46
|
+
setFocusedTidMid({ tid: tid, mid: mid });
|
47
|
+
};
|
48
|
+
const handleWhereItemChanged = (wi) => {
|
49
|
+
if (!wi)
|
50
|
+
return;
|
51
|
+
const whereCopy = qd?.where?.map((curItem) => {
|
52
|
+
if (curItem.mid != wi.mid)
|
53
|
+
return curItem;
|
54
|
+
return wi;
|
55
|
+
});
|
56
|
+
onQdChanged?.({ ...qd, where: whereCopy });
|
57
|
+
};
|
58
|
+
const getQueryOperatorsMenuItems = (wi, index) => {
|
59
|
+
const onChange_WhereItem_QueryOperator = (qo, index) => {
|
60
|
+
handleWhereItemChanged({ ...wi, operator: qo, value1: undefined, value2: undefined });
|
61
|
+
};
|
62
|
+
let items = [];
|
63
|
+
items.push({ text: LocalizeQueryOperators(QueryOperators.Equal), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.Equal, index) });
|
64
|
+
items.push({ text: LocalizeQueryOperators(QueryOperators.NotEqual), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.NotEqual, index) });
|
65
|
+
items.push({ text: LocalizeQueryOperators(QueryOperators.IsNull), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.IsNull, index) });
|
66
|
+
items.push({ text: LocalizeQueryOperators(QueryOperators.IsNotNull), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.IsNotNull, index) });
|
67
|
+
items.push({ text: LocalizeQueryOperators(QueryOperators.In), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.In, index) });
|
68
|
+
items.push({ text: LocalizeQueryOperators(QueryOperators.NotIn), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.NotIn, index) });
|
69
|
+
let md = fromDTD?.metadata?.find(o => o.id == wi.mid);
|
70
|
+
let mdDataType = md?.dataType;
|
71
|
+
if (mdDataType != MetadataDataTypes.Varchar) {
|
72
|
+
items.push({ text: LocalizeQueryOperators(QueryOperators.Greater), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.Greater, index) });
|
73
|
+
items.push({ text: LocalizeQueryOperators(QueryOperators.GreaterOrEqual), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.GreaterOrEqual, index) });
|
74
|
+
items.push({ text: LocalizeQueryOperators(QueryOperators.Less), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.Less, index) });
|
75
|
+
items.push({ text: LocalizeQueryOperators(QueryOperators.LessOrEqual), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.LessOrEqual, index) });
|
76
|
+
items.push({ text: LocalizeQueryOperators(QueryOperators.BetweenExclusive), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.BetweenExclusive, index) });
|
77
|
+
items.push({ text: LocalizeQueryOperators(QueryOperators.BetweenInclusive), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.BetweenInclusive, index) });
|
78
|
+
items.push({ text: LocalizeQueryOperators(QueryOperators.OutsideExclusive), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.OutsideExclusive, index) });
|
79
|
+
items.push({ text: LocalizeQueryOperators(QueryOperators.OutsideInclusive), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.OutsideInclusive, index) });
|
80
|
+
}
|
81
|
+
else {
|
82
|
+
items.push({ text: LocalizeQueryOperators(QueryOperators.Contain), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.Contain, index) });
|
83
|
+
items.push({ text: LocalizeQueryOperators(QueryOperators.NotContain), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.NotContain, index) });
|
84
|
+
items.push({ text: LocalizeQueryOperators(QueryOperators.BeginWith), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.BeginWith, index) });
|
85
|
+
items.push({ text: LocalizeQueryOperators(QueryOperators.NotBeginWith), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.NotBeginWith, index) });
|
86
|
+
items.push({ text: LocalizeQueryOperators(QueryOperators.EndWith), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.EndWith, index) });
|
87
|
+
items.push({ text: LocalizeQueryOperators(QueryOperators.NotEndWith), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.NotEndWith, index) });
|
88
|
+
items.push({ text: LocalizeQueryOperators(QueryOperators.Like), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.Like, index) });
|
89
|
+
items.push({ text: LocalizeQueryOperators(QueryOperators.NotLike), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.NotLike, index) });
|
90
|
+
}
|
91
|
+
items.push({ text: LocalizeQueryOperators(QueryOperators.Custom), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.Custom, index) });
|
92
|
+
if (mdDataType == MetadataDataTypes.DateTime) {
|
93
|
+
items.push({
|
94
|
+
text: "Operatori speciali", items: [
|
95
|
+
{ text: LocalizeQueryOperators(QueryOperators.Yesterday), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.Yesterday, index) },
|
96
|
+
{ text: LocalizeQueryOperators(QueryOperators.Today), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.Today, index) },
|
97
|
+
{ text: LocalizeQueryOperators(QueryOperators.Tomorrow), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.Tomorrow, index) },
|
98
|
+
{ text: LocalizeQueryOperators(QueryOperators.PreviousWeek), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.PreviousWeek, index) },
|
99
|
+
{ text: LocalizeQueryOperators(QueryOperators.ThisWeek), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.ThisWeek, index) },
|
100
|
+
{ text: LocalizeQueryOperators(QueryOperators.NextWeek), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.NextWeek, index) },
|
101
|
+
{ text: LocalizeQueryOperators(QueryOperators.PreviousMonth), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.PreviousMonth, index) },
|
102
|
+
{ text: LocalizeQueryOperators(QueryOperators.ThisMonth), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.ThisMonth, index) },
|
103
|
+
{ text: LocalizeQueryOperators(QueryOperators.NextMonth), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.NextMonth, index) },
|
104
|
+
{ text: LocalizeQueryOperators(QueryOperators.PreviousYear), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.PreviousYear, index) },
|
105
|
+
{ text: LocalizeQueryOperators(QueryOperators.ThisYear), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.ThisYear, index) },
|
106
|
+
{ text: LocalizeQueryOperators(QueryOperators.NextYear), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.NextYear, index) },
|
107
|
+
{ text: LocalizeQueryOperators(QueryOperators.LastXHours), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.LastXHours, index) },
|
108
|
+
{ text: LocalizeQueryOperators(QueryOperators.NextXHours), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.NextXHours, index) },
|
109
|
+
{ text: LocalizeQueryOperators(QueryOperators.LastXDays), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.LastXDays, index) },
|
110
|
+
{ text: LocalizeQueryOperators(QueryOperators.NextXDays), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.NextXDays, index) },
|
111
|
+
{ text: LocalizeQueryOperators(QueryOperators.LastXWeeks), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.LastXWeeks, index) },
|
112
|
+
{ text: LocalizeQueryOperators(QueryOperators.NextXWeeks), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.NextXWeeks, index) },
|
113
|
+
{ text: LocalizeQueryOperators(QueryOperators.LastXMonths), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.LastXMonths, index) },
|
114
|
+
{ text: LocalizeQueryOperators(QueryOperators.NextXMonths), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.NextXMonths, index) },
|
115
|
+
{ text: LocalizeQueryOperators(QueryOperators.LastXYears), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.LastXYears, index) },
|
116
|
+
{ text: LocalizeQueryOperators(QueryOperators.NextXYears), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.NextXYears, index) }
|
117
|
+
]
|
118
|
+
});
|
119
|
+
}
|
120
|
+
return items;
|
121
|
+
};
|
122
|
+
const getOperatorColor = (whereItem) => {
|
123
|
+
if (dcmtTypesList.length <= 0)
|
124
|
+
return 'green';
|
125
|
+
let dtd = dcmtTypesList.find(o => o.id === whereItem.tid);
|
126
|
+
let md = dtd?.metadata?.find(o => o.id === whereItem.mid);
|
127
|
+
return whereItem.operator === getDefaultOperator(md?.dataDomain, md?.dataType) ? 'green' : TMColors.tertiary;
|
128
|
+
};
|
129
|
+
const getAdvancedMenuItems = (tid, mid) => {
|
130
|
+
let isEditable = isEditableList(mid);
|
131
|
+
let dtd = dcmtTypesList.find(o => o.id == tid);
|
132
|
+
if (!dtd)
|
133
|
+
return [];
|
134
|
+
let md = dtd.metadata?.find(o => o.id == mid);
|
135
|
+
if (!md)
|
136
|
+
return [];
|
137
|
+
let menu = [
|
138
|
+
{ text: isEditable ? SDKUI_Localizator.Restore : SDKUI_Localizator.MakeEditable, icon: isEditable ? _jsx(IconUndo, {}) : _jsx(IconPencil, {}), onClick: () => { addOrRemoveEditableList(mid); } },
|
139
|
+
{ text: SDKUI_Localizator.DistinctValues, icon: _jsx(IconDataList, {}), onClick: () => { handleMetadataSelection(tid, mid); setShowDistinctValuesPanel(!showDistinctValuesPanel); } }
|
140
|
+
];
|
141
|
+
return menu;
|
142
|
+
};
|
143
|
+
return (_jsx(_Fragment, { children: deviceType === DeviceType.MOBILE ?
|
144
|
+
_jsx("div", { style: { overflow: 'auto', display: 'flex', flexDirection: 'column', height: '100%', padding: '5px', gap: '5px' }, children: qd?.where?.slice(0, showAllMdWhere ? qd?.where.length : initialMaxItems).map((wi, index) => (_jsx(StyledMetadataListItem, { id: `wi-item-${wi.mid}`, onClick: () => { handleMetadataSelection(wi.tid, wi.mid); }, onFocus: () => { handleMetadataSelection(wi.tid, wi.mid); }, "$backgroundColor": !PlatformObjectValidator.WhereItemHasValues(wi) ? `${TMColors.primary}66` : 'rgba(236, 202, 156, 1)', "$hoverColor": !PlatformObjectValidator.WhereItemHasValues(wi) ? `${TMColors.primary}33` : 'rgba(236, 202, 156, .5)', children: _jsx(TMSearchWhereItemCard, { isSelected: showDistinctValuesPanel && wi.mid === focusedTidMid?.mid, index: index, whereItem: wi, showEditor: currentEditingMID == wi.mid, isEditableList: isEditableList(wi.mid), queryParamsDynDataList: dynDataListsToBeRefreshed.find(o => o.mid == wi.mid)?.queryParams ?? [], onCascadeRefreshDynDataLists: (ddlToBeRefreshed) => {
|
145
|
+
let newDynDataListsToBeRefreshed = [];
|
146
|
+
for (const item of dynDataListsToBeRefreshed) {
|
147
|
+
let index = ddlToBeRefreshed.findIndex(o => o.mid == item.mid || (o.mid == -1 && o.midStarter == item.midStarter));
|
148
|
+
if (index >= 0)
|
149
|
+
continue;
|
150
|
+
newDynDataListsToBeRefreshed.push(item);
|
151
|
+
}
|
152
|
+
for (const item of ddlToBeRefreshed) {
|
153
|
+
if (item.queryParams.length <= 0)
|
154
|
+
continue;
|
155
|
+
if (!item.mid)
|
156
|
+
continue;
|
157
|
+
if (item.mid <= 0)
|
158
|
+
continue;
|
159
|
+
newDynDataListsToBeRefreshed.push(item);
|
160
|
+
}
|
161
|
+
setDynDataListsToBeRefreshed(newDynDataListsToBeRefreshed);
|
162
|
+
}, onCascadeUpdateMIDs: (midsToBeUpdated) => {
|
163
|
+
for (const item of midsToBeUpdated) {
|
164
|
+
const whereItem = qd?.where?.find(o => o.mid === item.mid);
|
165
|
+
if (whereItem) {
|
166
|
+
whereItem.value1 = item.value;
|
167
|
+
handleWhereItemChanged(whereItem);
|
168
|
+
}
|
169
|
+
}
|
170
|
+
}, onWhereItemChange: (newWi) => { handleWhereItemChanged(newWi); }, onHideEditor: () => { setCurrentEditingMID(0); } }) }, `${wi.tid}_${wi.mid}_${index}`))) })
|
171
|
+
:
|
172
|
+
_jsx("div", { style: { display: 'grid', borderRadius: '8px', alignItems: 'center', overflow: 'auto', padding: '5px', gap: '8px', gridTemplateColumns: 'minmax(0, max-content) minmax(0, max-content) minmax(50%, 1fr)' }, children: qd?.where?.slice(0, showAllMdWhere ? qd?.where.length : initialMaxItems).map((whereItem, index) => {
|
173
|
+
return (_jsxs(React.Fragment, { children: [_jsx("div", { id: `wi-item-${whereItem.mid}`, style: { gridColumn: 1 }, children: _jsx(TMMidViewer, { isMetadataSelected: showDistinctValuesPanel && whereItem.mid === focusedTidMid?.mid, showIcon: true, tid_mid: { tid: whereItem?.tid, mid: whereItem?.mid, aliasTID: whereItem?.alias } }) }), _jsx("div", { style: { gridColumn: 2, paddingLeft: '5px', paddingRight: '5px' }, children: _jsx(TMDropDownMenu, { backgroundColor: colorOperator, color: getOperatorColor(whereItem), items: getQueryOperatorsMenuItems(whereItem, index), content: _jsx(StyledItemWrapper, { children: LocalizeQueryOperators(whereItem.operator) }) }) }), _jsxs("div", { style: { gridColumn: 3, position: 'relative' }, onClick: () => { handleMetadataSelection(whereItem.tid, whereItem.mid); }, onFocus: () => { handleMetadataSelection(whereItem.tid, whereItem.mid); }, children: [_jsx(TMSearchWhereItemEditor, { isSelected: showDistinctValuesPanel && whereItem.mid === focusedTidMid?.mid, openChooserBySingleClick: !showDistinctValuesPanel, whereItem: whereItem, index: index, isEditableList: isEditableList(whereItem.mid), queryParamsDynDataList: dynDataListsToBeRefreshed.find(o => o.mid == whereItem.mid)?.queryParams ?? [], onValueChanged: (values) => {
|
174
|
+
handleWhereItemChanged({ ...whereItem, value1: values[0], value2: values[1] });
|
175
|
+
}, onCascadeRefreshDynDataLists: (ddlToBeRefreshed) => {
|
176
|
+
let newDynDataListsToBeRefreshed = [];
|
177
|
+
for (const item of dynDataListsToBeRefreshed) {
|
178
|
+
let index = ddlToBeRefreshed.findIndex(o => o.mid == item.mid || (o.mid == -1 && o.midStarter == item.midStarter));
|
179
|
+
if (index >= 0)
|
180
|
+
continue;
|
181
|
+
newDynDataListsToBeRefreshed.push(item);
|
182
|
+
}
|
183
|
+
for (const item of ddlToBeRefreshed) {
|
184
|
+
if (item.queryParams.length <= 0)
|
185
|
+
continue;
|
186
|
+
if (!item.mid)
|
187
|
+
continue;
|
188
|
+
if (item.mid <= 0)
|
189
|
+
continue;
|
190
|
+
newDynDataListsToBeRefreshed.push(item);
|
191
|
+
}
|
192
|
+
setDynDataListsToBeRefreshed(newDynDataListsToBeRefreshed);
|
193
|
+
}, onCascadeUpdateMIDs: (midsToBeUpdated) => {
|
194
|
+
for (const item of midsToBeUpdated) {
|
195
|
+
const whereItem = qd?.where?.find(o => o.mid === item.mid);
|
196
|
+
if (whereItem) {
|
197
|
+
whereItem.value1 = item.value;
|
198
|
+
handleWhereItemChanged(whereItem);
|
199
|
+
}
|
200
|
+
}
|
201
|
+
} }), FormulaHelper.isFormula(whereItem.value1)
|
202
|
+
? _jsx(IconFunction, { color: "#1a89d3", fontSize: 14, style: { position: "absolute", top: '-5px', left: '-10px' } })
|
203
|
+
: (isEditableList(whereItem.mid))
|
204
|
+
? _jsx(IconPencil, { color: "#138603", fontSize: 14, style: { position: "absolute", top: '-5px', left: '-10px' } })
|
205
|
+
: _jsx(_Fragment, {})] }), showAdvancedMenu && _jsx("div", { style: { gridColumn: 4 }, children: _jsx(TMDropDownMenu, { backgroundColor: 'white', color: TMColors.button_icon, borderRadius: '3px', content: _jsx(TMButton, { btnStyle: 'icon', icon: _jsx(IconMenuVertical, {}), showTooltip: false }), items: getAdvancedMenuItems(whereItem.tid, whereItem.mid) }) })] }, `${whereItem.tid}_${whereItem.mid}_${index}`));
|
206
|
+
}) }) }));
|
207
|
+
};
|
208
|
+
export default TMSearchQueryEditor;
|
209
|
+
const TMSearchWhereItemEditor = ({ whereItem, queryParamsDynDataList, index, isSelected, isEditableList, autoFocus, openChooserBySingleClick, onValueChanged, onCascadeRefreshDynDataLists, onCascadeUpdateMIDs }) => {
|
210
|
+
const [showValue1, setShowValue1] = useState(true);
|
211
|
+
const [showValue2, setShowValue2] = useState(false);
|
212
|
+
const [dataList, setDataList] = useState();
|
213
|
+
const [users, setUsers] = useState();
|
214
|
+
useEffect(() => {
|
215
|
+
let operands = PlatformObjectValidator.GetNumberOfOperands(whereItem.operator);
|
216
|
+
switch (operands) {
|
217
|
+
case 0:
|
218
|
+
setShowValue1(false);
|
219
|
+
setShowValue2(false);
|
220
|
+
break;
|
221
|
+
case 2:
|
222
|
+
setShowValue1(true);
|
223
|
+
setShowValue2(true);
|
224
|
+
break;
|
225
|
+
default:
|
226
|
+
setShowValue1(true);
|
227
|
+
setShowValue2(false);
|
228
|
+
break;
|
229
|
+
}
|
230
|
+
getMetadata().then((mdOut) => {
|
231
|
+
switch (mdOut?.dataDomain) {
|
232
|
+
case MetadataDataDomains.DataList:
|
233
|
+
if (dataList != undefined)
|
234
|
+
return;
|
235
|
+
TMSpinner.show({ description: `${SDKUI_Localizator.Loading} - ${SDK_Localizator.DataList} ...` });
|
236
|
+
mdOut.dataListID && DataListCacheService.GetAsync(mdOut.dataListID).then((dataList) => {
|
237
|
+
TMSpinner.hide();
|
238
|
+
setDataList(dataList);
|
239
|
+
});
|
240
|
+
break;
|
241
|
+
case MetadataDataDomains.UserID:
|
242
|
+
if (users !== undefined)
|
243
|
+
return;
|
244
|
+
TMSpinner.show({ description: `${SDKUI_Localizator.Loading} - ${SDK_Localizator.Users} ...` });
|
245
|
+
UserListCacheService.GetAllAsync().then((resultUsers) => {
|
246
|
+
TMSpinner.hide();
|
247
|
+
setUsers(resultUsers ?? []);
|
248
|
+
});
|
249
|
+
break;
|
250
|
+
default: break;
|
251
|
+
}
|
252
|
+
});
|
253
|
+
}, [whereItem]);
|
254
|
+
const getMetadata = async () => {
|
255
|
+
let dtd = await DcmtTypeListCacheService.GetAsync(whereItem.tid, true);
|
256
|
+
return dtd?.metadata?.find(o => o.id === whereItem.mid);
|
257
|
+
};
|
258
|
+
const normalizeValue = (value, isForValue1 = true) => {
|
259
|
+
let newValues = [];
|
260
|
+
let newValue = value;
|
261
|
+
if (isForValue1) {
|
262
|
+
newValues.push(newValue);
|
263
|
+
newValues.push(whereItem.value2);
|
264
|
+
}
|
265
|
+
else {
|
266
|
+
newValues.push(whereItem.value1);
|
267
|
+
newValues.push(newValue);
|
268
|
+
}
|
269
|
+
onValueChanged?.(newValues);
|
270
|
+
};
|
271
|
+
return (_jsxs(StyledRowItem, { style: { marginBottom: 0 }, children: [showValue1 && _jsx(TMMetadataEditor, { openChooserBySingleClick: openChooserBySingleClick, isSelected: isSelected, tid: whereItem.tid, mid: whereItem.mid, layoutMode: LayoutModes.None, isEditable: isEditableList, value: whereItem.value1, queryOperator: whereItem.operator, queryParamsDynDataList: queryParamsDynDataList, autoFocus: autoFocus ?? false, containerElement: undefined, onValueChanged: (value) => { normalizeValue(value, true); }, onCascadeRefreshDynDataLists: onCascadeRefreshDynDataLists, onCascadeUpdateMIDs: onCascadeUpdateMIDs }), showValue2 && _jsx(TMMetadataEditor, { openChooserBySingleClick: openChooserBySingleClick, isSelected: isSelected, tid: whereItem.tid, mid: whereItem.mid, layoutMode: LayoutModes.None, isEditable: isEditableList, value: whereItem.value2, queryOperator: whereItem.operator, autoFocus: autoFocus ?? false, containerElement: undefined, onValueChanged: (value) => { normalizeValue(value, false); } })] }));
|
272
|
+
};
|
273
|
+
const TMSearchWhereItemCard = ({ index, whereItem, isSelected, queryParamsDynDataList, showEditor, showCompleteMetadataName, showId, isEditableList, onWhereItemChange, onHideEditor, onCascadeRefreshDynDataLists, onCascadeUpdateMIDs }) => {
|
274
|
+
const [isOpen, setIsOpen] = useState(false);
|
275
|
+
const [md, setMd] = useState();
|
276
|
+
useEffect(() => { getMetadata().then((mdOut) => { setMd(mdOut); }); }, [whereItem]);
|
277
|
+
useEffect(() => { setIsOpen(showEditor); }, [showEditor]);
|
278
|
+
const onChange_WhereItem_QueryOperator = (qo, index) => {
|
279
|
+
onWhereItemChange?.({ ...whereItem, operator: qo, value1: undefined, value2: undefined });
|
280
|
+
};
|
281
|
+
const getMetadata = async () => {
|
282
|
+
let dtd = await DcmtTypeListCacheService.GetAsync(whereItem.tid, true);
|
283
|
+
return dtd?.metadata?.find(o => o.id === whereItem.mid);
|
284
|
+
};
|
285
|
+
const getQueryOperatorsMenuItems = (wi, index) => {
|
286
|
+
let items = [];
|
287
|
+
items.push({ text: LocalizeQueryOperators(QueryOperators.Equal), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.Equal, index) });
|
288
|
+
items.push({ text: LocalizeQueryOperators(QueryOperators.NotEqual), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.NotEqual, index) });
|
289
|
+
items.push({ text: LocalizeQueryOperators(QueryOperators.IsNull), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.IsNull, index) });
|
290
|
+
items.push({ text: LocalizeQueryOperators(QueryOperators.IsNotNull), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.IsNotNull, index) });
|
291
|
+
items.push({ text: LocalizeQueryOperators(QueryOperators.In), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.In, index) });
|
292
|
+
items.push({ text: LocalizeQueryOperators(QueryOperators.NotIn), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.NotIn, index) });
|
293
|
+
let mdDataType = md?.dataType;
|
294
|
+
if (mdDataType != MetadataDataTypes.Varchar) {
|
295
|
+
items.push({ text: LocalizeQueryOperators(QueryOperators.Greater), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.Greater, index) });
|
296
|
+
items.push({ text: LocalizeQueryOperators(QueryOperators.GreaterOrEqual), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.GreaterOrEqual, index) });
|
297
|
+
items.push({ text: LocalizeQueryOperators(QueryOperators.Less), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.Less, index) });
|
298
|
+
items.push({ text: LocalizeQueryOperators(QueryOperators.LessOrEqual), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.LessOrEqual, index) });
|
299
|
+
items.push({ text: LocalizeQueryOperators(QueryOperators.BetweenExclusive), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.BetweenExclusive, index) });
|
300
|
+
items.push({ text: LocalizeQueryOperators(QueryOperators.BetweenInclusive), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.BetweenInclusive, index) });
|
301
|
+
items.push({ text: LocalizeQueryOperators(QueryOperators.OutsideExclusive), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.OutsideExclusive, index) });
|
302
|
+
items.push({ text: LocalizeQueryOperators(QueryOperators.OutsideInclusive), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.OutsideInclusive, index) });
|
303
|
+
}
|
304
|
+
else {
|
305
|
+
items.push({ text: LocalizeQueryOperators(QueryOperators.Contain), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.Contain, index) });
|
306
|
+
items.push({ text: LocalizeQueryOperators(QueryOperators.NotContain), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.NotContain, index) });
|
307
|
+
items.push({ text: LocalizeQueryOperators(QueryOperators.BeginWith), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.BeginWith, index) });
|
308
|
+
items.push({ text: LocalizeQueryOperators(QueryOperators.NotBeginWith), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.NotBeginWith, index) });
|
309
|
+
items.push({ text: LocalizeQueryOperators(QueryOperators.EndWith), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.EndWith, index) });
|
310
|
+
items.push({ text: LocalizeQueryOperators(QueryOperators.NotEndWith), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.NotEndWith, index) });
|
311
|
+
items.push({ text: LocalizeQueryOperators(QueryOperators.Like), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.Like, index) });
|
312
|
+
items.push({ text: LocalizeQueryOperators(QueryOperators.NotLike), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.NotLike, index) });
|
313
|
+
}
|
314
|
+
items.push({ text: LocalizeQueryOperators(QueryOperators.Custom), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.Custom, index) });
|
315
|
+
if (mdDataType == MetadataDataTypes.DateTime) {
|
316
|
+
items.push({
|
317
|
+
text: SDKUI_Localizator.SpecialOperators, items: [
|
318
|
+
{ text: LocalizeQueryOperators(QueryOperators.Yesterday), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.Yesterday, index) },
|
319
|
+
{ text: LocalizeQueryOperators(QueryOperators.Today), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.Today, index) },
|
320
|
+
{ text: LocalizeQueryOperators(QueryOperators.Tomorrow), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.Tomorrow, index) },
|
321
|
+
{ text: LocalizeQueryOperators(QueryOperators.PreviousWeek), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.PreviousWeek, index) },
|
322
|
+
{ text: LocalizeQueryOperators(QueryOperators.ThisWeek), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.ThisWeek, index) },
|
323
|
+
{ text: LocalizeQueryOperators(QueryOperators.NextWeek), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.NextWeek, index) },
|
324
|
+
{ text: LocalizeQueryOperators(QueryOperators.PreviousMonth), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.PreviousMonth, index) },
|
325
|
+
{ text: LocalizeQueryOperators(QueryOperators.ThisMonth), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.ThisMonth, index) },
|
326
|
+
{ text: LocalizeQueryOperators(QueryOperators.NextMonth), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.NextMonth, index) },
|
327
|
+
{ text: LocalizeQueryOperators(QueryOperators.PreviousYear), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.PreviousYear, index) },
|
328
|
+
{ text: LocalizeQueryOperators(QueryOperators.ThisYear), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.ThisYear, index) },
|
329
|
+
{ text: LocalizeQueryOperators(QueryOperators.NextYear), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.NextYear, index) },
|
330
|
+
{ text: LocalizeQueryOperators(QueryOperators.LastXHours), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.LastXHours, index) },
|
331
|
+
{ text: LocalizeQueryOperators(QueryOperators.NextXHours), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.NextXHours, index) },
|
332
|
+
{ text: LocalizeQueryOperators(QueryOperators.LastXDays), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.LastXDays, index) },
|
333
|
+
{ text: LocalizeQueryOperators(QueryOperators.NextXDays), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.NextXDays, index) },
|
334
|
+
{ text: LocalizeQueryOperators(QueryOperators.LastXWeeks), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.LastXWeeks, index) },
|
335
|
+
{ text: LocalizeQueryOperators(QueryOperators.NextXWeeks), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.NextXWeeks, index) },
|
336
|
+
{ text: LocalizeQueryOperators(QueryOperators.LastXMonths), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.LastXMonths, index) },
|
337
|
+
{ text: LocalizeQueryOperators(QueryOperators.NextXMonths), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.NextXMonths, index) },
|
338
|
+
{ text: LocalizeQueryOperators(QueryOperators.LastXYears), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.LastXYears, index) },
|
339
|
+
{ text: LocalizeQueryOperators(QueryOperators.NextXYears), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.NextXYears, index) }
|
340
|
+
]
|
341
|
+
});
|
342
|
+
}
|
343
|
+
return items;
|
344
|
+
};
|
345
|
+
return (_jsxs("div", { style: { width: "100%", fontSize: '1rem', userSelect: 'none' }, children: [_jsxs("div", { style: { display: 'flex', flexDirection: 'row', justifyContent: 'space-between' }, children: [_jsx(TMSearchWhereItemViewer, { isSelected: isSelected, whereItem: whereItem, showCompleteMetadataName: showCompleteMetadataName, showId: showId, showValue: !isOpen }), isOpen &&
|
346
|
+
_jsx("div", { onClick: (e) => e.stopPropagation(), children: _jsx(TMButton, { btnStyle: 'icon', icon: _jsx(IconClearButton, { color: 'red' }), caption: SDKUI_Localizator.Close, showTooltip: false, onClick: () => { onHideEditor?.(); } }) })] }), _jsx("div", { style: { display: isOpen ? 'flex' : 'none', flexDirection: 'column', paddingTop: 5, gap: '5px' }, children: _jsxs(StyledDivHorizontal, { style: { gap: '5px' }, children: [_jsx(TMDropDownMenu, { backgroundColor: colorOperator, color: 'green', content: _jsx(StyledItemWrapper, { children: LocalizeQueryOperators(whereItem.operator) }), items: getQueryOperatorsMenuItems(whereItem, index) }), _jsx(TMSearchWhereItemEditor, { isSelected: isSelected, whereItem: whereItem, index: index, isEditableList: isEditableList, autoFocus: !!isOpen, onValueChanged: (values) => { onWhereItemChange?.({ ...whereItem, value1: values[0], value2: values[1] }); }, queryParamsDynDataList: queryParamsDynDataList, onCascadeRefreshDynDataLists: onCascadeRefreshDynDataLists, onCascadeUpdateMIDs: onCascadeUpdateMIDs })] }) })] }));
|
347
|
+
};
|
348
|
+
const TMSearchWhereItemViewer = ({ isSelected = false, whereItem, showCompleteMetadataName, showId, showValue }) => {
|
349
|
+
const [numberOfOperands, setNumberOfOperands] = useState(0);
|
350
|
+
const [md, setMd] = useState();
|
351
|
+
useEffect(() => {
|
352
|
+
let operands = PlatformObjectValidator.GetNumberOfOperands(whereItem?.operator);
|
353
|
+
setNumberOfOperands(operands);
|
354
|
+
getMetadata().then((mdOut) => { setMd(mdOut); });
|
355
|
+
}, [whereItem]);
|
356
|
+
const getMetadata = async () => {
|
357
|
+
let dtd = await DcmtTypeListCacheService.GetAsync(whereItem?.tid, true);
|
358
|
+
return dtd?.metadata?.find(o => o.id === whereItem?.mid);
|
359
|
+
};
|
360
|
+
return (_jsxs("div", { style: { width: "100%", gap: 5, fontSize: '1rem', userSelect: 'none', display: 'flex', flexDirection: 'row' }, children: [_jsx(TMMidViewer, { isMetadataSelected: isSelected, showIcon: true, showCompleteName: showCompleteMetadataName, showId: showId, tid_mid: { tid: whereItem?.tid, mid: whereItem?.mid, aliasTID: whereItem?.alias } }), whereItem && showValue && PlatformObjectValidator.WhereItemHasValues(whereItem) && _jsx(StyledItemWrapper, { style: { padding: 0, color: 'green' }, children: LocalizeQueryOperators(whereItem.operator) }), whereItem && showValue && PlatformObjectValidator.WhereItemHasValues(whereItem) &&
|
361
|
+
_jsx(StyledItemWrapper, { style: { padding: 0, fontWeight: 900 }, children: numberOfOperands == 11 || numberOfOperands == 12 || numberOfOperands == 99
|
362
|
+
? _jsx(_Fragment, { children: whereItem.value1 })
|
363
|
+
// ? <>{numberOfOperands == 11 ? whereItem.value1?.split(',').map((item: string) => !item.startsWith("'") ? item : item.slice(1, -1)).join(",") : whereItem.value1}</>
|
364
|
+
: _jsxs(_Fragment, { children: [displayMetadataValue(md, whereItem.value1, ""), numberOfOperands == 2 && (whereItem.value2 && whereItem.value2 != '' ? ` - ${displayMetadataValue(md, whereItem.value2, "")}` : ' - ?')] }) })] }));
|
365
|
+
};
|
@@ -0,0 +1,20 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { DcmtTypeDescriptor, QueryDescriptor, SavedQueryDescriptor, SearchResultDescriptor } from '@topconsultnpm/sdk-ts-beta';
|
3
|
+
import { TID_MID } from '../../../ts';
|
4
|
+
import { ITMRightSidebarItem } from '../../base/TMRightSidebar';
|
5
|
+
interface ITMSearchQueryPanelProps {
|
6
|
+
fromDTD?: DcmtTypeDescriptor;
|
7
|
+
SQD?: SavedQueryDescriptor;
|
8
|
+
isOpenDistinctValuesPanel?: boolean;
|
9
|
+
rightSidebarItems?: ITMRightSidebarItem[];
|
10
|
+
onRightSidebarItemClick?: (item: string) => void;
|
11
|
+
onSqdSaved?: (newSqd: SavedQueryDescriptor) => void;
|
12
|
+
onFocusedMetadataChanged?: (tid_mid: TID_MID | undefined) => void;
|
13
|
+
onCloseDistinctValuesPanel?: () => void;
|
14
|
+
onSearchCompleted?: (searchResult: SearchResultDescriptor[], qd: QueryDescriptor | undefined) => void;
|
15
|
+
}
|
16
|
+
declare const TMSearchQueryPanel: React.FunctionComponent<ITMSearchQueryPanelProps>;
|
17
|
+
export default TMSearchQueryPanel;
|
18
|
+
export declare const refreshLastSearch: (qd: QueryDescriptor | undefined) => Promise<SearchResultDescriptor[] | undefined>;
|
19
|
+
export declare const StyledToppyTextContainer: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
20
|
+
export declare const StyledToppyText: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLParagraphElement>, HTMLParagraphElement>, never>> & string;
|