@topconsultnpm/sdkui-react 6.20.0-dev3.1 → 6.20.0-dev3.11
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/features/archive/TMArchive.d.ts +1 -0
- package/lib/components/features/archive/TMArchive.js +2 -2
- package/lib/components/features/documents/TMFileUploader.d.ts +1 -0
- package/lib/components/features/documents/TMFileUploader.js +18 -13
- package/lib/components/features/search/TMSearchResult.js +5 -13
- package/lib/components/features/search/TMSearchResultsMenuItems.d.ts +1 -1
- package/lib/components/features/search/TMSearchResultsMenuItems.js +4 -16
- package/lib/components/features/search/TMTreeSelector.js +1 -1
- package/lib/components/grids/TMRecentsManager.js +1 -1
- package/lib/components/viewers/TMTidViewer.js +2 -1
- package/lib/helper/TMUtils.d.ts +8 -41
- package/lib/helper/TMUtils.js +76 -165
- package/package.json +1 -1
- package/lib/components/features/search/TMSignSettingsForm.d.ts +0 -9
- package/lib/components/features/search/TMSignSettingsForm.js +0 -621
package/lib/helper/TMUtils.js
CHANGED
|
@@ -2,7 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import styled from "styled-components";
|
|
3
3
|
import { TMTooltip } from '../components';
|
|
4
4
|
import { IconCADossier, IconKey, IconMenuCAWorkingGroups } from './TMIcons';
|
|
5
|
-
import { AppModules, DataListCacheService, MetadataDataDomains, PdGs } from '@topconsultnpm/sdk-ts';
|
|
5
|
+
import { AppModules, DataListCacheService, LicenseModuleStatus, MetadataDataDomains, PdGs, SDK_Globals } from '@topconsultnpm/sdk-ts';
|
|
6
6
|
import { SDKUI_Localizator } from './SDKUI_Localizator';
|
|
7
7
|
const StyledIconFileContainer = styled.div `
|
|
8
8
|
height: 22px;
|
|
@@ -178,6 +178,15 @@ export const isCreateCertificateEnabled = (widgetsString) => {
|
|
|
178
178
|
export const isPdfEditorEnabled = (widgetsString) => {
|
|
179
179
|
return isWidgetEnabled(PDF_EDITOR_ID, widgetsString);
|
|
180
180
|
};
|
|
181
|
+
/** Verifica se l'editor PDF è disponibile: richiede file PDF, licenza attiva e widget abilitato sul tipo documento. */
|
|
182
|
+
export const isPdfEditorAvailable = (fromDTD, ext) => {
|
|
183
|
+
if (fromDTD === undefined || !fromDTD.widgets || !ext)
|
|
184
|
+
return false;
|
|
185
|
+
if (ext.toLowerCase() !== "pdf")
|
|
186
|
+
return false;
|
|
187
|
+
const isPdfEditorLicensed = SDK_Globals?.license?.dcmtArchiveLicenses?.[0]?.siX_60007?.status === LicenseModuleStatus.Licensed;
|
|
188
|
+
return isPdfEditorLicensed && isPdfEditorEnabled(fromDTD.widgets);
|
|
189
|
+
};
|
|
181
190
|
export const StyledTabItem = styled.div `
|
|
182
191
|
display: flex;
|
|
183
192
|
align-items: center;
|
|
@@ -215,177 +224,79 @@ export const getPdgsIconMap = (fontSize = 20) => {
|
|
|
215
224
|
[PdGs.WG, _jsx(IconMenuCAWorkingGroups, { color: PDGS_COLORS.WORKING_GROUP, fontSize: 28 }, "PdGs-WG")],
|
|
216
225
|
]);
|
|
217
226
|
};
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
*
|
|
235
|
-
* // 2. "All" - Tutti i campi attivi con valori di default
|
|
236
|
-
* parseSignatureConfiguration(1, "All", "Mario", "Rossi", "Doc1")
|
|
237
|
-
*
|
|
238
|
-
* // 3. "None" - Nessun campo attivo
|
|
239
|
-
* parseSignatureConfiguration(1, "None", "Mario", "Rossi", "Doc1")
|
|
240
|
-
*
|
|
241
|
-
* // 4. Formato con valori espliciti: Key=Value
|
|
242
|
-
* parseSignatureConfiguration(1, "Date=Yes,SignerBy=Mario,Location=Milano,Copyright=TopConsult", ...)
|
|
243
|
-
*
|
|
244
|
-
* // 5. Formato chiavi semplici (attiva i default): key1,key2,key3
|
|
245
|
-
* parseSignatureConfiguration(1, "date,signerby,location", "Mario", "Rossi", "Doc1")
|
|
246
|
-
*
|
|
247
|
-
* // 6. Formato misto
|
|
248
|
-
* parseSignatureConfiguration(1, "date,SignerBy=Yes,Location=Roma", "Mario", "Rossi", "Doc1")
|
|
249
|
-
*/
|
|
250
|
-
export const parseSignatureConfiguration = (did, informationSign, firstName, lastName, title) => {
|
|
251
|
-
try {
|
|
252
|
-
// Rimuove spazi dalla stringa di input mantenendo il case originale
|
|
253
|
-
const signatureSign = informationSign?.trim();
|
|
254
|
-
// Definisce i valori di default per ciascun campo
|
|
255
|
-
const defaultLocationValue = SDKUI_Localizator.Torino;
|
|
256
|
-
const defaultCopyrightValue = "Sign4Top";
|
|
257
|
-
const defaultSignerByValue = `${firstName ?? ''} ${lastName ?? ''}`.trim() || '';
|
|
258
|
-
// Configurazione di default: solo data attiva
|
|
259
|
-
const defaultInfo = {
|
|
260
|
-
allowDate: true,
|
|
261
|
-
allowSignerBy: false,
|
|
262
|
-
signerByValue: defaultSignerByValue,
|
|
263
|
-
allowLocation: false,
|
|
264
|
-
locationValue: defaultLocationValue,
|
|
265
|
-
allowCopyright: false,
|
|
266
|
-
copyrightValue: defaultCopyrightValue
|
|
267
|
-
};
|
|
268
|
-
// Se la stringa è vuota o non definita, ritorna la configurazione di default
|
|
269
|
-
if (!signatureSign || signatureSign.length === 0) {
|
|
270
|
-
return defaultInfo;
|
|
271
|
-
}
|
|
272
|
-
// Caso speciale: "all" attiva tutti i campi con valori di default
|
|
273
|
-
if (signatureSign.toLowerCase() === "all") {
|
|
274
|
-
return {
|
|
275
|
-
allowDate: true,
|
|
276
|
-
allowSignerBy: true,
|
|
277
|
-
signerByValue: defaultSignerByValue,
|
|
278
|
-
allowLocation: true,
|
|
279
|
-
locationValue: defaultLocationValue,
|
|
280
|
-
allowCopyright: true,
|
|
281
|
-
copyrightValue: defaultCopyrightValue
|
|
282
|
-
};
|
|
227
|
+
export const parseSignatureConfiguration = (did, informationSign, title) => {
|
|
228
|
+
const signatureSign = informationSign?.trim() || "";
|
|
229
|
+
if (!signatureSign)
|
|
230
|
+
return {};
|
|
231
|
+
const infoParts = signatureSign.split(',').map(part => part.trim()).filter(Boolean);
|
|
232
|
+
const allowedKeys = ["copyright", "date", "location"];
|
|
233
|
+
const allowedDateValues = ["no", "yes", "true", "false", ""];
|
|
234
|
+
const invalidKeys = [];
|
|
235
|
+
const invalidDateValues = [];
|
|
236
|
+
for (const part of infoParts) {
|
|
237
|
+
const [key, ...valueParts] = part.split("=");
|
|
238
|
+
const currentKey = key.trim().toLowerCase();
|
|
239
|
+
const rawValue = valueParts.join("=").trim();
|
|
240
|
+
const currentValue = rawValue.replace(/^["']|["']$/g, "").toLowerCase();
|
|
241
|
+
if (!allowedKeys.includes(currentKey)) {
|
|
242
|
+
invalidKeys.push(key.trim());
|
|
283
243
|
}
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
return {
|
|
287
|
-
allowDate: false,
|
|
288
|
-
allowSignerBy: false,
|
|
289
|
-
signerByValue: defaultSignerByValue,
|
|
290
|
-
allowLocation: false,
|
|
291
|
-
locationValue: defaultLocationValue,
|
|
292
|
-
allowCopyright: false,
|
|
293
|
-
copyrightValue: defaultCopyrightValue
|
|
294
|
-
};
|
|
244
|
+
else if (currentKey === "date" && !allowedDateValues.includes(currentValue)) {
|
|
245
|
+
invalidDateValues.push(rawValue);
|
|
295
246
|
}
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
247
|
+
}
|
|
248
|
+
if (invalidKeys.length > 0) {
|
|
249
|
+
throw new Error(`${invalidKeys.length > 1 ? 'I parametri' : 'Il parametro'} "${invalidKeys.join('", "')}" non ${invalidKeys.length > 1 ? 'sono riconosciuti' : 'è riconosciuto'} nel campo "informationSign" per il documento "${title || did}". ` +
|
|
250
|
+
`I parametri ammessi sono: ${allowedKeys.join(", ")}. ` +
|
|
251
|
+
`Il valore attuale del campo è "${informationSign}"`);
|
|
252
|
+
}
|
|
253
|
+
if (invalidDateValues.length > 0) {
|
|
254
|
+
throw new Error(`${invalidDateValues.length > 1 ? 'I valori' : 'Il valore'} "${invalidDateValues.join('", "')}" non ${invalidDateValues.length > 1 ? 'sono validi' : 'è valido'} per il parametro "date" nel campo "informationSign" per il documento "${title || did}". ` +
|
|
255
|
+
`I valori ammessi per "date" sono: ${allowedDateValues.filter(v => v).join(", ")}. ` +
|
|
256
|
+
`Il valore attuale del campo è "${informationSign}"`);
|
|
257
|
+
}
|
|
258
|
+
// DEFAULT
|
|
259
|
+
let result = {
|
|
260
|
+
copyright: "",
|
|
261
|
+
date: false,
|
|
262
|
+
location: ""
|
|
263
|
+
};
|
|
264
|
+
const parseBooleanOrValue = (value) => {
|
|
265
|
+
const valueLower = value.toLowerCase();
|
|
266
|
+
if (valueLower === "no" || valueLower === "false")
|
|
267
|
+
return { enabled: false };
|
|
268
|
+
if (valueLower === "yes" || valueLower === "true" || !value)
|
|
269
|
+
return { enabled: true };
|
|
270
|
+
return { enabled: true, customValue: value };
|
|
271
|
+
};
|
|
272
|
+
for (const part of infoParts) {
|
|
273
|
+
const [key, ...valueParts] = part.split("=");
|
|
274
|
+
const currentKey = key.trim().toLowerCase();
|
|
275
|
+
const rawValue = valueParts.join("=").trim();
|
|
276
|
+
const currentValue = rawValue.replace(/^["']|["']$/g, "");
|
|
277
|
+
switch (currentKey) {
|
|
278
|
+
case "date": {
|
|
279
|
+
const parsed = parseBooleanOrValue(currentValue);
|
|
280
|
+
result.date = parsed.enabled;
|
|
281
|
+
break;
|
|
307
282
|
}
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
}
|
|
315
|
-
// Clone della configurazione di default per la modifica
|
|
316
|
-
const info = { ...defaultInfo };
|
|
317
|
-
// Itera su ogni parte della configurazione
|
|
318
|
-
for (const part of infoParts) {
|
|
319
|
-
const [key, ...valueParts] = part.split("=");
|
|
320
|
-
const currentKey = key.trim().toLowerCase();
|
|
321
|
-
// Ricostruisce il valore nel caso contenga "=" al suo interno
|
|
322
|
-
const rawValue = valueParts.join("=").trim();
|
|
323
|
-
// Rimuove le virgolette dall'inizio e dalla fine del valore
|
|
324
|
-
const currentValue = rawValue.replace(/^["']|["']$/g, "");
|
|
325
|
-
// Helper per gestire i valori booleani e custom
|
|
326
|
-
const parseBooleanOrValue = (value) => {
|
|
327
|
-
const valueLower = value.toLowerCase();
|
|
328
|
-
if (valueLower === "no" || valueLower === "false")
|
|
329
|
-
return { enabled: false };
|
|
330
|
-
if (valueLower === "yes" || valueLower === "true" || !value)
|
|
331
|
-
return { enabled: true };
|
|
332
|
-
return { enabled: true, customValue: value };
|
|
333
|
-
};
|
|
334
|
-
// Processa ciascuna chiave in base al tipo
|
|
335
|
-
if (part.includes("=")) {
|
|
336
|
-
// Formato: Key=Value
|
|
337
|
-
switch (currentKey) {
|
|
338
|
-
case "date":
|
|
339
|
-
// Data supporta solo Yes/No/True/False
|
|
340
|
-
const dateLower = currentValue.toLowerCase();
|
|
341
|
-
info.allowDate = dateLower === "yes" || dateLower === "true";
|
|
342
|
-
break;
|
|
343
|
-
case "signerby": {
|
|
344
|
-
const parsed = parseBooleanOrValue(currentValue);
|
|
345
|
-
info.allowSignerBy = parsed.enabled;
|
|
346
|
-
info.signerByValue = parsed.customValue || defaultSignerByValue;
|
|
347
|
-
break;
|
|
348
|
-
}
|
|
349
|
-
case "location": {
|
|
350
|
-
const parsed = parseBooleanOrValue(currentValue);
|
|
351
|
-
info.allowLocation = parsed.enabled;
|
|
352
|
-
info.locationValue = parsed.customValue || defaultLocationValue;
|
|
353
|
-
break;
|
|
354
|
-
}
|
|
355
|
-
case "copyright": {
|
|
356
|
-
const parsed = parseBooleanOrValue(currentValue);
|
|
357
|
-
info.allowCopyright = parsed.enabled;
|
|
358
|
-
info.copyrightValue = parsed.customValue || defaultCopyrightValue;
|
|
359
|
-
break;
|
|
360
|
-
}
|
|
361
|
-
}
|
|
283
|
+
case "location": {
|
|
284
|
+
const parsed = parseBooleanOrValue(currentValue);
|
|
285
|
+
result.location = parsed.enabled
|
|
286
|
+
? parsed.customValue || ""
|
|
287
|
+
: "";
|
|
288
|
+
break;
|
|
362
289
|
}
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
case "signerby":
|
|
370
|
-
info.allowSignerBy = true;
|
|
371
|
-
info.signerByValue = defaultSignerByValue;
|
|
372
|
-
break;
|
|
373
|
-
case "location":
|
|
374
|
-
info.allowLocation = true;
|
|
375
|
-
info.locationValue = defaultLocationValue;
|
|
376
|
-
break;
|
|
377
|
-
case "copyright":
|
|
378
|
-
info.allowCopyright = true;
|
|
379
|
-
info.copyrightValue = defaultCopyrightValue;
|
|
380
|
-
break;
|
|
381
|
-
}
|
|
290
|
+
case "copyright": {
|
|
291
|
+
const parsed = parseBooleanOrValue(currentValue);
|
|
292
|
+
result.copyright = parsed.enabled
|
|
293
|
+
? parsed.customValue || ""
|
|
294
|
+
: "";
|
|
295
|
+
break;
|
|
382
296
|
}
|
|
383
297
|
}
|
|
384
|
-
return info;
|
|
385
|
-
}
|
|
386
|
-
catch (error) {
|
|
387
|
-
throw error;
|
|
388
298
|
}
|
|
299
|
+
return result;
|
|
389
300
|
};
|
|
390
301
|
export const convertSearchResultDescriptorToFileItems = (documents) => {
|
|
391
302
|
const fileItems = [];
|
package/package.json
CHANGED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { DcmtTypeDescriptor, SearchResultDescriptor } from "@topconsultnpm/sdk-ts";
|
|
2
|
-
interface TMSignSettingsFormProps {
|
|
3
|
-
fromDTD: DcmtTypeDescriptor;
|
|
4
|
-
inputDcmts: any[];
|
|
5
|
-
onCloseSignSettingsForm: () => void;
|
|
6
|
-
onSavedAsyncCallback: ((tid: number | undefined, did: number | undefined, metadataResult?: SearchResultDescriptor | null) => Promise<void>);
|
|
7
|
-
}
|
|
8
|
-
declare const TMSignSettingsForm: (props: TMSignSettingsFormProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
9
|
-
export default TMSignSettingsForm;
|