@topconsultnpm/sdkui-react 6.19.0-dev2.36 → 6.19.0-dev2.37

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.
@@ -20,7 +20,7 @@ const TMCustomButton = (props) => {
20
20
  const { appName: scriptUrl, arguments: args } = button;
21
21
  const iframeRef = useRef(null);
22
22
  const attributes = useMemo(() => processButtonAttributes(args, formData), [args, formData]);
23
- const selectedItemsProcessed = useMemo(() => processSelectedItems(selectedItems), [selectedItems]);
23
+ const selectedItemsProcessed = useMemo(() => processSelectedItems(args, formData, selectedItems), [args, formData, selectedItems]);
24
24
  const RunOnce = button.mode === "RunOnce";
25
25
  const [loading, setLoading] = useState(true);
26
26
  const [error, setError] = useState(false);
@@ -33,8 +33,14 @@ const StyledProgressText = styled.p ` font-weight: bold; color: #333; margin: 0;
33
33
  const StyledMessage = styled.p ` color: #666; font-size: 0.9em; margin-top: 10px; `;
34
34
  const StyledAbortButton = styled.button ` background: #ff4d4d; color: white; border: none; border-radius: 5px; padding: 10px 20px; font-size: 1em; cursor: pointer; margin-top: 20px; &:hover { background: #ff6666; } `;
35
35
  export const TMWaitPanel = (props) => {
36
- let progressValue1 = 100 * (((props.valuePrimary ?? 0) / (props.maxValuePrimary ?? 0)) || 0);
37
- let progressValue2 = 100 * (((props.valueSecondary ?? 0) / (props.maxValueSecondary ?? 0)) || 0);
36
+ const calculateProgress = (value = 0, maxValue = 0) => {
37
+ if (maxValue === 0)
38
+ return 0;
39
+ const progress = (value / maxValue) * 100;
40
+ return Number.isFinite(progress) ? progress : 0;
41
+ };
42
+ let progressValue1 = calculateProgress(props.valuePrimary, props.maxValuePrimary);
43
+ let progressValue2 = calculateProgress(props.valueSecondary, props.maxValueSecondary);
38
44
  return (_jsx(StyledWaitPanelOverlay, { children: _jsxs(StyledWaitPanel, { "$height": (props.showPrimary && props.showSecondary) ? '350px' : '250px', children: [_jsx(StyledTitle, { children: props.title }), props.showPrimary &&
39
45
  _jsxs("div", { style: { width: '100%', height: '100px' }, children: [_jsx(StyledProgressBarContainer, { children: _jsx(StyledProgressBar, { style: { width: `${progressValue1.toFixed(2)}%` } }) }), _jsxs(StyledProgressText, { children: [progressValue1.toFixed(2), "%"] }), _jsx(StyledMessage, { children: props.textPrimary })] }), props.showSecondary &&
40
46
  _jsxs("div", { style: { width: '100%', height: '100px' }, children: [_jsx(StyledProgressBarContainer, { children: _jsx(StyledProgressBar, { style: { width: `${progressValue2.toFixed(2)}%` } }) }), _jsxs(StyledProgressText, { children: [progressValue2.toFixed(2), "%"] }), _jsx(StyledMessage, { children: props.textSecondary })] }), props.isCancelable && _jsx(StyledAbortButton, { onClick: () => props.onAbortClick?.(props.abortController), children: SDKUI_Localizator.Abort })] }) }));
@@ -15,11 +15,18 @@ import { TMSaveFormButtonPrevious, TMSaveFormButtonNext } from '../../forms/TMSa
15
15
  import { StyledAnimatedComponentOpacity } from '../../base/Styled';
16
16
  import TMPanel from '../../base/TMPanel';
17
17
  import TMTooltip from '../../base/TMTooltip';
18
+ const ErrorContent = ({ error, isAbortError, onRetry }) => {
19
+ if (isAbortError) {
20
+ 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 })] }) }));
21
+ }
22
+ return _jsx(TMNothingToShow, { icon: _jsx(IconCloseOutline, { fontSize: 92, color: TMColors.error }), text: error });
23
+ };
18
24
  const TMDcmtPreview = ({ dcmtData, isResizingActive, isVisible, canNext, canPrev, onClosePanel, onNext, onPrev, allowMaximize = true, onMaximizePanel }) => {
19
25
  const [dcmtBlob, setDcmtBlob] = useState(undefined);
20
26
  const [showPreview, setShowPreview] = useState(false);
21
27
  const [isFromCache, setIsFromCache] = useState(false);
22
28
  const [error, setError] = useState('');
29
+ const [isAbortError, setIsAbortError] = useState(false);
23
30
  const { abortController, showWaitPanel, waitPanelTitle, showPrimary, waitPanelTextPrimary, waitPanelValuePrimary, waitPanelMaxValuePrimary, showSecondary, waitPanelTextSecondary, waitPanelValueSecondary, waitPanelMaxValueSecondary, getDcmtFileAsync, clearDcmtsFileCache, removeDcmtsFileCache, isDcmtFileInCache } = useDcmtOperations();
24
31
  const cacheKey = dcmtData ? `${dcmtData.tid}-${dcmtData.did}` : '00';
25
32
  const [hasLoadedDataOnce, setHasLoadedDataOnce] = useState(false);
@@ -29,6 +36,7 @@ const TMDcmtPreview = ({ dcmtData, isResizingActive, isVisible, canNext, canPrev
29
36
  setLastLoadedDid(undefined); // Reset
30
37
  setDcmtBlob(undefined);
31
38
  setError('');
39
+ setIsAbortError(false);
32
40
  setShowPreview(false);
33
41
  return;
34
42
  }
@@ -42,6 +50,7 @@ const TMDcmtPreview = ({ dcmtData, isResizingActive, isVisible, canNext, canPrev
42
50
  if (shouldFetch) {
43
51
  setDcmtBlob(undefined);
44
52
  setError('');
53
+ setIsAbortError(false);
45
54
  if ((extensionHandler(dcmtData.fileExt) !== FileExtensionHandler.NONE) && ((dcmtData.fileSize ?? 0) <= (SDKUI_Globals.userSettings.searchSettings.previewThreshold * 1024))) {
46
55
  loadDocumentWithCache();
47
56
  setShowPreview(true);
@@ -65,15 +74,19 @@ const TMDcmtPreview = ({ dcmtData, isResizingActive, isVisible, canNext, canPrev
65
74
  let dcmtFile = await getDcmtFileAsync({ TID: dcmtData?.tid, DID: dcmtData?.did, FILEEXT: dcmtData?.fileExt }, rfo, 'Anteprima', false);
66
75
  setDcmtBlob(dcmtFile?.file);
67
76
  setIsFromCache(!!dcmtFile?.isFromCache);
77
+ setError('');
78
+ setIsAbortError(false);
68
79
  }
69
80
  catch (ex) {
70
81
  const err = ex;
71
82
  if (err.name === 'CanceledError') {
72
83
  setError('Operazione annullata.');
84
+ setIsAbortError(true);
73
85
  ShowAlert({ message: err.message, mode: 'warning', duration: 3000, title: 'Abort' });
74
86
  }
75
87
  else {
76
88
  setError(getExceptionMessage(ex));
89
+ setIsAbortError(false);
77
90
  TMExceptionBoxManager.show({ exception: ex });
78
91
  }
79
92
  }
@@ -101,6 +114,9 @@ const TMDcmtPreview = ({ dcmtData, isResizingActive, isVisible, canNext, canPrev
101
114
  const reOpenDcmt = async () => {
102
115
  removeDcmtsFileCache(cacheKey);
103
116
  setIsFromCache(false);
117
+ setError('');
118
+ setIsAbortError(false);
119
+ setDcmtBlob(undefined);
104
120
  try {
105
121
  await loadDocumentWithCache();
106
122
  }
@@ -112,7 +128,7 @@ const TMDcmtPreview = ({ dcmtData, isResizingActive, isVisible, canNext, canPrev
112
128
  { icon: _jsx(IconCloseCircle, {}), text: SDKUI_Localizator.RemoveFromCache, onClick: () => { removeDcmtsFileCache(cacheKey); setIsFromCache(false); } },
113
129
  { icon: _jsx(IconClear, {}), text: SDKUI_Localizator.ClearCache, onClick: () => { clearDcmtsFileCache(); setIsFromCache(false); } },
114
130
  ] }, "btn13") }), _jsx(StyledHeaderIcon, { onClick: reOpenDcmt, "$color": TMColors.primaryColor, children: _jsx(TMTooltip, { content: SDKUI_Localizator.ReopenDocument, children: _jsx(IconRefresh, {}) }) })] }), children: error
115
- ? _jsx(TMNothingToShow, { icon: _jsx(IconCloseOutline, { fontSize: 92, color: TMColors.error }), text: error })
131
+ ? _jsx(ErrorContent, { error: error, isAbortError: isAbortError, onRetry: reOpenDcmt })
116
132
  : renderedPreview(dcmtData?.tid, dcmtData?.did, dcmtData?.fileExt, dcmtData?.fileSize, dcmtData?.fileCount, extensionHandler(dcmtData?.fileExt), showPreview, isResizingActive, () => { loadDocumentWithCache(); setShowPreview(true); }, dcmtBlob) }) }));
