@nestledjs/data-browser 0.1.23 → 0.1.25
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.
|
@@ -279,8 +279,14 @@ function AdminDataEditPageContent({ model, id, basePath, formTheme }) {
|
|
|
279
279
|
var _a;
|
|
280
280
|
let value = item[field.name];
|
|
281
281
|
if (field.relationName && !field.isList) {
|
|
282
|
-
const relationFieldName = ((_a = field.relationFromFields) == null ? void 0 : _a[0]) || field.name
|
|
282
|
+
const relationFieldName = ((_a = field.relationFromFields) == null ? void 0 : _a[0]) || `${field.name}Id`;
|
|
283
283
|
value = item[relationFieldName];
|
|
284
|
+
if (value === void 0) {
|
|
285
|
+
const relationObject = item[field.name];
|
|
286
|
+
if (relationObject && typeof relationObject === "object" && relationObject.id) {
|
|
287
|
+
value = relationObject.id;
|
|
288
|
+
}
|
|
289
|
+
}
|
|
284
290
|
if (value && typeof value === "object") {
|
|
285
291
|
value = value.id || "";
|
|
286
292
|
}
|
|
@@ -137,8 +137,8 @@ function AdminDataListPage({ modelName: propModelName } = {}) {
|
|
|
137
137
|
return (model == null ? void 0 : model.pluralModelPropertyName) || pluralParam.replace(/-([a-z])/g, (_, letter) => letter.toUpperCase());
|
|
138
138
|
}, [model, pluralParam]);
|
|
139
139
|
const paginationPath = useMemo(() => {
|
|
140
|
-
return
|
|
141
|
-
}, [
|
|
140
|
+
return "counters";
|
|
141
|
+
}, []);
|
|
142
142
|
const fieldNames = useMemo(() => {
|
|
143
143
|
if (!model) return [];
|
|
144
144
|
return model.fields.filter((field) => !field.relationName || !field.isList).map((field) => field.name);
|
|
@@ -185,8 +185,14 @@ function buildFormFields(sdk, model, operation, currentItem, isSubmitting, baseP
|
|
|
185
185
|
break;
|
|
186
186
|
}
|
|
187
187
|
if (field.relationName && !field.isList) {
|
|
188
|
-
const relationFieldName = ((_a = field.relationFromFields) == null ? void 0 : _a[0]) || field.name
|
|
188
|
+
const relationFieldName = ((_a = field.relationFromFields) == null ? void 0 : _a[0]) || `${field.name}Id`;
|
|
189
189
|
let relationValue = currentItem && operation === "update" ? currentItem[relationFieldName] : void 0;
|
|
190
|
+
if (relationValue === void 0 && currentItem && operation === "update") {
|
|
191
|
+
const relationObject = currentItem[field.name];
|
|
192
|
+
if (relationObject && typeof relationObject === "object" && relationObject.id) {
|
|
193
|
+
relationValue = relationObject.id;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
190
196
|
if (relationValue && typeof relationValue === "object" && relationValue.id) {
|
|
191
197
|
relationValue = relationValue.id;
|
|
192
198
|
}
|
|
@@ -423,9 +429,7 @@ function cleanFormInput(input, model) {
|
|
|
423
429
|
if (typeof value === "string") {
|
|
424
430
|
const field = (_c = model == null ? void 0 : model.fields) == null ? void 0 : _c.find((f) => f.name === key);
|
|
425
431
|
const convertedValue = convertStringValue(value, field);
|
|
426
|
-
|
|
427
|
-
cleaned[key] = convertedValue;
|
|
428
|
-
}
|
|
432
|
+
cleaned[key] = convertedValue;
|
|
429
433
|
continue;
|
|
430
434
|
}
|
|
431
435
|
if (typeof value === "object" && value !== null && !Array.isArray(value)) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nestledjs/data-browser",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.25",
|
|
4
4
|
"description": "Universal admin data browser for Nestled framework projects with full CRUD operations",
|
|
5
5
|
"main": "./index.js",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"@apollo/client": "^4.0.0",
|
|
39
39
|
"@heroicons/react": "^2.0.0",
|
|
40
40
|
"@nestledjs/forms": "^0.5.0",
|
|
41
|
-
"@nestledjs/shared-components": "^0.1.
|
|
41
|
+
"@nestledjs/shared-components": "^0.1.25",
|
|
42
42
|
"react": "^19.0.0",
|
|
43
43
|
"react-router": "^7.0.0"
|
|
44
44
|
},
|