@topconsultnpm/sdkui-react 6.20.0-dev1.2 → 6.20.0-dev1.21

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.
Files changed (49) hide show
  1. package/lib/components/NewComponents/ContextMenu/TMContextMenu.js +3 -3
  2. package/lib/components/NewComponents/ContextMenu/hooks.d.ts +1 -0
  3. package/lib/components/NewComponents/ContextMenu/hooks.js +8 -4
  4. package/lib/components/NewComponents/ContextMenu/styles.d.ts +4 -1
  5. package/lib/components/NewComponents/ContextMenu/styles.js +41 -8
  6. package/lib/components/NewComponents/ContextMenu/types.d.ts +1 -0
  7. package/lib/components/NewComponents/FloatingMenuBar/TMFloatingMenuBar.js +38 -30
  8. package/lib/components/NewComponents/FloatingMenuBar/styles.d.ts +8 -0
  9. package/lib/components/NewComponents/FloatingMenuBar/styles.js +30 -19
  10. package/lib/components/base/TMAccordion.js +2 -2
  11. package/lib/components/base/TMCustomButton.js +0 -1
  12. package/lib/components/base/TMDataGrid.d.ts +2 -2
  13. package/lib/components/base/TMDataGrid.js +16 -5
  14. package/lib/components/editors/TMHtmlEditor.js +1 -1
  15. package/lib/components/editors/TMMetadataValues.js +20 -2
  16. package/lib/components/features/documents/TMDcmtBlog.d.ts +1 -7
  17. package/lib/components/features/documents/TMDcmtBlog.js +29 -2
  18. package/lib/components/features/documents/TMDcmtForm.js +270 -173
  19. package/lib/components/features/documents/TMDcmtPreview.js +100 -33
  20. package/lib/components/features/search/TMDcmtCheckoutInfoForm.d.ts +8 -0
  21. package/lib/components/features/search/{TMSearchResultCheckoutInfoForm.js → TMDcmtCheckoutInfoForm.js} +6 -11
  22. package/lib/components/features/search/TMSearchQueryPanel.js +13 -12
  23. package/lib/components/features/search/TMSearchResult.js +76 -114
  24. package/lib/components/features/search/TMSearchResultsMenuItems.d.ts +1 -1
  25. package/lib/components/features/search/TMSearchResultsMenuItems.js +16 -17
  26. package/lib/components/features/search/TMViewHistoryDcmt.js +1 -1
  27. package/lib/components/forms/Login/TMLoginForm.js +2 -0
  28. package/lib/css/tm-sdkui.css +1 -1
  29. package/lib/helper/SDKUI_Globals.d.ts +13 -14
  30. package/lib/helper/SDKUI_Globals.js +9 -0
  31. package/lib/helper/SDKUI_Localizator.d.ts +8 -0
  32. package/lib/helper/SDKUI_Localizator.js +98 -0
  33. package/lib/helper/TMUtils.d.ts +3 -1
  34. package/lib/helper/TMUtils.js +51 -0
  35. package/lib/helper/checkinCheckoutManager.d.ts +85 -0
  36. package/lib/helper/checkinCheckoutManager.js +348 -0
  37. package/lib/helper/devextremeCustomMessages.d.ts +30 -0
  38. package/lib/helper/devextremeCustomMessages.js +30 -0
  39. package/lib/helper/helpers.js +7 -1
  40. package/lib/helper/index.d.ts +1 -0
  41. package/lib/helper/index.js +1 -0
  42. package/lib/helper/queryHelper.js +29 -0
  43. package/lib/hooks/useCheckInOutOperations.d.ts +28 -0
  44. package/lib/hooks/useCheckInOutOperations.js +223 -0
  45. package/lib/services/platform_services.d.ts +1 -1
  46. package/package.json +12 -10
  47. package/lib/components/features/search/TMSearchResultCheckoutInfoForm.d.ts +0 -8
  48. package/lib/helper/cicoHelper.d.ts +0 -31
  49. package/lib/helper/cicoHelper.js +0 -155
@@ -8,13 +8,42 @@ import { FileExtensionHandler, FormModes } from '../../../ts';
8
8
  import { TMColors } from '../../../utils/theme';