117
133
  };
118
134
  export default TMDcmtPreview;
@@ -505,6 +505,7 @@ export declare class SDKUI_Localizator {
505
505
  static get RemovingFromList(): string;
506
506
  static get RememberCredentials(): "Anmeldedaten merken" | "Remember credentials" | "Recordar credenciales" | "Se souvenir des identifiants" | "Lembrar credenciais" | "Ricorda credenziali";
507
507
  static get ReopenDocument(): string;
508
+ static get TryAgain(): string;
508
509
  static get ReplaceDocument(): "Dokument ersetzen" | "Replace Document" | "Reemplazar Documento" | "Remplacer le Document" | "Substituir Documento" | "Sostituisci Documento";
509
510
  static get Request(): string;
510
511
  static get RequestTo(): string;
@@ -4978,6 +4978,16 @@ export class SDKUI_Localizator {
4978
4978
  default: return "Riapri documento";
4979
4979
  }
4980
4980
  }
4981
+ static get TryAgain() {
4982
+ switch (this._cultureID) {
4983
+ case CultureIDs.De_DE: return "Erneut versuchen";
4984
+ case CultureIDs.En_US: return "Try Again";
4985
+ case CultureIDs.Es_ES: return "Intentar de nuevo";
4986
+ case CultureIDs.Fr_FR: return "Réessayer";
4987
+ case CultureIDs.Pt_PT: return "Tentar novamente";
4988
+ default: return "Riprova";
4989
+ }
4990
+ }
4981
4991
  static get ReplaceDocument() {
4982
4992
  switch (this._cultureID) {
4983
4993
  case CultureIDs.De_DE: return "Dokument ersetzen";
@@ -4,5 +4,5 @@ export declare const hasDetailRelations: (mTID: number | undefined) => Promise<b
4
4
  /** Check if dcmtType (mTID) has configured Master or Many-to-Many relations */
5
5
  export declare const hasMasterRelations: (mTID: number | undefined) => Promise<boolean>;
6
6
  export declare const isXMLFileExt: (fileExt: string | undefined) => boolean;
7
- export declare const processButtonAttributes: (args: string | undefined, formData: MetadataValueDescriptorEx[] | undefined) => string[] | undefined;
8
- export declare const processSelectedItems: (selectedItems: Array<any> | undefined) => any[] | undefined;
7
+ export declare const processButtonAttributes: (args: string | undefined, formData: MetadataValueDescriptorEx[] | undefined) => (string | null)[] | undefined;
8
+ export declare const processSelectedItems: (args: string | undefined, formData: MetadataValueDescriptorEx[] | undefined, selectedItems: Array<any> | undefined) => any[][];
@@ -25,29 +25,26 @@ export const isXMLFileExt = (fileExt) => {
25
25
  };
26
26
  /*utility functions for TMCustomButton*/
27
27
  export const processButtonAttributes = (args, formData) => args && formData ? formDataMap(formData, args) : undefined;
28
- export const processSelectedItems = (selectedItems) => selectedItems?.map(item => {
29
- const tid = item.TID;
30
- if (!tid)
31
- return item;
32
- const prefix = `${tid}_`;
33
- const prefixLength = prefix.length;
34
- return Object.keys(item).reduce((acc, key) => {
35
- acc[key.startsWith(prefix) ? key.substring(prefixLength) : key] = item[key];
36
- return acc;
37
- }, {});
38
- });
39
- const formDataMap = (data, args) => {
28
+ export const processSelectedItems = (args, formData, selectedItems) => {
29
+ if (!args || !selectedItems)
30
+ return [];
31
+ const MidList = formData ? formDataMap(formData, args, true) : [];
32
+ return selectedItems.map(item =>
33
+ //salvo il did come primo elemento dell'array
34
+ [item["DID"], ...MidList.map(key => key && item[key])]);
35
+ };
36
+ const formDataMap = (data, args, returnMid = false) => {
40
37
  const tokens = args.match(/\{@?[^}]+\}/g) || [];
41
38
  return tokens.map(token => {
42
39
  if (token.startsWith('{@')) {
43
40
  // Campo dinamico: {@campo} -> cerca in formData
44
- const fieldName = token.slice(2, -1); // Rimuove {@...}
41
+ const fieldName = token.slice(2, -1);
45
42
  const md = data.find(md => md.md?.name === fieldName);
46
- return md?.value;
43
+ return returnMid ? (md ? `${md.tid}_${md.mid}` : null) : (md?.value ?? null);
47
44
  }
48
45
  else {
49
- // Campo statico: {valore} -> ritorna il valore direttamente
50
- return token.slice(1, -1); // Rimuove {...}
46
+ // Campo statico: {valore} -> ritorna il valore o null
47
+ return returnMid ? null : token.slice(1, -1);
51
48
  }
52
- }).filter((value) => value !== undefined && value !== null);
49
+ });
53
50
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@topconsultnpm/sdkui-react",
3
- "version": "6.19.0-dev2.36",
3
+ "version": "6.19.0-dev2.37",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1",