tycho-components 0.0.18-SNAPSHOT-5 → 0.0.18-SNAPSHOT-7
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.
|
@@ -19,6 +19,7 @@ const formatDate = (date, fmt) => {
|
|
|
19
19
|
export default function AppEditable({ translation, fields, item, save, group, className, reference, }) {
|
|
20
20
|
const { t } = useTranslation([translation, 'common']);
|
|
21
21
|
const handleSave = useCallback((value, field) => {
|
|
22
|
+
console.log(value);
|
|
22
23
|
if (!save)
|
|
23
24
|
return;
|
|
24
25
|
save({
|
|
@@ -87,11 +88,16 @@ export default function AppEditable({ translation, fields, item, save, group, cl
|
|
|
87
88
|
return (_jsx(AppColorpicker, { item: item, field: field, handleSave: handleSave }));
|
|
88
89
|
case 'function':
|
|
89
90
|
return _jsx("span", { children: field.fn ? field.fn(getValue(field)) : '' });
|
|
91
|
+
case 'check':
|
|
92
|
+
return (_jsx(EasyEdit, { type: "checkbox", options: getLabelValueForList(field.options || []), onSave: (value) => handleSave(value, field), value: Array.isArray(getValue(field))
|
|
93
|
+
? getValue(field)
|
|
94
|
+
: [getValue(field)].filter(Boolean), hideCancelButton: true, ...sharedEditProps }));
|
|
90
95
|
default:
|
|
91
96
|
return null;
|
|
92
97
|
}
|
|
93
98
|
};
|
|
99
|
+
const getTranslation = (field) => field.translation ? field.translation : translation;
|
|
94
100
|
return (_jsx(_Fragment, { children: fields.map((field, idx) => (_jsxs("div", { className: `editable-container ${className || ''}`, children: [_jsxs("div", { className: "title", children: [_jsxs("h6", { children: [field.title
|
|
95
101
|
? field.title
|
|
96
|
-
: t(`${
|
|
102
|
+
: t(`${getTranslation(field)}:${group || ''}.field.${field.name}`), field.required && _jsx("span", { children: "*" })] }), field.tooltip && (_jsx(FontAwesomeIcon, { icon: faQuestionCircle, className: "info", title: t(`${getTranslation(field)}:${group || ''}.tooltip.${field.name}`) }))] }), renderField(field)] }, idx))) }));
|
|
97
103
|
}
|
|
@@ -11,5 +11,6 @@ export type FormField = {
|
|
|
11
11
|
default?: string | boolean | number;
|
|
12
12
|
role?: string;
|
|
13
13
|
fn?: (value: any) => string | number;
|
|
14
|
+
translation?: string;
|
|
14
15
|
};
|
|
15
16
|
export declare const validateFormField: (entity: Record<string, unknown>, fields: FormField[]) => FormField[];
|