@nestledjs/data-browser 0.1.23 → 0.1.24

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
  }
@@ -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
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nestledjs/data-browser",
3
- "version": "0.1.23",
3
+ "version": "0.1.24",
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.23",
41
+ "@nestledjs/shared-components": "^0.1.24",
42
42
  "react": "^19.0.0",
43
43
  "react-router": "^7.0.0"
44
44
  },