@topconsultnpm/sdkui-react 6.20.0-dev2.12 → 6.20.0-dev2.13

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.
@@ -8,6 +8,20 @@ import { useFileDialog } from './useInputDialog';
8
8
  import { isXMLFileExt } from '../helper/dcmtsHelper';
9
9
  import { ShowConfirm } from '../components/base/TMConfirm';
10
10
  let abortController = new AbortController();
11
+ const downloadCountMap = new Map();
12
+ const compoundExts = ['.p7m', '.p7s', '.p7c', '.p7b'];
13
+ const getDownloadFileName = (fileName) => {
14
+ const lower = fileName.toLowerCase();
15
+ const isCompound = compoundExts.some(ext => lower.endsWith(ext) && lower.slice(0, -ext.length).includes('.'));
16
+ if (!isCompound)
17
+ return fileName;
18
+ const count = downloadCountMap.get(fileName) ?? 0;
19
+ downloadCountMap.set(fileName, count + 1);
20
+ if (count === 0)
21
+ return fileName;
22
+ const dotIndex = fileName.indexOf('.');
23
+ return `${fileName.slice(0, dotIndex)}(${count})${fileName.slice(dotIndex)}`;
24
+ };
11
25
  export function useDcmtOperations() {
12
26
  const [showWaitPanel, setShowWaitPanel] = useState(false);
13
27
  const [waitPanelTitle, setWaitPanelTitle] = useState('');
@@ -96,8 +110,8 @@ export function useDcmtOperations() {
96
110
  else {
97
111
  const alink2 = document.createElement('a');
98
112
  alink2.href = fileURL;
99
- const downloadFileName = inputDcmts[i].fileName ?? (inputDcmts[i].FILEEXT ? `${inputDcmts[i].DID}.${inputDcmts[i].FILEEXT}` : file?.name);
100
- alink2.download = downloadFileName;
113
+ const baseFileName = inputDcmts[i].fileName ?? (inputDcmts[i].FILEEXT ? `${inputDcmts[i].DID}.${inputDcmts[i].FILEEXT}` : file?.name);
114
+ alink2.download = getDownloadFileName(baseFileName);
101
115
  alink2.target = "_blank";
102
116
  alink2.rel = "noreferrer";
103
117
  alink2.click();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@topconsultnpm/sdkui-react",
3
- "version": "6.20.0-dev2.12",
3
+ "version": "6.20.0-dev2.13",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1",