@topconsultnpm/sdkui-react 6.21.0-dev1.51 → 6.21.0-dev1.52
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/helper/TMUtils.d.ts +0 -6
- package/lib/helper/TMUtils.js +0 -74
- package/package.json +1 -1
package/lib/helper/TMUtils.d.ts
CHANGED
|
@@ -32,12 +32,6 @@ export declare const PDGS_COLORS: {
|
|
|
32
32
|
WORKING_GROUP: string;
|
|
33
33
|
};
|
|
34
34
|
export declare const getPdgsIconMap: (fontSize?: number) => Map<PdGs, JSX.Element>;
|
|
35
|
-
export type SignatureConfiguration = {
|
|
36
|
-
copyright: string;
|
|
37
|
-
date: boolean;
|
|
38
|
-
location: string;
|
|
39
|
-
};
|
|
40
|
-
export declare const parseSignatureConfiguration: (did: number, informationSign: string | undefined | null, title: string | undefined | null) => Partial<SignatureConfiguration>;
|
|
41
35
|
export declare const convertSearchResultDescriptorToFileItems: (documents: Array<SearchResultDescriptor>) => Array<FileItem>;
|
|
42
36
|
export declare const getAppModuleGradient: (appModuleID: AppModules) => string;
|
|
43
37
|
export declare const getPanelManagerToolbarColor: (appModuleID: AppModules) => string;
|
package/lib/helper/TMUtils.js
CHANGED
|
@@ -225,80 +225,6 @@ export const getPdgsIconMap = (fontSize = 20) => {
|
|
|
225
225
|
[PdGs.WG, _jsx(IconMenuCAWorkingGroups, { color: PDGS_COLORS.WORKING_GROUP, fontSize: 28 }, "PdGs-WG")],
|
|
226
226
|
]);
|
|
227
227
|
};
|
|
228
|
-
export const parseSignatureConfiguration = (did, informationSign, title) => {
|
|
229
|
-
const signatureSign = informationSign?.trim() || "";
|
|
230
|
-
if (!signatureSign)
|
|
231
|
-
return {};
|
|
232
|
-
const infoParts = signatureSign.split(',').map(part => part.trim()).filter(Boolean);
|
|
233
|
-
const allowedKeys = ["copyright", "date", "location"];
|
|
234
|
-
const allowedDateValues = ["no", "yes", "true", "false", ""];
|
|
235
|
-
const invalidKeys = [];
|
|
236
|
-
const invalidDateValues = [];
|
|
237
|
-
for (const part of infoParts) {
|
|
238
|
-
const [key, ...valueParts] = part.split("=");
|
|
239
|
-
const currentKey = key.trim().toLowerCase();
|
|
240
|
-
const rawValue = valueParts.join("=").trim();
|
|
241
|
-
const currentValue = rawValue.replace(/^["']|["']$/g, "").toLowerCase();
|
|
242
|
-
if (!allowedKeys.includes(currentKey)) {
|
|
243
|
-
invalidKeys.push(key.trim());
|
|
244
|
-
}
|
|
245
|
-
else if (currentKey === "date" && !allowedDateValues.includes(currentValue)) {
|
|
246
|
-
invalidDateValues.push(rawValue);
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
if (invalidKeys.length > 0) {
|
|
250
|
-
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}". ` +
|
|
251
|
-
`I parametri ammessi sono: ${allowedKeys.join(", ")}. ` +
|
|
252
|
-
`Il valore attuale del campo è "${informationSign}"`);
|
|
253
|
-
}
|
|
254
|
-
if (invalidDateValues.length > 0) {
|
|
255
|
-
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}". ` +
|
|
256
|
-
`I valori ammessi per "date" sono: ${allowedDateValues.filter(v => v).join(", ")}. ` +
|
|
257
|
-
`Il valore attuale del campo è "${informationSign}"`);
|
|
258
|
-
}
|
|
259
|
-
// DEFAULT
|
|
260
|
-
let result = {
|
|
261
|
-
copyright: "",
|
|
262
|
-
date: false,
|
|
263
|
-
location: ""
|
|
264
|
-
};
|
|
265
|
-
const parseBooleanOrValue = (value) => {
|
|
266
|
-
const valueLower = value.toLowerCase();
|
|
267
|
-
if (valueLower === "no" || valueLower === "false")
|
|
268
|
-
return { enabled: false };
|
|
269
|
-
if (valueLower === "yes" || valueLower === "true" || !value)
|
|
270
|
-
return { enabled: true };
|
|
271
|
-
return { enabled: true, customValue: value };
|
|
272
|
-
};
|
|
273
|
-
for (const part of infoParts) {
|
|
274
|
-
const [key, ...valueParts] = part.split("=");
|
|
275
|
-
const currentKey = key.trim().toLowerCase();
|
|
276
|
-
const rawValue = valueParts.join("=").trim();
|
|
277
|
-
const currentValue = rawValue.replace(/^["']|["']$/g, "");
|
|
278
|
-
switch (currentKey) {
|
|
279
|
-
case "date": {
|
|
280
|
-
const parsed = parseBooleanOrValue(currentValue);
|
|
281
|
-
result.date = parsed.enabled;
|
|
282
|
-
break;
|
|
283
|
-
}
|
|
284
|
-
case "location": {
|
|
285
|
-
const parsed = parseBooleanOrValue(currentValue);
|
|
286
|
-
result.location = parsed.enabled
|
|
287
|
-
? parsed.customValue || ""
|
|
288
|
-
: "";
|
|
289
|
-
break;
|
|
290
|
-
}
|
|
291
|
-
case "copyright": {
|
|
292
|
-
const parsed = parseBooleanOrValue(currentValue);
|
|
293
|
-
result.copyright = parsed.enabled
|
|
294
|
-
? parsed.customValue || ""
|
|
295
|
-
: "";
|
|
296
|
-
break;
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
return result;
|
|
301
|
-
};
|
|
302
228
|
export const convertSearchResultDescriptorToFileItems = (documents) => {
|
|
303
229
|
const fileItems = [];
|
|
304
230
|
documents.forEach((doc, docIndex) => {
|