@topconsultnpm/sdkui-react-beta 6.12.41 → 6.12.43

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.
@@ -0,0 +1,296 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { useEffect, useState } from 'react';
3
+ import { PlatformObjectValidator, WhereItem, SDK_Localizator, OrderByItem, SelectItem, SelectItemVisibilities, SDK_Globals, SystemMIDsAsNumber, SavedQueryCacheService, SearchEngine, QueryOperators } from '@topconsultnpm/sdk-ts-beta';
4
+ import styled from 'styled-components';
5
+ import TMSearchQueryEditor from './TMSearchQueryEditor';
6
+ import Logo from '../../assets/Toppy-generico.png';
7
+ import { getDcmtTypesByQdAsync, SDKUI_Localizator, getQD, IconMenuVertical, IconAddCircleOutline, IconEdit, IconArchiveDoc, IconEasy, IconAdvanced, IconHide, IconShow, deepCompare, IconSearch, IconClear, getDefaultOperator, prepareQdForSearchAsync, IsParametricQuery } from '../../helper';
8
+ import { useQueryParametersDialog } from '../../hooks/useQueryParametersDialog';
9
+ import { FormModes } from '../../ts';
10
+ import { TMColors } from '../../utils/theme';
11
+ import { StyledModalContainer } from '../base/Styled';
12
+ import ShowAlert from '../base/TMAlert';
13
+ import TMButton from '../base/TMButton';
14
+ import { useDeviceType, DeviceType } from '../base/TMDeviceProvider';
15
+ import TMDropDownMenu from '../base/TMDropDownMenu';
16
+ import TMLayoutContainer, { TMSplitterLayout, TMLayoutItem } from '../base/TMLayout';
17
+ import { TMExceptionBoxManager } from '../base/TMPopUp';
18
+ import TMSpinner from '../base/TMSpinner';
19
+ import TMToolbarCard from '../base/TMToolbarCard';
20
+ import TMDistinctValues from '../choosers/TMDistinctValues';
21
+ import { TMMetadataChooserForm } from '../choosers/TMMetadataChooser';
22
+ import TMQueryEditor from '../query/TMQueryEditor';
23
+ import TMSavedQueryForm from './TMSavedQueryForm';
24
+ const TMSearchQueryPanel = ({ fromDTD, rightSidebarItems, isOpenDistinctValuesPanel = false, SQD, onRightSidebarItemClick, onSearchCompleted, onFocusedMetadataChanged, onCloseDistinctValuesPanel, onSqdSaved }) => {
25
+ const [confirmQueryParams, ConfirmQueryParamsDialog] = useQueryParametersDialog();
26
+ const [qd, setQd] = useState();
27
+ const [lastQdParams, setLastQdParams] = useState([]);
28
+ const [dcmtTypesList, setDcmtTypesList] = useState([]);
29
+ const [showSqdForm, setShowSqdForm] = useState(false);
30
+ const [formModeSqdForm, setFormModeSqdForm] = useState(FormModes.Update);
31
+ const [showAdvancedMenu, setShowAdvancedMenu] = useState(false);
32
+ const [showAllMdWhere, setShowAllMdWhere] = useState(false);
33
+ const [showAdvancedSearch, setShowAdvancedSearch] = useState(false);
34
+ const [showFiltersConfig, setShowFiltersConfig] = useState(false);
35
+ const [showOutputConfig, setShowOutputConfig] = useState(false);
36
+ const [showOrderByConfig, setShowOrderByConfig] = useState(false);
37
+ const [focusedTidMid, setFocusedTidMid] = useState();
38
+ const deviceType = useDeviceType();
39
+ let initialMaxItems = deviceType === DeviceType.MOBILE ? 8 : 12;
40
+ useEffect(() => {
41
+ if (!SQD)
42
+ return;
43
+ setDataAsync(SQD);
44
+ }, [SQD]);
45
+ useEffect(() => { onFocusedMetadataChanged?.(focusedTidMid); }, [focusedTidMid]);
46
+ const setDataAsync = async (sqd) => {
47
+ let newSqd = (sqd?.id == 1) ? sqd : await SavedQueryCacheService.GetAsync(sqd?.id);
48
+ let newQd = SearchEngine.NormalizeQueryDescriptor(newSqd?.qd);
49
+ setQd(newQd);
50
+ if (newQd)
51
+ getDcmtTypesByQdAsync(newQd).then((dtdl) => setDcmtTypesList(dtdl)).catch((err) => { TMExceptionBoxManager.show({ exception: err }); });
52
+ setLastQdParams([]);
53
+ if (newSqd?.runSearchWhenSelected == 1)
54
+ await searchAsync?.(newQd, newSqd?.isEasyWhere != 1);
55
+ setShowAdvancedSearch(newSqd?.isEasyWhere != 1);
56
+ };
57
+ const clearFilters = () => {
58
+ const newWhere = qd?.where?.map((curItem, curIndex) => {
59
+ let newWi = new WhereItem();
60
+ newWi.init({ ...curItem, value1: undefined, value2: undefined });
61
+ return newWi;
62
+ });
63
+ setQd({ ...qd, where: newWhere });
64
+ };
65
+ const searchAsync = async (qdInput, isAdvancedSearch) => {
66
+ let searchParams = { isAdvancedSearch: isAdvancedSearch, lastQdParams: lastQdParams, confirmQueryParams: confirmQueryParams, setLastQdParamsCallback: setLastQdParams };
67
+ let searchResult = await searchByQdAsync(qdInput, searchParams);
68
+ let dcmtsFound = searchResult?.result?.dcmtsFound ?? 0;
69
+ if (dcmtsFound <= 0)
70
+ ShowAlert({ message: SDKUI_Localizator.NoDcmtFound, mode: 'info', title: SDKUI_Localizator.SearchResult, duration: 3000 });
71
+ else {
72
+ let results = [];
73
+ if (searchResult?.result)
74
+ results.push(searchResult?.result);
75
+ onSearchCompleted?.(results, searchResult?.qd);
76
+ }
77
+ };
78
+ const openSqdForm = (formMode) => { setFormModeSqdForm(formMode); setShowSqdForm(true); };
79
+ const changeAdvancedSearchAsync = async (show) => {
80
+ setShowAdvancedSearch(show);
81
+ if (show)
82
+ setQd({ ...qd, where: qd?.where?.filter(o => PlatformObjectValidator.WhereItemHasValues(o)) });
83
+ else {
84
+ let qdEasy = SQD?.qd ?? await getQD(fromDTD?.id, false);
85
+ if (qdEasy && qd?.where) {
86
+ for (const wi of qd.where) {
87
+ let wiEasy = qdEasy.where?.find(o => o.mid == wi.mid);
88
+ if (wiEasy) {
89
+ wiEasy.or = false;
90
+ wiEasy.leftBrackets = "(";
91
+ wiEasy.operator = wi.operator;
92
+ wiEasy.value1 = wi.value1;
93
+ wiEasy.value2 = wi.value2;
94
+ wiEasy.rightBrackets = ")";
95
+ }
96
+ }
97
+ setQd({ ...qd, where: qdEasy?.where });
98
+ }
99
+ }
100
+ };
101
+ return (_jsxs(TMSplitterLayout, { direction: 'horizontal', showSeparator: deviceType !== DeviceType.MOBILE && isOpenDistinctValuesPanel, separatorSize: 8, separatorColor: 'transparent', separatorActiveColor: 'transparent', min: ['0', '0'], start: deviceType === DeviceType.MOBILE ? ['100%', '0%'] : (isOpenDistinctValuesPanel ? ['55%', '45%'] : ['100%', '0%']), children: [_jsxs(TMToolbarCard, { title: fromDTD?.nameLoc ?? SDKUI_Localizator.Search_Metadata, items: rightSidebarItems, onItemClick: onRightSidebarItemClick,
102
+ // onBack={deviceType !== DeviceType.DESKTOP ? () => { setCurrentTID(0) } : undefined}
103
+ toolbar: _jsx(_Fragment, { children: (SQD && !showSqdForm) ?
104
+ _jsx(TMDropDownMenu, { backgroundColor: 'white', borderRadius: '3px', content: _jsx(TMButton, { btnStyle: 'icon', caption: 'Altro', icon: _jsx(IconMenuVertical, { color: 'white' }), showTooltip: false }), items: [
105
+ { icon: _jsx(IconAddCircleOutline, {}), text: SDKUI_Localizator.SavedQueryNew, onClick: () => { openSqdForm(FormModes.Create); } },
106
+ { icon: _jsx(IconEdit, {}), text: SDKUI_Localizator.SavedQueryUpdate, disabled: (SQD && SQD.id == 1), onClick: () => { openSqdForm(FormModes.Update); } },
107
+ { icon: _jsx(IconArchiveDoc, {}), beginGroup: true, text: "Passa ad archiviazione", onClick: () => ShowAlert({ message: "TODO", mode: 'info', title: `${"TODO"}`, duration: 3000 }) },
108
+ { icon: showAdvancedSearch ? _jsx(IconEasy, {}) : _jsx(IconAdvanced, {}), text: showAdvancedSearch ? SDKUI_Localizator.Search_Easy : SDKUI_Localizator.Search_Advanced, onClick: () => { changeAdvancedSearchAsync(!showAdvancedSearch); } },
109
+ { icon: _jsx(IconEdit, {}), beginGroup: true, text: `${SDKUI_Localizator.Configure} - ${SDK_Localizator.QueryWhere}`, onClick: () => { setShowFiltersConfig(true); } },
110
+ { icon: _jsx(IconEdit, {}), text: `${SDKUI_Localizator.Configure} - ${SDK_Localizator.QuerySelect}`, onClick: () => { setShowOutputConfig(true); } },
111
+ { icon: _jsx(IconEdit, {}), text: `${SDKUI_Localizator.Configure} - ${SDK_Localizator.QueryOrderBy}`, onClick: () => { setShowOrderByConfig(true); } },
112
+ { icon: showAdvancedMenu ? _jsx(IconHide, {}) : _jsx(IconShow, {}), beginGroup: true, operationType: 'singleRow', text: showAdvancedMenu ? SDKUI_Localizator.StandardMode : SDKUI_Localizator.ExpertMode, onClick: () => setShowAdvancedMenu(!showAdvancedMenu) },
113
+ ] })
114
+ : _jsx(_Fragment, {}) }), children: [_jsx(ConfirmQueryParamsDialog, {}), SQD
115
+ ? _jsxs("div", { style: { height: '100%', width: '100%', position: 'relative', display: 'flex', flexDirection: 'column', gap: 5 }, children: [showAdvancedSearch
116
+ ? _jsx(TMQueryEditor, { formMode: FormModes.Update, showToolbar: false, inputData: qd, validateSelect: true, showApply: false, onQDChanged: (newQd) => { if (!deepCompare(qd, newQd))
117
+ setQd(newQd); } })
118
+ : _jsx(TMSearchQueryEditor, { qd: qd, fromDTD: fromDTD, dcmtTypesList: dcmtTypesList, isOpenDistinctValuesPanel: isOpenDistinctValuesPanel, showAdvancedMenu: showAdvancedMenu, showAllMdWhere: showAllMdWhere, onFocusedMetadataChanged: setFocusedTidMid, onQdChanged: (newQd) => { if (!deepCompare(qd, newQd))
119
+ setQd(newQd); } }), _jsxs("div", { style: { display: 'flex', justifyContent: 'center', alignItems: 'center', gap: '80px', padding: '15px', position: 'relative' }, children: [_jsxs("div", { style: { display: 'flex', justifyContent: 'center', alignItems: 'center', gap: '8px' }, children: [_jsx(TMButton, { btnStyle: 'advanced', icon: _jsx(IconSearch, {}), showTooltip: false, caption: SDKUI_Localizator.Search, onClick: async () => await searchAsync(qd, showAdvancedSearch), advancedColor: '#f09c0a' }), _jsx(TMButton, { btnStyle: 'advanced', showTooltip: false, caption: SDKUI_Localizator.Clear, icon: _jsx(IconClear, {}), advancedColor: TMColors.primaryColor, onClick: clearFilters })] }), (!showAdvancedSearch && qd?.where && qd?.where?.length > initialMaxItems) && _jsx(TMButton, { elementStyle: { position: 'absolute', right: '10px' }, btnStyle: 'icon', caption: showAllMdWhere ? "Mostra meno" : `Mostra tutti i metadati (+${qd?.where?.length - initialMaxItems})`, icon: showAllMdWhere ?
120
+ _jsx("div", { style: { backgroundColor: TMColors.primaryColor, minWidth: '30px', minHeight: '30px', borderRadius: '10px', display: 'flex', alignItems: 'center', justifyContent: 'center' }, children: _jsx("p", { style: { color: 'white' }, children: `-${qd?.where?.length - initialMaxItems}` }) }) :
121
+ _jsx("div", { style: { backgroundColor: TMColors.primaryColor, minWidth: '30px', minHeight: '30px', borderRadius: '10px', display: 'flex', alignItems: 'center', justifyContent: 'center' }, children: _jsx("p", { style: { color: 'white' }, children: `+${qd?.where?.length - initialMaxItems}` }) }), onClick: () => setShowAllMdWhere(!showAllMdWhere) })] }), showFiltersConfig &&
122
+ _jsx(TMMetadataChooserForm, { allowMultipleSelection: true, height: '500px', width: '600px', allowSysMetadata: true, qd: qd, selectedIDs: qd?.where?.map((w) => ({ tid: w.tid, mid: w.mid })), onClose: () => setShowFiltersConfig(false), onChoose: (tid_mids) => {
123
+ if (!fromDTD?.metadata)
124
+ return;
125
+ if (!tid_mids)
126
+ return;
127
+ // copia dei whereItem senza i rimossi
128
+ let newWhere = qd?.where?.filter(wi => tid_mids?.some(tm => tm.mid == wi.mid)) ?? [];
129
+ // aggiungiamo i nuovi
130
+ for (const tm of tid_mids.filter(tm => !qd?.where?.some(wi => wi.mid == tm.mid))) {
131
+ let md = fromDTD?.metadata.find(o => o.id == tm.mid);
132
+ let wi = new WhereItem();
133
+ wi.or = false;
134
+ wi.leftBrackets = "(";
135
+ wi.tid = SQD.masterTID;
136
+ wi.mid = tm.mid;
137
+ wi.operator = getDefaultOperator(md?.dataDomain, md?.dataType);
138
+ wi.rightBrackets = ")";
139
+ let indexMD = 0;
140
+ for (const m of fromDTD?.metadata ?? []) {
141
+ if (m.id == wi.mid)
142
+ break;
143
+ if (newWhere.findIndex(o => o.mid == m.id && o.tid == SQD.masterTID) < 0)
144
+ continue;
145
+ indexMD++;
146
+ }
147
+ newWhere.splice(indexMD, 0, wi);
148
+ }
149
+ setQd({ ...qd, where: newWhere });
150
+ } }), showOutputConfig &&
151
+ _jsx(TMMetadataChooserForm, { allowMultipleSelection: true, height: '500px', width: '600px', allowSysMetadata: true, qd: qd, selectedIDs: qd?.select?.map((item) => ({ tid: item.tid, mid: item.mid })), onClose: () => setShowOutputConfig(false), onChoose: (tid_mids) => {
152
+ if (!fromDTD?.metadata)
153
+ return;
154
+ if (!tid_mids)
155
+ return;
156
+ // copia dei SelectItems senza i rimossi
157
+ let newSelect = qd?.select?.filter(item => tid_mids?.some(tm => tm.mid == item.mid)) ?? [];
158
+ // aggiungiamo i nuovi
159
+ for (const tm of tid_mids.filter(tm => !qd?.select?.some(item => item.mid == tm.mid))) {
160
+ let md = fromDTD?.metadata.find(o => o.id == tm.mid);
161
+ let si = new SelectItem();
162
+ si.visibility = SelectItemVisibilities.Visible;
163
+ si.tid = SQD.masterTID;
164
+ si.mid = md?.id;
165
+ let indexMD = 0;
166
+ for (const m of fromDTD?.metadata ?? []) {
167
+ if (m.id == si.mid)
168
+ break;
169
+ if (newSelect.findIndex(o => o.mid == m.id && o.tid == SQD.masterTID) < 0)
170
+ continue;
171
+ indexMD++;
172
+ }
173
+ newSelect.splice(indexMD, 0, si);
174
+ }
175
+ setQd({ ...qd, select: newSelect });
176
+ } }), showOrderByConfig &&
177
+ _jsx(TMMetadataChooserForm, { allowMultipleSelection: true, height: '500px', width: '600px', allowSysMetadata: true, qd: qd, selectedIDs: qd?.orderBy?.map((item) => ({ tid: item.tid, mid: item.mid })), onClose: () => setShowOrderByConfig(false), onChoose: (tid_mids) => {
178
+ if (!fromDTD?.metadata)
179
+ return;
180
+ if (!tid_mids)
181
+ return;
182
+ // copia dei OrderByItems senza i rimossi
183
+ let newOrderBy = qd?.orderBy?.filter(item => tid_mids?.some(tm => tm.mid == item.mid)) ?? [];
184
+ // aggiungiamo i nuovi
185
+ for (const tm of tid_mids.filter(tm => !qd?.orderBy?.some(item => item.mid == tm.mid))) {
186
+ let md = fromDTD?.metadata.find(o => o.id == tm.mid);
187
+ let oi = new OrderByItem();
188
+ oi.tid = SQD.masterTID;
189
+ oi.mid = md?.id;
190
+ oi.asc = true;
191
+ newOrderBy.push(oi);
192
+ }
193
+ setQd({ ...qd, orderBy: newOrderBy });
194
+ } })] })
195
+ :
196
+ _jsxs(TMLayoutContainer, { gap: 30, alignItems: 'center', justifyContent: 'center', children: [_jsxs(TMLayoutItem, { width: 'max-content', height: 'max-content', children: [" ", _jsxs(StyledToppyTextContainer, { children: [" ", _jsxs(StyledToppyText, { children: [" ", 'Selezionare un tipo documento o ricerca rapida', " "] }), " "] }), " "] }), _jsxs(TMLayoutItem, { width: 'max-content', height: 'max-content', children: [" ", _jsx("img", { src: Logo, width: 120, alt: '' }), " "] })] }), showSqdForm &&
197
+ _jsx(StyledModalContainer, { style: { backgroundColor: `${TMColors.backgroundColorHeader}12` }, children: _jsx(TMSavedQueryForm, { height: '50%', width: '50%', id: formModeSqdForm === FormModes.Create ? -1 : SQD?.id, title: 'Ricerca rapida', formMode: formModeSqdForm, showBackButton: true, qd: qd, isAdvancedSearch: showAdvancedSearch, isModal: false, onClose: () => { setShowSqdForm(false); }, onSaved: onSqdSaved }) })] }), _jsx(TMDistinctValues, { tid: focusedTidMid?.tid, mid: focusedTidMid?.mid, separator: ',', onClosePanelCallback: onCloseDistinctValuesPanel, onSelectionChanged: (e) => {
198
+ if (!e)
199
+ return;
200
+ let wi = qd?.where?.find(o => o.tid === focusedTidMid?.tid && o.mid === focusedTidMid?.mid);
201
+ if (!wi)
202
+ return;
203
+ wi.value1 = e.newValue;
204
+ let md = fromDTD?.metadata?.find(o => o.id === focusedTidMid?.mid);
205
+ wi.operator = e.isAppendMode ? QueryOperators.In : getDefaultOperator(md?.dataDomain, md?.dataType);
206
+ const whereCopy = qd?.where?.map((curItem) => {
207
+ if (curItem.mid != wi.mid)
208
+ return curItem;
209
+ return wi;
210
+ });
211
+ setQd({ ...qd, where: whereCopy });
212
+ } })] }));
213
+ };
214
+ export default TMSearchQueryPanel;
215
+ const searchByQdAsync = async (qdInput, searchParams) => {
216
+ let result;
217
+ let qdSearch;
218
+ try {
219
+ qdSearch = await prepareQdForSearchAsync(qdInput);
220
+ let fromTID = qdSearch?.from?.tid;
221
+ // In modalità easy rimuovi filtri non valorizzati
222
+ if (!searchParams.isAdvancedSearch) {
223
+ qdSearch.where = qdSearch?.where?.filter(o => PlatformObjectValidator.WhereItemHasValues(o));
224
+ qdSearch.where?.forEach(o => o.or = false); // props.easyOr
225
+ }
226
+ qdSearch.select?.forEach(o => { o.visibility ??= SelectItemVisibilities.Visible; });
227
+ if (qdSearch.orderBy && qdSearch.orderBy.length <= 0) {
228
+ let obi = new OrderByItem();
229
+ obi.tid = fromTID;
230
+ obi.mid = SystemMIDsAsNumber.DID;
231
+ obi.asc = false;
232
+ qdSearch.orderBy.push(obi);
233
+ }
234
+ if (IsParametricQuery(qdSearch)) {
235
+ const qdParams = await searchParams.confirmQueryParams?.(qdSearch, searchParams.lastQdParams) ?? [];
236
+ searchParams.setLastQdParamsCallback?.(qdParams);
237
+ if (!qdParams || qdParams.length <= 0)
238
+ return;
239
+ for (const qpd of qdParams) {
240
+ let wi = qdSearch.where?.find(o => o.value1 == qpd.name);
241
+ if (wi)
242
+ wi.value1 = wi.value1?.replace(wi.value1, !qpd.value ? '' : qpd.value.toString());
243
+ else {
244
+ wi = qdSearch.where?.find(o => o.value2 == qpd.name);
245
+ if (wi)
246
+ wi.value2 = wi.value2?.replace(wi.value2, !qpd.value ? '' : qpd.value.toString());
247
+ }
248
+ }
249
+ }
250
+ TMSpinner.show({ description: `${SDKUI_Localizator.Search} ...`, backgroundColor: 'transparent' });
251
+ result = await SDK_Globals.tmSession?.NewSearchEngine().SearchByIDAsync(qdSearch);
252
+ }
253
+ catch (ex) {
254
+ TMExceptionBoxManager.show({ title: SDKUI_Localizator.Search, exception: ex });
255
+ }
256
+ finally {
257
+ TMSpinner.hide();
258
+ }
259
+ return { result: result, qd: qdSearch };
260
+ };
261
+ export const refreshLastSearch = async (qd) => {
262
+ if (!qd)
263
+ return;
264
+ let searchResults = [];
265
+ try {
266
+ TMSpinner.show({ description: `${SDKUI_Localizator.Search} ...`, backgroundColor: 'transparent' });
267
+ let result = await SDK_Globals.tmSession?.NewSearchEngine().SearchByIDAsync(qd);
268
+ let dcmtsFound = result?.dcmtsFound ?? 0;
269
+ if (dcmtsFound <= 0)
270
+ ShowAlert({ message: SDKUI_Localizator.NoDcmtFound, mode: 'info', title: SDKUI_Localizator.SearchResult, duration: 3000 });
271
+ else if (result)
272
+ searchResults.push(result);
273
+ }
274
+ catch (ex) {
275
+ TMExceptionBoxManager.show({ title: SDKUI_Localizator.Search, exception: ex });
276
+ }
277
+ finally {
278
+ TMSpinner.hide();
279
+ }
280
+ return searchResults;
281
+ };
282
+ export const StyledToppyTextContainer = styled.div `
283
+ padding: 30px 50px;
284
+ max-width: 345px;
285
+ border: 1px solid #8D2F88;
286
+ border-radius: 30px;
287
+ display: flex;
288
+ align-items: center;
289
+ justify-content: center;
290
+ `;
291
+ export const StyledToppyText = styled.p `
292
+ text-align: center;
293
+ color: #8d2f88;
294
+ font-size: 30px;
295
+ user-select: none;
296
+ `;
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import { SearchResultDescriptor } from '@topconsultnpm/sdk-ts-beta';
3
- import { SearchResultContext } from '../../ts';
3
+ import { SearchResultContext, TaskContext } from '../../ts';
4
4
  interface ITMSearchResultProps {
5
5
  context?: SearchResultContext;
6
6
  title?: string;
@@ -21,11 +21,7 @@ interface ITMSearchResultProps {
21
21
  onRefreshSearchAsync?: () => Promise<void>;
22
22
  onRefreshAfterAddDcmtToFavs?: () => void;
23
23
  onClosePreview?: () => void;
24
- onTaskCreateRequest?: (activityContext: {
25
- tid: number;
26
- did: number;
27
- name: string;
28
- } | undefined) => void;
24
+ onTaskCreateRequest?: (taskContext: TaskContext | undefined) => void;
29
25
  }
30
26
  declare const TMSearchResult: React.FC<ITMSearchResultProps>;
31
27
  export default TMSearchResult;
@@ -156,7 +156,7 @@ const TMSearchResult = ({ context = SearchResultContext.METADATA_SEARCH, isVisib
156
156
  const dtd = await DcmtTypeListCacheService.GetAsync(item.TID);
157
157
  if (dtd) {
158
158
  const name = `${dtd.name ?? '-'} (DID: ${item.DID})`;
159
- onTaskCreateRequest?.({ tid: item.TID, did: item.DID, name });
159
+ onTaskCreateRequest?.({ document: { tid: item.TID, did: item.DID, name } });
160
160
  }
161
161
  }
162
162
  catch (error) {
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ import { LayoutModes } from '@topconsultnpm/sdk-ts-beta';
3
+ interface ITMTreeSelectorProps {
4
+ layoutMode?: LayoutModes;
5
+ onSelectedTIDChanged?: (tid: number | undefined, treeId?: number | undefined) => void;
6
+ onClose?: () => void;
7
+ }
8
+ declare const TMTreeSelector: React.FC<ITMTreeSelectorProps>;
9
+ export default TMTreeSelector;
@@ -0,0 +1,125 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useCallback, useEffect, useState } from 'react';
3
+ import { LayoutModes, LocalStorageService, SDK_Globals, SDK_Localizator, TreeCacheService, TreeItemTypes } from '@topconsultnpm/sdk-ts-beta';
4
+ import { TreeList, Column, Scrolling, Selection } from 'devextreme-react/tree-list';
5
+ import { DropDownBox } from 'devextreme-react';
6
+ import { IconStarRemove, IconStar, SDKUI_Localizator, SDKUI_Globals } from '../../helper';
7
+ import { StyledDivHorizontal } from '../base/Styled';
8
+ import TMButton from '../base/TMButton';
9
+ import TMDataGrid from '../base/TMDataGrid';
10
+ import TMLayoutContainer, { TMLayoutItem } from '../base/TMLayout';
11
+ import TMToolbarCard from '../base/TMToolbarCard';
12
+ import TMTidViewer from '../viewers/TMTidViewer';
13
+ const TMTreeSelector = ({ layoutMode = LayoutModes.Update, onSelectedTIDChanged, onClose }) => {
14
+ const [trees, setTrees] = useState([]);
15
+ const [treeItems, setTreeItems] = useState([]);
16
+ const [selectedTreeId, setSelectedTreeId] = useState(0);
17
+ // State to store selected row keys
18
+ const [selectedRowKeys, setSelectedRowKeys] = useState([]);
19
+ // State hook to store the currently focused row key, initially set to undefined
20
+ const [focusedRowKey, setFocusedRowKey] = useState(undefined);
21
+ const [isGridBoxOpened, setIsGridBoxOpened] = useState(false);
22
+ const [defaultTreeId, setDefaultTreeId] = useState(-1);
23
+ const DEFAULT_TREE_KEY_NAME = `DEFAULT_TREE_${SDK_Globals.tmSession?.SessionDescr?.archiveID}_${SDK_Globals.tmSession?.SessionDescr?.userID}`;
24
+ useEffect(() => {
25
+ if (treeItems.length > 0 && treeItems[0].id) {
26
+ setSelectedRowKeys([treeItems[0].id]);
27
+ }
28
+ }, [treeItems]);
29
+ useEffect(() => {
30
+ const setResultCache = (result) => {
31
+ if (result && result.length > 0) {
32
+ setTrees(result);
33
+ let defaultTree = Number(LocalStorageService.getItem(DEFAULT_TREE_KEY_NAME) ?? -1);
34
+ if (defaultTree > 0) {
35
+ setDefaultTreeId(defaultTree);
36
+ setSelectedTreeId(defaultTree);
37
+ const treeItemDescriptor = result.find(o => o.id == defaultTree);
38
+ if (treeItemDescriptor?.id)
39
+ setSelectedRowKeys([treeItemDescriptor.id]);
40
+ }
41
+ else {
42
+ setSelectedTreeId(result?.[0].id ?? 0);
43
+ const treeItemDescriptor = result?.[0];
44
+ if (treeItemDescriptor?.id)
45
+ setSelectedRowKeys([treeItemDescriptor.id]);
46
+ }
47
+ }
48
+ };
49
+ if (layoutMode == LayoutModes.Update) {
50
+ TreeCacheService.GetAllSearchAsync().then((result) => { setResultCache(result); });
51
+ }
52
+ else {
53
+ TreeCacheService.GetAllArchiveAsync().then((result) => { setResultCache(result); });
54
+ }
55
+ }, []);
56
+ useEffect(() => {
57
+ let newTreeItems = trees.find(o => o.id == selectedTreeId)?.items ?? [];
58
+ setTreeItems(newTreeItems);
59
+ }, [selectedTreeId]);
60
+ const renderCell = (data) => {
61
+ let treeItem = data.data;
62
+ if (treeItem.type == TreeItemTypes.DcmtType)
63
+ return (_jsx(TMTidViewer, { tid: treeItem.tid, showIcon: true }));
64
+ else
65
+ return (_jsxs(StyledDivHorizontal, { style: { gap: 5 }, children: [_jsx(IconFolder, { fontSize: 18 }), _jsx("p", { children: treeItem.nameLoc })] }));
66
+ };
67
+ // Handles selection change in the data grid
68
+ const onSelectionChanged = useCallback((e) => {
69
+ const selectedKeys = e.component.getSelectedRowKeys() ?? [];
70
+ if (selectedKeys.length === 0)
71
+ return;
72
+ if (selectedKeys[0] === undefined)
73
+ return;
74
+ if (selectedKeys.length > 0)
75
+ setSelectedTreeId(selectedKeys[0]);
76
+ setSelectedRowKeys(selectedKeys);
77
+ setIsGridBoxOpened(false);
78
+ }, []);
79
+ // Handles focus change in the data grid
80
+ const onFocusedRowChanged = useCallback((e) => {
81
+ setFocusedRowKey(e.row?.key);
82
+ }, []);
83
+ const syncDataGridSelection = useCallback((e) => {
84
+ const treeItemDescriptor = e.value;
85
+ if (treeItemDescriptor?.id)
86
+ setSelectedRowKeys([treeItemDescriptor.id]);
87
+ }, []);
88
+ const onGridBoxOpened = useCallback((e) => {
89
+ if (e.name === 'opened') {
90
+ setIsGridBoxOpened(e.value);
91
+ }
92
+ ;
93
+ }, []);
94
+ return (_jsx(TMToolbarCard, { title: SDK_Localizator.Trees, totalItems: trees.length, onClose: onClose, toolbar: _jsx(TMButton, { btnStyle: 'icon', caption: defaultTreeId == selectedTreeId ? SDKUI_Localizator.TreeRemoveDefault : SDKUI_Localizator.SetAsDefault, icon: defaultTreeId == selectedTreeId ? _jsx(IconStarRemove, { color: 'rgb(243, 114, 92)' }) : _jsx(IconStar, { color: 'rgb(248, 215, 117)' }), onClick: () => {
95
+ if (defaultTreeId == selectedTreeId) {
96
+ LocalStorageService.deleteItem(DEFAULT_TREE_KEY_NAME);
97
+ setDefaultTreeId(-1);
98
+ }
99
+ else {
100
+ LocalStorageService.setItem(DEFAULT_TREE_KEY_NAME, selectedTreeId.toString());
101
+ setDefaultTreeId(selectedTreeId);
102
+ }
103
+ } }), children: trees.length > 0
104
+ ?
105
+ _jsxs(TMLayoutContainer, { gap: 20, children: [_jsx(TMLayoutItem, { height: '30px', children: _jsx(DropDownBox, { dropDownOptions: {
106
+ resizeEnabled: true,
107
+ minWidth: "100%",
108
+ height: trees.length <= 10 ? 300 : 500,
109
+ maxWidth: "100%"
110
+ }, value: selectedTreeId, opened: isGridBoxOpened, valueExpr: "id", displayExpr: "nameLoc", deferRendering: false, dataSource: trees, onValueChanged: syncDataGridSelection, onOptionChanged: onGridBoxOpened, children: _jsx(TMDataGrid, { height: "100%", width: "100%", dataSource: trees, dataColumns: [
111
+ { dataField: 'nameLoc', caption: SDKUI_Localizator.Name, width: 'auto' },
112
+ { dataField: 'description', caption: SDKUI_Localizator.Description, width: 'auto' },
113
+ ], selection: { mode: 'single', showCheckBoxesMode: "none" },
114
+ // scrolling={{ mode: 'virtual', useNative: SDKUI_Globals.dataGridUseNativeScrollbar }}
115
+ showRowLines: SDKUI_Globals.dataGridShowRowLines, showColumnLines: SDKUI_Globals.dataGridShowColumnLines, showHeaderFilter: false, selectedRowKeys: selectedRowKeys, onSelectionChanged: onSelectionChanged, focusedRowKey: focusedRowKey, onFocusedRowChanged: onFocusedRowChanged }) }) }), _jsx(TMLayoutItem, { height: 'calc(100% - 50px)', children: _jsxs(TreeList, { height: "100%", elementAttr: { class: 'tm-dx-treelist' }, dataSource: treeItems, showRowLines: SDKUI_Globals.dataGridShowRowLines, showColumnLines: SDKUI_Globals.dataGridShowColumnLines, showBorders: false, columnAutoWidth: true, keyExpr: "id", parentIdExpr: "parentID", dataStructure: "plain", showColumnHeaders: false, onContentReady: (e) => e.component.clearSelection(), onSelectionChanged: (e) => {
116
+ if (e.selectedRowsData[0] && e.selectedRowsData[0].type == TreeItemTypes.DcmtType) {
117
+ onSelectedTIDChanged?.(e.selectedRowsData[0].tid, selectedTreeId);
118
+ }
119
+ }, children: [_jsx(Column, { dataField: "nameLoc", caption: SDKUI_Localizator.Name, cellRender: renderCell }), _jsx(Scrolling, { mode: "virtual", useNative: SDKUI_Globals.dataGridUseNativeScrollbar }), _jsx(Selection, { mode: "single" })] }) })] })
120
+ : _jsx("div", { style: { display: 'flex', flexDirection: 'column', alignItems: 'center', justifyContent: 'center', height: '100%', width: '100%', fontSize: '1.5rem' }, children: SDKUI_Localizator.TreesNoAvailable }) }));
121
+ };
122
+ export default TMTreeSelector;
123
+ function IconFolder(props) {
124
+ return (_jsx("svg", { viewBox: "0 0 512 512", height: "1em", width: "1em", ...props, children: _jsx("g", { id: "Icon", children: _jsx("g", { id: "_10", children: _jsxs("g", { id: "Folder", children: [_jsx("path", { d: "m214.2 107-40.2-29.9c-9.5-7-20.9-10.8-32.7-10.8h-110.2c-16.6 0-30 13.4-30 30v349.5h404.1c15.2 0 27.4-12.3 27.4-27.4v-270.6c0-16.6-13.4-30-30-30h-155.6c-11.8 0-23.3-3.8-32.8-10.8z", fill: "#f6c012" }), _jsxs("g", { children: [_jsx("path", { d: "m76.9 143.7h300c8.3 0 15 6.7 15 15v200c0 8.3-6.7 15-15 15h-300c-8.3 0-15-6.7-15-15v-200c0-8.3 6.7-15 15-15z", fill: "#ffeac5" }), _jsx("path", { d: "m56.9 163.7h300c8.3 0 15 6.7 15 15v200c0 8.3-6.7 15-15 15h-300c-8.3 0-15-6.7-15-15v-200c0-8.3 6.7-15 15-15z", fill: "#fff7e6" })] }), _jsx("path", { d: "m85.2 220.1-84.1 225.6h410.8c12.5 0 23.7-7.8 28.1-19.5l69-185.2c7.3-19.6-7.2-40.5-28.1-40.5h-367.6c-12.5.1-23.7 7.8-28.1 19.6z", fill: "#fbd87c" })] }) }) }) }));
125
+ }
@@ -1,4 +1,4 @@
1
- import { ArchiveConstraints, JobTypes, JoinTypes, MetadataFormats, OwnershipLevels, ParametricFilterTypes, QueryFunctions, QueryOperators, UserLevels } from "@topconsultnpm/sdk-ts-beta";
1
+ import { ArchiveConstraints, JobTypes, JoinTypes, MetadataFormats, OwnershipLevels, ParametricFilterTypes, QueryFunctions, QueryOperators, SharingModes, UserLevels } from "@topconsultnpm/sdk-ts-beta";
2
2
  import { DcmtOperationTypes, FormModes } from "../ts";
3
3
  export declare function LocalizeArchiveConstraints(value: ArchiveConstraints | undefined): "Archivierung nur mit Dateien erlauben" | "Allow file only archiving" | "Permitir solo almacenamientos con archivo" | "Autorise uniquement l'archivage de fichiers" | "Permitir somente depósitos com arquivos" | "Consenti solo archiviazioni con file" | "Alles zulassen" | "Allow everything" | "Permitir todo" | "Autorise tout" | "Permitir que todos" | "Consenti tutto" | "Nur Methadatenarchivierung erlauben" | "Allow metadata only archiving" | "Permitir solo almacenamiento de metadatos" | "Autorise uniquement l'archivage de métadonnées" | "Permitir somente os metadados de arquivamento" | "Consenti solo archiviazioni di metadati";
4
4
  export declare function LocalizeDcmtOperationTypes(value: DcmtOperationTypes | undefined): string;
@@ -10,4 +10,5 @@ export declare function LocalizeParametricFilterTypes(value: ParametricFilterTyp
10
10
  export declare function LocalizeQueryFunctions(value: QueryFunctions | undefined): "Zählen" | "Count" | "Contar" | "Compte" | "Contagem" | "Conta" | "" | "None" | "Niemand" | "Ninguno" | "Aucun" | "Nenhum" | "Nessuno" | "Max" | "Höchstwert" | "Máximo" | "Massimo" | "Min" | "Mindestwert" | "Mínimo" | "Minimo" | "Sum" | "Summe" | "Suma" | "Somme" | "Soma" | "Somma";
11
11
  export declare function LocalizeQueryJoinTypes(value: JoinTypes | undefined): string;
12
12
  export declare function LocalizeQueryOperators(value: QueryOperators | undefined): string;
13
+ export declare function LocalizeSharingModes(value: SharingModes | undefined): string;
13
14
  export declare function LocalizeUserLevels(value: UserLevels | undefined): string | undefined;
@@ -1,4 +1,4 @@
1
- import { ArchiveConstraints, CultureIDs, JobTypes, JoinTypes, MetadataFormats, OwnershipLevels, ParametricFilterTypes, QueryFunctions, QueryOperators, SDK_Globals, SDK_Localizator, UserLevels } from "@topconsultnpm/sdk-ts-beta";
1
+ import { ArchiveConstraints, CultureIDs, JobTypes, JoinTypes, MetadataFormats, OwnershipLevels, ParametricFilterTypes, QueryFunctions, QueryOperators, SDK_Globals, SDK_Localizator, SharingModes, UserLevels } from "@topconsultnpm/sdk-ts-beta";
2
2
  import { SDKUI_Localizator } from "./SDKUI_Localizator";
3
3
  import { DcmtOperationTypes, FormModes } from "../ts";
4
4
  export function LocalizeArchiveConstraints(value) {
@@ -181,6 +181,14 @@ export function LocalizeQueryOperators(value) {
181
181
  default: return '';
182
182
  }
183
183
  }
184
+ export function LocalizeSharingModes(value) {
185
+ switch (value) {
186
+ case SharingModes.Private: return SDKUI_Localizator.SharingModes_Private;
187
+ case SharingModes.Public: return SDKUI_Localizator.SharingModes_Public;
188
+ case SharingModes.Shared: return SDKUI_Localizator.SharingModes_Shared;
189
+ default: return value;
190
+ }
191
+ }
184
192
  export function LocalizeUserLevels(value) {
185
193
  switch (value) {
186
194
  case UserLevels.Administrator: return SDKUI_Localizator.UserLevelAdmin;
@@ -16,7 +16,9 @@ export declare class SDKUI_Localizator {
16
16
  static get AddAlls(): "Alle hinzufügen" | "Add all" | "Añadir todos" | "Ajoute toutes" | "Adicionar todos" | "Aggiungi tutti";
17
17
  static get AddDefinition(): "Definition hinzufügen" | "Add definition" | "Añadir definición" | "Ajoute la définition" | "Adicionar definição" | "Aggiungi definizione";
18
18
  static get AddOrSubstFile(): "Dateien hinzufügen/ersetzen" | "Add/substitute file" | "Añadir/sustituir archivo" | "Ajoute/Remplace le fichier" | "Adicionar / substituir arquivos" | "Aggiungi/sostituisci file";
19
+ static get AddToHomePage(): "Zur Startseite hinzufügen" | "Add to Home Page" | "Añadir a la página inicial" | "Ajoute à Home Page" | "Adicionar a Home Page" | "Aggiungi alla Home Page";
19
20
  static get All(): "Alle" | "All" | "Todos" | "Tous" | "Tutti";
21
+ static get AllDcmtTypes(): "Alle Dokumenttypen" | "All document types" | "Todos los tipos documento" | "Tous les types de documents" | "Todos os tipos de documentos" | "Tutti i tipi documento";
20
22
  static get AllFilesAndFoldersInSupportArea(): "Alle Dateien und Ordner im Support-Bereich" | "All files and folders within the support area" | "Todos los archivos y carpetas dentro del área de soporte" | "Tous les fichiers et dossiers dans la zone de support" | "Todos os arquivos e pastas na área de apoio" | "Tutti i file e le cartelle all'interno dell'area di appoggio";
21
23
  static get AllItems(): "alle Artikel" | "All items" | "Todos los artículos" | "tous les articles" | "todos os artigos" | "tutti gli elementi";
22
24
  static get Alls2(): "Alle" | "All" | "Todos" | "Tous" | "Tutte";
@@ -329,9 +331,14 @@ export declare class SDKUI_Localizator {
329
331
  static get SelectedItems(): "Ausgewählte Artikel" | "Selected items" | "Artículos seleccionados" | "Articles sélectionnés" | "Itens selecionados" | "Elementi selezionati";
330
332
  static get SendLinkByMail(): "Link per E-Mail senden" | "Send link via mail" | "Enviar enlace por correo electrónico" | "Envoyer le lien par email" | "Enviar link por e-mail" | "Invia link tramite mail";
331
333
  static get SendToSupport(): "An den Support senden" | "Send to support" | "Enviar a soporte" | "Envoyer au support" | "Enviar para suporte" | "Invia a supporto";
334
+ static get SetAsDefault(): "Als Standardbaum festlegen" | "Set as default" | "Establecer como predeterminado" | "Définir par défaut" | "Definir como padrão" | "Imposta come predefinito";
335
+ static get SetAsDefault2(): "Standard setzen" | "Set default" | "Configurar predeterminado" | "Place le défaut" | "Definir padrão" | "Imposta default";
332
336
  static get SetAsFavorite(): "Als Favorit festlegen" | "Set as favorite" | "Establecer como favorito" | "Définir comme favori" | "Definir como favorito" | "Imposta come preferito";
333
337
  static get SetNamedCredentialsAsPreferred(): "Möchten Sie die Anmeldedaten '{{0}}' als bevorzugt festlegen?" | "Do you want to set the '{{0}}' credentials as preferred?" | "¿Quieres configurar las credenciales '{{0}}' como preferidas?" | "Voulez-vous définir les identifiants '{{0}}' comme préférés ?" | "Deseja definir as credenciais '{{0}}' como preferidas?" | "Vuoi impostare le credenziali '{{0}}' come preferite?";
334
338
  static get Settings(): "Einstellungen" | "Settings" | "Ajustes" | "Réglages" | "Definições" | "Impostazioni";
339
+ static get SharingModes_Private(): "Privat" | "Private" | "Privada" | "Privé" | "Privado" | "Privata";
340
+ static get SharingModes_Public(): "Öffentlich" | "Public" | "Pública" | "Público" | "Pubblica";
341
+ static get SharingModes_Shared(): "Geteilt" | "Shared" | "Compartida" | "Partagé" | "Partilhada" | "Condivisa";
335
342
  static get Show_CompleteName(): "Vollständigen Namen anzeigen" | "View full name" | "Mostrar nombre completo" | "Afficher le nom complet" | "Mostrar nome completo" | "Visualizza nome completo";
336
343
  static get ShowDetails(): "Details anzeigen" | "Show details" | "Mostrar detalles" | "Afficher les détails" | "Mostrar detalhes" | "Mostra dettagli";
337
344
  static get ShowFilters(): string;
@@ -354,6 +361,8 @@ export declare class SDKUI_Localizator {
354
361
  static get Type(): "Typ" | "Type" | "Tipo";
355
362
  static get TypeAMessage(): "Geben Sie eine Nachricht ein" | "Type a message" | "Escribe un mensaje" | "Tapez un message" | "Digite uma mensagem" | "Digita un messaggio";
356
363
  static get Tracing(): "Trassierung" | "Tracing" | "Trazado" | "Marquage" | "Marcação" | "Tracciatura";
364
+ static get TreesNoAvailable(): "Keine Bäume vorhanden" | "No trees available" | "No hay árboles disponibles" | "Aucun arbre disponible" | "Não há árvores disponíveis" | "Nessun albero disponibile";
365
+ static get TreeRemoveDefault(): "Standardbaum entfernen" | "Remove default tree" | "Eliminar árbol predeterminado" | "Supprimer l'arbre par défaut" | "Remover árvore padrão" | "Rimuovi albero predefinito";
357
366
  static get UBLViewFormats_ER_HTML(): "ER Style Sheet (HTML)" | "Hoja de estilo ER (HTML)" | "Feuille de style ER (HTML)" | "Folha de estilo ER (HTML)" | "Foglio di stile ER (HTML)";
358
367
  static get UBLViewFormats_ER_PDF(): "ER Style Sheet (PDF)" | "Hoja de estilo ER (PDF)" | "Feuille de style ER (PDF)" | "Folha de estilo ER (PDF)" | "Foglio di stile ER (PDF)";
359
368
  static get UBLViewFormats_NSO_HTML(): "NSO Style Sheet (HTML)" | "Hoja de estilo NSO (HTML)" | "Feuille de style NSO (HTML)" | "Folha de estilo NSO (HTML)" | "Foglio di stile NSO (HTML)";