@topconsultnpm/sdkui-react 6.21.0-dev3.9 → 6.21.0-dev4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/components/NewComponents/ContextMenu/TMContextMenu.js +22 -1
- package/lib/components/NewComponents/FloatingMenuBar/styles.d.ts +6 -6
- package/lib/components/base/TMAreaManager.js +11 -0
- package/lib/components/base/TMDataGrid.js +12 -2
- package/lib/components/base/TMDataGridExportForm.js +19 -8
- package/lib/components/base/TMModal.js +2 -2
- package/lib/components/base/TMPopUp.d.ts +1 -0
- package/lib/components/base/TMPopUp.js +59 -2
- package/lib/components/base/TMSpinner.d.ts +4 -2
- package/lib/components/base/TMSpinner.js +33 -6
- package/lib/components/choosers/TMDistinctValues.js +1 -1
- package/lib/components/choosers/TMGroupChooser.js +1 -1
- package/lib/components/editors/TMEditorStyled.d.ts +4 -4
- package/lib/components/editors/TMFormulaEditor.d.ts +1 -0
- package/lib/components/editors/TMFormulaEditor.js +98 -49
- package/lib/components/editors/TMMetadataValues.js +23 -6
- package/lib/components/features/documents/TMMasterDetailDcmts.js +1 -1
- package/lib/components/features/documents/TMRelationViewer.js +3 -3
- package/lib/components/features/search/TMMetadataOutputForm.d.ts +17 -0
- package/lib/components/features/search/TMMetadataOutputForm.js +225 -0
- package/lib/components/features/search/TMMetadataSorterForm.d.ts +17 -0
- package/lib/components/features/search/TMMetadataSorterForm.js +243 -0
- package/lib/components/features/search/TMSearchQueryPanel.js +249 -58
- package/lib/components/features/search/TMSearchResult.d.ts +1 -0
- package/lib/components/features/search/TMSearchResult.js +39 -18
- package/lib/components/features/search/metadataFormHelper.d.ts +16 -0
- package/lib/components/features/search/metadataFormHelper.js +77 -0
- package/lib/components/forms/Login/TMLoginForm.js +15 -3
- package/lib/components/wizard/TMWizard.d.ts +1 -0
- package/lib/components/wizard/TMWizard.js +5 -3
- package/lib/helper/Enum_Localizator.js +1 -0
- package/lib/helper/SDKUI_Localizator.d.ts +4 -0
- package/lib/helper/SDKUI_Localizator.js +40 -0
- package/lib/helper/checkinCheckoutManager.js +10 -2
- package/lib/helper/helpers.d.ts +2 -1
- package/lib/helper/helpers.js +1 -0
- package/lib/hooks/useDataUserIdItem.js +1 -1
- package/lib/hooks/useDcmtOperations.js +168 -3
- package/lib/hooks/useDocumentOperations.js +19 -0
- package/lib/services/platform_services.d.ts +4 -4
- package/lib/ts/types.d.ts +2 -1
- package/lib/ts/types.js +1 -0
- package/package.json +62 -56
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
3
|
-
import { PlatformObjectValidator, QueryDescriptor, WhereItem, SDK_Localizator,
|
|
3
|
+
import { PlatformObjectValidator, QueryDescriptor, WhereItem, SDK_Localizator, SelectItemVisibilities, SDK_Globals, SavedQueryCacheService, SearchEngine, QueryOperators, AccessLevelsEx, AccessLevels } from '@topconsultnpm/sdk-ts';
|
|
4
4
|
import styled from 'styled-components';
|
|
5
5
|
import TMSearchQueryEditor from './TMSearchQueryEditor';
|
|
6
|
-
import { getDcmtTypesByQdAsync, SDKUI_Localizator, getQD, IconMenuVertical, IconAddCircleOutline, IconEdit, IconEasy, IconAdvanced, deepCompare, IconSearch, IconClear, getDefaultOperator, prepareQdForSearchAsync, IsParametricQuery, SDKUI_Globals, IconArrowRight, IconMenuCAArchive, getListMaxItems, DEFAULT_MAX_DCMTS_TO_BE_RETURNED } from '../../../helper';
|
|
6
|
+
import { getDcmtTypesByQdAsync, SDKUI_Localizator, getQD, IconMenuVertical, IconAddCircleOutline, IconEdit, IconEasy, IconAdvanced, deepCompare, IconSearch, IconClear, getDefaultOperator, prepareQdForSearchAsync, IsParametricQuery, SDKUI_Globals, IconArrowRight, IconMenuCAArchive, getListMaxItems, DEFAULT_MAX_DCMTS_TO_BE_RETURNED, IconSortAsc, IconSortDesc, IconFilter, IconColumns, IconSort } from '../../../helper';
|
|
7
7
|
import { useQueryParametersDialog } from '../../../hooks/useQueryParametersDialog';
|
|
8
8
|
import { FormModes } from '../../../ts';
|
|
9
9
|
import { TMColors } from '../../../utils/theme';
|
|
@@ -21,6 +21,9 @@ import TMSavedQueryForm from './TMSavedQueryForm';
|
|
|
21
21
|
import { ContextMenu } from '../../NewComponents/ContextMenu';
|
|
22
22
|
import { AdvancedMenuButtons } from '../../editors/TMMetadataValues';
|
|
23
23
|
import TMToppyMessage from '../../../helper/TMToppyMessage';
|
|
24
|
+
import TMMetadataSorterForm from './TMMetadataSorterForm';
|
|
25
|
+
import TMMetadataOutputForm from './TMMetadataOutputForm';
|
|
26
|
+
import TMTooltip from '../../base/TMTooltip';
|
|
24
27
|
const TMSearchQueryPanel = ({ fromDTD, showBackToResultButton, isExpertMode = SDKUI_Globals.userSettings.advancedSettings.expertMode === 1, SQD, inputMids, onSearchCompleted, onSqdSaved, onBack, onClosePanel, allowMaximize = true, onMaximizePanel, onBackToResult, passToArchiveCallback, maxDcmtsToBeReturned }) => {
|
|
25
28
|
const [confirmQueryParams, ConfirmQueryParamsDialog] = useQueryParametersDialog();
|
|
26
29
|
const [qd, setQd] = useState();
|
|
@@ -34,7 +37,7 @@ const TMSearchQueryPanel = ({ fromDTD, showBackToResultButton, isExpertMode = SD
|
|
|
34
37
|
const [showAdvancedSearch, setShowAdvancedSearch] = useState(false);
|
|
35
38
|
const [showFiltersConfig, setShowFiltersConfig] = useState(false);
|
|
36
39
|
const [showOutputConfig, setShowOutputConfig] = useState(false);
|
|
37
|
-
const [
|
|
40
|
+
const [showMetadataSorterForm, setShowMetadataSorterForm] = useState(false);
|
|
38
41
|
const [showDistinctValuesPanel, setShowDistinctValuesPanel] = useState(false);
|
|
39
42
|
const [focusedTidMid, setFocusedTidMid] = useState();
|
|
40
43
|
const [modalIsOpen, setModalIsOpen] = useState(false);
|
|
@@ -162,7 +165,7 @@ const TMSearchQueryPanel = ({ fromDTD, showBackToResultButton, isExpertMode = SD
|
|
|
162
165
|
newWi.init({ ...curItem, value1: undefined, value2: undefined });
|
|
163
166
|
return newWi;
|
|
164
167
|
});
|
|
165
|
-
setQd({ ...qd, where: newWhere });
|
|
168
|
+
setQd({ ...qd, where: newWhere, orderBy: [] });
|
|
166
169
|
};
|
|
167
170
|
const searchAsync = async (qdInput, isAdvancedSearch) => {
|
|
168
171
|
onSearchCompleted?.([], undefined); // reset results
|
|
@@ -266,70 +269,84 @@ const TMSearchQueryPanel = ({ fromDTD, showBackToResultButton, isExpertMode = SD
|
|
|
266
269
|
setQd({ ...qd, where: newWhere });
|
|
267
270
|
}, [qd, fromDTD?.metadata, SQD?.masterTID]);
|
|
268
271
|
const handleCloseOutputConfig = useCallback(() => setShowOutputConfig(false), []);
|
|
269
|
-
const handleChooseOutput = useCallback((tid_mids) => {
|
|
270
|
-
if (!fromDTD?.metadata)
|
|
271
|
-
return;
|
|
272
|
-
if (!tid_mids)
|
|
273
|
-
return;
|
|
274
|
-
// copia dei SelectItems senza i rimossi
|
|
275
|
-
let newSelect = qd?.select?.filter(item => tid_mids?.some(tm => tm.mid == item.mid)) ?? [];
|
|
276
|
-
// aggiungiamo i nuovi
|
|
277
|
-
for (const tm of tid_mids.filter(tm => !qd?.select?.some(item => item.mid == tm.mid))) {
|
|
278
|
-
let md = fromDTD?.metadata.find(o => o.id == tm.mid);
|
|
279
|
-
let si = new SelectItem();
|
|
280
|
-
si.visibility = SelectItemVisibilities.Visible;
|
|
281
|
-
si.tid = SQD?.masterTID;
|
|
282
|
-
si.mid = md?.id;
|
|
283
|
-
let indexMD = 0;
|
|
284
|
-
for (const m of fromDTD?.metadata ?? []) {
|
|
285
|
-
if (m.id == si.mid)
|
|
286
|
-
break;
|
|
287
|
-
if (newSelect.findIndex(o => o.mid == m.id && o.tid == SQD?.masterTID) < 0)
|
|
288
|
-
continue;
|
|
289
|
-
indexMD++;
|
|
290
|
-
}
|
|
291
|
-
newSelect.splice(indexMD, 0, si);
|
|
292
|
-
}
|
|
293
|
-
setQd({ ...qd, select: newSelect });
|
|
294
|
-
}, [qd, fromDTD?.metadata, SQD?.masterTID]);
|
|
295
|
-
const handleCloseOrderByConfig = useCallback(() => setShowOrderByConfig(false), []);
|
|
296
|
-
const handleChooseOrderBy = useCallback((tid_mids) => {
|
|
297
|
-
if (!fromDTD?.metadata)
|
|
298
|
-
return;
|
|
299
|
-
if (!tid_mids)
|
|
300
|
-
return;
|
|
301
|
-
// copia dei OrderByItems senza i rimossi
|
|
302
|
-
let newOrderBy = qd?.orderBy?.filter(item => tid_mids?.some(tm => tm.mid == item.mid)) ?? [];
|
|
303
|
-
// aggiungiamo i nuovi
|
|
304
|
-
for (const tm of tid_mids.filter(tm => !qd?.orderBy?.some(item => item.mid == tm.mid))) {
|
|
305
|
-
let md = fromDTD?.metadata.find(o => o.id == tm.mid);
|
|
306
|
-
let oi = new OrderByItem();
|
|
307
|
-
oi.tid = SQD?.masterTID;
|
|
308
|
-
oi.mid = md?.id;
|
|
309
|
-
oi.asc = true;
|
|
310
|
-
newOrderBy.push(oi);
|
|
311
|
-
}
|
|
312
|
-
setQd({ ...qd, orderBy: newOrderBy });
|
|
313
|
-
}, [qd, fromDTD?.metadata, SQD?.masterTID]);
|
|
314
272
|
const contextMenuItems = useMemo(() => [
|
|
315
273
|
...(showBackToResultButton ? [{ icon: _jsx(IconArrowRight, {}), name: "Vai a risultato", onClick: () => { onBackToResult?.(); } }] : []),
|
|
316
274
|
{ icon: _jsx(IconAddCircleOutline, {}), name: SDKUI_Localizator.SavedQueryNew, beginGroup: showBackToResultButton, onClick: () => { openSqdForm(FormModes.Create); } },
|
|
317
275
|
{ icon: _jsx(IconEdit, {}), name: SDKUI_Localizator.SavedQueryUpdate, disabled: (SQD && SQD.id == 1), onClick: () => { openSqdForm(FormModes.Update); } },
|
|
318
276
|
{ icon: showAdvancedSearch ? _jsx(IconEasy, {}) : _jsx(IconAdvanced, {}), beginGroup: true, name: showAdvancedSearch ? SDKUI_Localizator.Search_Easy : SDKUI_Localizator.Search_Advanced, onClick: () => { changeAdvancedSearchAsync(!showAdvancedSearch); } },
|
|
319
|
-
{ icon: _jsx(
|
|
320
|
-
{ icon: _jsx(
|
|
321
|
-
{ icon: _jsx(
|
|
277
|
+
{ icon: _jsx(IconFilter, {}), name: `${SDKUI_Localizator.Configure} - ${SDK_Localizator.QueryWhere}`, beginGroup: true, onClick: () => { setShowFiltersConfig(true); } },
|
|
278
|
+
{ icon: _jsx(IconColumns, {}), name: `${SDKUI_Localizator.Configure} - ${SDK_Localizator.QuerySelect}`, onClick: () => { setShowOutputConfig(true); } },
|
|
279
|
+
{ icon: _jsx(IconSort, {}), name: `${SDKUI_Localizator.Configure} - ${SDK_Localizator.QueryOrderBy}`, onClick: () => { setShowMetadataSorterForm(true); } },
|
|
322
280
|
{ icon: _jsx(IconMenuCAArchive, { viewBox: '11 11.5 26 27', fontSize: 16, strokeWidth: 2, color: 'black' }), beginGroup: true, name: SDKUI_Localizator.PassToArchive, disabled: fromDTD?.perm?.canArchive !== AccessLevelsEx.Yes && fromDTD?.perm?.canArchive !== AccessLevelsEx.Mixed, onClick: handlePassToArchive }
|
|
323
|
-
], [showBackToResultButton, showAdvancedSearch, SQD, onBackToResult, openSqdForm, changeAdvancedSearchAsync, setShowFiltersConfig, setShowOutputConfig,
|
|
281
|
+
], [showBackToResultButton, showAdvancedSearch, SQD, onBackToResult, openSqdForm, changeAdvancedSearchAsync, setShowFiltersConfig, setShowOutputConfig, handlePassToArchive, fromDTD?.perm?.canArchive]);
|
|
324
282
|
const captionText = showAllMdWhere ? SDKUI_Localizator.ShowLess : SDKUI_Localizator.ShowAll;
|
|
325
283
|
let maxItems = getListMaxItems(deviceType ?? DeviceType.DESKTOP);
|
|
326
284
|
const diff = (qd?.where?.length ?? 0) - maxItems;
|
|
285
|
+
// Calcola se mostrare i badges di output
|
|
286
|
+
// Non mostrare se: modalità avanzata, tutti i metadati selezionati, o tutti tranne quelli di sistema
|
|
287
|
+
const shouldShowOutputBadges = useMemo(() => {
|
|
288
|
+
// In modalità avanzata non mostrare mai i badges di output
|
|
289
|
+
if (showAdvancedSearch)
|
|
290
|
+
return false;
|
|
291
|
+
if (!qd?.select || qd.select.length === 0)
|
|
292
|
+
return false;
|
|
293
|
+
if (!fromDTD?.metadata)
|
|
294
|
+
return true;
|
|
295
|
+
// Filtra i metadati disponibili per output (stessa logica usata in TMMetadataOutputForm)
|
|
296
|
+
const availableOutputMetadata = fromDTD.metadata.filter(o => o.perm?.canView === AccessLevels.Yes || o.perm?.canUpdate === AccessLevels.Yes);
|
|
297
|
+
// Metadati non di sistema disponibili per output
|
|
298
|
+
const availableNonSystemMetadata = availableOutputMetadata.filter(o => o.isSystem !== 1);
|
|
299
|
+
const selectedCount = qd.select.length;
|
|
300
|
+
const totalAvailable = availableOutputMetadata.length;
|
|
301
|
+
const totalNonSystem = availableNonSystemMetadata.length;
|
|
302
|
+
// Non mostrare se sono selezionati tutti i metadati disponibili
|
|
303
|
+
if (selectedCount === totalAvailable)
|
|
304
|
+
return false;
|
|
305
|
+
// Non mostrare se sono selezionati tutti i metadati non di sistema
|
|
306
|
+
// (verifica che tutti quelli selezionati siano non di sistema e che siano tutti)
|
|
307
|
+
const selectedMids = new Set(qd.select.map(s => s.mid));
|
|
308
|
+
const allSelectedAreNonSystem = qd.select.every(s => {
|
|
309
|
+
const md = fromDTD.metadata?.find(m => m.id === s.mid);
|
|
310
|
+
return md && md.isSystem !== 1;
|
|
311
|
+
});
|
|
312
|
+
const allNonSystemAreSelected = availableNonSystemMetadata.every(m => selectedMids.has(m.id));
|
|
313
|
+
if (allSelectedAreNonSystem && allNonSystemAreSelected && selectedCount === totalNonSystem) {
|
|
314
|
+
return false;
|
|
315
|
+
}
|
|
316
|
+
return true;
|
|
317
|
+
}, [showAdvancedSearch, qd?.select, fromDTD?.metadata]);
|
|
318
|
+
// In modalità avanzata non mostrare i badges di ordinamento
|
|
319
|
+
const shouldShowOrderByBadges = useMemo(() => {
|
|
320
|
+
if (showAdvancedSearch)
|
|
321
|
+
return false;
|
|
322
|
+
return qd?.orderBy && qd.orderBy.length > 0;
|
|
323
|
+
}, [showAdvancedSearch, qd?.orderBy]);
|
|
327
324
|
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) ?
|
|
328
325
|
_jsx(ContextMenu, { items: contextMenuItems, trigger: "left", children: _jsx(TMButton, { btnStyle: 'icon', caption: 'Altro', icon: _jsx(IconMenuVertical, { color: 'white' }), showTooltip: false, onClick: () => setIsQueryPanelActive(true) }) })
|
|
329
326
|
: _jsx(_Fragment, {}) }), children: [_jsx(ConfirmQueryParamsDialog, {}), SQD
|
|
330
327
|
? _jsxs("div", { onContextMenu: (e) => e.preventDefault(), style: { height: '100%', width: '100%', position: 'relative', display: showSqdForm ? 'none' : 'flex', flexDirection: 'column', gap: 5 }, children: [showAdvancedSearch
|
|
331
328
|
? _jsx(TMQueryEditor, { formMode: FormModes.Update, showToolbar: false, inputData: qd, validateSelect: true, showApply: false, onQDChanged: handleQdChanged, updateIsModalOpen: updateIsModalOpen })
|
|
332
|
-
: _jsx(TMSearchQueryEditor, { qd: qd, dcmtTypesList: dcmtTypesList, isExpertMode: isExpertMode, showAllMdWhere: showAllMdWhere, onQdChanged: handleQdChanged, onFocusedMetadataChanged: setFocusedTidMid, onAdvancedMenuClick: handleAdvancedMenuClick, updateIsModalOpen: updateIsModalOpen }), _jsxs("
|
|
329
|
+
: _jsx(TMSearchQueryEditor, { qd: qd, dcmtTypesList: dcmtTypesList, isExpertMode: isExpertMode, showAllMdWhere: showAllMdWhere, onQdChanged: handleQdChanged, onFocusedMetadataChanged: setFocusedTidMid, onAdvancedMenuClick: handleAdvancedMenuClick, updateIsModalOpen: updateIsModalOpen }), shouldShowOutputBadges && qd?.select && qd.select.length > 0 && (_jsxs(StyledSelectBadgesContainer, { children: [_jsxs(StyledSelectLabel, { children: [SDK_Localizator.QuerySelect, ":"] }), _jsx(StyledSelectBadgesWrapper, { children: (() => {
|
|
330
|
+
const selectItems = qd.select ?? [];
|
|
331
|
+
const maxVisible = isMobile ? 1 : 2;
|
|
332
|
+
const visibleItems = selectItems.slice(0, maxVisible);
|
|
333
|
+
const hiddenCount = selectItems.length - maxVisible;
|
|
334
|
+
return (_jsxs(_Fragment, { children: [visibleItems.map((si, index) => {
|
|
335
|
+
const md = fromDTD?.metadata?.find(m => m.id === si.mid);
|
|
336
|
+
const mdName = md?.nameLoc ?? md?.name ?? `MID ${si.mid}`;
|
|
337
|
+
return (_jsxs(StyledSelectBadge, { children: [_jsx(IconColumns, { fontSize: 12 }), _jsx("span", { className: "badge-name", children: mdName })] }, `${si.tid}-${si.mid}-${index}`));
|
|
338
|
+
}), hiddenCount > 0 && (_jsxs(StyledSelectBadgeMore, { onClick: () => setShowOutputConfig(true), children: ["+", hiddenCount] }))] }));
|
|
339
|
+
})() }), _jsx(StyledSelectEditButton, { title: SDKUI_Localizator.Configure, onClick: () => setShowOutputConfig(true), children: _jsx(IconEdit, { fontSize: 16 }) })] })), shouldShowOrderByBadges && qd?.orderBy && qd.orderBy.length > 0 && (_jsxs(StyledOrderByBadgesContainer, { children: [_jsxs(StyledOrderByLabel, { children: [qd.orderBy.length === 1 ? SDKUI_Localizator.SortBy : SDKUI_Localizator.SortByPlural, ":"] }), _jsx(StyledOrderByBadgesWrapper, { children: (() => {
|
|
340
|
+
const orderByItems = qd.orderBy ?? [];
|
|
341
|
+
const maxVisible = isMobile ? 1 : 2;
|
|
342
|
+
const visibleItems = orderByItems.slice(0, maxVisible);
|
|
343
|
+
const hiddenCount = orderByItems.length - maxVisible;
|
|
344
|
+
return (_jsxs(_Fragment, { children: [visibleItems.map((obi, index) => {
|
|
345
|
+
const md = fromDTD?.metadata?.find(m => m.id === obi.mid);
|
|
346
|
+
const mdName = md?.nameLoc ?? md?.name ?? `MID ${obi.mid}`;
|
|
347
|
+
return (_jsxs(StyledOrderByBadge, { children: [_jsx(TMTooltip, { content: obi.asc !== false ? SDKUI_Localizator.ValueAscending : SDKUI_Localizator.ValueDescending, children: obi.asc !== false ? (_jsx(IconSortAsc, { fontSize: 12 })) : (_jsx(IconSortDesc, { fontSize: 12 })) }), _jsx("span", { className: "badge-name", children: mdName })] }, `${obi.tid}-${obi.mid}-${index}`));
|
|
348
|
+
}), hiddenCount > 0 && (_jsxs(StyledOrderByBadgeMore, { onClick: () => setShowMetadataSorterForm(true), children: ["+", hiddenCount] }))] }));
|
|
349
|
+
})() }), _jsx(StyledOrderByEditButton, { title: SDKUI_Localizator.Configure, onClick: () => setShowMetadataSorterForm(true), children: _jsx(IconEdit, { fontSize: 16 }) })] })), _jsxs("div", { style: {
|
|
333
350
|
display: 'flex',
|
|
334
351
|
flexWrap: 'wrap',
|
|
335
352
|
justifyContent: 'center',
|
|
@@ -338,8 +355,12 @@ const TMSearchQueryPanel = ({ fromDTD, showBackToResultButton, isExpertMode = SD
|
|
|
338
355
|
width: '100%'
|
|
339
356
|
}, children: [_jsx(TMButton, { btnStyle: 'advanced', icon: _jsx(IconSearch, {}), showTooltip: false, width: '90px', caption: SDKUI_Localizator.Search, advancedColor: '#4A96D2', onClick: handleSearchButtonClick }), _jsx(TMButton, { width: '90px', btnStyle: 'advanced', advancedType: 'primary', showTooltip: false, caption: SDKUI_Localizator.Clear, icon: _jsx(IconClear, {}), advancedColor: 'white', color: 'primaryOutline', onClick: clearFilters }), (!showAdvancedSearch && qd?.where && qd.where.length > initialMaxItems) && (_jsx(TMButton, { width: '120px', btnStyle: isMobile ? 'icon' : 'advanced', advancedColor: TMColors.button_primary, caption: captionText, showTooltip: false, icon: isMobile ? (_jsx("div", { children: _jsx("p", { children: showAllMdWhere ? `-${diff}` : `+${diff}` }) })) : (_jsx("p", { children: showAllMdWhere ? `-${diff}` : `+${diff}` })), onClick: () => setShowAllMdWhere(!showAllMdWhere) }))] }), showFiltersConfig &&
|
|
340
357
|
_jsx(TMMetadataChooserForm, { allowMultipleSelection: true, height: '500px', width: '600px', allowSysMetadata: true, filterMetadata: (o => o.perm?.canSearch === AccessLevels.Yes), qd: qd, selectedIDs: qd?.where?.map((w) => ({ tid: w.tid, mid: w.mid })), onClose: handleCloseFiltersConfig, onChoose: handleChooseFilters }), showOutputConfig &&
|
|
341
|
-
_jsx(
|
|
342
|
-
|
|
358
|
+
_jsx(TMMetadataOutputForm, { qd: qd, selectedSelectItems: qd?.select, allowSysMetadata: true, filterMetadata: (o => o.perm?.canView === AccessLevels.Yes || o.perm?.canUpdate === AccessLevels.Yes), onClose: handleCloseOutputConfig, onChoose: (selectItems) => {
|
|
359
|
+
setQd({ ...qd, select: selectItems });
|
|
360
|
+
} }), showMetadataSorterForm &&
|
|
361
|
+
_jsx(TMMetadataSorterForm, { qd: qd, selectedOrderByItems: qd?.orderBy, allowSysMetadata: true, filterMetadata: (o => o.perm?.canView === AccessLevels.Yes || o.perm?.canUpdate === AccessLevels.Yes), onClose: () => setShowMetadataSorterForm(false), onChoose: (orderByItems) => {
|
|
362
|
+
setQd({ ...qd, orderBy: orderByItems });
|
|
363
|
+
} })] })
|
|
343
364
|
:
|
|
344
365
|
_jsx(TMToppyMessage, { message: SDKUI_Localizator.DcmtTypeSelectOrQuickSearch, titleTooltip: SDKUI_Localizator.DcmtTypeSelectOrQuickSearch }), showSqdForm &&
|
|
345
366
|
_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 }) })] }), showDistinctValuesPanel &&
|
|
@@ -415,6 +436,174 @@ export const refreshLastSearch = async (qd) => {
|
|
|
415
436
|
}
|
|
416
437
|
return searchResults;
|
|
417
438
|
};
|
|
439
|
+
// =============================================================================
|
|
440
|
+
// STYLED COMPONENTS per i badge degli ordinamenti
|
|
441
|
+
// =============================================================================
|
|
442
|
+
const StyledOrderByBadgesContainer = styled.div `
|
|
443
|
+
display: flex;
|
|
444
|
+
flex-wrap: wrap;
|
|
445
|
+
align-items: center;
|
|
446
|
+
gap: 8px;
|
|
447
|
+
padding: 6px 10px;
|
|
448
|
+
margin: 1px 0;
|
|
449
|
+
background: linear-gradient(135deg, rgba(74, 150, 210, 0.08) 0%, rgba(37, 89, 165, 0.08) 100%);
|
|
450
|
+
border-radius: 8px;
|
|
451
|
+
border: 1px solid rgba(74, 150, 210, 0.2);
|
|
452
|
+
`;
|
|
453
|
+
const StyledOrderByLabel = styled.span `
|
|
454
|
+
font-size: 0.82rem;
|
|
455
|
+
font-weight: 600;
|
|
456
|
+
color: #4A96D2;
|
|
457
|
+
white-space: nowrap;
|
|
458
|
+
`;
|
|
459
|
+
const StyledOrderByBadgesWrapper = styled.div `
|
|
460
|
+
display: flex;
|
|
461
|
+
flex-wrap: wrap;
|
|
462
|
+
gap: 6px;
|
|
463
|
+
align-items: center;
|
|
464
|
+
flex: 1;
|
|
465
|
+
`;
|
|
466
|
+
const StyledOrderByBadge = styled.div `
|
|
467
|
+
display: inline-flex;
|
|
468
|
+
align-items: center;
|
|
469
|
+
gap: 4px;
|
|
470
|
+
padding: 3px 8px;
|
|
471
|
+
background: white;
|
|
472
|
+
border: 1px solid #d1d9e6;
|
|
473
|
+
border-radius: 16px;
|
|
474
|
+
font-size: 0.82rem;
|
|
475
|
+
color: #333;
|
|
476
|
+
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
|
|
477
|
+
|
|
478
|
+
.badge-name {
|
|
479
|
+
max-width: 120px;
|
|
480
|
+
overflow: hidden;
|
|
481
|
+
text-overflow: ellipsis;
|
|
482
|
+
white-space: nowrap;
|
|
483
|
+
|
|
484
|
+
@media (max-width: 600px) {
|
|
485
|
+
max-width: 80px;
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
`;
|
|
489
|
+
const StyledOrderByBadgeMore = styled.div `
|
|
490
|
+
display: inline-flex;
|
|
491
|
+
align-items: center;
|
|
492
|
+
justify-content: center;
|
|
493
|
+
padding: 3px 10px;
|
|
494
|
+
background: linear-gradient(135deg, #4A96D2 0%, #2559A5 100%);
|
|
495
|
+
border: none;
|
|
496
|
+
border-radius: 16px;
|
|
497
|
+
font-size: 0.82rem;
|
|
498
|
+
font-weight: 600;
|
|
499
|
+
color: white;
|
|
500
|
+
cursor: pointer;
|
|
501
|
+
transition: all 0.2s ease;
|
|
502
|
+
|
|
503
|
+
&:hover {
|
|
504
|
+
transform: scale(1.05);
|
|
505
|
+
box-shadow: 0 2px 6px rgba(74, 150, 210, 0.4);
|
|
506
|
+
}
|
|
507
|
+
`;
|
|
508
|
+
const StyledOrderByEditButton = styled.div `
|
|
509
|
+
display: flex;
|
|
510
|
+
align-items: center;
|
|
511
|
+
justify-content: center;
|
|
512
|
+
width: 28px;
|
|
513
|
+
height: 28px;
|
|
514
|
+
border-radius: 4px;
|
|
515
|
+
color: #4A96D2;
|
|
516
|
+
cursor: pointer;
|
|
517
|
+
transition: all 0.2s ease;
|
|
518
|
+
|
|
519
|
+
&:hover {
|
|
520
|
+
background-color: rgba(74, 150, 210, 0.15);
|
|
521
|
+
}
|
|
522
|
+
`;
|
|
523
|
+
// =============================================================================
|
|
524
|
+
// STYLED COMPONENTS per i badge degli output (select) - colore verde/teal
|
|
525
|
+
// =============================================================================
|
|
526
|
+
const StyledSelectBadgesContainer = styled.div `
|
|
527
|
+
display: flex;
|
|
528
|
+
flex-wrap: wrap;
|
|
529
|
+
align-items: center;
|
|
530
|
+
gap: 8px;
|
|
531
|
+
padding: 6px 10px;
|
|
532
|
+
margin: 1px 0;
|
|
533
|
+
background: linear-gradient(135deg, rgba(46, 125, 50, 0.08) 0%, rgba(27, 94, 32, 0.08) 100%);
|
|
534
|
+
border-radius: 8px;
|
|
535
|
+
border: 1px solid rgba(46, 125, 50, 0.2);
|
|
536
|
+
`;
|
|
537
|
+
const StyledSelectLabel = styled.span `
|
|
538
|
+
font-size: 0.82rem;
|
|
539
|
+
font-weight: 600;
|
|
540
|
+
color: #2E7D32;
|
|
541
|
+
white-space: nowrap;
|
|
542
|
+
`;
|
|
543
|
+
const StyledSelectBadgesWrapper = styled.div `
|
|
544
|
+
display: flex;
|
|
545
|
+
flex-wrap: wrap;
|
|
546
|
+
gap: 6px;
|
|
547
|
+
align-items: center;
|
|
548
|
+
flex: 1;
|
|
549
|
+
`;
|
|
550
|
+
const StyledSelectBadge = styled.div `
|
|
551
|
+
display: inline-flex;
|
|
552
|
+
align-items: center;
|
|
553
|
+
gap: 4px;
|
|
554
|
+
padding: 3px 8px;
|
|
555
|
+
background: white;
|
|
556
|
+
border: 1px solid #c8e6c9;
|
|
557
|
+
border-radius: 16px;
|
|
558
|
+
font-size: 0.82rem;
|
|
559
|
+
color: #333;
|
|
560
|
+
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
|
|
561
|
+
|
|
562
|
+
.badge-name {
|
|
563
|
+
max-width: 120px;
|
|
564
|
+
overflow: hidden;
|
|
565
|
+
text-overflow: ellipsis;
|
|
566
|
+
white-space: nowrap;
|
|
567
|
+
|
|
568
|
+
@media (max-width: 600px) {
|
|
569
|
+
max-width: 80px;
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
`;
|
|
573
|
+
const StyledSelectBadgeMore = styled.div `
|
|
574
|
+
display: inline-flex;
|
|
575
|
+
align-items: center;
|
|
576
|
+
justify-content: center;
|
|
577
|
+
padding: 3px 10px;
|
|
578
|
+
background: linear-gradient(135deg, #43A047 0%, #2E7D32 100%);
|
|
579
|
+
border: none;
|
|
580
|
+
border-radius: 16px;
|
|
581
|
+
font-size: 0.82rem;
|
|
582
|
+
font-weight: 600;
|
|
583
|
+
color: white;
|
|
584
|
+
cursor: pointer;
|
|
585
|
+
transition: all 0.2s ease;
|
|
586
|
+
|
|
587
|
+
&:hover {
|
|
588
|
+
transform: scale(1.05);
|
|
589
|
+
box-shadow: 0 2px 6px rgba(46, 125, 50, 0.4);
|
|
590
|
+
}
|
|
591
|
+
`;
|
|
592
|
+
const StyledSelectEditButton = styled.div `
|
|
593
|
+
display: flex;
|
|
594
|
+
align-items: center;
|
|
595
|
+
justify-content: center;
|
|
596
|
+
width: 28px;
|
|
597
|
+
height: 28px;
|
|
598
|
+
border-radius: 4px;
|
|
599
|
+
color: #2E7D32;
|
|
600
|
+
cursor: pointer;
|
|
601
|
+
transition: all 0.2s ease;
|
|
602
|
+
|
|
603
|
+
&:hover {
|
|
604
|
+
background-color: rgba(46, 125, 50, 0.15);
|
|
605
|
+
}
|
|
606
|
+
`;
|
|
418
607
|
export const StyledToppyTextContainer = styled.div `
|
|
419
608
|
padding: 22px 8px;
|
|
420
609
|
width: 100%;
|
|
@@ -433,11 +622,13 @@ export const StyledToppyText = styled.p `
|
|
|
433
622
|
font-size: 1rem;
|
|
434
623
|
user-select: none;
|
|
435
624
|
-webkit-touch-callout: none;
|
|
436
|
-
|
|
625
|
+
-webkit-user-select: none;
|
|
626
|
+
-moz-user-select: none;
|
|
627
|
+
-ms-user-select: none;
|
|
437
628
|
margin: 0;
|
|
438
629
|
display: -webkit-box;
|
|
439
630
|
-webkit-box-orient: vertical;
|
|
440
|
-
-webkit-line-clamp: 3;
|
|
631
|
+
-webkit-line-clamp: 3;
|
|
441
632
|
overflow: hidden;
|
|
442
633
|
text-overflow: ellipsis;
|
|
443
634
|
white-space: normal;
|
|
@@ -12,6 +12,7 @@ interface ITMSearchResultProps {
|
|
|
12
12
|
floatingActionConfig?: TMSearchResultFloatingActionConfig;
|
|
13
13
|
workingGroupContext?: WorkingGroupDescriptor;
|
|
14
14
|
inputDID?: number;
|
|
15
|
+
autoFocusFirstRow?: boolean;
|
|
15
16
|
formAutoOpen?: boolean;
|
|
16
17
|
allowFloatingBar?: boolean;
|
|
17
18
|
allowRelations?: boolean;
|
|
@@ -54,7 +54,7 @@ const TMSearchResult = ({
|
|
|
54
54
|
// Data
|
|
55
55
|
groupId, searchResults = [], context = SearchResultContext.METADATA_SEARCH, title, selectedSearchResultTID, floatingActionConfig, workingGroupContext = undefined, inputDID,
|
|
56
56
|
// Boolean flags to enable/disable features
|
|
57
|
-
formAutoOpen, isVisible = true, allowRelations = true, openDcmtFormAsModal = false, showSearchResultSidebar = true, showDcmtFormSidebar = true, showSelector = false, isClosable = false, allowFloatingBar = true, showToolbarHeader = true, showBackButton = true, disableAccordionIfSingleCategory = false, editPdfForm = false, openS4TViewer = false, showTodoDcmtForm = false, showToppyDraggableHelpCenter = true, toppyHelpCenterUsePortal = false, showNoDcmtFoundMessage = true, enablePinIcons = true,
|
|
57
|
+
autoFocusFirstRow = true, formAutoOpen, isVisible = true, allowRelations = true, openDcmtFormAsModal = false, showSearchResultSidebar = true, showDcmtFormSidebar = true, showSelector = false, isClosable = false, allowFloatingBar = true, showToolbarHeader = true, showBackButton = true, disableAccordionIfSingleCategory = false, editPdfForm = false, openS4TViewer = false, showTodoDcmtForm = false, showToppyDraggableHelpCenter = true, toppyHelpCenterUsePortal = false, showNoDcmtFoundMessage = true, enablePinIcons = true,
|
|
58
58
|
// Callbacks (optional)
|
|
59
59
|
openInOffice, onRefreshAfterAddDcmtToFavs, onRefreshSearchAsyncDatagrid, onSelectedTIDChanged, onWFOperationCompleted, onClose, onFileOpened, onTaskCreateRequest, openWGsCopyMoveForm, openCommentFormCallback, openAddDocumentForm, onOpenS4TViewerRequest, onOpenPdfEditorRequest, openFileUploaderPdfEditor, passToArchiveCallback, onReferenceClick,
|
|
60
60
|
// Tasks
|
|
@@ -63,6 +63,11 @@ allTasks = [], getAllTasks, deleteTaskByIdsCallback, addTaskCallback, editTaskCa
|
|
|
63
63
|
handleNavigateToWGs, handleNavigateToDossiers, }) => {
|
|
64
64
|
// Ref for the floating bar container (used to position the floating action buttons)
|
|
65
65
|
const floatingBarContainerRef = useRef(null);
|
|
66
|
+
// Ref per tracciare se autoFocusFirstRow=false deve bloccare l'auto-focus.
|
|
67
|
+
// Resta true finché l'utente non clicca manualmente sulla griglia per selezionare una riga.
|
|
68
|
+
// Quando l'utente seleziona manualmente, il ref viene settato a false e il focus automatico
|
|
69
|
+
// torna al comportamento normale.
|
|
70
|
+
const isFirstAutoFocusRef = useRef(true);
|
|
66
71
|
// ID state to force remount of components
|
|
67
72
|
const [id, setID] = useState('');
|
|
68
73
|
// Document type descriptor of the currently document
|
|
@@ -139,6 +144,12 @@ handleNavigateToWGs, handleNavigateToDossiers, }) => {
|
|
|
139
144
|
}
|
|
140
145
|
}
|
|
141
146
|
};
|
|
147
|
+
// Handler unico per tutte le azioni utente che cambiano il focus (click, navigazione, etc.).
|
|
148
|
+
// Resetta isFirstAutoFocusRef perché da questo momento autoFocusFirstRow non deve più essere considerato.
|
|
149
|
+
const handleFocusedItemChangedFromGrid = useCallback((item) => {
|
|
150
|
+
isFirstAutoFocusRef.current = false;
|
|
151
|
+
setFocusedItem(item);
|
|
152
|
+
}, []);
|
|
142
153
|
const onNavigateHandler = (dir) => {
|
|
143
154
|
let index = -1;
|
|
144
155
|
if (visibleItems && focusedItem) {
|
|
@@ -146,10 +157,10 @@ handleNavigateToWGs, handleNavigateToDossiers, }) => {
|
|
|
146
157
|
}
|
|
147
158
|
switch (dir) {
|
|
148
159
|
case 'next':
|
|
149
|
-
|
|
160
|
+
handleFocusedItemChangedFromGrid(visibleItems[index + 1]);
|
|
150
161
|
break;
|
|
151
162
|
default:
|
|
152
|
-
|
|
163
|
+
handleFocusedItemChangedFromGrid(visibleItems[index - 1]);
|
|
153
164
|
break;
|
|
154
165
|
}
|
|
155
166
|
};
|
|
@@ -378,6 +389,9 @@ handleNavigateToWGs, handleNavigateToDossiers, }) => {
|
|
|
378
389
|
updateBatchUpdateForm(false);
|
|
379
390
|
closeDcmtFormHandler();
|
|
380
391
|
setCurrentSearchResults(searchResults);
|
|
392
|
+
// Resetta il ref quando arrivano nuovi risultati di ricerca,
|
|
393
|
+
// così la logica autoFocusFirstRow=false si riapplica per ogni nuova ricerca
|
|
394
|
+
isFirstAutoFocusRef.current = true;
|
|
381
395
|
if (searchResults.length <= 0) {
|
|
382
396
|
setSelectedSearchResult(undefined);
|
|
383
397
|
return;
|
|
@@ -413,6 +427,12 @@ handleNavigateToWGs, handleNavigateToDossiers, }) => {
|
|
|
413
427
|
});
|
|
414
428
|
checkRelatedDcmtsArchiveCapability();
|
|
415
429
|
checkManyToManyCapability();
|
|
430
|
+
// se autoFocusFirstRow è false, non selezionare automaticamente la prima riga del nuovo risultato della ricerca
|
|
431
|
+
// Il ref resta true finché l'utente non clicca manualmente sulla griglia
|
|
432
|
+
if (autoFocusFirstRow === false && isFirstAutoFocusRef.current) {
|
|
433
|
+
setFocusedItem(undefined);
|
|
434
|
+
return;
|
|
435
|
+
}
|
|
416
436
|
// Ricava il nuovo dataSource
|
|
417
437
|
const newDataSource = searchResultDescriptorToSimpleArray(selectedSearchResult);
|
|
418
438
|
// Se esiste almeno una riga, seleziona la prima
|
|
@@ -420,6 +440,12 @@ handleNavigateToWGs, handleNavigateToDossiers, }) => {
|
|
|
420
440
|
}, [selectedSearchResult, checkRelatedDcmtsArchiveCapability, checkManyToManyCapability]);
|
|
421
441
|
// Quando inputDID è fornito e i dati della griglia sono pronti, seleziona il documento corrispondente
|
|
422
442
|
useEffect(() => {
|
|
443
|
+
// Se autoFocusFirstRow è false, non selezionare automaticamente la riga corrispondente a inputDID
|
|
444
|
+
// Il ref resta true finché l'utente non clicca manualmente sulla griglia
|
|
445
|
+
if (autoFocusFirstRow === false && isFirstAutoFocusRef.current) {
|
|
446
|
+
setFocusedItem(undefined);
|
|
447
|
+
return;
|
|
448
|
+
}
|
|
423
449
|
if (!inputDID || visibleItems.length === 0)
|
|
424
450
|
return;
|
|
425
451
|
const targetItem = visibleItems.find((item) => item.DID == inputDID);
|
|
@@ -467,8 +493,10 @@ handleNavigateToWGs, handleNavigateToDossiers, }) => {
|
|
|
467
493
|
onOpenS4TViewerRequest?.([{ TID: focusedItem.TID, DID: focusedItem.DID }]);
|
|
468
494
|
}, [openS4TViewer, inputDID, focusedItem, fromDTD]);
|
|
469
495
|
useEffect(() => {
|
|
470
|
-
if (!focusedItem)
|
|
496
|
+
if (!focusedItem) {
|
|
497
|
+
setCurrentDcmt(undefined);
|
|
471
498
|
return;
|
|
499
|
+
}
|
|
472
500
|
if (!fromDTD)
|
|
473
501
|
return;
|
|
474
502
|
let dtd = searchResults.length > 1 ? searchResults.find(res => res.fromTID == focusedItem?.TID)?.dtdResult : searchResults[0]?.dtdResult;
|
|
@@ -635,7 +663,7 @@ handleNavigateToWGs, handleNavigateToDossiers, }) => {
|
|
|
635
663
|
_jsxs(_Fragment, { children: [_jsxs(TMLayoutItem, { height: '100%', children: [_jsxs("div", { ref: floatingBarContainerRef, style: { position: 'relative', height: '100%', width: '100%' }, children: [_jsxs(TMSplitterLayout, { direction: 'horizontal', overflow: 'visible', separatorSize: Gutters.getGutters(), separatorActiveColor: 'transparent', separatorColor: 'transparent', min: ['0', '0'], showSeparator: showSelector && deviceType !== DeviceType.MOBILE, start: showSelector ? deviceType !== DeviceType.MOBILE ? ['30%', '70%'] : splitterSize : ['0%', '100%'], children: [showSelector ?
|
|
636
664
|
_jsx(TMLayoutItem, { children: _jsx(TMSearchResultSelector, { searchResults: currentSearchResults, disableAccordionIfSingleCategory: disableAccordionIfSingleCategory, selectedTID: selectedSearchResultTID, selectedSearchResult: selectedSearchResult, autoSelectFirst: !isMobile || currentSearchResults.length === 1, onSelectionChanged: onSearchResultSelectionChanged }) })
|
|
637
665
|
:
|
|
638
|
-
_jsx(_Fragment, {}), _jsx(TMLayoutItem, { children: _jsx(TMSearchResultGrid, { openInOffice: openInOffice, fromDTD: fromDTD, operationItems: operationItems, allUsers: allUsers, inputFocusedItem: focusedItem, inputSelectedItems: selectedItems, showExportForm: showExportForm, onFocusedItemChanged:
|
|
666
|
+
_jsx(_Fragment, {}), _jsx(TMLayoutItem, { children: _jsx(TMSearchResultGrid, { openInOffice: openInOffice, fromDTD: fromDTD, operationItems: operationItems, allUsers: allUsers, inputFocusedItem: focusedItem, inputSelectedItems: selectedItems, showExportForm: showExportForm, onFocusedItemChanged: handleFocusedItemChangedFromGrid, onDownloadDcmtsAsync: async (inputDcmts, downloadType, downloadMode, _y, confirmAttachments) => await downloadDcmtsAsync({ inputDcmts, downloadType, downloadMode, onFileDownloaded: onFileOpened, confirmAttachments }), lastUpdateSearchTime: lastUpdateSearchTime, searchResult: searchResults.length > 1 ? selectedSearchResult : searchResults[0], onSelectionChanged: (items) => { setSelectedItems(items); }, onDblClick: () => openFormHandler(LayoutModes.Update), showSearchTMDatagrid: showSearchTMDatagrid, onVisibleItemChanged: setVisibleItems, updateDataColumnsFromDataGrid: updateDataColumnsFromDataGrid, updateDataSourceFromDataGrid: updateDataSourceFromDataGrid, updateSelectedRowKeysFromDataGrid: updateSelectedRowKeysFromDataGrid, disableAutoFocus: autoFocusFirstRow === false && isFirstAutoFocusRef.current }) })] }), renderFloatingBar] }), _jsx(TMToppyDraggableHelpCenter, { usePortal: toppyHelpCenterUsePortal, isVisible: isToppyHelpCenterVisible, content: _jsx("div", { style: { display: 'flex', flexDirection: 'column', gap: '10px' }, children: _jsx(WorkFlowOperationButtons, { dtd: fromDTD, deviceType: deviceType, onApprove: () => {
|
|
639
667
|
updateShowApprovePopup(true);
|
|
640
668
|
}, onSignApprove: () => {
|
|
641
669
|
handleSignApprove();
|
|
@@ -826,7 +854,7 @@ handleNavigateToWGs, handleNavigateToDossiers, }) => {
|
|
|
826
854
|
_jsxs(TMPanelManagerProvider, { panels: initialPanels, initialVisibility: allInitialPanelVisibility, defaultDimensions: initialPanelDimensions, initialDimensions: initialPanelDimensions, initialMobilePanelId: 'tmSearchResult', children: [_jsx(PanelDisabledStateHandler, { isBoardDisabled: isBoardDisabled }), _jsx(TMPanelManagerContainer, { panels: initialPanels, direction: "horizontal", parentId: groupId, showToolbar: showSearchResultSidebar })] }) }) }) }), renderDcmtOperations] }));
|
|
827
855
|
};
|
|
828
856
|
export default TMSearchResult;
|
|
829
|
-
const TMSearchResultGrid = ({ openInOffice, fromDTD, operationItems, allUsers, inputFocusedItem, allowMultipleSelection = true, showExportForm = false, onFocusedItemChanged, onDownloadDcmtsAsync, onVisibleItemChanged, inputSelectedItems = [], lastUpdateSearchTime, searchResult, onSelectionChanged, onDblClick, showSearchTMDatagrid, updateDataColumnsFromDataGrid, updateDataSourceFromDataGrid, updateSelectedRowKeysFromDataGrid }) => {
|
|
857
|
+
const TMSearchResultGrid = ({ openInOffice, fromDTD, operationItems, allUsers, inputFocusedItem, allowMultipleSelection = true, showExportForm = false, onFocusedItemChanged, onDownloadDcmtsAsync, onVisibleItemChanged, inputSelectedItems = [], lastUpdateSearchTime, searchResult, onSelectionChanged, onDblClick, showSearchTMDatagrid, updateDataColumnsFromDataGrid, updateDataSourceFromDataGrid, updateSelectedRowKeysFromDataGrid, disableAutoFocus = false }) => {
|
|
830
858
|
const [dataSource, setDataSource] = useState();
|
|
831
859
|
const [columns, setColumns] = useState([]);
|
|
832
860
|
const [selectedRowKeys, setSelectedRowKeys] = useState([]);
|
|
@@ -850,6 +878,7 @@ const TMSearchResultGrid = ({ openInOffice, fromDTD, operationItems, allUsers, i
|
|
|
850
878
|
const { loadDataListsAsync, renderDataListCell, dataListsCache } = useDataListItem();
|
|
851
879
|
const { loadUsersAsync, renderUserIdViewer, usersCache } = useDataUserIdItem();
|
|
852
880
|
useEffect(() => {
|
|
881
|
+
// Sincronizza focusedItem con inputFocusedItem dal padre
|
|
853
882
|
if (deepCompare(inputFocusedItem, focusedItem))
|
|
854
883
|
return;
|
|
855
884
|
setFocusedItem(inputFocusedItem);
|
|
@@ -1124,8 +1153,7 @@ const TMSearchResultGrid = ({ openInOffice, fromDTD, operationItems, allUsers, i
|
|
|
1124
1153
|
// Previene l'errore E1047 quando il filtro riferisce campi non più presenti nelle nuove colonne.
|
|
1125
1154
|
const oldFields = columns.map(c => c.dataField);
|
|
1126
1155
|
const newFields = cols.map(c => c.dataField);
|
|
1127
|
-
const columnsChanged = oldFields.length !== newFields.length ||
|
|
1128
|
-
oldFields.some((f, i) => f !== newFields[i]);
|
|
1156
|
+
const columnsChanged = oldFields.length !== newFields.length || oldFields.some((f, i) => f !== newFields[i]);
|
|
1129
1157
|
if (columnsChanged) {
|
|
1130
1158
|
const gridInstance = dataGridRef.current?.instance();
|
|
1131
1159
|
if (gridInstance) {
|
|
@@ -1143,7 +1171,6 @@ const TMSearchResultGrid = ({ openInOffice, fromDTD, operationItems, allUsers, i
|
|
|
1143
1171
|
useEffect(() => {
|
|
1144
1172
|
let newDataSource = searchResultDescriptorToSimpleArray(searchResult);
|
|
1145
1173
|
setDataSource(newDataSource);
|
|
1146
|
-
// setFocusedItem(newDataSource?.find(o => o?.rowIndex === focusedItem?.rowIndex));
|
|
1147
1174
|
}, [lastUpdateSearchTime]);
|
|
1148
1175
|
// Handles selection change in the data grid
|
|
1149
1176
|
const handleSelectionChange = useCallback((e) => {
|
|
@@ -1154,14 +1181,9 @@ const TMSearchResultGrid = ({ openInOffice, fromDTD, operationItems, allUsers, i
|
|
|
1154
1181
|
}, [onSelectionChanged]);
|
|
1155
1182
|
// Handles focus change in the data grid
|
|
1156
1183
|
const handleFocusedRowChange = useCallback((e) => {
|
|
1157
|
-
//
|
|
1158
|
-
// if (e.row === undefined) { setFocusedItem(undefined); return; }
|
|
1159
|
-
// setFocusedItem(e.row.data);
|
|
1184
|
+
// Non bloccare mai questo handler: è chiamato quando l'utente clicca su una riga
|
|
1160
1185
|
onFocusedItemChanged?.(e.row?.data);
|
|
1161
|
-
}, [
|
|
1162
|
-
// useEffect(() => {
|
|
1163
|
-
// onFocusedItemChanged?.(focusedItem)
|
|
1164
|
-
// }, [focusedItem])
|
|
1186
|
+
}, [onFocusedItemChanged]);
|
|
1165
1187
|
// Handler for double-click row event
|
|
1166
1188
|
const onRowDblClick = useCallback((e) => {
|
|
1167
1189
|
if (onDblClick === undefined)
|
|
@@ -1182,7 +1204,6 @@ const TMSearchResultGrid = ({ openInOffice, fromDTD, operationItems, allUsers, i
|
|
|
1182
1204
|
});
|
|
1183
1205
|
return;
|
|
1184
1206
|
}
|
|
1185
|
-
// setFocusedItem(e.data);
|
|
1186
1207
|
onFocusedItemChanged?.(e.data);
|
|
1187
1208
|
onDblClick();
|
|
1188
1209
|
}, [onDblClick]);
|
|
@@ -1212,7 +1233,7 @@ const TMSearchResultGrid = ({ openInOffice, fromDTD, operationItems, allUsers, i
|
|
|
1212
1233
|
setVisibleItems(visibleData);
|
|
1213
1234
|
}, []);
|
|
1214
1235
|
useEffect(() => { onVisibleItemChanged?.(visibleItems); }, [visibleItems]);
|
|
1215
|
-
return _jsxs("div", { style: { width: "100%", height: "100%" }, children: [!isDataGridReady && (_jsxs("div", { style: { display: 'flex', flexDirection: 'column', alignItems: 'center', justifyContent: 'center', height: '100%', width: '100%', gap: '10px' }, children: [_jsx(LoadIndicator, { height: 60, width: 60 }), _jsx("div", { children: SDKUI_Localizator.Loading })] })), isDataGridReady && _jsx(TMDataGrid, { ref: dataGridRef, id: "tm-search-result", keyExpr: "rowIndex", dataColumns: dataColumns, dataSource: dataSource, repaintChangesOnly: true, selectedRowKeys: selectedRowKeys, focusedRowKey: Number(focusedItem?.rowIndex ?? 0), showSearchPanel: showSearchTMDatagrid, showFilterPanel: true, sorting: { mode: "multiple" }, selection: { mode: allowMultipleSelection ? 'multiple' : 'single' }, pageSize: pageSize, onSelectionChanged: handleSelectionChange, onFocusedRowChanged: handleFocusedRowChange, onRowDblClick: onRowDblClick, onContentReady: onContentReady, showHeaderColumnChooser: true, onKeyDown: onKeyDown, customContextMenuItems: operationItems, counterConfig: { show: true } })] });
|
|
1236
|
+
return _jsxs("div", { style: { width: "100%", height: "100%" }, children: [!isDataGridReady && (_jsxs("div", { style: { display: 'flex', flexDirection: 'column', alignItems: 'center', justifyContent: 'center', height: '100%', width: '100%', gap: '10px' }, children: [_jsx(LoadIndicator, { height: 60, width: 60 }), _jsx("div", { children: SDKUI_Localizator.Loading })] })), isDataGridReady && _jsx(TMDataGrid, { ref: dataGridRef, id: "tm-search-result", keyExpr: "rowIndex", dataColumns: dataColumns, dataSource: dataSource, repaintChangesOnly: true, selectedRowKeys: selectedRowKeys, focusedRowKey: disableAutoFocus ? undefined : Number(focusedItem?.rowIndex ?? 0), showSearchPanel: showSearchTMDatagrid, showFilterPanel: true, sorting: { mode: "multiple" }, selection: { mode: allowMultipleSelection ? 'multiple' : 'single' }, pageSize: pageSize, onSelectionChanged: handleSelectionChange, onFocusedRowChanged: handleFocusedRowChange, onRowDblClick: onRowDblClick, onContentReady: onContentReady, showHeaderColumnChooser: true, onKeyDown: onKeyDown, customContextMenuItems: operationItems, counterConfig: { show: true } })] });
|
|
1216
1237
|
};
|
|
1217
1238
|
//#region TMSearchResultSelector
|
|
1218
1239
|
const StyledItemTemplate = styled.div `
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { DcmtTypeDescriptor, MetadataDescriptor, QueryDescriptor } from "@topconsultnpm/sdk-ts";
|
|
2
|
+
export type MetadataDescriptorWithKey = MetadataDescriptor & {
|
|
3
|
+
uniqueKey: string;
|
|
4
|
+
};
|
|
5
|
+
export declare function removeDuplicatesByTidMid<T extends {
|
|
6
|
+
tid?: number;
|
|
7
|
+
mid?: number;
|
|
8
|
+
}>(items: T[]): T[];
|
|
9
|
+
export declare function loadMetadataFromQd(qd: QueryDescriptor | undefined, filterMetadata?: (value: MetadataDescriptor, index: number, array: MetadataDescriptor[]) => unknown): Promise<{
|
|
10
|
+
metadata: MetadataDescriptorWithKey[];
|
|
11
|
+
dcmtTypes: DcmtTypeDescriptor[];
|
|
12
|
+
}>;
|
|
13
|
+
export declare function areArraysEqual<T extends {
|
|
14
|
+
tid?: number;
|
|
15
|
+
mid?: number;
|
|
16
|
+
}>(arr1: T[], arr2: T[], additionalCompare?: (a: T, b: T) => boolean): boolean;
|