@topconsultnpm/sdkui-react-beta 6.10.52 → 6.10.53
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.
|
@@ -7,12 +7,12 @@ import FileSystemError from "devextreme/file_management/error";
|
|
|
7
7
|
import Button from "devextreme/ui/button";
|
|
8
8
|
import { alert, confirm } from "devextreme/ui/dialog";
|
|
9
9
|
import { loadMessages } from 'devextreme/localization';
|
|
10
|
-
import { Globalization, IconAll, IconSelected, SDKUI_Localizator } from '../../helper';
|
|
10
|
+
import { Globalization, IconAll, IconCloud, IconFolder, IconSelected, SDKUI_Localizator } from '../../helper';
|
|
11
11
|
import { TMExceptionBoxManager } from './TMPopUp';
|
|
12
12
|
import ShowAlert from './TMAlert';
|
|
13
|
-
import { IconFolder, IconPdf, IconTxt, IconXls, IconDocx, IconImage, IconZip, IconXml, IconMp4, IconEmail, IconPpt, IconSigned, IconExe, IconHtml, IconDwg, IconDicom, IconSlddrw } from '../../assets/thumbnails';
|
|
14
13
|
import { TMLayoutWaitingContainer } from './TMWaitPanel';
|
|
15
|
-
import
|
|
14
|
+
import TMCounterContainer, { CounterItemKey } from './TMCounterContainer';
|
|
15
|
+
import { IconPdf, IconXls, IconTxt, IconXml, IconDwg, IconDicom, IconSlddrw, IconMp4, IconDocx, IconPpt, IconEmail, IconExe, IconHtml, IconSigned, IconImage, IconZip } from '../../assets/thumbnails';
|
|
16
16
|
export class TMFileSystemItem {
|
|
17
17
|
constructor() {
|
|
18
18
|
this.name = "";
|
|
@@ -34,16 +34,18 @@ const TMAreaManager = (props = { selectionMode: 'multiple', isPathChooser: false
|
|
|
34
34
|
const [areas, setAreas] = useState([]);
|
|
35
35
|
// State to maintain the Area Descriptor Name Set (Support area - left panel)
|
|
36
36
|
const [areasRoots, setAreasRoots] = useState(new Set());
|
|
37
|
+
// State to store the file system items of the current directory's parent
|
|
38
|
+
const [parentDirectoryFileSystemItems, setParentDirectoryFileSystemItems] = useState([]);
|
|
37
39
|
// State to maintain the selected area file (File System Item - right panel)
|
|
38
40
|
const [areaFile, setAreaFile] = useState('');
|
|
39
41
|
// State to maintain the selected area folder (File System Item - right panel)
|
|
40
42
|
const [areaFolder, setAreaFolder] = useState('');
|
|
41
43
|
// State to maintain the focused/clicked file system item (File System Item - right panel)
|
|
42
44
|
const [focusedFileSystemItem, setFocusedFileSystemItem] = useState(undefined);
|
|
43
|
-
// State to maintain the number of total item into selected support area
|
|
44
|
-
const [counter, setCounter] = useState(0);
|
|
45
45
|
// State to maintain the number of selected items)
|
|
46
46
|
const [selectedItemsCount, setSelectedItemsCount] = useState(0);
|
|
47
|
+
// State to maintain the counter values (total item into selected support area and selected items)
|
|
48
|
+
const [counterValues, setCounterValues] = useState(new Map());
|
|
47
49
|
// State to maintain the selection mode (File System Item - right panel)
|
|
48
50
|
const [selectionMode, setSelectionMode] = useState('single');
|
|
49
51
|
/* State to manage the Wait Panel */
|
|
@@ -72,6 +74,44 @@ const TMAreaManager = (props = { selectionMode: 'multiple', isPathChooser: false
|
|
|
72
74
|
const fileManagerRef = useRef(null);
|
|
73
75
|
// Cache for uploaded file IDs, mapping file paths to their corresponding IDs
|
|
74
76
|
let _cacheUploadFileId = new Map();
|
|
77
|
+
useEffect(() => {
|
|
78
|
+
const defaultCounterItems = new Map([
|
|
79
|
+
[
|
|
80
|
+
String(SDKUI_Localizator.AllItems),
|
|
81
|
+
{
|
|
82
|
+
key: String(SDK_Localizator.Areas),
|
|
83
|
+
show: true,
|
|
84
|
+
caption: String(SDK_Localizator.Areas),
|
|
85
|
+
value: areasRoots.size,
|
|
86
|
+
icon: _jsx(IconCloud, {}),
|
|
87
|
+
order: 0
|
|
88
|
+
}
|
|
89
|
+
],
|
|
90
|
+
[
|
|
91
|
+
String(SDKUI_Localizator.All),
|
|
92
|
+
{
|
|
93
|
+
key: String(SDKUI_Localizator.AllFilesAndFoldersInSupportArea),
|
|
94
|
+
show: true,
|
|
95
|
+
caption: String(SDKUI_Localizator.AllFilesAndFoldersInSupportArea),
|
|
96
|
+
value: focusedFileSystemItem?.name === '' ? 0 : parentDirectoryFileSystemItems.length,
|
|
97
|
+
icon: _jsx(IconAll, {}),
|
|
98
|
+
order: 0
|
|
99
|
+
}
|
|
100
|
+
],
|
|
101
|
+
[
|
|
102
|
+
String(CounterItemKey.selectedItems),
|
|
103
|
+
{
|
|
104
|
+
key: String(CounterItemKey.selectedItems),
|
|
105
|
+
show: true,
|
|
106
|
+
caption: String(SDKUI_Localizator.SelectedItems),
|
|
107
|
+
value: selectedItemsCount,
|
|
108
|
+
icon: _jsx(IconSelected, {}),
|
|
109
|
+
order: 1
|
|
110
|
+
}
|
|
111
|
+
]
|
|
112
|
+
]);
|
|
113
|
+
setCounterValues(defaultCounterItems);
|
|
114
|
+
}, [areasRoots, focusedFileSystemItem, parentDirectoryFileSystemItems, selectedItemsCount]);
|
|
75
115
|
useEffect(() => {
|
|
76
116
|
// If areaProvider is already set, exit early to prevent reinitialization
|
|
77
117
|
if (areaProvider)
|
|
@@ -127,7 +167,6 @@ const TMAreaManager = (props = { selectionMode: 'multiple', isPathChooser: false
|
|
|
127
167
|
const btnSearchFile = document.querySelector(".dx-filemanager-wrapper [aria-label='Carica i files']");
|
|
128
168
|
const instanceBtnSearchFile = Button.getInstance(btnSearchFile);
|
|
129
169
|
if (currentRoute === '') {
|
|
130
|
-
initCounter();
|
|
131
170
|
instanceBtnNewDir?.option("disabled", true);
|
|
132
171
|
instanceBtnSearchFile?.option("disabled", true);
|
|
133
172
|
}
|
|
@@ -165,12 +204,6 @@ const TMAreaManager = (props = { selectionMode: 'multiple', isPathChooser: false
|
|
|
165
204
|
setSelectionMode('multiple');
|
|
166
205
|
fileManagerRef.current?.instance().refresh();
|
|
167
206
|
}, [props.areaStatus]);
|
|
168
|
-
const initCounter = async () => {
|
|
169
|
-
const tms = props.tmSession ?? SDK_Globals.tmSession;
|
|
170
|
-
const adlist = await tms?.NewAreaEngine().RetrieveAllAsync();
|
|
171
|
-
if (adlist)
|
|
172
|
-
setCounter(adlist.length);
|
|
173
|
-
};
|
|
174
207
|
const checkTargetDirectory = (operationType, e, data, resolve) => {
|
|
175
208
|
const fileExists = !!data.find((x) => x.name === (operationType === 'copyOrMove' ? e.item.name : e.fileData.name));
|
|
176
209
|
if (fileExists) {
|
|
@@ -434,6 +467,7 @@ const TMAreaManager = (props = { selectionMode: 'multiple', isPathChooser: false
|
|
|
434
467
|
// Set the areas
|
|
435
468
|
setAreas(adlist);
|
|
436
469
|
setAreasRoots(areasRootsName);
|
|
470
|
+
setParentDirectoryFileSystemItems([]);
|
|
437
471
|
}
|
|
438
472
|
else {
|
|
439
473
|
// If the parent directory is not the root, retrieve files within the area
|
|
@@ -452,6 +486,7 @@ const TMAreaManager = (props = { selectionMode: 'multiple', isPathChooser: false
|
|
|
452
486
|
fsi.size = file.size; // Store the file size
|
|
453
487
|
fileSystem.push(fsi); // Add the file system item to the list
|
|
454
488
|
});
|
|
489
|
+
setParentDirectoryFileSystemItems(fileSystem);
|
|
455
490
|
}
|
|
456
491
|
// Return the constructed list of file system items (directories or files)
|
|
457
492
|
return fileSystem;
|
|
@@ -515,7 +550,7 @@ const TMAreaManager = (props = { selectionMode: 'multiple', isPathChooser: false
|
|
|
515
550
|
let subFolder = e.directory.path.replace(ad.name + '/', '').replace(ad.name, '');
|
|
516
551
|
setAreaFolder(getAreaPath(aid, subFolder));
|
|
517
552
|
e.component.option("fileSystemProvider").getItems(e.directory).then((items) => {
|
|
518
|
-
|
|
553
|
+
setParentDirectoryFileSystemItems(items);
|
|
519
554
|
});
|
|
520
555
|
};
|
|
521
556
|
const onSelectionChanged = async (e) => {
|
|
@@ -632,7 +667,11 @@ const TMAreaManager = (props = { selectionMode: 'multiple', isPathChooser: false
|
|
|
632
667
|
alert(`"${e.name}" ${SDKUI_Localizator.FolderExist}`, SDKUI_Localizator.Attention);
|
|
633
668
|
}
|
|
634
669
|
};
|
|
635
|
-
|
|
636
|
-
|
|
670
|
+
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: _jsxs("div", { style: { width: "100%", height: "100%" }, children: [_jsxs(FileManager, { width: props.width, ref: fileManagerRef, height: `calc(${props.height} - 30px)`, onItemMoving: onItemCopying, onItemCopying: onItemCopying, onFileUploading: onFileUploading, fileSystemProvider: areaProvider, customizeThumbnail: customizeIcon, rootFolderName: SDK_Localizator.Areas, onSelectionChanged: onSelectionChanged, onDirectoryCreating: onDirectoryCreating, onFocusedItemChanged: onFocusedItemChanged, onSelectedFileOpened: onSelectedFileOpened, onContextMenuItemClick: onContextMenuItemClick,
|
|
671
|
+
/* onItemMoved={() => setCounter(counter => counter + 1)}
|
|
672
|
+
onItemCopied={() => setCounter(counter => counter + 1)}
|
|
673
|
+
onItemDeleted={() => setCounter(counter => counter - 1)}
|
|
674
|
+
onFileUploaded={() => setCounter(counter => counter + 1)} */
|
|
675
|
+
onCurrentDirectoryChanged: onCurrentDirectoryChanged, selectionMode: props.selectionMode === 'single' ? 'single' : selectionMode, children: [_jsxs(Toolbar, { children: [_jsx(Item, { name: "showNavPane", visible: true }), _jsx(Item, { name: "create", visible: true }), _jsx(Item, { name: "upload", visible: true }), _jsx(Item, { name: "separator", location: 'after' }), _jsx(Item, { name: "switchView", visible: true }), _jsx(Item, { name: "refresh", visible: true })] }), _jsx(ContextMenu, { items: ["create", "upload", "rename", "move", "copy", "delete", "refresh", "download"] }), _jsx(Permissions, { copy: focusedFileSystemItem && focusedFileSystemItem.name !== "" && !areasRoots.has(focusedFileSystemItem.name), move: focusedFileSystemItem && focusedFileSystemItem.name !== "" && !areasRoots.has(focusedFileSystemItem.name), create: focusedFileSystemItem && focusedFileSystemItem.name !== "", upload: focusedFileSystemItem && focusedFileSystemItem.name !== "", rename: focusedFileSystemItem && focusedFileSystemItem.name !== "" && !areasRoots.has(focusedFileSystemItem.name), delete: focusedFileSystemItem && focusedFileSystemItem.name !== "" && !areasRoots.has(focusedFileSystemItem.name), download: true }), _jsx(ItemView, { children: _jsxs(Details, { children: [_jsx(Column, { dataField: "thumbnail", cssClass: 'file-thumbnail' }, "thumbnail"), _jsx(Column, { dataField: "name", caption: SDKUI_Localizator.Name }, "name"), _jsx(Column, { dataField: 'size', width: '120px', alignment: 'center', dataType: 'number', caption: SDKUI_Localizator.File_Size }, "size"), _jsx(Column, { dataField: 'dateModified', width: '160px', alignment: 'center', dataType: 'datetime', caption: SDKUI_Localizator.Date_Modified }, "dateModified")] }) }), _jsx(Notifications, { showPopup: false })] }), _jsx("div", { style: { width: "100%", height: "30px", overflowY: "hidden" }, children: _jsx(TMCounterContainer, { items: counterValues }) })] }) }));
|
|
637
676
|
};
|
|
638
677
|
export default TMAreaManager;
|