@deviceinsight/ng-ui-scale-lib 10.2.0 → 10.3.0
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/dist/{AccessEditModal-Rn7DKmYR.js → AccessEditModal-EVgqtRQn.js} +17 -17
- package/dist/{AccessEditModal-Rn7DKmYR.js.map → AccessEditModal-EVgqtRQn.js.map} +1 -1
- package/dist/{BundleManagementContainer-TrGIe0YX.js → BundleManagementContainer-48Mfx5AV.js} +4 -4
- package/dist/{BundleManagementContainer-TrGIe0YX.js.map → BundleManagementContainer-48Mfx5AV.js.map} +1 -1
- package/dist/{BundlesContainer-DBDS1cey.js → BundlesContainer-nZS9tMML.js} +40 -40
- package/dist/{BundlesContainer-DBDS1cey.js.map → BundlesContainer-nZS9tMML.js.map} +1 -1
- package/dist/{DatapointImport-DmBB5IO_.js → DatapointImport-DGgPh1uk.js} +10 -10
- package/dist/DatapointImport-DGgPh1uk.js.map +1 -0
- package/dist/{FileUploadInput-DWMYm62d.js → FileUploadInput-COocUgkB.js} +2 -2
- package/dist/{FileUploadInput-DWMYm62d.js.map → FileUploadInput-COocUgkB.js.map} +1 -1
- package/dist/{Files-DZoDxerS.js → Files-DfQGLE39.js} +3 -3
- package/dist/{Files-DZoDxerS.js.map → Files-DfQGLE39.js.map} +1 -1
- package/dist/{GlobalPowerBiReports-B0FFOZL6.js → GlobalPowerBiReports-B1nYGKvp.js} +2 -2
- package/dist/{GlobalPowerBiReports-B0FFOZL6.js.map → GlobalPowerBiReports-B1nYGKvp.js.map} +1 -1
- package/dist/{JsonSettingWidget-DdS4dPsa.js → JsonSettingWidget-CGANHs8P.js} +9 -9
- package/dist/JsonSettingWidget-CGANHs8P.js.map +1 -0
- package/dist/{LicensesEditPage-DPJ4lLaV.js → LicensesEditPage-D1I6dogi.js} +11 -11
- package/dist/{LicensesEditPage-DPJ4lLaV.js.map → LicensesEditPage-D1I6dogi.js.map} +1 -1
- package/dist/{LicensesList-CkgWMSnM.js → LicensesList-CYyuylk_.js} +2 -2
- package/dist/{LicensesList-CkgWMSnM.js.map → LicensesList-CYyuylk_.js.map} +1 -1
- package/dist/{PropertiesEditPage--t5jnFmT.js → PropertiesEditPage-BOlFs_u9.js} +29 -29
- package/dist/{PropertiesEditPage--t5jnFmT.js.map → PropertiesEditPage-BOlFs_u9.js.map} +1 -1
- package/dist/{PropertiesList-BwbcDHUj.js → PropertiesList-DCPkWqaf.js} +5 -5
- package/dist/{PropertiesList-BwbcDHUj.js.map → PropertiesList-DCPkWqaf.js.map} +1 -1
- package/dist/{TemplateEditPage-IqiYJ6eB.js → TemplateEditPage-BeV5ZSVV.js} +25 -25
- package/dist/{TemplateEditPage-IqiYJ6eB.js.map → TemplateEditPage-BeV5ZSVV.js.map} +1 -1
- package/dist/{TemplateTextInput-bjR36XPj.js → TemplateTextInput-EDyDopjf.js} +2 -2
- package/dist/{TemplateTextInput-bjR36XPj.js.map → TemplateTextInput-EDyDopjf.js.map} +1 -1
- package/dist/{TemplatesListPage-Cv2vJe8b.js → TemplatesListPage-BVAiLKAE.js} +13 -13
- package/dist/{TemplatesListPage-Cv2vJe8b.js.map → TemplatesListPage-BVAiLKAE.js.map} +1 -1
- package/dist/{UserGroupAssignments-wEhudUHe.js → UserGroupAssignments-C7c3INUy.js} +10 -10
- package/dist/{UserGroupAssignments-wEhudUHe.js.map → UserGroupAssignments-C7c3INUy.js.map} +1 -1
- package/dist/{UserGroupTheme-C16SwuPr.js → UserGroupTheme-CFaudF3q.js} +5 -5
- package/dist/{UserGroupTheme-C16SwuPr.js.map → UserGroupTheme-CFaudF3q.js.map} +1 -1
- package/dist/api.js +23 -23
- package/dist/index.js +1144 -1122
- package/dist/index.js.map +1 -1
- package/dist/{setTitle-OKcazNTt.js → setTitle-Cyf8DxtL.js} +4976 -4964
- package/dist/setTitle-Cyf8DxtL.js.map +1 -0
- package/package.json +23 -21
- package/dist/DatapointImport-DmBB5IO_.js.map +0 -1
- package/dist/JsonSettingWidget-DdS4dPsa.js.map +0 -1
- package/dist/api.d.ts +0 -1195
- package/dist/index.d.ts +0 -7
- package/dist/setTitle-OKcazNTt.js.map +0 -1
- package/dist/setupRuntimeEnv.js +0 -27
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { jsx as e, jsxs as h, Fragment as V } from "react/jsx-runtime";
|
|
2
2
|
import { useState as E, useCallback as B, useEffect as G } from "react";
|
|
3
3
|
import { Prompt as U, useLocation as D, useHistory as M, useParams as R } from "react-router-dom";
|
|
4
|
-
import { getPropertyById as
|
|
5
|
-
import { Button as w, Checkbox as A, Icon as O, ButtonRow as
|
|
6
|
-
import { messageBoxError as K, ContentHeader as
|
|
4
|
+
import { getPropertyById as H, updateProperty as X, createProperty as Y } from "@deviceinsight/ng-ui-api-client";
|
|
5
|
+
import { Button as w, Checkbox as A, Icon as O, ButtonRow as _, Spinner as j } from "@deviceinsight/ng-ui-basic-components";
|
|
6
|
+
import { messageBoxError as K, ContentHeader as Q } from "@deviceinsight/ng-ui-components";
|
|
7
7
|
import "react-i18next";
|
|
8
|
-
import {
|
|
8
|
+
import { Y as N, bT as W, a as d, u as Z, Q as I, bU as $, bV as C, bW as q, bX as z, bY as J, b9 as ee, t as re, bZ as le } from "./setTitle-Cyf8DxtL.js";
|
|
9
9
|
import te from "axios";
|
|
10
10
|
import { useFormContext as ae, useController as ne, useForm as ie, FormProvider as se, Controller as f } from "react-hook-form";
|
|
11
11
|
import oe from "classnames";
|
|
@@ -22,7 +22,7 @@ function de(r) {
|
|
|
22
22
|
active: i.includes(l.value)
|
|
23
23
|
}),
|
|
24
24
|
disabled: r.disabled,
|
|
25
|
-
children: /* @__PURE__ */ e(
|
|
25
|
+
children: /* @__PURE__ */ e(W, { translationDescriptor: l.label })
|
|
26
26
|
},
|
|
27
27
|
String(l.value)
|
|
28
28
|
)) }) });
|
|
@@ -44,13 +44,13 @@ function ue() {
|
|
|
44
44
|
function v(n) {
|
|
45
45
|
l(c?.filter((p, m) => m !== n));
|
|
46
46
|
}
|
|
47
|
-
function
|
|
47
|
+
function T(n) {
|
|
48
48
|
l(c ? [...c, n] : [n]);
|
|
49
49
|
}
|
|
50
50
|
function g(n, p) {
|
|
51
51
|
l(c?.map((m, b) => p === b ? n : m));
|
|
52
52
|
}
|
|
53
|
-
async function
|
|
53
|
+
async function S(n) {
|
|
54
54
|
l(n ? [] : null), s(n), !n && y && await u();
|
|
55
55
|
}
|
|
56
56
|
return /* @__PURE__ */ h(V, { children: [
|
|
@@ -58,14 +58,14 @@ function ue() {
|
|
|
58
58
|
N,
|
|
59
59
|
{
|
|
60
60
|
label: /* @__PURE__ */ h("div", { className: "di allowed-values-header", children: [
|
|
61
|
-
/* @__PURE__ */ e(A, { type: "toggle", value: i, toggleSmall: !0, onChange:
|
|
61
|
+
/* @__PURE__ */ e(A, { type: "toggle", value: i, toggleSmall: !0, onChange: S }),
|
|
62
62
|
" ",
|
|
63
63
|
/* @__PURE__ */ e(d, { i18nKey: "properties.labels.allowedValues", children: "Allowed Values" })
|
|
64
64
|
] }),
|
|
65
65
|
error: a.allowedValues ? "Required" : void 0,
|
|
66
66
|
className: "di allowed-values-container",
|
|
67
67
|
children: [
|
|
68
|
-
/* @__PURE__ */ e(A, { value: i, onChange:
|
|
68
|
+
/* @__PURE__ */ e(A, { value: i, onChange: S }),
|
|
69
69
|
c?.length === 0 ? /* @__PURE__ */ e("div", { className: "empty-placeholder", children: /* @__PURE__ */ e(d, { i18nKey: "properties.labels.allowedValuesEmptyPlaceholder", children: "No values" }) }) : /* @__PURE__ */ e("ul", { children: c?.map((n, p) => /* @__PURE__ */ h("li", { className: "item", children: [
|
|
70
70
|
/* @__PURE__ */ e(N, { className: "value-container", children: /* @__PURE__ */ e(
|
|
71
71
|
"input",
|
|
@@ -80,7 +80,7 @@ function ue() {
|
|
|
80
80
|
]
|
|
81
81
|
}
|
|
82
82
|
),
|
|
83
|
-
i && /* @__PURE__ */ h(w, { onClick: () =>
|
|
83
|
+
i && /* @__PURE__ */ h(w, { onClick: () => T(""), children: [
|
|
84
84
|
/* @__PURE__ */ e(O, { add: !0 }),
|
|
85
85
|
/* @__PURE__ */ e(d, { i18nKey: "properties.labels.allowedValuesAdd", children: "Add" })
|
|
86
86
|
] })
|
|
@@ -105,14 +105,14 @@ function me() {
|
|
|
105
105
|
};
|
|
106
106
|
}
|
|
107
107
|
function he({ editedProperty: r, isReadonly: a, onSubmit: u, onCancel: i }) {
|
|
108
|
-
const { t: s } =
|
|
108
|
+
const { t: s } = Z(), c = ie({
|
|
109
109
|
defaultValues: r || me()
|
|
110
110
|
}), {
|
|
111
111
|
control: l,
|
|
112
112
|
handleSubmit: y,
|
|
113
113
|
watch: v,
|
|
114
|
-
setError:
|
|
115
|
-
formState: { isSubmitting: g, isDirty:
|
|
114
|
+
setError: T,
|
|
115
|
+
formState: { isSubmitting: g, isDirty: S }
|
|
116
116
|
} = c;
|
|
117
117
|
function n() {
|
|
118
118
|
async function t(o) {
|
|
@@ -120,10 +120,10 @@ function he({ editedProperty: r, isReadonly: a, onSubmit: u, onCancel: i }) {
|
|
|
120
120
|
await u(o);
|
|
121
121
|
} catch (P) {
|
|
122
122
|
if (te.isAxiosError(P)) {
|
|
123
|
-
const { fieldName: x, message: k } =
|
|
124
|
-
x ?
|
|
123
|
+
const { fieldName: x, message: k } = z(P, s);
|
|
124
|
+
x ? T(x, { message: k }) : K(k);
|
|
125
125
|
} else
|
|
126
|
-
K(
|
|
126
|
+
K(J(s));
|
|
127
127
|
}
|
|
128
128
|
}
|
|
129
129
|
return y(t, (o) => {
|
|
@@ -160,7 +160,7 @@ function he({ editedProperty: r, isReadonly: a, onSubmit: u, onCancel: i }) {
|
|
|
160
160
|
name: "type",
|
|
161
161
|
control: l,
|
|
162
162
|
render: ({ field: t }) => /* @__PURE__ */ e(
|
|
163
|
-
|
|
163
|
+
$,
|
|
164
164
|
{
|
|
165
165
|
label: /* @__PURE__ */ e(d, { i18nKey: "properties.labels.type", children: "Type" }),
|
|
166
166
|
options: ce,
|
|
@@ -299,11 +299,11 @@ function he({ editedProperty: r, isReadonly: a, onSubmit: u, onCancel: i }) {
|
|
|
299
299
|
"* ",
|
|
300
300
|
/* @__PURE__ */ e(d, { i18nKey: "form.field.required", children: "required" })
|
|
301
301
|
] }),
|
|
302
|
-
/* @__PURE__ */ h(
|
|
302
|
+
/* @__PURE__ */ h(_, { dividing: !0, children: [
|
|
303
303
|
/* @__PURE__ */ e(w, { className: "with-spinner", primary: !0, onClick: n, disabled: g, children: /* @__PURE__ */ e(d, { i18nKey: "general.actions.save", children: "Save" }) }),
|
|
304
304
|
/* @__PURE__ */ e(w, { disabled: g, onClick: i, children: /* @__PURE__ */ e(d, { i18nKey: "general.actions.cancel", children: "Cancel" }) })
|
|
305
305
|
] }),
|
|
306
|
-
/* @__PURE__ */ e(U, { message: "", when:
|
|
306
|
+
/* @__PURE__ */ e(U, { message: "", when: S && !g })
|
|
307
307
|
] }) });
|
|
308
308
|
}
|
|
309
309
|
const fe = (r) => r ? {
|
|
@@ -329,9 +329,9 @@ function L(r) {
|
|
|
329
329
|
return r;
|
|
330
330
|
}
|
|
331
331
|
function xe() {
|
|
332
|
-
const { pathname: r } = D(), a = M(), { propertyKey: u } = R(), [i, s] = E(void 0), [c, l] = E(!0), [y, v] = E(!1),
|
|
332
|
+
const { pathname: r } = D(), a = M(), { propertyKey: u } = R(), [i, s] = E(void 0), [c, l] = E(!0), [y, v] = E(!1), T = B(async (m) => {
|
|
333
333
|
try {
|
|
334
|
-
const b = await
|
|
334
|
+
const b = await H(m);
|
|
335
335
|
s(b);
|
|
336
336
|
} catch (b) {
|
|
337
337
|
console.error(b), v(!0);
|
|
@@ -340,13 +340,13 @@ function xe() {
|
|
|
340
340
|
}
|
|
341
341
|
}, []);
|
|
342
342
|
G(() => {
|
|
343
|
-
u && u !== "create" ?
|
|
344
|
-
}, [u,
|
|
343
|
+
u && u !== "create" ? T(u) : l(!1);
|
|
344
|
+
}, [u, T]);
|
|
345
345
|
function g() {
|
|
346
346
|
a.push(r.substring(0, r.lastIndexOf("/")));
|
|
347
347
|
}
|
|
348
|
-
async function
|
|
349
|
-
i ? await
|
|
348
|
+
async function S(m) {
|
|
349
|
+
i ? await X(L(m)) : await Y(L(m)), le(ge), g();
|
|
350
350
|
}
|
|
351
351
|
function n() {
|
|
352
352
|
g();
|
|
@@ -354,14 +354,14 @@ function xe() {
|
|
|
354
354
|
if (y)
|
|
355
355
|
return /* @__PURE__ */ e(ee, {});
|
|
356
356
|
const p = fe(!i);
|
|
357
|
-
return c ? /* @__PURE__ */ e(
|
|
358
|
-
/* @__PURE__ */ e(
|
|
357
|
+
return c ? /* @__PURE__ */ e(j, { center: !0 }) : /* @__PURE__ */ h(V, { children: [
|
|
358
|
+
/* @__PURE__ */ e(Q, { title: p, parentPageLink: !0 }),
|
|
359
359
|
/* @__PURE__ */ e(
|
|
360
360
|
he,
|
|
361
361
|
{
|
|
362
362
|
editedProperty: i,
|
|
363
363
|
isReadonly: !!i && !re(["UPDATE_PROPERTY"]),
|
|
364
|
-
onSubmit:
|
|
364
|
+
onSubmit: S,
|
|
365
365
|
onCancel: n
|
|
366
366
|
}
|
|
367
367
|
)
|
|
@@ -370,4 +370,4 @@ function xe() {
|
|
|
370
370
|
export {
|
|
371
371
|
xe as default
|
|
372
372
|
};
|
|
373
|
-
//# sourceMappingURL=PropertiesEditPage
|
|
373
|
+
//# sourceMappingURL=PropertiesEditPage-BOlFs_u9.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PropertiesEditPage--t5jnFmT.js","sources":["../ng-ui-scale/src/components/inputs/buttonPicker/ButtonPicker.tsx","../ng-ui-scale/src/modules/properties/AllowedValues.tsx","../ng-ui-scale/src/modules/properties/PropertyForm.tsx","../ng-ui-scale/src/modules/properties/PropertiesEditPage.tsx"],"sourcesContent":["import cx from 'classnames';\n\nimport {Button} from '@deviceinsight/ng-ui-basic-components';\n\nimport type {TranslationDescriptor} from 'i18n';\nimport TransByDescriptor from 'i18n/TransByDescriptor';\nimport FieldDecorator, {type FieldDecoratorProps} from '../FieldDecorator';\n\nimport '../input.scss';\n\nexport type ButtonPickerOption<T> = {\n\tvalue: T;\n\tlabel: string | TranslationDescriptor;\n};\n\ntype OwnProps<T> = {\n\tonChange: (values: T[]) => void;\n\toptions: ButtonPickerOption<T>[];\n\tvalues: T[];\n\tdisabled?: boolean;\n};\n\ntype Props<T> = FieldDecoratorProps & OwnProps<T>;\n\nexport default function ButtonPicker<T>(props: Props<T>) {\n\tconst {options, onChange, values, ...rest} = props;\n\n\tfunction toggleOption(option: ButtonPickerOption<T>) {\n\t\tif (values.includes(option.value)) {\n\t\t\tonChange(values.filter(v => v !== option.value));\n\t\t} else {\n\t\t\tonChange([...values, option.value]);\n\t\t}\n\t}\n\n\treturn (\n\t\t<FieldDecorator {...rest}>\n\t\t\t<div className=\"buttonpicker\">\n\t\t\t\t{options.map(option => (\n\t\t\t\t\t<Button\n\t\t\t\t\t\tkey={String(option.value)}\n\t\t\t\t\t\tonClick={() => toggleOption(option)}\n\t\t\t\t\t\tclassName={cx({\n\t\t\t\t\t\t\tactive: values.includes(option.value),\n\t\t\t\t\t\t})}\n\t\t\t\t\t\tdisabled={props.disabled}\n\t\t\t\t\t>\n\t\t\t\t\t\t<TransByDescriptor translationDescriptor={option.label} />\n\t\t\t\t\t</Button>\n\t\t\t\t))}\n\t\t\t</div>\n\t\t</FieldDecorator>\n\t);\n}\n","import {useState} from 'react';\nimport {useController, useFormContext} from 'react-hook-form';\n\nimport type {Property} from '@deviceinsight/ng-ui-api-client';\nimport {Button, Checkbox, Icon} from '@deviceinsight/ng-ui-basic-components';\n\nimport FieldDecorator from 'components/inputs/FieldDecorator';\nimport {Trans} from 'i18n';\n\nexport default function AllowedValues() {\n\tconst {\n\t\tgetValues,\n\t\tformState: {errors},\n\t\ttrigger,\n\t} = useFormContext<Property>();\n\tconst [enabled, setEnabled] = useState<boolean>(!!getValues('allowedValues'));\n\tconst {\n\t\tfield: {value: allowedValues, onChange},\n\t\tfieldState: {invalid: allowedValuesInvalid},\n\t} = useController<Property, 'allowedValues'>({\n\t\tname: 'allowedValues',\n\t\trules: {\n\t\t\tvalidate: allowedValues =>\n\t\t\t\tallowedValues == null || allowedValues?.some(v => v !== '') ? undefined : 'Required',\n\t\t},\n\t});\n\n\tfunction remove(index: number) {\n\t\tonChange(allowedValues?.filter((v, i) => i !== index));\n\t}\n\n\tfunction append(value: string) {\n\t\tonChange(allowedValues ? [...allowedValues, value] : [value]);\n\t}\n\n\tfunction change(value: string, index: number) {\n\t\tonChange(allowedValues?.map((allowedValue, i) => (index === i ? value : allowedValue)));\n\t}\n\n\tasync function handleEnabledChange(enabled: boolean) {\n\t\tonChange(enabled ? [] : null);\n\t\tsetEnabled(enabled);\n\n\t\tif (!enabled && allowedValuesInvalid) {\n\t\t\tawait trigger();\n\t\t}\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<FieldDecorator\n\t\t\t\tlabel={\n\t\t\t\t\t<div className=\"di allowed-values-header\">\n\t\t\t\t\t\t<Checkbox type=\"toggle\" value={enabled} toggleSmall onChange={handleEnabledChange} />{' '}\n\t\t\t\t\t\t<Trans i18nKey=\"properties.labels.allowedValues\">Allowed Values</Trans>\n\t\t\t\t\t</div>\n\t\t\t\t}\n\t\t\t\terror={errors.allowedValues ? 'Required' : undefined}\n\t\t\t\tclassName=\"di allowed-values-container\"\n\t\t\t>\n\t\t\t\t<Checkbox value={enabled} onChange={handleEnabledChange} />\n\t\t\t\t{allowedValues?.length === 0 ? (\n\t\t\t\t\t<div className=\"empty-placeholder\">\n\t\t\t\t\t\t<Trans i18nKey=\"properties.labels.allowedValuesEmptyPlaceholder\">No values</Trans>\n\t\t\t\t\t</div>\n\t\t\t\t) : (\n\t\t\t\t\t<ul>\n\t\t\t\t\t\t{allowedValues?.map((allowedValue, index) => (\n\t\t\t\t\t\t\t<li key={index} className=\"item\">\n\t\t\t\t\t\t\t\t<FieldDecorator className=\"value-container\">\n\t\t\t\t\t\t\t\t\t<input\n\t\t\t\t\t\t\t\t\t\ttype=\"text\"\n\t\t\t\t\t\t\t\t\t\tvalue={allowedValue}\n\t\t\t\t\t\t\t\t\t\tonChange={e => change(e.target.value, index)}\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t</FieldDecorator>\n\t\t\t\t\t\t\t\t<Button onClick={() => remove(index)}>\n\t\t\t\t\t\t\t\t\t<Icon del />\n\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t</li>\n\t\t\t\t\t\t))}\n\t\t\t\t\t</ul>\n\t\t\t\t)}\n\t\t\t</FieldDecorator>\n\t\t\t{enabled && (\n\t\t\t\t<Button onClick={() => append('')}>\n\t\t\t\t\t<Icon add />\n\t\t\t\t\t<Trans i18nKey=\"properties.labels.allowedValuesAdd\">Add</Trans>\n\t\t\t\t</Button>\n\t\t\t)}\n\t\t</>\n\t);\n}\n","import axios from 'axios';\nimport {Controller, FormProvider, useForm} from 'react-hook-form';\nimport {Prompt} from 'react-router-dom';\n\nimport type {EntityTarget, Property} from '@deviceinsight/ng-ui-api-client';\nimport {Button, ButtonRow} from '@deviceinsight/ng-ui-basic-components';\nimport {messageBoxError} from '@deviceinsight/ng-ui-components';\n\nimport ButtonPicker from 'components/inputs/buttonPicker/ButtonPicker';\nimport Checkbox from 'components/inputs/checkbox/Checkbox';\nimport NumberInput from 'components/inputs/numberInput/NumberInput';\nimport SelectInput from 'components/inputs/selectInput/SelectInput';\nimport TextInput from 'components/inputs/textInput/TextInput';\nimport {Trans, useTranslation} from 'i18n';\nimport AllowedValues from './AllowedValues';\nimport {getUnknownBackendErrorMessage, parseBackendError} from './utils';\n\nimport './propertiesEditPage.scss';\n\nconst typeOptions = ['STRING', 'TEXT', 'DATE', 'LONG', 'DOUBLE', 'BOOLEAN', 'IP', 'GEO'].map(pType => {\n\treturn {\n\t\tvalue: pType,\n\t\tname: pType,\n\t};\n});\n\nconst entityTargetOptions = (['ASSET', 'ASSET_GROUP', 'ACCOUNT', 'ACCOUNT_GROUP', 'DATAPOINT'] as EntityTarget[]).map(\n\tpType => ({\n\t\tvalue: pType,\n\t\tlabel: pType,\n\t}),\n);\n\ntype Props = {\n\teditedProperty: Property | undefined;\n\tisReadonly: boolean;\n\tonSubmit: (property: Property) => Promise<void>;\n\tonCancel: () => void;\n};\n\nfunction createEmptyFormData(): Property {\n\treturn {\n\t\tkey: '',\n\t\ttype: 'STRING',\n\t\tentityTargets: [],\n\t\taddToAll: false,\n\t\tdeletable: true,\n\t};\n}\n\nfunction PropertyForm({editedProperty, isReadonly, onSubmit, onCancel}: Props) {\n\tconst {t} = useTranslation();\n\tconst formContext = useForm<Property>({\n\t\tdefaultValues: editedProperty ? editedProperty : createEmptyFormData(),\n\t});\n\tconst {\n\t\tcontrol,\n\t\thandleSubmit,\n\t\twatch,\n\t\tsetError,\n\t\tformState: {isSubmitting, isDirty},\n\t} = formContext;\n\n\tfunction submit(): Promise<void> {\n\t\tasync function submitFunction(property: Property) {\n\t\t\ttry {\n\t\t\t\tawait onSubmit(property);\n\t\t\t} catch (error: unknown) {\n\t\t\t\tif (axios.isAxiosError(error)) {\n\t\t\t\t\tconst {fieldName, message} = parseBackendError(error, t);\n\t\t\t\t\tif (fieldName) {\n\t\t\t\t\t\tsetError(fieldName as any, {message});\n\t\t\t\t\t} else {\n\t\t\t\t\t\tmessageBoxError(message);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tmessageBoxError(getUnknownBackendErrorMessage(t));\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn handleSubmit(submitFunction, errors => {\n\t\t\tconsole.warn('Validation error', errors);\n\t\t})();\n\t}\n\n\tconst type = watch('type');\n\n\tconst isEditMode = !!editedProperty;\n\tconst isStringOrText = type === 'STRING' || type === 'TEXT';\n\tconst areAllowedValuesEnabled = !!watch('allowedValues');\n\n\treturn (\n\t\t<FormProvider {...formContext}>\n\t\t\t<div className=\"property-form\">\n\t\t\t\t<Controller\n\t\t\t\t\tname=\"key\"\n\t\t\t\t\tcontrol={control}\n\t\t\t\t\trules={{\n\t\t\t\t\t\trequired: t('properties.form.validation.key.required', {\n\t\t\t\t\t\t\tdefaultValue: 'Please enter a property key',\n\t\t\t\t\t\t}),\n\t\t\t\t\t}}\n\t\t\t\t\trender={({field, fieldState: {error}}) => (\n\t\t\t\t\t\t<TextInput\n\t\t\t\t\t\t\t{...field}\n\t\t\t\t\t\t\tlabel={<Trans i18nKey=\"properties.labels.key\">Key</Trans>}\n\t\t\t\t\t\t\terror={error?.message}\n\t\t\t\t\t\t\trequired\n\t\t\t\t\t\t\tdisabled={isReadonly || isEditMode}\n\t\t\t\t\t\t/>\n\t\t\t\t\t)}\n\t\t\t\t/>\n\t\t\t\t<Controller\n\t\t\t\t\tname=\"type\"\n\t\t\t\t\tcontrol={control}\n\t\t\t\t\trender={({field}) => (\n\t\t\t\t\t\t<SelectInput\n\t\t\t\t\t\t\tlabel={<Trans i18nKey=\"properties.labels.type\">Type</Trans>}\n\t\t\t\t\t\t\toptions={typeOptions}\n\t\t\t\t\t\t\trequired\n\t\t\t\t\t\t\tdisabled={isReadonly || isEditMode}\n\t\t\t\t\t\t\tvalue={field.value}\n\t\t\t\t\t\t\tonChange={field.onChange}\n\t\t\t\t\t\t/>\n\t\t\t\t\t)}\n\t\t\t\t/>\n\t\t\t\t<Controller\n\t\t\t\t\tname=\"entityTargets\"\n\t\t\t\t\tcontrol={control}\n\t\t\t\t\trules={{validate: entityTargets => (entityTargets.length === 0 ? 'Required' : undefined)}}\n\t\t\t\t\trender={({field: {value, onChange}, fieldState: {error}}) => (\n\t\t\t\t\t\t<ButtonPicker\n\t\t\t\t\t\t\tlabel={<Trans i18nKey=\"properties.labels.entityTargets\">Entity targets</Trans>}\n\t\t\t\t\t\t\tvalues={value}\n\t\t\t\t\t\t\tonChange={onChange}\n\t\t\t\t\t\t\toptions={entityTargetOptions}\n\t\t\t\t\t\t\terror={\n\t\t\t\t\t\t\t\terror\n\t\t\t\t\t\t\t\t\t? t('properties.form.validation.entityTargets.required', {\n\t\t\t\t\t\t\t\t\t\t\tdefaultValue: 'Please select a at least one entity target',\n\t\t\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\trequired\n\t\t\t\t\t\t\tdisabled={isReadonly}\n\t\t\t\t\t\t/>\n\t\t\t\t\t)}\n\t\t\t\t/>\n\t\t\t\t<Controller\n\t\t\t\t\tname=\"addToAll\"\n\t\t\t\t\tcontrol={control}\n\t\t\t\t\trender={({field}) => (\n\t\t\t\t\t\t<Checkbox\n\t\t\t\t\t\t\t{...field}\n\t\t\t\t\t\t\tlabel={<Trans i18nKey=\"properties.labels.addToSearch\">Add to Search</Trans>}\n\t\t\t\t\t\t\tdisabled={isReadonly || isEditMode}\n\t\t\t\t\t\t/>\n\t\t\t\t\t)}\n\t\t\t\t/>\n\t\t\t\t<Controller\n\t\t\t\t\tname=\"unique\"\n\t\t\t\t\tcontrol={control}\n\t\t\t\t\trender={({field: {value, onChange}}) => (\n\t\t\t\t\t\t<Checkbox\n\t\t\t\t\t\t\tvalue={!!value}\n\t\t\t\t\t\t\tonChange={onChange}\n\t\t\t\t\t\t\tlabel={<Trans i18nKey=\"properties.labels.unique\">Unique</Trans>}\n\t\t\t\t\t\t\tdisabled={isReadonly}\n\t\t\t\t\t\t/>\n\t\t\t\t\t)}\n\t\t\t\t/>\n\t\t\t\t<Controller\n\t\t\t\t\tname=\"final\"\n\t\t\t\t\tcontrol={control}\n\t\t\t\t\trender={({field: {value, onChange}}) => (\n\t\t\t\t\t\t<Checkbox\n\t\t\t\t\t\t\tvalue={!!value}\n\t\t\t\t\t\t\tonChange={onChange}\n\t\t\t\t\t\t\tlabel={<Trans i18nKey=\"properties.labels.final\">Final</Trans>}\n\t\t\t\t\t\t\tdisabled={isReadonly}\n\t\t\t\t\t\t/>\n\t\t\t\t\t)}\n\t\t\t\t/>\n\t\t\t\t{isStringOrText && !areAllowedValuesEnabled && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<Controller\n\t\t\t\t\t\t\tname=\"minLength\"\n\t\t\t\t\t\t\tcontrol={control}\n\t\t\t\t\t\t\trender={({field: {value, ...rest}}) => (\n\t\t\t\t\t\t\t\t<NumberInput\n\t\t\t\t\t\t\t\t\t{...rest}\n\t\t\t\t\t\t\t\t\tvalue={value ?? undefined}\n\t\t\t\t\t\t\t\t\tlabel={<Trans i18nKey=\"properties.label.minLength\">Minimum length</Trans>}\n\t\t\t\t\t\t\t\t\tplaceholder={\n\t\t\t\t\t\t\t\t\t\tisReadonly ? t('properties.placeholder.notSet', {defaultValue: 'Not set'}) : '0'\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\treadOnly={isReadonly}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<Controller\n\t\t\t\t\t\t\tname=\"maxLength\"\n\t\t\t\t\t\t\tcontrol={control}\n\t\t\t\t\t\t\trender={({field: {value, ...rest}}) => (\n\t\t\t\t\t\t\t\t<NumberInput\n\t\t\t\t\t\t\t\t\t{...rest}\n\t\t\t\t\t\t\t\t\tvalue={value ?? undefined}\n\t\t\t\t\t\t\t\t\tlabel={<Trans i18nKey=\"properties.label.maxLength\">Maximum length</Trans>}\n\t\t\t\t\t\t\t\t\tplaceholder={\n\t\t\t\t\t\t\t\t\t\tisReadonly ? t('properties.placeholder.notSet', {defaultValue: 'Not set'}) : '0'\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\treadOnly={isReadonly}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<Controller\n\t\t\t\t\t\t\tname=\"regularExpression\"\n\t\t\t\t\t\t\tcontrol={control}\n\t\t\t\t\t\t\trender={({field: {value, ...rest}}) => (\n\t\t\t\t\t\t\t\t<TextInput\n\t\t\t\t\t\t\t\t\t{...rest}\n\t\t\t\t\t\t\t\t\tvalue={value ?? undefined}\n\t\t\t\t\t\t\t\t\tlabel={\n\t\t\t\t\t\t\t\t\t\t<Trans i18nKey=\"properties.labels.regularExpression\">Regular expression</Trans>\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\treadOnly={isReadonly}\n\t\t\t\t\t\t\t\t\tplaceholder={\n\t\t\t\t\t\t\t\t\t\tisReadonly ? t('properties.placeholder.notSet', {defaultValue: 'Not set'}) : ''\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t/>\n\t\t\t\t\t</>\n\t\t\t\t)}\n\t\t\t\t{type === 'STRING' && <AllowedValues />}\n\n\t\t\t\t<div className=\"formRequired\">\n\t\t\t\t\t* <Trans i18nKey=\"form.field.required\">required</Trans>\n\t\t\t\t</div>\n\t\t\t\t<ButtonRow dividing>\n\t\t\t\t\t<Button className=\"with-spinner\" primary onClick={submit} disabled={isSubmitting}>\n\t\t\t\t\t\t{<Trans i18nKey=\"general.actions.save\">Save</Trans>}\n\t\t\t\t\t</Button>\n\t\t\t\t\t<Button disabled={isSubmitting} onClick={onCancel}>\n\t\t\t\t\t\t<Trans i18nKey=\"general.actions.cancel\">Cancel</Trans>\n\t\t\t\t\t</Button>\n\t\t\t\t</ButtonRow>\n\t\t\t\t<Prompt message=\"\" when={isDirty && !isSubmitting} />\n\t\t\t</div>\n\t\t</FormProvider>\n\t);\n}\n\nexport default PropertyForm;\n","import {useCallback, useEffect, useState} from 'react';\nimport {useHistory, useLocation, useParams} from 'react-router-dom';\n\nimport {\n\tcreateProperty as createPropertyApi,\n\tgetPropertyById,\n\ttype Property,\n\tupdateProperty as updatePropertyApi,\n} from '@deviceinsight/ng-ui-api-client';\nimport {Spinner} from '@deviceinsight/ng-ui-basic-components';\nimport {ContentHeader} from '@deviceinsight/ng-ui-components';\n\nimport {Trans} from 'i18n';\nimport PageNotFound from '../../components/page/misc/PageNotFound';\nimport {hasAuthorities} from '../../utils/hasAuthorities';\nimport PropertyForm from './PropertyForm';\nimport {displaySuccessMessage} from './utils';\n\nconst getContentHeaderTitle = (createMode: boolean) => {\n\treturn createMode\n\t\t? {\n\t\t\t\tid: 'properties.create.title',\n\t\t\t\tdefaultValue: 'Create Property',\n\t\t\t}\n\t\t: {\n\t\t\t\tid: 'properties.edit.title',\n\t\t\t\tdefaultValue: 'Edit Property',\n\t\t\t};\n};\n\nconst messageSuccessSaveProperty = (\n\t<Trans i18nKey=\"properties.saveSuccessMessage\">Property has been saved successfully.</Trans>\n);\n\nfunction clearPropertyFields(property: Property): Property {\n\tif (property.type === 'STRING' && property.allowedValues && property.allowedValues.length > 0) {\n\t\t// biome-ignore lint/correctness/noUnusedVariables: It's ok\n\t\tconst {regularExpression, maxLength, minLength, allowedValues, ...newProperty} = property;\n\t\treturn {...newProperty, allowedValues: [...new Set(allowedValues.filter(value => value !== ''))]};\n\t}\n\n\t// The backend does not accept an empty array for allowedValues\n\tif (property.allowedValues && property.allowedValues.length === 0) {\n\t\t// biome-ignore lint/correctness/noUnusedVariables: It's ok\n\t\tconst {allowedValues, ...newProperty} = property;\n\t\treturn newProperty;\n\t}\n\tif (property.type !== 'STRING' && property.type !== 'TEXT') {\n\t\t// biome-ignore lint/correctness/noUnusedVariables: It's ok\n\t\tconst {regularExpression, maxLength, minLength, ...newProperty} = property;\n\t\treturn newProperty;\n\t}\n\n\treturn property;\n}\n\nexport default function PropertiesEditPage() {\n\tconst {pathname} = useLocation();\n\tconst history = useHistory();\n\tconst {propertyKey} = useParams<{propertyKey: string}>();\n\tconst [property, setProperty] = useState<Property | undefined>(undefined);\n\tconst [isLoading, setIsLoading] = useState<boolean>(true);\n\tconst [notFound, setNotFound] = useState<boolean>(false);\n\n\tconst loadProperty = useCallback(async (propertyKey: string) => {\n\t\ttry {\n\t\t\tconst property = await getPropertyById(propertyKey);\n\t\t\tsetProperty(property);\n\t\t} catch (e) {\n\t\t\tconsole.error(e);\n\t\t\tsetNotFound(true);\n\t\t} finally {\n\t\t\tsetIsLoading(false);\n\t\t}\n\t}, []);\n\n\tuseEffect(() => {\n\t\tif (propertyKey && propertyKey !== 'create') {\n\t\t\tloadProperty(propertyKey);\n\t\t} else {\n\t\t\tsetIsLoading(false);\n\t\t}\n\t}, [propertyKey, loadProperty]);\n\n\tfunction goToParentPage() {\n\t\thistory.push(pathname.substring(0, pathname.lastIndexOf('/')));\n\t}\n\n\tasync function handleSubmit(formData: Property) {\n\t\tif (property) {\n\t\t\tawait updatePropertyApi(clearPropertyFields(formData));\n\t\t} else {\n\t\t\tawait createPropertyApi(clearPropertyFields(formData));\n\t\t}\n\t\tdisplaySuccessMessage(messageSuccessSaveProperty);\n\t\tgoToParentPage();\n\t}\n\n\tfunction cancel() {\n\t\tgoToParentPage();\n\t}\n\n\tif (notFound) {\n\t\treturn <PageNotFound />;\n\t}\n\tconst contentHeaderTitle = getContentHeaderTitle(!property);\n\treturn !isLoading ? (\n\t\t<>\n\t\t\t<ContentHeader title={contentHeaderTitle} parentPageLink />\n\t\t\t<PropertyForm\n\t\t\t\teditedProperty={property}\n\t\t\t\tisReadonly={!!property && !hasAuthorities(['UPDATE_PROPERTY'] as string[])}\n\t\t\t\tonSubmit={handleSubmit}\n\t\t\t\tonCancel={cancel}\n\t\t\t/>\n\t\t</>\n\t) : (\n\t\t<Spinner center />\n\t);\n}\n"],"names":["ButtonPicker","props","options","onChange","values","rest","toggleOption","option","v","jsx","FieldDecorator","Button","cx","TransByDescriptor","AllowedValues","getValues","errors","trigger","useFormContext","enabled","setEnabled","useState","allowedValues","allowedValuesInvalid","useController","remove","index","i","append","value","change","allowedValue","handleEnabledChange","jsxs","Fragment","Checkbox","Trans","e","Icon","typeOptions","pType","entityTargetOptions","createEmptyFormData","PropertyForm","editedProperty","isReadonly","onSubmit","onCancel","t","useTranslation","formContext","useForm","control","handleSubmit","watch","setError","isSubmitting","isDirty","submit","submitFunction","property","error","axios","fieldName","message","parseBackendError","messageBoxError","getUnknownBackendErrorMessage","type","isEditMode","isStringOrText","areAllowedValuesEnabled","FormProvider","Controller","field","TextInput","SelectInput","entityTargets","NumberInput","ButtonRow","Prompt","getContentHeaderTitle","createMode","messageSuccessSaveProperty","clearPropertyFields","regularExpression","maxLength","minLength","newProperty","PropertiesEditPage","pathname","useLocation","history","useHistory","propertyKey","useParams","setProperty","isLoading","setIsLoading","notFound","setNotFound","loadProperty","useCallback","getPropertyById","useEffect","goToParentPage","formData","updatePropertyApi","createPropertyApi","displaySuccessMessage","cancel","PageNotFound","contentHeaderTitle","Spinner","ContentHeader","hasAuthorities"],"mappings":";;;;;;;;;;;AAwBA,SAAwBA,GAAgBC,GAAiB;AACxD,QAAM,EAAC,SAAAC,GAAS,UAAAC,GAAU,QAAAC,GAAQ,GAAGC,MAAQJ;AAE7C,WAASK,EAAaC,GAA+B;AACpD,IAAIH,EAAO,SAASG,EAAO,KAAK,IAC/BJ,EAASC,EAAO,OAAO,CAAAI,MAAKA,MAAMD,EAAO,KAAK,CAAC,IAE/CJ,EAAS,CAAC,GAAGC,GAAQG,EAAO,KAAK,CAAC;AAAA,EAEpC;AAEA,SACC,gBAAAE,EAACC,GAAA,EAAgB,GAAGL,GACnB,UAAA,gBAAAI,EAAC,SAAI,WAAU,gBACb,UAAAP,EAAQ,IAAI,CAAAK,MACZ,gBAAAE;AAAA,IAACE;AAAA,IAAA;AAAA,MAEA,SAAS,MAAML,EAAaC,CAAM;AAAA,MAClC,WAAWK,GAAG;AAAA,QACb,QAAQR,EAAO,SAASG,EAAO,KAAK;AAAA,MAAA,CACpC;AAAA,MACD,UAAUN,EAAM;AAAA,MAEhB,UAAA,gBAAAQ,EAACI,GAAA,EAAkB,uBAAuBN,EAAO,MAAA,CAAO;AAAA,IAAA;AAAA,IAPnD,OAAOA,EAAO,KAAK;AAAA,EAAA,CASzB,GACF,EAAA,CACD;AAEF;AC5CA,SAAwBO,KAAgB;AACv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AAA,EACX,EAAA,CACD;AAIF;"}
|
|
1
|
+
{"version":3,"file":"PropertiesEditPage-BOlFs_u9.js","sources":["../ng-ui-scale/src/components/inputs/buttonPicker/ButtonPicker.tsx","../ng-ui-scale/src/modules/properties/AllowedValues.tsx","../ng-ui-scale/src/modules/properties/PropertyForm.tsx","../ng-ui-scale/src/modules/properties/PropertiesEditPage.tsx"],"sourcesContent":["import cx from 'classnames';\n\nimport {Button} from '@deviceinsight/ng-ui-basic-components';\n\nimport type {TranslationDescriptor} from 'i18n';\nimport TransByDescriptor from 'i18n/TransByDescriptor';\nimport FieldDecorator, {type FieldDecoratorProps} from '../FieldDecorator';\n\nimport '../input.scss';\n\nexport type ButtonPickerOption<T> = {\n\tvalue: T;\n\tlabel: string | TranslationDescriptor;\n};\n\ntype OwnProps<T> = {\n\tonChange: (values: T[]) => void;\n\toptions: ButtonPickerOption<T>[];\n\tvalues: T[];\n\tdisabled?: boolean;\n};\n\ntype Props<T> = FieldDecoratorProps & OwnProps<T>;\n\nexport default function ButtonPicker<T>(props: Props<T>) {\n\tconst {options, onChange, values, ...rest} = props;\n\n\tfunction toggleOption(option: ButtonPickerOption<T>) {\n\t\tif (values.includes(option.value)) {\n\t\t\tonChange(values.filter(v => v !== option.value));\n\t\t} else {\n\t\t\tonChange([...values, option.value]);\n\t\t}\n\t}\n\n\treturn (\n\t\t<FieldDecorator {...rest}>\n\t\t\t<div className=\"buttonpicker\">\n\t\t\t\t{options.map(option => (\n\t\t\t\t\t<Button\n\t\t\t\t\t\tkey={String(option.value)}\n\t\t\t\t\t\tonClick={() => toggleOption(option)}\n\t\t\t\t\t\tclassName={cx({\n\t\t\t\t\t\t\tactive: values.includes(option.value),\n\t\t\t\t\t\t})}\n\t\t\t\t\t\tdisabled={props.disabled}\n\t\t\t\t\t>\n\t\t\t\t\t\t<TransByDescriptor translationDescriptor={option.label} />\n\t\t\t\t\t</Button>\n\t\t\t\t))}\n\t\t\t</div>\n\t\t</FieldDecorator>\n\t);\n}\n","import {useState} from 'react';\nimport {useController, useFormContext} from 'react-hook-form';\n\nimport type {Property} from '@deviceinsight/ng-ui-api-client';\nimport {Button, Checkbox, Icon} from '@deviceinsight/ng-ui-basic-components';\n\nimport FieldDecorator from 'components/inputs/FieldDecorator';\nimport {Trans} from 'i18n';\n\nexport default function AllowedValues() {\n\tconst {\n\t\tgetValues,\n\t\tformState: {errors},\n\t\ttrigger,\n\t} = useFormContext<Property>();\n\tconst [enabled, setEnabled] = useState<boolean>(!!getValues('allowedValues'));\n\tconst {\n\t\tfield: {value: allowedValues, onChange},\n\t\tfieldState: {invalid: allowedValuesInvalid},\n\t} = useController<Property, 'allowedValues'>({\n\t\tname: 'allowedValues',\n\t\trules: {\n\t\t\tvalidate: allowedValues =>\n\t\t\t\tallowedValues == null || allowedValues?.some(v => v !== '') ? undefined : 'Required',\n\t\t},\n\t});\n\n\tfunction remove(index: number) {\n\t\tonChange(allowedValues?.filter((v, i) => i !== index));\n\t}\n\n\tfunction append(value: string) {\n\t\tonChange(allowedValues ? [...allowedValues, value] : [value]);\n\t}\n\n\tfunction change(value: string, index: number) {\n\t\tonChange(allowedValues?.map((allowedValue, i) => (index === i ? value : allowedValue)));\n\t}\n\n\tasync function handleEnabledChange(enabled: boolean) {\n\t\tonChange(enabled ? [] : null);\n\t\tsetEnabled(enabled);\n\n\t\tif (!enabled && allowedValuesInvalid) {\n\t\t\tawait trigger();\n\t\t}\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<FieldDecorator\n\t\t\t\tlabel={\n\t\t\t\t\t<div className=\"di allowed-values-header\">\n\t\t\t\t\t\t<Checkbox type=\"toggle\" value={enabled} toggleSmall onChange={handleEnabledChange} />{' '}\n\t\t\t\t\t\t<Trans i18nKey=\"properties.labels.allowedValues\">Allowed Values</Trans>\n\t\t\t\t\t</div>\n\t\t\t\t}\n\t\t\t\terror={errors.allowedValues ? 'Required' : undefined}\n\t\t\t\tclassName=\"di allowed-values-container\"\n\t\t\t>\n\t\t\t\t<Checkbox value={enabled} onChange={handleEnabledChange} />\n\t\t\t\t{allowedValues?.length === 0 ? (\n\t\t\t\t\t<div className=\"empty-placeholder\">\n\t\t\t\t\t\t<Trans i18nKey=\"properties.labels.allowedValuesEmptyPlaceholder\">No values</Trans>\n\t\t\t\t\t</div>\n\t\t\t\t) : (\n\t\t\t\t\t<ul>\n\t\t\t\t\t\t{allowedValues?.map((allowedValue, index) => (\n\t\t\t\t\t\t\t<li key={index} className=\"item\">\n\t\t\t\t\t\t\t\t<FieldDecorator className=\"value-container\">\n\t\t\t\t\t\t\t\t\t<input\n\t\t\t\t\t\t\t\t\t\ttype=\"text\"\n\t\t\t\t\t\t\t\t\t\tvalue={allowedValue}\n\t\t\t\t\t\t\t\t\t\tonChange={e => change(e.target.value, index)}\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t</FieldDecorator>\n\t\t\t\t\t\t\t\t<Button onClick={() => remove(index)}>\n\t\t\t\t\t\t\t\t\t<Icon del />\n\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t</li>\n\t\t\t\t\t\t))}\n\t\t\t\t\t</ul>\n\t\t\t\t)}\n\t\t\t</FieldDecorator>\n\t\t\t{enabled && (\n\t\t\t\t<Button onClick={() => append('')}>\n\t\t\t\t\t<Icon add />\n\t\t\t\t\t<Trans i18nKey=\"properties.labels.allowedValuesAdd\">Add</Trans>\n\t\t\t\t</Button>\n\t\t\t)}\n\t\t</>\n\t);\n}\n","import axios from 'axios';\nimport {Controller, FormProvider, useForm} from 'react-hook-form';\nimport {Prompt} from 'react-router-dom';\n\nimport type {EntityTarget, Property} from '@deviceinsight/ng-ui-api-client';\nimport {Button, ButtonRow} from '@deviceinsight/ng-ui-basic-components';\nimport {messageBoxError} from '@deviceinsight/ng-ui-components';\n\nimport ButtonPicker from 'components/inputs/buttonPicker/ButtonPicker';\nimport Checkbox from 'components/inputs/checkbox/Checkbox';\nimport NumberInput from 'components/inputs/numberInput/NumberInput';\nimport SelectInput from 'components/inputs/selectInput/SelectInput';\nimport TextInput from 'components/inputs/textInput/TextInput';\nimport {Trans, useTranslation} from 'i18n';\nimport AllowedValues from './AllowedValues';\nimport {getUnknownBackendErrorMessage, parseBackendError} from './utils';\n\nimport './propertiesEditPage.scss';\n\nconst typeOptions = ['STRING', 'TEXT', 'DATE', 'LONG', 'DOUBLE', 'BOOLEAN', 'IP', 'GEO'].map(pType => {\n\treturn {\n\t\tvalue: pType,\n\t\tname: pType,\n\t};\n});\n\nconst entityTargetOptions = (['ASSET', 'ASSET_GROUP', 'ACCOUNT', 'ACCOUNT_GROUP', 'DATAPOINT'] as EntityTarget[]).map(\n\tpType => ({\n\t\tvalue: pType,\n\t\tlabel: pType,\n\t}),\n);\n\ntype Props = {\n\teditedProperty: Property | undefined;\n\tisReadonly: boolean;\n\tonSubmit: (property: Property) => Promise<void>;\n\tonCancel: () => void;\n};\n\nfunction createEmptyFormData(): Property {\n\treturn {\n\t\tkey: '',\n\t\ttype: 'STRING',\n\t\tentityTargets: [],\n\t\taddToAll: false,\n\t\tdeletable: true,\n\t};\n}\n\nfunction PropertyForm({editedProperty, isReadonly, onSubmit, onCancel}: Props) {\n\tconst {t} = useTranslation();\n\tconst formContext = useForm<Property>({\n\t\tdefaultValues: editedProperty ? editedProperty : createEmptyFormData(),\n\t});\n\tconst {\n\t\tcontrol,\n\t\thandleSubmit,\n\t\twatch,\n\t\tsetError,\n\t\tformState: {isSubmitting, isDirty},\n\t} = formContext;\n\n\tfunction submit(): Promise<void> {\n\t\tasync function submitFunction(property: Property) {\n\t\t\ttry {\n\t\t\t\tawait onSubmit(property);\n\t\t\t} catch (error: unknown) {\n\t\t\t\tif (axios.isAxiosError(error)) {\n\t\t\t\t\tconst {fieldName, message} = parseBackendError(error, t);\n\t\t\t\t\tif (fieldName) {\n\t\t\t\t\t\tsetError(fieldName as any, {message});\n\t\t\t\t\t} else {\n\t\t\t\t\t\tmessageBoxError(message);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tmessageBoxError(getUnknownBackendErrorMessage(t));\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn handleSubmit(submitFunction, errors => {\n\t\t\tconsole.warn('Validation error', errors);\n\t\t})();\n\t}\n\n\tconst type = watch('type');\n\n\tconst isEditMode = !!editedProperty;\n\tconst isStringOrText = type === 'STRING' || type === 'TEXT';\n\tconst areAllowedValuesEnabled = !!watch('allowedValues');\n\n\treturn (\n\t\t<FormProvider {...formContext}>\n\t\t\t<div className=\"property-form\">\n\t\t\t\t<Controller\n\t\t\t\t\tname=\"key\"\n\t\t\t\t\tcontrol={control}\n\t\t\t\t\trules={{\n\t\t\t\t\t\trequired: t('properties.form.validation.key.required', {\n\t\t\t\t\t\t\tdefaultValue: 'Please enter a property key',\n\t\t\t\t\t\t}),\n\t\t\t\t\t}}\n\t\t\t\t\trender={({field, fieldState: {error}}) => (\n\t\t\t\t\t\t<TextInput\n\t\t\t\t\t\t\t{...field}\n\t\t\t\t\t\t\tlabel={<Trans i18nKey=\"properties.labels.key\">Key</Trans>}\n\t\t\t\t\t\t\terror={error?.message}\n\t\t\t\t\t\t\trequired\n\t\t\t\t\t\t\tdisabled={isReadonly || isEditMode}\n\t\t\t\t\t\t/>\n\t\t\t\t\t)}\n\t\t\t\t/>\n\t\t\t\t<Controller\n\t\t\t\t\tname=\"type\"\n\t\t\t\t\tcontrol={control}\n\t\t\t\t\trender={({field}) => (\n\t\t\t\t\t\t<SelectInput\n\t\t\t\t\t\t\tlabel={<Trans i18nKey=\"properties.labels.type\">Type</Trans>}\n\t\t\t\t\t\t\toptions={typeOptions}\n\t\t\t\t\t\t\trequired\n\t\t\t\t\t\t\tdisabled={isReadonly || isEditMode}\n\t\t\t\t\t\t\tvalue={field.value}\n\t\t\t\t\t\t\tonChange={field.onChange}\n\t\t\t\t\t\t/>\n\t\t\t\t\t)}\n\t\t\t\t/>\n\t\t\t\t<Controller\n\t\t\t\t\tname=\"entityTargets\"\n\t\t\t\t\tcontrol={control}\n\t\t\t\t\trules={{validate: entityTargets => (entityTargets.length === 0 ? 'Required' : undefined)}}\n\t\t\t\t\trender={({field: {value, onChange}, fieldState: {error}}) => (\n\t\t\t\t\t\t<ButtonPicker\n\t\t\t\t\t\t\tlabel={<Trans i18nKey=\"properties.labels.entityTargets\">Entity targets</Trans>}\n\t\t\t\t\t\t\tvalues={value}\n\t\t\t\t\t\t\tonChange={onChange}\n\t\t\t\t\t\t\toptions={entityTargetOptions}\n\t\t\t\t\t\t\terror={\n\t\t\t\t\t\t\t\terror\n\t\t\t\t\t\t\t\t\t? t('properties.form.validation.entityTargets.required', {\n\t\t\t\t\t\t\t\t\t\t\tdefaultValue: 'Please select a at least one entity target',\n\t\t\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\trequired\n\t\t\t\t\t\t\tdisabled={isReadonly}\n\t\t\t\t\t\t/>\n\t\t\t\t\t)}\n\t\t\t\t/>\n\t\t\t\t<Controller\n\t\t\t\t\tname=\"addToAll\"\n\t\t\t\t\tcontrol={control}\n\t\t\t\t\trender={({field}) => (\n\t\t\t\t\t\t<Checkbox\n\t\t\t\t\t\t\t{...field}\n\t\t\t\t\t\t\tlabel={<Trans i18nKey=\"properties.labels.addToSearch\">Add to Search</Trans>}\n\t\t\t\t\t\t\tdisabled={isReadonly || isEditMode}\n\t\t\t\t\t\t/>\n\t\t\t\t\t)}\n\t\t\t\t/>\n\t\t\t\t<Controller\n\t\t\t\t\tname=\"unique\"\n\t\t\t\t\tcontrol={control}\n\t\t\t\t\trender={({field: {value, onChange}}) => (\n\t\t\t\t\t\t<Checkbox\n\t\t\t\t\t\t\tvalue={!!value}\n\t\t\t\t\t\t\tonChange={onChange}\n\t\t\t\t\t\t\tlabel={<Trans i18nKey=\"properties.labels.unique\">Unique</Trans>}\n\t\t\t\t\t\t\tdisabled={isReadonly}\n\t\t\t\t\t\t/>\n\t\t\t\t\t)}\n\t\t\t\t/>\n\t\t\t\t<Controller\n\t\t\t\t\tname=\"final\"\n\t\t\t\t\tcontrol={control}\n\t\t\t\t\trender={({field: {value, onChange}}) => (\n\t\t\t\t\t\t<Checkbox\n\t\t\t\t\t\t\tvalue={!!value}\n\t\t\t\t\t\t\tonChange={onChange}\n\t\t\t\t\t\t\tlabel={<Trans i18nKey=\"properties.labels.final\">Final</Trans>}\n\t\t\t\t\t\t\tdisabled={isReadonly}\n\t\t\t\t\t\t/>\n\t\t\t\t\t)}\n\t\t\t\t/>\n\t\t\t\t{isStringOrText && !areAllowedValuesEnabled && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<Controller\n\t\t\t\t\t\t\tname=\"minLength\"\n\t\t\t\t\t\t\tcontrol={control}\n\t\t\t\t\t\t\trender={({field: {value, ...rest}}) => (\n\t\t\t\t\t\t\t\t<NumberInput\n\t\t\t\t\t\t\t\t\t{...rest}\n\t\t\t\t\t\t\t\t\tvalue={value ?? undefined}\n\t\t\t\t\t\t\t\t\tlabel={<Trans i18nKey=\"properties.label.minLength\">Minimum length</Trans>}\n\t\t\t\t\t\t\t\t\tplaceholder={\n\t\t\t\t\t\t\t\t\t\tisReadonly ? t('properties.placeholder.notSet', {defaultValue: 'Not set'}) : '0'\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\treadOnly={isReadonly}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<Controller\n\t\t\t\t\t\t\tname=\"maxLength\"\n\t\t\t\t\t\t\tcontrol={control}\n\t\t\t\t\t\t\trender={({field: {value, ...rest}}) => (\n\t\t\t\t\t\t\t\t<NumberInput\n\t\t\t\t\t\t\t\t\t{...rest}\n\t\t\t\t\t\t\t\t\tvalue={value ?? undefined}\n\t\t\t\t\t\t\t\t\tlabel={<Trans i18nKey=\"properties.label.maxLength\">Maximum length</Trans>}\n\t\t\t\t\t\t\t\t\tplaceholder={\n\t\t\t\t\t\t\t\t\t\tisReadonly ? t('properties.placeholder.notSet', {defaultValue: 'Not set'}) : '0'\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\treadOnly={isReadonly}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<Controller\n\t\t\t\t\t\t\tname=\"regularExpression\"\n\t\t\t\t\t\t\tcontrol={control}\n\t\t\t\t\t\t\trender={({field: {value, ...rest}}) => (\n\t\t\t\t\t\t\t\t<TextInput\n\t\t\t\t\t\t\t\t\t{...rest}\n\t\t\t\t\t\t\t\t\tvalue={value ?? undefined}\n\t\t\t\t\t\t\t\t\tlabel={\n\t\t\t\t\t\t\t\t\t\t<Trans i18nKey=\"properties.labels.regularExpression\">Regular expression</Trans>\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\treadOnly={isReadonly}\n\t\t\t\t\t\t\t\t\tplaceholder={\n\t\t\t\t\t\t\t\t\t\tisReadonly ? t('properties.placeholder.notSet', {defaultValue: 'Not set'}) : ''\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t/>\n\t\t\t\t\t</>\n\t\t\t\t)}\n\t\t\t\t{type === 'STRING' && <AllowedValues />}\n\n\t\t\t\t<div className=\"formRequired\">\n\t\t\t\t\t* <Trans i18nKey=\"form.field.required\">required</Trans>\n\t\t\t\t</div>\n\t\t\t\t<ButtonRow dividing>\n\t\t\t\t\t<Button className=\"with-spinner\" primary onClick={submit} disabled={isSubmitting}>\n\t\t\t\t\t\t{<Trans i18nKey=\"general.actions.save\">Save</Trans>}\n\t\t\t\t\t</Button>\n\t\t\t\t\t<Button disabled={isSubmitting} onClick={onCancel}>\n\t\t\t\t\t\t<Trans i18nKey=\"general.actions.cancel\">Cancel</Trans>\n\t\t\t\t\t</Button>\n\t\t\t\t</ButtonRow>\n\t\t\t\t<Prompt message=\"\" when={isDirty && !isSubmitting} />\n\t\t\t</div>\n\t\t</FormProvider>\n\t);\n}\n\nexport default PropertyForm;\n","import {useCallback, useEffect, useState} from 'react';\nimport {useHistory, useLocation, useParams} from 'react-router-dom';\n\nimport {\n\tcreateProperty as createPropertyApi,\n\tgetPropertyById,\n\ttype Property,\n\tupdateProperty as updatePropertyApi,\n} from '@deviceinsight/ng-ui-api-client';\nimport {Spinner} from '@deviceinsight/ng-ui-basic-components';\nimport {ContentHeader} from '@deviceinsight/ng-ui-components';\n\nimport {Trans} from 'i18n';\nimport PageNotFound from '../../components/page/misc/PageNotFound';\nimport {hasAuthorities} from '../../utils/hasAuthorities';\nimport PropertyForm from './PropertyForm';\nimport {displaySuccessMessage} from './utils';\n\nconst getContentHeaderTitle = (createMode: boolean) => {\n\treturn createMode\n\t\t? {\n\t\t\t\tid: 'properties.create.title',\n\t\t\t\tdefaultValue: 'Create Property',\n\t\t\t}\n\t\t: {\n\t\t\t\tid: 'properties.edit.title',\n\t\t\t\tdefaultValue: 'Edit Property',\n\t\t\t};\n};\n\nconst messageSuccessSaveProperty = (\n\t<Trans i18nKey=\"properties.saveSuccessMessage\">Property has been saved successfully.</Trans>\n);\n\nfunction clearPropertyFields(property: Property): Property {\n\tif (property.type === 'STRING' && property.allowedValues && property.allowedValues.length > 0) {\n\t\t// biome-ignore lint/correctness/noUnusedVariables: It's ok\n\t\tconst {regularExpression, maxLength, minLength, allowedValues, ...newProperty} = property;\n\t\treturn {...newProperty, allowedValues: [...new Set(allowedValues.filter(value => value !== ''))]};\n\t}\n\n\t// The backend does not accept an empty array for allowedValues\n\tif (property.allowedValues && property.allowedValues.length === 0) {\n\t\t// biome-ignore lint/correctness/noUnusedVariables: It's ok\n\t\tconst {allowedValues, ...newProperty} = property;\n\t\treturn newProperty;\n\t}\n\tif (property.type !== 'STRING' && property.type !== 'TEXT') {\n\t\t// biome-ignore lint/correctness/noUnusedVariables: It's ok\n\t\tconst {regularExpression, maxLength, minLength, ...newProperty} = property;\n\t\treturn newProperty;\n\t}\n\n\treturn property;\n}\n\nexport default function PropertiesEditPage() {\n\tconst {pathname} = useLocation();\n\tconst history = useHistory();\n\tconst {propertyKey} = useParams<{propertyKey: string}>();\n\tconst [property, setProperty] = useState<Property | undefined>(undefined);\n\tconst [isLoading, setIsLoading] = useState<boolean>(true);\n\tconst [notFound, setNotFound] = useState<boolean>(false);\n\n\tconst loadProperty = useCallback(async (propertyKey: string) => {\n\t\ttry {\n\t\t\tconst property = await getPropertyById(propertyKey);\n\t\t\tsetProperty(property);\n\t\t} catch (e) {\n\t\t\tconsole.error(e);\n\t\t\tsetNotFound(true);\n\t\t} finally {\n\t\t\tsetIsLoading(false);\n\t\t}\n\t}, []);\n\n\tuseEffect(() => {\n\t\tif (propertyKey && propertyKey !== 'create') {\n\t\t\tloadProperty(propertyKey);\n\t\t} else {\n\t\t\tsetIsLoading(false);\n\t\t}\n\t}, [propertyKey, loadProperty]);\n\n\tfunction goToParentPage() {\n\t\thistory.push(pathname.substring(0, pathname.lastIndexOf('/')));\n\t}\n\n\tasync function handleSubmit(formData: Property) {\n\t\tif (property) {\n\t\t\tawait updatePropertyApi(clearPropertyFields(formData));\n\t\t} else {\n\t\t\tawait createPropertyApi(clearPropertyFields(formData));\n\t\t}\n\t\tdisplaySuccessMessage(messageSuccessSaveProperty);\n\t\tgoToParentPage();\n\t}\n\n\tfunction cancel() {\n\t\tgoToParentPage();\n\t}\n\n\tif (notFound) {\n\t\treturn <PageNotFound />;\n\t}\n\tconst contentHeaderTitle = getContentHeaderTitle(!property);\n\treturn !isLoading ? (\n\t\t<>\n\t\t\t<ContentHeader title={contentHeaderTitle} parentPageLink />\n\t\t\t<PropertyForm\n\t\t\t\teditedProperty={property}\n\t\t\t\tisReadonly={!!property && !hasAuthorities(['UPDATE_PROPERTY'] as string[])}\n\t\t\t\tonSubmit={handleSubmit}\n\t\t\t\tonCancel={cancel}\n\t\t\t/>\n\t\t</>\n\t) : (\n\t\t<Spinner center />\n\t);\n}\n"],"names":["ButtonPicker","props","options","onChange","values","rest","toggleOption","option","v","jsx","FieldDecorator","Button","cx","TransByDescriptor","AllowedValues","getValues","errors","trigger","useFormContext","enabled","setEnabled","useState","allowedValues","allowedValuesInvalid","useController","remove","index","i","append","value","change","allowedValue","handleEnabledChange","jsxs","Fragment","Checkbox","Trans","e","Icon","typeOptions","pType","entityTargetOptions","createEmptyFormData","PropertyForm","editedProperty","isReadonly","onSubmit","onCancel","t","useTranslation","formContext","useForm","control","handleSubmit","watch","setError","isSubmitting","isDirty","submit","submitFunction","property","error","axios","fieldName","message","parseBackendError","messageBoxError","getUnknownBackendErrorMessage","type","isEditMode","isStringOrText","areAllowedValuesEnabled","FormProvider","Controller","field","TextInput","SelectInput","entityTargets","NumberInput","ButtonRow","Prompt","getContentHeaderTitle","createMode","messageSuccessSaveProperty","clearPropertyFields","regularExpression","maxLength","minLength","newProperty","PropertiesEditPage","pathname","useLocation","history","useHistory","propertyKey","useParams","setProperty","isLoading","setIsLoading","notFound","setNotFound","loadProperty","useCallback","getPropertyById","useEffect","goToParentPage","formData","updatePropertyApi","createPropertyApi","displaySuccessMessage","cancel","PageNotFound","contentHeaderTitle","Spinner","ContentHeader","hasAuthorities"],"mappings":";;;;;;;;;;;AAwBA,SAAwBA,GAAgBC,GAAiB;AACxD,QAAM,EAAC,SAAAC,GAAS,UAAAC,GAAU,QAAAC,GAAQ,GAAGC,MAAQJ;AAE7C,WAASK,EAAaC,GAA+B;AACpD,IAAIH,EAAO,SAASG,EAAO,KAAK,IAC/BJ,EAASC,EAAO,OAAO,CAAAI,MAAKA,MAAMD,EAAO,KAAK,CAAC,IAE/CJ,EAAS,CAAC,GAAGC,GAAQG,EAAO,KAAK,CAAC;AAAA,EAEpC;AAEA,SACC,gBAAAE,EAACC,GAAA,EAAgB,GAAGL,GACnB,UAAA,gBAAAI,EAAC,SAAI,WAAU,gBACb,UAAAP,EAAQ,IAAI,CAAAK,MACZ,gBAAAE;AAAA,IAACE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G,GAAA,EAAQ,QAAM,GAAA,CAAC,IAVhB,gBAAAhF,EAAAC,GAAA,EACC,UAAA;AAAA,IAAA,gBAAAzB,EAACyG,GAAA,EAAc,OAAOF,GAAoB,gBAAc,IAAC;AAAA,IACzD,gBAAAvG;AAAA,MAACkC;AAAA,MAAA;AAAA,QACA,gBAAgBiB;AAAA,QAChB,YAAY,CAAC,CAACA,KAAY,CAACuD,GAAe,CAAC,iBAAiB,CAAa;AAAA,QACzE,UAAU9D;AAAA,QACV,UAAUyD;AAAA,MAAA;AAAA,IAAA;AAAA,EACX,EAAA,CACD;AAIF;"}
|
|
@@ -2,8 +2,8 @@ import { jsx as r, jsxs as f } from "react/jsx-runtime";
|
|
|
2
2
|
import { useContext as c, useState as y, useCallback as b, useEffect as m } from "react";
|
|
3
3
|
import { deleteProperty as T } from "@deviceinsight/ng-ui-api-client";
|
|
4
4
|
import { Bubble as P, Button as h, Icon as A, withConfirm as I } from "@deviceinsight/ng-ui-basic-components";
|
|
5
|
-
import { ContentHeader as
|
|
6
|
-
import {
|
|
5
|
+
import { ContentHeader as O } from "@deviceinsight/ng-ui-components";
|
|
6
|
+
import { t as g, a, G, u as v, bN as D, bO as E } from "./setTitle-Cyf8DxtL.js";
|
|
7
7
|
import { Link as C } from "react-router-dom";
|
|
8
8
|
import "react-i18next";
|
|
9
9
|
const V = [
|
|
@@ -30,7 +30,7 @@ const V = [
|
|
|
30
30
|
"definitionId"
|
|
31
31
|
];
|
|
32
32
|
function S(p, o) {
|
|
33
|
-
const i =
|
|
33
|
+
const i = g(["DELETE_PROPERTY"]);
|
|
34
34
|
return [
|
|
35
35
|
{
|
|
36
36
|
name: "propertyKey",
|
|
@@ -230,7 +230,7 @@ const w = {
|
|
|
230
230
|
}
|
|
231
231
|
return /* @__PURE__ */ f("div", { "data-testid": "properties-list", children: [
|
|
232
232
|
/* @__PURE__ */ r(
|
|
233
|
-
|
|
233
|
+
O,
|
|
234
234
|
{
|
|
235
235
|
title: {
|
|
236
236
|
id: "route.label.properties.name",
|
|
@@ -264,4 +264,4 @@ const w = {
|
|
|
264
264
|
export {
|
|
265
265
|
U as default
|
|
266
266
|
};
|
|
267
|
-
//# sourceMappingURL=PropertiesList-
|
|
267
|
+
//# sourceMappingURL=PropertiesList-DCPkWqaf.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PropertiesList-BwbcDHUj.js","sources":["../ng-ui-scale/src/modules/properties/columnDefs/properties.tsx","../ng-ui-scale/src/modules/properties/PropertiesList.tsx"],"sourcesContent":["import {Link} from 'react-router-dom';\n\nimport type {EntityTarget, Property} from '@deviceinsight/ng-ui-api-client';\nimport {Bubble, Button, Icon} from '@deviceinsight/ng-ui-basic-components';\nimport type {ReactableColumnDef} from '@deviceinsight/ng-ui-components';\n\nimport {type TFunction, Trans} from 'i18n';\nimport {hasAuthorities} from 'utils/hasAuthorities';\n\nconst nonDeletableProperties = [\n\t'name',\n\t'urn',\n\t'parentId',\n\t'createdAt',\n\t'assetGroupId',\n\t'accountNumber',\n\t'username',\n\t'emailAddress',\n\t'accountGroupId',\n\t'assetGroupDefinitionId',\n\t'description',\n\t'locale',\n\t'timezone',\n\t'state',\n\t'transitiveAssetGroupId',\n\t'transitiveAssetGroupDefinitionId',\n\t'isGateway',\n\t'gatewayId',\n\t'roleId',\n\t'displayName',\n\t'definitionId',\n];\n\nexport function getColumnDefs(\n\tt: TFunction,\n\tonDeleteProperty: (arg0: Property) => any,\n): Array<ReactableColumnDef<Property>> {\n\tconst hasDeleteProperty = hasAuthorities(['DELETE_PROPERTY'] as string[]);\n\treturn [\n\t\t{\n\t\t\tname: 'propertyKey',\n\t\t\tlabel: <Trans i18nKey=\"properties.tableHeaders.key\">Property</Trans>,\n\t\t\tsortable: true,\n\t\t\tfilterable: {\n\t\t\t\tfilterType: 'text',\n\t\t\t\tfilterFn: (item: Property, value: string) => item.key.toLowerCase().indexOf(value.toLowerCase()) >= 0,\n\t\t\t},\n\t\t\trender: item => (\n\t\t\t\t<Link\n\t\t\t\t\tto={`properties/${item.key}`}\n\t\t\t\t\t// @ts-expect-error state does not exists in the Link definition\n\t\t\t\t\tstate={item}\n\t\t\t\t>\n\t\t\t\t\t{item.key}\n\t\t\t\t</Link>\n\t\t\t),\n\t\t},\n\t\t{\n\t\t\tname: 'propertyType',\n\t\t\tlabel: <Trans i18nKey=\"properties.tableHeaders.type\">Type</Trans>,\n\t\t\twidth: '10%',\n\t\t\tfilterable: {\n\t\t\t\tfilterType: 'options',\n\t\t\t\tfilterOptions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tvalue: 'STRING',\n\t\t\t\t\t\tlabel: {\n\t\t\t\t\t\t\tid: 'string',\n\t\t\t\t\t\t\tdefaultValue: 'String',\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tvalue: 'TEXT',\n\t\t\t\t\t\tlabel: {\n\t\t\t\t\t\t\tid: 'text',\n\t\t\t\t\t\t\tdefaultValue: 'Text',\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tvalue: 'DATE',\n\t\t\t\t\t\tlabel: {\n\t\t\t\t\t\t\tid: 'date',\n\t\t\t\t\t\t\tdefaultValue: 'Date',\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tvalue: 'LONG',\n\t\t\t\t\t\tlabel: {\n\t\t\t\t\t\t\tid: 'long',\n\t\t\t\t\t\t\tdefaultValue: 'Long',\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tvalue: 'DOUBLE',\n\t\t\t\t\t\tlabel: {\n\t\t\t\t\t\t\tid: 'double',\n\t\t\t\t\t\t\tdefaultValue: 'Double',\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tvalue: 'BOOLEAN',\n\t\t\t\t\t\tlabel: {\n\t\t\t\t\t\t\tid: 'boolean',\n\t\t\t\t\t\t\tdefaultValue: 'Boolean',\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tvalue: 'IP',\n\t\t\t\t\t\tlabel: {\n\t\t\t\t\t\t\tid: 'ip',\n\t\t\t\t\t\t\tdefaultValue: 'Ip',\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tvalue: 'GEO',\n\t\t\t\t\t\tlabel: {\n\t\t\t\t\t\t\tid: 'geo',\n\t\t\t\t\t\t\tdefaultValue: 'Geo',\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\tfilterFn: (item: Property, value: string) => item.type === value,\n\t\t\t},\n\t\t\trender: item => item.type,\n\t\t},\n\t\t{\n\t\t\tname: 'propertyEntityTargets',\n\t\t\tlabel: <Trans i18nKey=\"properties.tableHeaders.entityTargets\">Scope</Trans>,\n\t\t\twidth: '30%',\n\t\t\tfilterable: {\n\t\t\t\tfilterType: 'options',\n\t\t\t\tfilterOptions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tvalue: 'DATAPOINT',\n\t\t\t\t\t\tlabel: {\n\t\t\t\t\t\t\tid: 'properties.filterOptions.datapoint',\n\t\t\t\t\t\t\tdefaultValue: 'Datapoint',\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tvalue: 'ASSET',\n\t\t\t\t\t\tlabel: {\n\t\t\t\t\t\t\tid: 'properties.filterOptions.asset',\n\t\t\t\t\t\t\tdefaultValue: 'Asset',\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tvalue: 'ASSET_GROUP',\n\t\t\t\t\t\tlabel: {\n\t\t\t\t\t\t\tid: 'properties.filterOptions.assetGroup',\n\t\t\t\t\t\t\tdefaultValue: 'Asset Group',\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tvalue: 'ACCOUNT',\n\t\t\t\t\t\tlabel: {\n\t\t\t\t\t\t\tid: 'properties.filterOptions.account',\n\t\t\t\t\t\t\tdefaultValue: 'Account',\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tvalue: 'ACCOUNT_GROUP',\n\t\t\t\t\t\tlabel: {\n\t\t\t\t\t\t\tid: 'properties.filterOptions.accountGroup',\n\t\t\t\t\t\t\tdefaultValue: 'Account Group',\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\tfilterFn: (item: Property, value: string) => item.entityTargets.includes(value as EntityTarget),\n\t\t\t},\n\t\t\trender: item => [...item.entityTargets].sort().join(', '),\n\t\t},\n\t\t{\n\t\t\tname: 'actions',\n\t\t\tlabel: '',\n\t\t\twidth: '10%',\n\t\t\talign: 'right',\n\t\t\trender: item => {\n\t\t\t\tconst disabled = nonDeletableProperties.includes(item.key);\n\t\t\t\tif (hasDeleteProperty) {\n\t\t\t\t\tconst button = (\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tnaked\n\t\t\t\t\t\t\ttitle={{\n\t\t\t\t\t\t\t\tid: 'properties.tableHeaders.deleteProperty',\n\t\t\t\t\t\t\t\tdefaultValue: 'Delete this Property',\n\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\tonClick={() => onDeleteProperty(item)}\n\t\t\t\t\t\t\tdisabled={disabled}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<Icon del />\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t);\n\t\t\t\t\tif (disabled) {\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t<Bubble\n\t\t\t\t\t\t\t\tcontent={\n\t\t\t\t\t\t\t\t\t<Trans i18nKey=\"properties.tableHeaders.reserved\">{`This property is reserved and can't be deleted`}</Trans>\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{button}\n\t\t\t\t\t\t\t</Bubble>\n\t\t\t\t\t\t);\n\t\t\t\t\t} else {\n\t\t\t\t\t\treturn button;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\t\t\t},\n\t\t},\n\t];\n}\n","import {type ComponentType, useCallback, useContext, useEffect, useState} from 'react';\n\nimport {deleteProperty, type PaginationSettings, type Property} from '@deviceinsight/ng-ui-api-client';\nimport {type ConfirmProps, withConfirm} from '@deviceinsight/ng-ui-basic-components';\nimport {ContentHeader} from '@deviceinsight/ng-ui-components';\n\nimport {ReactableClientSidePaginationWithSizeSave} from 'components/reactable/ReactableClientSidePaginationWithSizeSave';\nimport {GlobalResourcesContext} from 'contexts/globalResources/GlobalResourcesContext';\nimport {Trans, useTranslation} from 'i18n';\nimport {SidebarElementsCreateButton} from '../../utils/portalAdminUtils';\nimport {getColumnDefs} from './columnDefs/properties';\n\nconst INITIAL_PAGINATION_SETTINGS: PaginationSettings = {\n\tpage: 0,\n\tsize: 15,\n\tsort: {\n\t\tproperty: 'key',\n\t\tdirection: 'ASC',\n\t},\n};\n\nconst PropertiesList = ({confirm}: ConfirmProps) => {\n\tconst {properties, reloadProperties} = useContext(GlobalResourcesContext);\n\tconst [loading, setLoading] = useState<boolean>(false);\n\tconst {t} = useTranslation();\n\tconst tooltip = <Trans i18nKey=\"portalAdmin.sidebarElements.properties.create\">Create new property</Trans>;\n\n\tconst fetchProperties = useCallback(async () => {\n\t\ttry {\n\t\t\tsetLoading(true);\n\t\t\tawait reloadProperties();\n\t\t} finally {\n\t\t\tsetLoading(false);\n\t\t}\n\t}, [reloadProperties]);\n\n\tuseEffect(() => {\n\t\tfetchProperties();\n\t}, [fetchProperties]);\n\n\tasync function handleDeleteProperty(property: Property) {\n\t\tawait confirm(\n\t\t\t{\n\t\t\t\tid: 'properties.confirmDeletePropertyTitle',\n\t\t\t\tdefaultValue: 'Delete Property',\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: 'properties.confirmDeletePropertyMessage',\n\t\t\t\tdefaultValue: 'Do you really want to delete this Property?',\n\t\t\t},\n\t\t);\n\t\tsetLoading(true);\n\t\tawait deleteProperty(property);\n\t\tawait fetchProperties();\n\t}\n\n\treturn (\n\t\t<div data-testid=\"properties-list\">\n\t\t\t<ContentHeader\n\t\t\t\ttitle={{\n\t\t\t\t\tid: 'route.label.properties.name',\n\t\t\t\t\tdefaultValue: 'Properties',\n\t\t\t\t}}\n\t\t\t/>\n\t\t\t<SidebarElementsCreateButton\n\t\t\t\ttooltip={tooltip}\n\t\t\t\tauthorities=\"CREATE_PROPERTY\"\n\t\t\t\tpath=\"properties/create\"\n\t\t\t\tdataTestId=\"create-property-button\"\n\t\t\t/>\n\t\t\t<ReactableClientSidePaginationWithSizeSave\n\t\t\t\tcolumnDefs={getColumnDefs(t, handleDeleteProperty)}\n\t\t\t\titems={properties}\n\t\t\t\tisLoading={loading}\n\t\t\t\tuniqueItemKey={item => item.key}\n\t\t\t\tpaginationSettings={INITIAL_PAGINATION_SETTINGS}\n\t\t\t\tdata-testid=\"properties-table\"\n\t\t\t\ttableName={'properties'}\n\t\t\t/>\n\t\t</div>\n\t);\n};\n\nexport default withConfirm(PropertiesList) as ComponentType;\n"],"names":["nonDeletableProperties","getColumnDefs","t","onDeleteProperty","hasDeleteProperty","hasAuthorities","jsx","Trans","item","value","Link","disabled","button","Button","Icon","Bubble","INITIAL_PAGINATION_SETTINGS","PropertiesList","confirm","properties","reloadProperties","useContext","GlobalResourcesContext","loading","setLoading","useState","useTranslation","tooltip","fetchProperties","useCallback","useEffect","handleDeleteProperty","property","deleteProperty","jsxs","ContentHeader","SidebarElementsCreateButton","ReactableClientSidePaginationWithSizeSave","PropertiesList_default","withConfirm"],"mappings":";;;;;;;;AASA,MAAMA,IAAyB;AAAA,EAC9B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;A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Defs/properties.tsx","../ng-ui-scale/src/modules/properties/PropertiesList.tsx"],"sourcesContent":["import {Link} from 'react-router-dom';\n\nimport type {EntityTarget, Property} from '@deviceinsight/ng-ui-api-client';\nimport {Bubble, Button, Icon} from '@deviceinsight/ng-ui-basic-components';\nimport type {ReactableColumnDef} from '@deviceinsight/ng-ui-components';\n\nimport {type TFunction, Trans} from 'i18n';\nimport {hasAuthorities} from 'utils/hasAuthorities';\n\nconst nonDeletableProperties = [\n\t'name',\n\t'urn',\n\t'parentId',\n\t'createdAt',\n\t'assetGroupId',\n\t'accountNumber',\n\t'username',\n\t'emailAddress',\n\t'accountGroupId',\n\t'assetGroupDefinitionId',\n\t'description',\n\t'locale',\n\t'timezone',\n\t'state',\n\t'transitiveAssetGroupId',\n\t'transitiveAssetGroupDefinitionId',\n\t'isGateway',\n\t'gatewayId',\n\t'roleId',\n\t'displayName',\n\t'definitionId',\n];\n\nexport function getColumnDefs(\n\tt: TFunction,\n\tonDeleteProperty: (arg0: Property) => any,\n): Array<ReactableColumnDef<Property>> {\n\tconst hasDeleteProperty = hasAuthorities(['DELETE_PROPERTY'] as string[]);\n\treturn [\n\t\t{\n\t\t\tname: 'propertyKey',\n\t\t\tlabel: <Trans i18nKey=\"properties.tableHeaders.key\">Property</Trans>,\n\t\t\tsortable: true,\n\t\t\tfilterable: {\n\t\t\t\tfilterType: 'text',\n\t\t\t\tfilterFn: (item: Property, value: string) => item.key.toLowerCase().indexOf(value.toLowerCase()) >= 0,\n\t\t\t},\n\t\t\trender: item => (\n\t\t\t\t<Link\n\t\t\t\t\tto={`properties/${item.key}`}\n\t\t\t\t\t// @ts-expect-error state does not exists in the Link definition\n\t\t\t\t\tstate={item}\n\t\t\t\t>\n\t\t\t\t\t{item.key}\n\t\t\t\t</Link>\n\t\t\t),\n\t\t},\n\t\t{\n\t\t\tname: 'propertyType',\n\t\t\tlabel: <Trans i18nKey=\"properties.tableHeaders.type\">Type</Trans>,\n\t\t\twidth: '10%',\n\t\t\tfilterable: {\n\t\t\t\tfilterType: 'options',\n\t\t\t\tfilterOptions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tvalue: 'STRING',\n\t\t\t\t\t\tlabel: {\n\t\t\t\t\t\t\tid: 'string',\n\t\t\t\t\t\t\tdefaultValue: 'String',\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tvalue: 'TEXT',\n\t\t\t\t\t\tlabel: {\n\t\t\t\t\t\t\tid: 'text',\n\t\t\t\t\t\t\tdefaultValue: 'Text',\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tvalue: 'DATE',\n\t\t\t\t\t\tlabel: {\n\t\t\t\t\t\t\tid: 'date',\n\t\t\t\t\t\t\tdefaultValue: 'Date',\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tvalue: 'LONG',\n\t\t\t\t\t\tlabel: {\n\t\t\t\t\t\t\tid: 'long',\n\t\t\t\t\t\t\tdefaultValue: 'Long',\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tvalue: 'DOUBLE',\n\t\t\t\t\t\tlabel: {\n\t\t\t\t\t\t\tid: 'double',\n\t\t\t\t\t\t\tdefaultValue: 'Double',\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tvalue: 'BOOLEAN',\n\t\t\t\t\t\tlabel: {\n\t\t\t\t\t\t\tid: 'boolean',\n\t\t\t\t\t\t\tdefaultValue: 'Boolean',\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tvalue: 'IP',\n\t\t\t\t\t\tlabel: {\n\t\t\t\t\t\t\tid: 'ip',\n\t\t\t\t\t\t\tdefaultValue: 'Ip',\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tvalue: 'GEO',\n\t\t\t\t\t\tlabel: {\n\t\t\t\t\t\t\tid: 'geo',\n\t\t\t\t\t\t\tdefaultValue: 'Geo',\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\tfilterFn: (item: Property, value: string) => item.type === value,\n\t\t\t},\n\t\t\trender: item => item.type,\n\t\t},\n\t\t{\n\t\t\tname: 'propertyEntityTargets',\n\t\t\tlabel: <Trans i18nKey=\"properties.tableHeaders.entityTargets\">Scope</Trans>,\n\t\t\twidth: '30%',\n\t\t\tfilterable: {\n\t\t\t\tfilterType: 'options',\n\t\t\t\tfilterOptions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tvalue: 'DATAPOINT',\n\t\t\t\t\t\tlabel: {\n\t\t\t\t\t\t\tid: 'properties.filterOptions.datapoint',\n\t\t\t\t\t\t\tdefaultValue: 'Datapoint',\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tvalue: 'ASSET',\n\t\t\t\t\t\tlabel: {\n\t\t\t\t\t\t\tid: 'properties.filterOptions.asset',\n\t\t\t\t\t\t\tdefaultValue: 'Asset',\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tvalue: 'ASSET_GROUP',\n\t\t\t\t\t\tlabel: {\n\t\t\t\t\t\t\tid: 'properties.filterOptions.assetGroup',\n\t\t\t\t\t\t\tdefaultValue: 'Asset Group',\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tvalue: 'ACCOUNT',\n\t\t\t\t\t\tlabel: {\n\t\t\t\t\t\t\tid: 'properties.filterOptions.account',\n\t\t\t\t\t\t\tdefaultValue: 'Account',\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tvalue: 'ACCOUNT_GROUP',\n\t\t\t\t\t\tlabel: {\n\t\t\t\t\t\t\tid: 'properties.filterOptions.accountGroup',\n\t\t\t\t\t\t\tdefaultValue: 'Account Group',\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\tfilterFn: (item: Property, value: string) => item.entityTargets.includes(value as EntityTarget),\n\t\t\t},\n\t\t\trender: item => [...item.entityTargets].sort().join(', '),\n\t\t},\n\t\t{\n\t\t\tname: 'actions',\n\t\t\tlabel: '',\n\t\t\twidth: '10%',\n\t\t\talign: 'right',\n\t\t\trender: item => {\n\t\t\t\tconst disabled = nonDeletableProperties.includes(item.key);\n\t\t\t\tif (hasDeleteProperty) {\n\t\t\t\t\tconst button = (\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tnaked\n\t\t\t\t\t\t\ttitle={{\n\t\t\t\t\t\t\t\tid: 'properties.tableHeaders.deleteProperty',\n\t\t\t\t\t\t\t\tdefaultValue: 'Delete this Property',\n\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\tonClick={() => onDeleteProperty(item)}\n\t\t\t\t\t\t\tdisabled={disabled}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<Icon del />\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t);\n\t\t\t\t\tif (disabled) {\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t<Bubble\n\t\t\t\t\t\t\t\tcontent={\n\t\t\t\t\t\t\t\t\t<Trans i18nKey=\"properties.tableHeaders.reserved\">{`This property is reserved and can't be deleted`}</Trans>\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{button}\n\t\t\t\t\t\t\t</Bubble>\n\t\t\t\t\t\t);\n\t\t\t\t\t} else {\n\t\t\t\t\t\treturn button;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\t\t\t},\n\t\t},\n\t];\n}\n","import {type ComponentType, useCallback, useContext, useEffect, useState} from 'react';\n\nimport {deleteProperty, type PaginationSettings, type Property} from '@deviceinsight/ng-ui-api-client';\nimport {type ConfirmProps, withConfirm} from '@deviceinsight/ng-ui-basic-components';\nimport {ContentHeader} from '@deviceinsight/ng-ui-components';\n\nimport {ReactableClientSidePaginationWithSizeSave} from 'components/reactable/ReactableClientSidePaginationWithSizeSave';\nimport {GlobalResourcesContext} from 'contexts/globalResources/GlobalResourcesContext';\nimport {Trans, useTranslation} from 'i18n';\nimport {SidebarElementsCreateButton} from '../../utils/portalAdminUtils';\nimport {getColumnDefs} from './columnDefs/properties';\n\nconst INITIAL_PAGINATION_SETTINGS: PaginationSettings = {\n\tpage: 0,\n\tsize: 15,\n\tsort: {\n\t\tproperty: 'key',\n\t\tdirection: 'ASC',\n\t},\n};\n\nconst PropertiesList = ({confirm}: ConfirmProps) => {\n\tconst {properties, reloadProperties} = useContext(GlobalResourcesContext);\n\tconst [loading, setLoading] = useState<boolean>(false);\n\tconst {t} = useTranslation();\n\tconst tooltip = <Trans i18nKey=\"portalAdmin.sidebarElements.properties.create\">Create new property</Trans>;\n\n\tconst fetchProperties = useCallback(async () => {\n\t\ttry {\n\t\t\tsetLoading(true);\n\t\t\tawait reloadProperties();\n\t\t} finally {\n\t\t\tsetLoading(false);\n\t\t}\n\t}, [reloadProperties]);\n\n\tuseEffect(() => {\n\t\tfetchProperties();\n\t}, [fetchProperties]);\n\n\tasync function handleDeleteProperty(property: Property) {\n\t\tawait confirm(\n\t\t\t{\n\t\t\t\tid: 'properties.confirmDeletePropertyTitle',\n\t\t\t\tdefaultValue: 'Delete Property',\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: 'properties.confirmDeletePropertyMessage',\n\t\t\t\tdefaultValue: 'Do you really want to delete this Property?',\n\t\t\t},\n\t\t);\n\t\tsetLoading(true);\n\t\tawait deleteProperty(property);\n\t\tawait fetchProperties();\n\t}\n\n\treturn (\n\t\t<div data-testid=\"properties-list\">\n\t\t\t<ContentHeader\n\t\t\t\ttitle={{\n\t\t\t\t\tid: 'route.label.properties.name',\n\t\t\t\t\tdefaultValue: 'Properties',\n\t\t\t\t}}\n\t\t\t/>\n\t\t\t<SidebarElementsCreateButton\n\t\t\t\ttooltip={tooltip}\n\t\t\t\tauthorities=\"CREATE_PROPERTY\"\n\t\t\t\tpath=\"properties/create\"\n\t\t\t\tdataTestId=\"create-property-button\"\n\t\t\t/>\n\t\t\t<ReactableClientSidePaginationWithSizeSave\n\t\t\t\tcolumnDefs={getColumnDefs(t, handleDeleteProperty)}\n\t\t\t\titems={properties}\n\t\t\t\tisLoading={loading}\n\t\t\t\tuniqueItemKey={item => item.key}\n\t\t\t\tpaginationSettings={INITIAL_PAGINATION_SETTINGS}\n\t\t\t\tdata-testid=\"properties-table\"\n\t\t\t\ttableName={'properties'}\n\t\t\t/>\n\t\t</div>\n\t);\n};\n\nexport default withConfirm(PropertiesList) as ComponentType;\n"],"names":["nonDeletableProperties","getColumnDefs","t","onDeleteProperty","hasDeleteProperty","hasAuthorities","jsx","Trans","item","value","Link","disabled","button","Button","Icon","Bubble","INITIAL_PAGINATION_SETTINGS","PropertiesList","confirm","properties","reloadProperties","useContext","GlobalResourcesContext","loading","setLoading","useState","useTranslation","tooltip","fetchProperties","useCallback","useEffect","handleDeleteProperty","property","deleteProperty","jsxs","ContentHeader","SidebarElementsCreateButton","ReactableClientSidePaginationWithSizeSave","PropertiesList_default","withConfirm"],"mappings":";;;;;;;;AASA,MAAMA,IAAyB;AAAA,EAC9B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD;AAEO,SAASC,EACfC,GACAC,GACsC;AACtC,QAAMC,IAAoBC,EAAe,CAAC,iBAAiB,CAAa;AACxE,SAAO;AAAA,IACN;AAAA,MACC,MAAM;AAAA,MACN,OAAO,gBAAAC,EAACC,GAAA,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EpB,iBAAeG,EAAqBC,GAAoB;AACvD,UAAMd;AAAA,MACL;AAAA,QACC,IAAI;AAAA,QACJ,cAAc;AAAA,MAAA;AAAA,MAEf;AAAA,QACC,IAAI;AAAA,QACJ,cAAc;AAAA,MAAA;AAAA,IACf,GAEDM,EAAW,EAAI,GACf,MAAMS,EAAeD,CAAQ,GAC7B,MAAMJ,EAAA;AAAA,EACP;AAEA,SACC,gBAAAM,EAAC,OAAA,EAAI,eAAY,mBAChB,UAAA;AAAA,IAAA,gBAAA5B;AAAA,MAAC6B;AAAA,MAAA;AAAA,QACA,OAAO;AAAA,UACN,IAAI;AAAA,UACJ,cAAc;AAAA,QAAA;AAAA,MACf;AAAA,IAAA;AAAA,IAED,gBAAA7B;AAAA,MAAC8B;AAAA,MAAA;AAAA,QACA,SAAAT;AAAA,QACA,aAAY;AAAA,QACZ,MAAK;AAAA,QACL,YAAW;AAAA,MAAA;AAAA,IAAA;AAAA,IAEZ,gBAAArB;AAAA,MAAC+B;AAAA,MAAA;AAAA,QACA,YAAYpC,EAAcC,GAAG6B,CAAoB;AAAA,QACjD,OAAOZ;AAAA,QACP,WAAWI;AAAA,QACX,eAAe,OAAQf,EAAK;AAAA,QAC5B,oBAAoBQ;AAAA,QACpB,eAAY;AAAA,QACZ,WAAW;AAAA,MAAA;AAAA,IAAA;AAAA,EACZ,GACD;AAEF,GAEAsB,IAAeC,EAAYtB,CAAc;"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { jsx as e, jsxs as v } from "react/jsx-runtime";
|
|
2
2
|
import { useState as w, useRef as R, lazy as B, useContext as $, useEffect as V } from "react";
|
|
3
3
|
import { Prompt as M, useParams as U, useHistory as z, useLocation as H } from "react-router-dom";
|
|
4
|
-
import { fetchEmailTemplateById as
|
|
5
|
-
import { Modal as O, Button as x, ButtonRow as ee, useConfirm as te, Accordion as ae, AccordionItem as ne, Icon as
|
|
6
|
-
import { ReactableWithClientSidePagination as W, nanoid10 as oe, messageBoxError as
|
|
7
|
-
import { a as s,
|
|
4
|
+
import { fetchEmailTemplateById as Q, fetchEmailTemplates as J, createEmailTemplate as X, updateEmailTemplate as Y, deleteEmailTemplate as Z } from "@deviceinsight/ng-ui-api-client";
|
|
5
|
+
import { Modal as O, Button as x, ButtonRow as ee, useConfirm as te, Accordion as ae, AccordionItem as ne, Icon as K, SpinnerContainer as ie } from "@deviceinsight/ng-ui-basic-components";
|
|
6
|
+
import { ReactableWithClientSidePagination as W, nanoid10 as oe, messageBoxError as E, ContentHeader as le } from "@deviceinsight/ng-ui-components";
|
|
7
|
+
import { a as s, b_ as N, aO as re, u as j, b$ as se, c0 as ce, Q as q, G as de, aD as me, b9 as ue, U as fe } from "./setTitle-Cyf8DxtL.js";
|
|
8
8
|
import { useFormContext as _, Controller as F, useForm as pe, FormProvider as he } from "react-hook-form";
|
|
9
9
|
import "react-i18next";
|
|
10
|
-
import { A as be } from "./AccessEditModal-
|
|
10
|
+
import { A as be } from "./AccessEditModal-EVgqtRQn.js";
|
|
11
11
|
const Te = (t) => [
|
|
12
12
|
{
|
|
13
13
|
name: "locale",
|
|
@@ -103,7 +103,7 @@ const Pe = (t, a) => [
|
|
|
103
103
|
width: 600
|
|
104
104
|
}
|
|
105
105
|
);
|
|
106
|
-
}, G = B(() => import("./TemplateTextInput-
|
|
106
|
+
}, G = B(() => import("./TemplateTextInput-EDyDopjf.js")), Ne = (t, a) => t.locale === "default" ? -1 : a.locale === "default" ? 1 : t.locale.localeCompare(a.locale);
|
|
107
107
|
function we() {
|
|
108
108
|
const t = te(), [a, n] = w(!1), [c, o] = w("message"), {
|
|
109
109
|
watch: u,
|
|
@@ -158,7 +158,7 @@ function we() {
|
|
|
158
158
|
disabled: m === "default",
|
|
159
159
|
onClick: () => r(m),
|
|
160
160
|
"data-testid": "delete-locale-button",
|
|
161
|
-
children: /* @__PURE__ */ e(
|
|
161
|
+
children: /* @__PURE__ */ e(K, { del: !0, large: !0 })
|
|
162
162
|
}
|
|
163
163
|
)
|
|
164
164
|
],
|
|
@@ -183,7 +183,7 @@ function we() {
|
|
|
183
183
|
}) : void 0,
|
|
184
184
|
label: /* @__PURE__ */ e(s, { i18nKey: "notificationTemplate.form.subject", children: "Subject" }),
|
|
185
185
|
required: !0,
|
|
186
|
-
refField: (
|
|
186
|
+
refField: (D) => k.current = D
|
|
187
187
|
}
|
|
188
188
|
)
|
|
189
189
|
}
|
|
@@ -212,7 +212,7 @@ function we() {
|
|
|
212
212
|
defaultValue: "Please input message"
|
|
213
213
|
}) : void 0,
|
|
214
214
|
label: P,
|
|
215
|
-
refField: (
|
|
215
|
+
refField: (D) => d.current = D,
|
|
216
216
|
renderAs: "textarea",
|
|
217
217
|
required: !0
|
|
218
218
|
}
|
|
@@ -223,7 +223,7 @@ function we() {
|
|
|
223
223
|
)
|
|
224
224
|
] }),
|
|
225
225
|
/* @__PURE__ */ e("div", { className: "notification-content-variables-wrapper", children: /* @__PURE__ */ v(x, { naked: !0, onClick: g, "data-testid": "add-button", children: [
|
|
226
|
-
/* @__PURE__ */ e(
|
|
226
|
+
/* @__PURE__ */ e(K, { add: !0 }),
|
|
227
227
|
/* @__PURE__ */ e("span", { children: /* @__PURE__ */ e(s, { i18nKey: "notificationTemplate.form.addVariables", children: "Add variables..." }) })
|
|
228
228
|
] }) })
|
|
229
229
|
] })
|
|
@@ -323,7 +323,7 @@ function Ve({ onCancel: t, onSubmit: a, editedTemplateData: n }) {
|
|
|
323
323
|
disabled: !P().length,
|
|
324
324
|
naked: !0,
|
|
325
325
|
children: [
|
|
326
|
-
/* @__PURE__ */ e(
|
|
326
|
+
/* @__PURE__ */ e(K, { add: !0 }),
|
|
327
327
|
/* @__PURE__ */ e("span", { children: /* @__PURE__ */ e(s, { i18nKey: "notificationTemplate.form.addLocale", children: "Add locale..." }) })
|
|
328
328
|
]
|
|
329
329
|
}
|
|
@@ -364,7 +364,7 @@ function Fe() {
|
|
|
364
364
|
}
|
|
365
365
|
(async () => {
|
|
366
366
|
try {
|
|
367
|
-
const f = await
|
|
367
|
+
const f = await Q(parseInt(t)), k = (await J({
|
|
368
368
|
name: f.name,
|
|
369
369
|
page: 0,
|
|
370
370
|
size: 2e3
|
|
@@ -393,14 +393,14 @@ function Fe() {
|
|
|
393
393
|
};
|
|
394
394
|
}
|
|
395
395
|
function Le(t) {
|
|
396
|
-
return t.map((a) => Q(a));
|
|
397
|
-
}
|
|
398
|
-
function Ie(t) {
|
|
399
396
|
return t.map((a) => X(a));
|
|
400
397
|
}
|
|
401
|
-
function
|
|
398
|
+
function Ie(t) {
|
|
402
399
|
return t.map((a) => Y(a));
|
|
403
400
|
}
|
|
401
|
+
function De(t) {
|
|
402
|
+
return t.map((a) => Z(a));
|
|
403
|
+
}
|
|
404
404
|
function A(t, a) {
|
|
405
405
|
const { name: n, displayName: c, accountGroupsWithAccess: o } = a, u = a.locales.find((y) => y.locale === t);
|
|
406
406
|
if (!u)
|
|
@@ -417,17 +417,17 @@ function A(t, a) {
|
|
|
417
417
|
scope: "CONDITION_MONITORING"
|
|
418
418
|
};
|
|
419
419
|
}
|
|
420
|
-
function
|
|
420
|
+
function Ee(t, a, n) {
|
|
421
421
|
return {
|
|
422
422
|
id: t,
|
|
423
423
|
...A(a, n)
|
|
424
424
|
};
|
|
425
425
|
}
|
|
426
|
-
const
|
|
426
|
+
const Ke = (t, a) => t.subject !== a.subject || t.text !== a.text;
|
|
427
427
|
function Me() {
|
|
428
428
|
const { t } = j(), { setContextInfo: a } = $(me), n = z(), { pathname: c } = H(), { initialFormData: o, error: u, loading: h } = Fe();
|
|
429
429
|
async function f(l, r, g) {
|
|
430
|
-
const T = Le(l), b = Ie(r), m =
|
|
430
|
+
const T = Le(l), b = Ie(r), m = De(g);
|
|
431
431
|
await Promise.all([...T, ...b, ...m]);
|
|
432
432
|
}
|
|
433
433
|
function y(l) {
|
|
@@ -447,13 +447,13 @@ function Me() {
|
|
|
447
447
|
const p = T.find(
|
|
448
448
|
(S) => S.locale === i.locale
|
|
449
449
|
);
|
|
450
|
-
return p &&
|
|
450
|
+
return p && Ke(p, i);
|
|
451
451
|
}) : r.filter(
|
|
452
452
|
(i) => T.some((p) => p.locale === i.locale)
|
|
453
453
|
);
|
|
454
454
|
return f(
|
|
455
455
|
m.map(({ locale: i }) => A(i, l)),
|
|
456
|
-
P.map(({ locale: i, id: p }) =>
|
|
456
|
+
P.map(({ locale: i, id: p }) => Ee(p, i, l)),
|
|
457
457
|
b.map(({ id: i }) => i)
|
|
458
458
|
);
|
|
459
459
|
}
|
|
@@ -461,9 +461,9 @@ function Me() {
|
|
|
461
461
|
try {
|
|
462
462
|
o ? await C(l) : await y(l), d();
|
|
463
463
|
} catch (r) {
|
|
464
|
-
console.error("An error occured while trying to submit the template(s): ", r), r.response && r.response.status === 400 ?
|
|
464
|
+
console.error("An error occured while trying to submit the template(s): ", r), r.response && r.response.status === 400 ? E(
|
|
465
465
|
/* @__PURE__ */ e(s, { i18nKey: "notificationTemplates.form.nameOccupied", children: "Template with this name already exists" })
|
|
466
|
-
) :
|
|
466
|
+
) : E(/* @__PURE__ */ e(s, { i18nKey: "notificationTemplates.form.unknownError", children: "Unknown error occured" }));
|
|
467
467
|
}
|
|
468
468
|
}
|
|
469
469
|
function d() {
|
|
@@ -476,7 +476,7 @@ function Me() {
|
|
|
476
476
|
pathname: c
|
|
477
477
|
});
|
|
478
478
|
}, [o, c, a]), V(() => () => a(), [a]), V(() => {
|
|
479
|
-
u && (console.error(u),
|
|
479
|
+
u && (console.error(u), E(
|
|
480
480
|
/* @__PURE__ */ e(s, { i18nKey: "notificationTemplates.form.fetchFailed", children: "An error occurred while trying to fetch the template(s)" })
|
|
481
481
|
));
|
|
482
482
|
}, [u]), u ? /* @__PURE__ */ e(ue, {}) : /* @__PURE__ */ v(ie, { show: h, children: [
|
|
@@ -505,4 +505,4 @@ function Me() {
|
|
|
505
505
|
export {
|
|
506
506
|
Me as default
|
|
507
507
|
};
|
|
508
|
-
//# sourceMappingURL=TemplateEditPage-
|
|
508
|
+
//# sourceMappingURL=TemplateEditPage-BeV5ZSVV.js.map
|