9
9
  import ShowAlert from '../../base/TMAlert';
10
10
  import TMButton from '../../base/TMButton';
11
- import TMDropDownMenu from '../../base/TMDropDownMenu';
12
11
  import { TMExceptionBoxManager } from '../../base/TMPopUp';
13
12
  import { TMLayoutWaitingContainer } from '../../base/TMWaitPanel';
14
13
  import { TMSaveFormButtonPrevious, TMSaveFormButtonNext } from '../../forms/TMSaveForm';
15
14
  import { StyledAnimatedComponentOpacity } from '../../base/Styled';
16
15
  import TMPanel from '../../base/TMPanel';
17
16
  import TMTooltip from '../../base/TMTooltip';
17
+ import { ContextMenu } from '../../NewComponents/ContextMenu';
18
+ let Document = null;
19
+ let Page = null;
20
+ let pdfjs = null;
21
+ let isPdfLibraryLoaded = false;
22
+ let loadingPromise = null;
23
+ const loadPdfLibrary = async () => {
24
+ if (isPdfLibraryLoaded)
25
+ return;
26
+ if (loadingPromise)
27
+ return loadingPromise;
28
+ loadingPromise = (async () => {
29
+ try {
30
+ const reactPdf = await import('react-pdf');
31
+ Document = reactPdf.Document;
32
+ Page = reactPdf.Page;
33
+ pdfjs = reactPdf.pdfjs;
34
+ pdfjs.GlobalWorkerOptions.workerSrc = `https://unpkg.com/pdfjs-dist@${pdfjs.version}/build/pdf.worker.min.mjs`;
35
+ isPdfLibraryLoaded = true;
36
+ }
37
+ catch (error) {
38
+ console.error('Failed to load react-pdf library:', error);
39
+ throw error;
40
+ }
41
+ finally {
42
+ loadingPromise = null;
43
+ }
44
+ })();
45
+ return loadingPromise;
46
+ };
18
47
  const ErrorContent = ({ error, isAbortError, onRetry }) => {
19
48
  if (isAbortError) {
20
49
  return (_jsx(StyledAnimatedComponentOpacity, { style: { width: '100%', height: '100%' }, children: _jsxs(StyledPanelStatusContainer, { children: [_jsx(IconCloseOutline, { fontSize: 92, color: TMColors.error }), _jsxs(StyledPreviewNotAvailable, { children: [_jsx("div", { children: error }), _jsx("div", { children: SDKUI_Localizator.PreviewNotAvailable })] }), _jsx(TMButton, { caption: SDKUI_Localizator.TryAgain, onClick: onRetry, showTooltip: false })] }) }));
@@ -124,10 +153,11 @@ const TMDcmtPreview = ({ dcmtData, isResizingActive, isVisible, canNext, canPrev
124
153
  console.error('Error reopening document:', error);
125
154
  }
126
155
  };
127
- return (_jsx(TMLayoutWaitingContainer, { direction: 'vertical', showWaitPanel: showWaitPanel, showWaitPanelPrimary: showPrimary, showWaitPanelSecondary: showSecondary, waitPanelTitle: waitPanelTitle, waitPanelTextPrimary: waitPanelTextPrimary, waitPanelValuePrimary: waitPanelValuePrimary, waitPanelMaxValuePrimary: waitPanelMaxValuePrimary, waitPanelTextSecondary: waitPanelTextSecondary, waitPanelValueSecondary: waitPanelValueSecondary, waitPanelMaxValueSecondary: waitPanelMaxValueSecondary, isCancelable: true, abortController: abortController, children: _jsx(TMPanel, { padding: '0', title: titleHandler(), onClose: onClosePanel, allowMaximize: allowMaximize, onMaximize: onMaximizePanel, onHeaderDoubleClick: onMaximizePanel, toolbar: _jsxs("div", { style: { width: 'max-content', display: 'flex', alignItems: 'center', gap: '10px' }, children: [onPrev && _jsx(TMSaveFormButtonPrevious, { btnStyle: 'icon', isModified: false, formMode: FormModes.ReadOnly, canPrev: canPrev, onPrev: onPrev }), onNext && _jsx(TMSaveFormButtonNext, { btnStyle: 'icon', isModified: false, formMode: FormModes.ReadOnly, canNext: canNext, onNext: onNext }), _jsx(StyledHeaderIcon, { "$color": TMColors.primaryColor, children: _jsx(TMDropDownMenu, { backgroundColor: 'white', borderRadius: '3px', content: _jsx(TMButton, { btnStyle: 'icon', caption: 'Altro', icon: _jsx(IconMenuVertical, {}), showTooltip: false }), items: [
128
- { icon: _jsx(IconCloseCircle, {}), text: SDKUI_Localizator.RemoveFromCache, onClick: () => { removeDcmtsFileCache(cacheKey); setIsFromCache(false); } },
129
- { icon: _jsx(IconClear, {}), text: SDKUI_Localizator.ClearCache, onClick: () => { clearDcmtsFileCache(); setIsFromCache(false); } },
130
- ] }, "btn13") }), _jsx(StyledHeaderIcon, { onClick: reOpenDcmt, "$color": TMColors.primaryColor, children: _jsx(TMTooltip, { content: SDKUI_Localizator.ReopenDocument, children: _jsx(IconRefresh, {}) }) })] }), children: error
156
+ const cacheMenuItems = useMemo(() => [
157
+ { icon: _jsx(IconCloseCircle, {}), name: SDKUI_Localizator.RemoveFromCache, onClick: () => { removeDcmtsFileCache(cacheKey); setIsFromCache(false); } },
158
+ { icon: _jsx(IconClear, {}), name: SDKUI_Localizator.ClearCache, onClick: () => { clearDcmtsFileCache(); setIsFromCache(false); } },
159
+ ], [cacheKey, removeDcmtsFileCache, clearDcmtsFileCache, setIsFromCache]);
160
+ return (_jsx(TMLayoutWaitingContainer, { direction: 'vertical', showWaitPanel: showWaitPanel, showWaitPanelPrimary: showPrimary, showWaitPanelSecondary: showSecondary, waitPanelTitle: waitPanelTitle, waitPanelTextPrimary: waitPanelTextPrimary, waitPanelValuePrimary: waitPanelValuePrimary, waitPanelMaxValuePrimary: waitPanelMaxValuePrimary, waitPanelTextSecondary: waitPanelTextSecondary, waitPanelValueSecondary: waitPanelValueSecondary, waitPanelMaxValueSecondary: waitPanelMaxValueSecondary, isCancelable: true, abortController: abortController, children: _jsx(TMPanel, { padding: '0', title: titleHandler(), onClose: onClosePanel, allowMaximize: allowMaximize, onMaximize: onMaximizePanel, onHeaderDoubleClick: onMaximizePanel, toolbar: _jsxs("div", { style: { width: 'max-content', display: 'flex', alignItems: 'center', gap: '10px' }, children: [onPrev && _jsx(TMSaveFormButtonPrevious, { btnStyle: 'icon', isModified: false, formMode: FormModes.ReadOnly, canPrev: canPrev, onPrev: onPrev }), onNext && _jsx(TMSaveFormButtonNext, { btnStyle: 'icon', isModified: false, formMode: FormModes.ReadOnly, canNext: canNext, onNext: onNext }), _jsx(StyledHeaderIcon, { "$color": TMColors.primaryColor, children: _jsx(ContextMenu, { items: cacheMenuItems, trigger: "left", children: _jsx(IconMenuVertical, {}) }) }), _jsx(StyledHeaderIcon, { onClick: reOpenDcmt, "$color": TMColors.primaryColor, children: _jsx(TMTooltip, { content: SDKUI_Localizator.ReopenDocument, children: _jsx(IconRefresh, {}) }) })] }), children: error
131
161
  ? _jsx(ErrorContent, { error: error, isAbortError: isAbortError, onRetry: reOpenDcmt })
132
162
  : renderedPreview(dcmtData?.tid, dcmtData?.did, dcmtData?.fileExt, dcmtData?.fileSize, dcmtData?.fileCount, extensionHandler(dcmtData?.fileExt), showPreview, isResizingActive, () => { loadDocumentWithCache(); setShowPreview(true); }, dcmtBlob) }) }));
133
163
  };
@@ -137,6 +167,8 @@ export const TMFileViewer = ({ fileBlob, isResizingActive }) => {
137
167
  const [fileType, setFileType] = useState(undefined);
138
168
  const [formattedXml, setFormattedXml] = useState(undefined);
139
169
  const [isMobile, setIsMobile] = useState(false);
170
+ const [numPages, setNumPages] = useState(0);
171
+ const [pdfLibraryLoading, setPdfLibraryLoading] = useState(false);
140
172
  useEffect(() => {
141
173
  const checkIsMobile = () => {
142
174
  const userAgent = navigator.userAgent || navigator.vendor || window.opera;
@@ -164,8 +196,23 @@ export const TMFileViewer = ({ fileBlob, isResizingActive }) => {
164
196
  }, []);
165
197
  useEffect(() => {
166
198
  if (fileBlob) {
167
- setFileType(fileBlob.type);
199
+ const blobType = fileBlob.type;
200
+ setFileType(blobType);
168
201
  setFormattedXml(undefined);
202
+ // Load PDF library immediately if it's a PDF file on mobile
203
+ if (isMobile && blobType === 'application/pdf' && !isPdfLibraryLoaded && !pdfLibraryLoading) {
204
+ setPdfLibraryLoading(true);
205
+ loadPdfLibrary()
206
+ .then(() => {
207
+ console.log('PDF library loaded successfully');
208
+ })
209
+ .catch((error) => {
210
+ console.error('Failed to load PDF library:', error);
211
+ })
212
+ .finally(() => {
213
+ setPdfLibraryLoading(false);
214
+ });
215
+ }
169
216
  const fileName = fileBlob.name || '';
170
217
  const fileExtension = fileName.split('.').pop()?.toLowerCase() || '';
171
218
  const isConfigFile = ['config', 'cfg'].includes(fileExtension);
@@ -223,36 +270,31 @@ export const TMFileViewer = ({ fileBlob, isResizingActive }) => {
223
270
  return (_jsx(ImageViewer, { fileBlob: fileBlob, alt: '' }));
224
271
  }
225
272
  if (fileType === 'application/pdf' && isMobile) {
226
- return (_jsx("object", { data: blobUrl, type: "application/pdf", width: "100%", height: "100%", style: {
227
- border: 'none',
228
- zIndex: 0,
229
- pointerEvents: isResizingActive === true ? "none" : "auto"
230
- }, children: _jsxs("div", { style: {
231
- padding: '40px',
232
- textAlign: 'center',
273
+ if (!isPdfLibraryLoaded || pdfLibraryLoading || !Document || !Page) {
274
+ return (_jsxs("div", { style: {
233
275
  display: 'flex',
234
- flexDirection: 'column',
235
- alignItems: 'center',
236
276
  justifyContent: 'center',
277
+ alignItems: 'center',
237
278
  height: '100%',
238
- gap: '20px'
239
- }, children: [_jsx(IconPreview, { fontSize: 96 }), _jsxs("div", { children: [_jsx("h3", { children: SDKUI_Localizator.PDFDocument }), _jsx("p", { children: SDKUI_Localizator.PreviewNotAvailableOnDevice })] }), _jsxs("div", { style: { display: 'flex', gap: '10px', flexWrap: 'wrap', alignItems: 'center', justifyContent: 'center' }, children: [_jsx("a", { href: blobUrl, download: "document.pdf", style: {
240
- minWidth: '180px',
241
- padding: '12px 24px',
242
- backgroundColor: TMColors.primaryColor,
243
- color: 'white',
244
- textDecoration: 'none',
245
- borderRadius: '4px',
246
- display: 'inline-block'
247
- }, children: SDKUI_Localizator.DownloadFile }), _jsx("a", { href: blobUrl, target: "_blank", rel: "noopener noreferrer", style: {
248
- minWidth: '180px',
249
- padding: '12px 24px',
250
- backgroundColor: TMColors.primaryColor,
251
- color: 'white',
252
- textDecoration: 'none',
253
- borderRadius: '4px',
254
- display: 'inline-block'
255
- }, children: SDKUI_Localizator.OpenInNewTab })] })] }) }, blobUrl));
279
+ flexDirection: 'column',
280
+ gap: '10px'
281
+ }, children: [_jsx(IconPreview, { fontSize: 64 }), _jsxs("div", { children: [SDKUI_Localizator.Loading, "..."] })] }));
282
+ }
283
+ return (_jsx(PDFViewerContainer, { children: _jsx(Document, { file: blobUrl, onLoadSuccess: ({ numPages }) => setNumPages(numPages), loading: _jsxs("div", { style: {
284
+ display: 'flex',
285
+ justifyContent: 'center',
286
+ alignItems: 'center',
287
+ height: '100%',
288
+ flexDirection: 'column',
289
+ gap: '10px'
290
+ }, children: [_jsx(IconPreview, { fontSize: 64 }), _jsxs("div", { children: [SDKUI_Localizator.Loading, "..."] })] }), error: _jsxs("div", { style: {
291
+ display: 'flex',
292
+ justifyContent: 'center',
293
+ alignItems: 'center',
294
+ height: '100%',
295
+ flexDirection: 'column',
296
+ gap: '10px'
297
+ }, children: [_jsx(IconCloseOutline, { fontSize: 64, color: TMColors.error }), _jsx("div", { children: "Errore nel caricamento del PDF" })] }), children: Array.from(new Array(numPages), (el, index) => (_jsx(Page, { pageNumber: index + 1, renderTextLayer: false, renderAnnotationLayer: false, width: window.innerWidth }, `page_${index + 1}`))) }) }));
256
298
  }
257
299
  return (_jsx("iframe", { srcDoc: formattedXml ? `<html><body>${formattedXml}</body></html>` : undefined, src: !formattedXml
258
300
  ? (fileType === 'application/pdf' ? `${blobUrl}#view=FitH&scrollbar=1` : blobUrl)
@@ -475,3 +517,28 @@ const StyledImage = styled.img.attrs(props => ({
475
517
  pointer-events: none;
476
518
  position: absolute;
477
519
  `;
520
+ const PDFViewerContainer = styled.div `
521
+ width: 100%;
522
+ height: 100%;
523
+ overflow-y: auto;
524
+ overflow-x: hidden;
525
+ background-color: #f5f5f5;
526
+
527
+ .react-pdf__Document {
528
+ display: flex;
529
+ flex-direction: column;
530
+ align-items: center;
531
+ gap: 10px;
532
+ padding: 10px 0;
533
+ }
534
+
535
+ .react-pdf__Page {
536
+ box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
537
+ margin: 0 auto;
538
+ }
539
+
540
+ .react-pdf__Page__canvas {
541
+ max-width: 100%;
542
+ height: auto !important;
543
+ }
544
+ `;
@@ -0,0 +1,8 @@
1
+ import { DcmtInfo } from "../../../ts";
2
+ interface TMDcmtCheckoutInfoFormProps {
3
+ dtdName: string;
4
+ selectedDcmtOrFocused: DcmtInfo;
5
+ onClose: () => void;
6
+ }
7
+ declare const TMDcmtCheckoutInfoForm: (props: TMDcmtCheckoutInfoFormProps) => import("react/jsx-runtime").JSX.Element;
8
+ export default TMDcmtCheckoutInfoForm;
@@ -5,14 +5,14 @@ import { IconBxInfo, IconFileDots, IconFolder, SDKUI_Globals, SDKUI_Localizator
5
5
  import { FormModes } from "../../../ts";
6
6
  import { ResultTypes, ValidationItem } from "@topconsultnpm/sdk-ts";
7
7
  import { SaveFormOptions, useSaveForm } from "../../../hooks/useForm";
8
- import { getCicoDownloadFileName, updateDcmtCheckoutItem } from "../../../helper/cicoHelper";
8
+ import { getCicoDownloadFileName, updateCicoCheckoutStorageItem } from "../../../helper/checkinCheckoutManager";
9
9
  import { TMColors } from "../../../utils/theme";
10
10
  import TMLayoutContainer, { TMLayoutItem } from "../../base/TMLayout";
11
11
  import TMTooltip from "../../base/TMTooltip";
12
12
  import TMTextBox from "../../editors/TMTextBox";
13
13
  import ShowAlert from "../../base/TMAlert";
14
14
  import { TMExceptionBoxManager } from "../../base/TMPopUp";
15
- const TMSearchResultCheckoutInfoForm = (props) => {
15
+ const TMDcmtCheckoutInfoForm = (props) => {
16
16
  const { dtdName, selectedDcmtOrFocused, onClose } = props;
17
17
  const [initialDcmtCheckoutFolder, setInitialDcmtCheckoutFolder] = useState("");
18
18
  const [initialDcmtCheckoutName, setInitialDcmtCheckoutName] = useState("");
@@ -31,7 +31,7 @@ const TMSearchResultCheckoutInfoForm = (props) => {
31
31
  const dcmtCheckoutInfoCurrentItems = [...SDKUI_Globals.userSettings.dcmtCheckoutInfo];
32
32
  const existingItem = dcmtCheckoutInfoCurrentItems.find((item) => item.TID === selectedDcmtOrFocused.TID.toString() && item.DID === selectedDcmtOrFocused.DID.toString());
33
33
  const folder = existingItem?.checkoutFolder ?? "";
34
- const name = existingItem?.checkoutName ?? getCicoDownloadFileName(dtdName ?? SDKUI_Localizator.SearchResult, selectedDcmtOrFocused, true, false);
34
+ const name = existingItem?.checkoutName ?? getCicoDownloadFileName({ type: 'dcmtInfo', dcmtInfo: selectedDcmtOrFocused, originalFileName: dtdName ?? SDKUI_Localizator.SearchResult }, true, false);
35
35
  // Set form data
36
36
  setFormData({
37
37
  ...formData,
@@ -57,13 +57,8 @@ const TMSearchResultCheckoutInfoForm = (props) => {
57
57
  // Check: formData must exist, selectedDcmtOrFocused.TID and selectedDcmtOrFocused.DID must exist, and at least one of checkoutFolder or checkoutName must be filled
58
58
  if (formData && selectedDcmtOrFocused.TID && selectedDcmtOrFocused.DID) {
59
59
  // Create a new draft checkout item with TID, DID, and folder/name values
60
- const newItem = {
61
- TID: selectedDcmtOrFocused.TID.toString(),
62
- DID: selectedDcmtOrFocused.DID.toString(),
63
- checkoutFolder: formData.checkoutFolder ?? "",
64
- checkoutName: formData.checkoutName ?? ""
65
- };
66
- updateDcmtCheckoutItem(newItem, "addOrUpdate");
60
+ const newItem = { TID: selectedDcmtOrFocused.TID.toString(), DID: selectedDcmtOrFocused.DID.toString(), checkoutFolder: formData.checkoutFolder ?? "", checkoutName: formData.checkoutName ?? "" };
61
+ updateCicoCheckoutStorageItem(newItem, "dcmtInfo", "addOrUpdate");
67
62
  onClose();
68
63
  ShowAlert({ mode: 'success', title: SDKUI_Localizator.CheckoutInfo, message: SDKUI_Localizator.OperationSuccess, duration: 3000 });
69
64
  }
@@ -131,4 +126,4 @@ const TMSearchResultCheckoutInfoForm = (props) => {
131
126
  e.currentTarget.style.color = TMColors.primary;
132
127
  }, children: SDKUI_Localizator.Cancel })] })] }) }) }) }) });
133
128
  };
134
- export default TMSearchResultCheckoutInfoForm;
129
+ export default TMDcmtCheckoutInfoForm;
@@ -1,5 +1,5 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
- import { useCallback, useEffect, useRef, useState } from 'react';
2
+ import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
3
3
  import { PlatformObjectValidator, WhereItem, SDK_Localizator, OrderByItem, SelectItem, SelectItemVisibilities, SDK_Globals, SavedQueryCacheService, SearchEngine, QueryOperators } from '@topconsultnpm/sdk-ts';
4
4
  import styled from 'styled-components';
5
5
  import TMSearchQueryEditor from './TMSearchQueryEditor';
@@ -11,7 +11,6 @@ import { StyledModalContainer } from '../../base/Styled';
11
11
  import ShowAlert from '../../base/TMAlert';
12
12
  import TMButton from '../../base/TMButton';
13
13
  import { useDeviceType, DeviceType } from '../../base/TMDeviceProvider';
14
- import TMDropDownMenu from '../../base/TMDropDownMenu';
15
14
  import { TMExceptionBoxManager } from '../../base/TMPopUp';
16
15
  import TMSpinner from '../../base/TMSpinner';
17
16
  import TMPanel from '../../base/TMPanel';
@@ -19,6 +18,7 @@ import TMDistinctValues from '../../choosers/TMDistinctValues';
19
18
  import { TMMetadataChooserForm } from '../../choosers/TMMetadataChooser';
20
19
  import TMQueryEditor from '../../query/TMQueryEditor';
21
20
  import TMSavedQueryForm from './TMSavedQueryForm';
21
+ import { ContextMenu } from '../../NewComponents/ContextMenu';
22
22
  import { AdvancedMenuButtons } from '../../editors/TMMetadataValues';
23
23
  import TMToppyMessage from '../../../helper/TMToppyMessage';
24
24
  const TMSearchQueryPanel = ({ fromDTD, showBackToResultButton, isExpertMode = SDKUI_Globals.userSettings.advancedSettings.expertMode === 1, SQD, inputMids, onSearchCompleted, onSqdSaved, onBack, onClosePanel, allowMaximize = true, onMaximizePanel, onBackToResult, passToArchiveCallback }) => {
@@ -299,20 +299,21 @@ const TMSearchQueryPanel = ({ fromDTD, showBackToResultButton, isExpertMode = SD
299
299
  }
300
300
  setQd({ ...qd, orderBy: newOrderBy });
301
301
  }, [qd, fromDTD?.metadata, SQD?.masterTID]);
302
+ const contextMenuItems = useMemo(() => [
303
+ ...(showBackToResultButton ? [{ icon: _jsx(IconArrowRight, {}), name: "Vai a risultato", onClick: () => { onBackToResult?.(); } }] : []),
304
+ { icon: _jsx(IconAddCircleOutline, {}), name: SDKUI_Localizator.SavedQueryNew, beginGroup: showBackToResultButton, onClick: () => { openSqdForm(FormModes.Create); } },
305
+ { icon: _jsx(IconEdit, {}), name: SDKUI_Localizator.SavedQueryUpdate, disabled: (SQD && SQD.id == 1), onClick: () => { openSqdForm(FormModes.Update); } },
306
+ { icon: showAdvancedSearch ? _jsx(IconEasy, {}) : _jsx(IconAdvanced, {}), beginGroup: true, name: showAdvancedSearch ? SDKUI_Localizator.Search_Easy : SDKUI_Localizator.Search_Advanced, onClick: () => { changeAdvancedSearchAsync(!showAdvancedSearch); } },
307
+ { icon: _jsx(IconEdit, {}), name: `${SDKUI_Localizator.Configure} - ${SDK_Localizator.QueryWhere}`, beginGroup: true, onClick: () => { setShowFiltersConfig(true); } },
308
+ { icon: _jsx(IconEdit, {}), name: `${SDKUI_Localizator.Configure} - ${SDK_Localizator.QuerySelect}`, onClick: () => { setShowOutputConfig(true); } },
309
+ { icon: _jsx(IconEdit, {}), name: `${SDKUI_Localizator.Configure} - ${SDK_Localizator.QueryOrderBy}`, onClick: () => { setShowOrderByConfig(true); } },
310
+ { icon: _jsx(IconMenuCAArchive, { viewBox: '11 11.5 26 27', fontSize: 16, strokeWidth: 2, color: 'black' }), beginGroup: true, name: SDKUI_Localizator.PassToArchive, onClick: handlePassToArchive }
311
+ ], [showBackToResultButton, showAdvancedSearch, SQD, onBackToResult, openSqdForm, changeAdvancedSearchAsync, setShowFiltersConfig, setShowOutputConfig, setShowOrderByConfig, handlePassToArchive]);
302
312
  const captionText = showAllMdWhere ? SDKUI_Localizator.ShowLess : SDKUI_Localizator.ShowAll;
303
313
  let maxItems = getListMaxItems(deviceType ?? DeviceType.DESKTOP);
304
314
  const diff = (qd?.where?.length ?? 0) - maxItems;
305
315
  return (_jsxs(_Fragment, { children: [_jsxs(TMPanel, { title: fromDTD?.nameLoc ?? SDKUI_Localizator.Search_Metadata, allowMaximize: allowMaximize, onMaximize: onMaximizePanel, onHeaderDoubleClick: onMaximizePanel, onBack: onBack, onActiveChanged: handlePanelActiveChanged, toolbar: _jsx(_Fragment, { children: (SQD && !showSqdForm) ?
306
- _jsx(TMDropDownMenu, { backgroundColor: 'white', borderRadius: '3px', content: _jsx(TMButton, { btnStyle: 'icon', caption: 'Altro', icon: _jsx(IconMenuVertical, { color: 'white' }), showTooltip: false, onClick: () => setIsQueryPanelActive(true) }), items: [
307
- ...(showBackToResultButton ? [{ icon: _jsx(IconArrowRight, {}), text: "Vai a risultato", onClick: () => { onBackToResult?.(); } }] : []),
308
- { icon: _jsx(IconAddCircleOutline, {}), beginGroup: true, text: SDKUI_Localizator.SavedQueryNew, onClick: () => { openSqdForm(FormModes.Create); } },
309
- { icon: _jsx(IconEdit, {}), text: SDKUI_Localizator.SavedQueryUpdate, disabled: (SQD && SQD.id == 1), onClick: () => { openSqdForm(FormModes.Update); } },
310
- { icon: showAdvancedSearch ? _jsx(IconEasy, {}) : _jsx(IconAdvanced, {}), beginGroup: true, text: showAdvancedSearch ? SDKUI_Localizator.Search_Easy : SDKUI_Localizator.Search_Advanced, onClick: () => { changeAdvancedSearchAsync(!showAdvancedSearch); } },
311
- { icon: _jsx(IconEdit, {}), beginGroup: true, text: `${SDKUI_Localizator.Configure} - ${SDK_Localizator.QueryWhere}`, onClick: () => { setShowFiltersConfig(true); } },
312
- { icon: _jsx(IconEdit, {}), text: `${SDKUI_Localizator.Configure} - ${SDK_Localizator.QuerySelect}`, onClick: () => { setShowOutputConfig(true); } },
313
- { icon: _jsx(IconEdit, {}), text: `${SDKUI_Localizator.Configure} - ${SDK_Localizator.QueryOrderBy}`, onClick: () => { setShowOrderByConfig(true); } },
314
- { icon: _jsx(IconMenuCAArchive, { viewBox: '11 11.5 26 27', fontSize: 16, strokeWidth: 2, color: 'black' }), beginGroup: true, text: SDKUI_Localizator.PassToArchive, onClick: handlePassToArchive }
315
- ], onMenuShown: () => setIsQueryPanelActive(true) })
316
+ _jsx(ContextMenu, { items: contextMenuItems, trigger: "left", children: _jsx(TMButton, { btnStyle: 'icon', caption: 'Altro', icon: _jsx(IconMenuVertical, { color: 'white' }), showTooltip: false, onClick: () => setIsQueryPanelActive(true) }) })
316
317
  : _jsx(_Fragment, {}) }), children: [_jsx(ConfirmQueryParamsDialog, {}), SQD
317
318
  ? _jsxs("div", { onContextMenu: (e) => e.preventDefault(), style: { height: '100%', width: '100%', position: 'relative', display: 'flex', flexDirection: 'column', gap: 5 }, children: [showAdvancedSearch
318
319
  ? _jsx(TMQueryEditor, { formMode: FormModes.Update, showToolbar: false, inputData: qd, validateSelect: true, showApply: false, onQDChanged: handleQdChanged })