@topconsultnpm/sdkui-react-beta 6.9.93 → 6.9.94
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/editors/TMTextExpression.d.ts +18 -0
- package/lib/components/editors/TMTextExpression.js +142 -0
- package/lib/helper/SDKUI_Localizator.d.ts +2 -0
- package/lib/helper/SDKUI_Localizator.js +20 -0
- package/lib/helper/helpers.d.ts +1 -0
- package/lib/helper/helpers.js +9 -0
- package/package.json +1 -1
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { QueryDescriptor, ValidationItem } from '@topconsultnpm/sdk-ts-beta';
|
|
3
|
+
import { ITMEditorBase } from '../base/TMEditorBase';
|
|
4
|
+
interface ITMTextExpression extends ITMEditorBase {
|
|
5
|
+
value: string | undefined;
|
|
6
|
+
valueOrig: string | undefined;
|
|
7
|
+
qd?: QueryDescriptor;
|
|
8
|
+
formulaItems?: string[];
|
|
9
|
+
label?: string;
|
|
10
|
+
validationItems?: ValidationItem[];
|
|
11
|
+
onValueChanged?: (newText: string | undefined) => void;
|
|
12
|
+
}
|
|
13
|
+
declare const TMTextExpression: React.FunctionComponent<ITMTextExpression>;
|
|
14
|
+
export declare class FormulaItemHelper {
|
|
15
|
+
id: number;
|
|
16
|
+
paramName: string;
|
|
17
|
+
}
|
|
18
|
+
export default TMTextExpression;
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useState } from 'react';
|
|
3
|
+
import { DcmtTypeListCacheService } from '@topconsultnpm/sdk-ts-beta';
|
|
4
|
+
import { Column } from 'devextreme-react/cjs/data-grid';
|
|
5
|
+
import { IconClear, IconColumns, IconDataList, SDKUI_Localizator, stringIsNullOrEmpty } from '../../helper';
|
|
6
|
+
import { TMExceptionBoxManager } from '../base/TMPopUp';
|
|
7
|
+
import { TMMetadataChooserForm } from '../choosers/TMMetadataChooser';
|
|
8
|
+
import TMChooserForm from '../forms/TMChooserForm';
|
|
9
|
+
import TMTextBox from './TMTextBox';
|
|
10
|
+
const TMTextExpression = (props) => {
|
|
11
|
+
const [metadatas_Info_Source, setMetadatas_Info_Source] = useState([]);
|
|
12
|
+
const [showMetadataChooser, setShowMetadataChooser] = useState(false);
|
|
13
|
+
const [showFormulaChooser, setShowFormulaChooser] = useState(false);
|
|
14
|
+
useEffect(() => { MetadataInfos_Source_Get_Async(); }, [props.qd]);
|
|
15
|
+
async function MetadataInfos_Source_Get_Async() {
|
|
16
|
+
if (!props.qd?.select)
|
|
17
|
+
return;
|
|
18
|
+
let mhs_source = [];
|
|
19
|
+
try {
|
|
20
|
+
let dtd_source;
|
|
21
|
+
let md_source;
|
|
22
|
+
let tid_source = -1;
|
|
23
|
+
let si;
|
|
24
|
+
let sis = props.qd?.select?.slice();
|
|
25
|
+
sis = sis.slice().sort((a, b) => a.tid - b.tid);
|
|
26
|
+
for (si of sis) {
|
|
27
|
+
if (si.tid == undefined || si.mid == undefined)
|
|
28
|
+
continue;
|
|
29
|
+
if (tid_source != si.tid) {
|
|
30
|
+
dtd_source = await DcmtTypeListCacheService.GetAsync(si.tid, true);
|
|
31
|
+
if (dtd_source == undefined)
|
|
32
|
+
continue;
|
|
33
|
+
tid_source = si.tid;
|
|
34
|
+
}
|
|
35
|
+
if (dtd_source?.metadata == undefined)
|
|
36
|
+
continue;
|
|
37
|
+
md_source = dtd_source.metadata.find(o => o.id == si.mid);
|
|
38
|
+
if (md_source?.name == undefined)
|
|
39
|
+
continue;
|
|
40
|
+
if (tid_source == undefined)
|
|
41
|
+
continue;
|
|
42
|
+
mhs_source.push(new MetatadaHelper(si.mid, md_source.name));
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
catch (e) {
|
|
46
|
+
TMExceptionBoxManager.show({ exception: e, title: 'MetadataInfos_Source_Get_Async' });
|
|
47
|
+
}
|
|
48
|
+
setMetadatas_Info_Source(mhs_source);
|
|
49
|
+
}
|
|
50
|
+
function Expression_IDs2Names(expression) {
|
|
51
|
+
if (expression == undefined)
|
|
52
|
+
return expression;
|
|
53
|
+
let temp = expression.slice();
|
|
54
|
+
let mh;
|
|
55
|
+
for (mh of metadatas_Info_Source) {
|
|
56
|
+
temp = temp.replaceAll(mh.Mid.toString(), mh.MetadataName);
|
|
57
|
+
}
|
|
58
|
+
temp = temp.replaceAll("{@1}", "{@DID}");
|
|
59
|
+
return temp;
|
|
60
|
+
}
|
|
61
|
+
function Expression_Names2IDs(expression) {
|
|
62
|
+
if (expression == undefined)
|
|
63
|
+
return expression;
|
|
64
|
+
let temp = expression.slice();
|
|
65
|
+
let mh;
|
|
66
|
+
for (mh of metadatas_Info_Source)
|
|
67
|
+
temp = temp.replaceAll(mh.MetadataName, mh.Mid.toString());
|
|
68
|
+
temp = temp.replaceAll("{@DID}", "{@1}");
|
|
69
|
+
return temp;
|
|
70
|
+
}
|
|
71
|
+
const renderButtons = () => {
|
|
72
|
+
let buttons = [];
|
|
73
|
+
if (props.qd)
|
|
74
|
+
buttons.push({ icon: _jsx(IconColumns, {}), text: SDKUI_Localizator.MetadataReferenceInsert, onClick: () => { setShowMetadataChooser(true); } });
|
|
75
|
+
if (props.formulaItems && props.formulaItems.length > 0)
|
|
76
|
+
buttons.push({ icon: _jsx(IconDataList, {}), text: SDKUI_Localizator.Parameters, onClick: () => setShowFormulaChooser(true) });
|
|
77
|
+
buttons.push({ icon: _jsx(IconClear, {}), text: SDKUI_Localizator.Clear, onClick: () => props.onValueChanged?.('') });
|
|
78
|
+
return buttons;
|
|
79
|
+
};
|
|
80
|
+
function mdList(tids_mids) {
|
|
81
|
+
let output = props.value ?? '';
|
|
82
|
+
if (tids_mids == undefined)
|
|
83
|
+
return output;
|
|
84
|
+
let isAll = (tids_mids.length == props.qd?.select?.length);
|
|
85
|
+
if (isAll)
|
|
86
|
+
output = '';
|
|
87
|
+
for (let si of tids_mids) {
|
|
88
|
+
if (si.tid == undefined)
|
|
89
|
+
continue;
|
|
90
|
+
if (si.mid == undefined)
|
|
91
|
+
continue;
|
|
92
|
+
if (stringIsNullOrEmpty(output))
|
|
93
|
+
output = `{@${si.mid}}`;
|
|
94
|
+
else
|
|
95
|
+
output += (isAll ? '_' : '') + `{@${si.mid}}`;
|
|
96
|
+
}
|
|
97
|
+
return output;
|
|
98
|
+
}
|
|
99
|
+
function getFormulaDataSorce() {
|
|
100
|
+
let fiarray = [];
|
|
101
|
+
if (!props.formulaItems)
|
|
102
|
+
return [];
|
|
103
|
+
let i = 0;
|
|
104
|
+
for (const f of props.formulaItems) {
|
|
105
|
+
let fi = new FormulaItemHelper();
|
|
106
|
+
fi.id = i;
|
|
107
|
+
fi.paramName = f;
|
|
108
|
+
fiarray.push(fi);
|
|
109
|
+
i++;
|
|
110
|
+
}
|
|
111
|
+
return fiarray;
|
|
112
|
+
}
|
|
113
|
+
const openMetadataChooseForm = () => {
|
|
114
|
+
return (showMetadataChooser ?
|
|
115
|
+
_jsx(TMMetadataChooserForm, { allowMultipleSelection: true, qd: props.qd, qdShowOnlySelectItems: true, allowSysMetadata: true, onClose: () => setShowMetadataChooser(false), onChoose: (tid_mid) => {
|
|
116
|
+
let list = mdList(tid_mid);
|
|
117
|
+
props.onValueChanged?.(list);
|
|
118
|
+
} }) : _jsx(_Fragment, {}));
|
|
119
|
+
};
|
|
120
|
+
const openFormulaChooseForm = () => {
|
|
121
|
+
return (showFormulaChooser ?
|
|
122
|
+
_jsx(TMChooserForm, { title: SDKUI_Localizator.Parameters, height: '300', width: '300', hasShowId: false, showDefaultColumns: false, allowMultipleSelection: true, columns: [_jsx(Column, { caption: SDKUI_Localizator.Name, dataField: "paramName", sortOrder: 'asc', alignment: 'left' }, 0)], dataSource: getFormulaDataSorce(), onClose: () => { setShowFormulaChooser(false); }, onChoose: (IDs) => {
|
|
123
|
+
let expr = props.value ?? '';
|
|
124
|
+
IDs.map(i => expr += props.formulaItems[i]);
|
|
125
|
+
props.onValueChanged?.(expr);
|
|
126
|
+
} }) : _jsx(_Fragment, {}));
|
|
127
|
+
};
|
|
128
|
+
return (_jsxs(_Fragment, { children: [_jsx(TMTextBox, { buttons: renderButtons(), isModifiedWhen: props.value != props.valueOrig, label: props.label, value: Expression_IDs2Names(props.value) ?? '', validationItems: props.validationItems, onValueChanged: (e) => { props.onValueChanged?.(Expression_Names2IDs(e.target.value)); } }), openMetadataChooseForm(), " ", openFormulaChooseForm()] }));
|
|
129
|
+
};
|
|
130
|
+
class MetatadaHelper {
|
|
131
|
+
constructor(mid, metadataName) {
|
|
132
|
+
this.Mid = mid;
|
|
133
|
+
this.MetadataName = metadataName;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
export class FormulaItemHelper {
|
|
137
|
+
constructor() {
|
|
138
|
+
this.id = 0;
|
|
139
|
+
this.paramName = '';
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
export default TMTextExpression;
|
|
@@ -160,6 +160,7 @@ export declare class SDKUI_Localizator {
|
|
|
160
160
|
static get MetadataFormats_ShortDateShortTime(): "Kurzes Datum/Uhrzeit" | "Short date/time" | "Fecha/hora breve" | "Date/heure brève" | "Data/hora curta" | "Data/ora breve";
|
|
161
161
|
static get MetadataFormats_ShortTime(): "Kurze Stunde" | "Short time" | "Hora breve" | "Heure brève" | "Hora curta" | "Ora breve";
|
|
162
162
|
static get MetadataFormats_UpperCase(): "Alle SHIFT" | "Upper case" | "Todo MAYÚSCULA" | "Tout MAJUSCULE" | "Todos os CAPS" | "Tutto MAIUSCOLO";
|
|
163
|
+
static get MetadataReferenceInsert(): "Metadaten-Referenz einfügen" | "Add metadata reference" | "Introducir referencia metadato" | "Entrez les métadonnée de référence" | "Insira metadados de referência" | "Inserisci riferimento metadato";
|
|
163
164
|
static get MetadataRoot(): "Methadatenstamm" | "Root metadata" | "Metadato raíz" | "Métadonnée racine" | "Metadados raiz" | "Metadato radice";
|
|
164
165
|
static get MetadataSelected(): "Ausgewählte Metadaten" | "Selected metadata" | "Metadatos seleccionados" | "Métadonnées sélectionnées" | "Metadados selecionados" | "Metadati selezionati";
|
|
165
166
|
static get Message(): "Nachricht" | "Message" | "Mensaje" | "Mensagem" | "Messaggio";
|
|
@@ -203,6 +204,7 @@ export declare class SDKUI_Localizator {
|
|
|
203
204
|
static get PasswordNumberError(): "Das Passwort muss Zahlen enthalten (0-9)" | "Password must include number (0-9)" | "La contraseña debe incluir números (0-9)" | "Le mot de passe doit inclure des chiffres (0-9)" | "A senha deve incluir números (0-9)" | "La password deve includere numeri (0-9)";
|
|
204
205
|
static get PasswordSymbolError(): "Das Passwort muss mindestens ein Sonderzeichen enthalten (!\"#$%&'()*+,-./:;<=>?@[]^_{|})" | "The password must contain at least one special character (!\"#$%&'()*+,-./:;<=>?@[]^_{|})" | "La contraseña debe contener al menos un carácter especial. (!\"#$%&'()*+,-./:;<=>?@[]^_{|})" | "Le mot de passe doit contenir au moins un caractère spécial (!\"#$%&'()*+,-./:;<=>?@[]^_{|})" | "A senha deve conter pelo menos um caractere especial (!\"#$%&'()*+,-./:;<=>?@[]^_{|})" | "La password deve contenere almeno un carattere speciale (!\"#$%&'()*+,-./:;<=>?@[]^_{|})";
|
|
205
206
|
static get PasswordUppercaseError(): "Das Passwort muss Großbuchstaben enthalten (A-Z)" | "Password must include uppercase character (A-Z)" | "La contraseña debe incluir caracteres en mayúscula (A-Z)" | "Le mot de passe doit inclure un caractère majuscule (A-Z)" | "A senha deve incluir caracteres maiúsculos (A-Z)" | "La password deve includere caratteri maiuscoli (A-Z)";
|
|
207
|
+
static get Parameters(): "Parameter" | "Parameters" | "Parámetros" | "Paramètres" | "Parâmetros" | "Parametri";
|
|
206
208
|
static get Perms(): "Berechtigungen" | "Permissions" | "Permisos" | "Autorisations" | "Permissão" | "Permessi";
|
|
207
209
|
static get PhysDelete(): "Physische Stornierung" | "Physical delete" | "Cancelación física" | "Supression" | "Cancelamento física" | "Cancellazione fisica";
|
|
208
210
|
static get Previous(): "Vorherige" | "Previous" | "Anterior" | "Précédent" | "Precedente";
|
|
@@ -1551,6 +1551,16 @@ export class SDKUI_Localizator {
|
|
|
1551
1551
|
default: return "Tutto MAIUSCOLO";
|
|
1552
1552
|
}
|
|
1553
1553
|
}
|
|
1554
|
+
static get MetadataReferenceInsert() {
|
|
1555
|
+
switch (this._cultureID) {
|
|
1556
|
+
case CultureIDs.De_DE: return "Metadaten-Referenz einfügen";
|
|
1557
|
+
case CultureIDs.En_US: return "Add metadata reference";
|
|
1558
|
+
case CultureIDs.Es_ES: return "Introducir referencia metadato";
|
|
1559
|
+
case CultureIDs.Fr_FR: return "Entrez les métadonnée de référence";
|
|
1560
|
+
case CultureIDs.Pt_PT: return "Insira metadados de referência";
|
|
1561
|
+
default: return "Inserisci riferimento metadato";
|
|
1562
|
+
}
|
|
1563
|
+
}
|
|
1554
1564
|
static get MetadataRoot() {
|
|
1555
1565
|
switch (this._cultureID) {
|
|
1556
1566
|
case CultureIDs.De_DE: return "Methadatenstamm";
|
|
@@ -1981,6 +1991,16 @@ export class SDKUI_Localizator {
|
|
|
1981
1991
|
default: return "La password deve includere caratteri maiuscoli (A-Z)";
|
|
1982
1992
|
}
|
|
1983
1993
|
}
|
|
1994
|
+
static get Parameters() {
|
|
1995
|
+
switch (this._cultureID) {
|
|
1996
|
+
case CultureIDs.De_DE: return "Parameter";
|
|
1997
|
+
case CultureIDs.En_US: return "Parameters";
|
|
1998
|
+
case CultureIDs.Es_ES: return "Parámetros";
|
|
1999
|
+
case CultureIDs.Fr_FR: return "Paramètres";
|
|
2000
|
+
case CultureIDs.Pt_PT: return "Parâmetros";
|
|
2001
|
+
default: return "Parametri";
|
|
2002
|
+
}
|
|
2003
|
+
}
|
|
1984
2004
|
static get Perms() {
|
|
1985
2005
|
switch (this._cultureID) {
|
|
1986
2006
|
case CultureIDs.De_DE: return "Berechtigungen";
|
package/lib/helper/helpers.d.ts
CHANGED
|
@@ -28,6 +28,7 @@ export declare function moduleVersion(module: moduleTypes): string;
|
|
|
28
28
|
export declare function buildtype(module: moduleTypes): string;
|
|
29
29
|
export declare function versionAndBuildtypeInfo(module: moduleTypes): string;
|
|
30
30
|
export declare const svgToString: (icon: React.ReactElement) => string;
|
|
31
|
+
export declare function stringIsNullOrEmpty(value: string | undefined): boolean;
|
|
31
32
|
export declare function sleep(ms: number): Promise<void>;
|
|
32
33
|
export declare const dialogConfirmOperation: (title: string, msg: string, operationAsync: () => Promise<void>) => void;
|
|
33
34
|
export declare function getExceptionMessage(ex: any): string;
|
package/lib/helper/helpers.js
CHANGED
|
@@ -298,6 +298,15 @@ export function versionAndBuildtypeInfo(module) {
|
|
|
298
298
|
export const svgToString = (icon) => {
|
|
299
299
|
return ReactDOMServer.renderToString(icon);
|
|
300
300
|
};
|
|
301
|
+
export function stringIsNullOrEmpty(value) {
|
|
302
|
+
if (value == undefined)
|
|
303
|
+
return true;
|
|
304
|
+
if (value == null)
|
|
305
|
+
return true;
|
|
306
|
+
if (value == "")
|
|
307
|
+
return true;
|
|
308
|
+
return false;
|
|
309
|
+
}
|
|
301
310
|
export async function sleep(ms) {
|
|
302
311
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
303
312
|
}
|