@nestledjs/data-browser 0.1.22 → 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
|
}
|
|
@@ -355,18 +361,21 @@ function AdminDataEditPageContent({ model, id, basePath, formTheme }) {
|
|
|
355
361
|
status: "error",
|
|
356
362
|
message: result.errors.map((err) => err.message).join(", ")
|
|
357
363
|
});
|
|
364
|
+
window.scrollTo({ top: 0, behavior: "smooth" });
|
|
358
365
|
return;
|
|
359
366
|
}
|
|
360
367
|
setSubmissionState({
|
|
361
368
|
status: "success",
|
|
362
369
|
message: `${toReadableText(model.name)} updated successfully!`
|
|
363
370
|
});
|
|
371
|
+
window.scrollTo({ top: 0, behavior: "smooth" });
|
|
364
372
|
await refetch();
|
|
365
373
|
} catch (error2) {
|
|
366
374
|
setSubmissionState({
|
|
367
375
|
status: "error",
|
|
368
376
|
message: error2 instanceof Error ? error2.message : "An unexpected error occurred"
|
|
369
377
|
});
|
|
378
|
+
window.scrollTo({ top: 0, behavior: "smooth" });
|
|
370
379
|
}
|
|
371
380
|
};
|
|
372
381
|
const handleDelete = async () => {
|
|
@@ -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
|
}
|
|
@@ -375,6 +381,7 @@ function shouldSkipValue(key, value) {
|
|
|
375
381
|
return SYSTEM_FIELDS.has(key) || value === void 0;
|
|
376
382
|
}
|
|
377
383
|
function convertStringValue(value, field) {
|
|
384
|
+
var _a;
|
|
378
385
|
if (value === "") {
|
|
379
386
|
return null;
|
|
380
387
|
}
|
|
@@ -388,11 +395,15 @@ function convertStringValue(value, field) {
|
|
|
388
395
|
}
|
|
389
396
|
if (value === "true") return true;
|
|
390
397
|
if (value === "false") return false;
|
|
391
|
-
const
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
398
|
+
const fieldType = (_a = field == null ? void 0 : field.type) == null ? void 0 : _a.toLowerCase();
|
|
399
|
+
const isNumericField = fieldType && ["int", "bigint", "float", "decimal"].includes(fieldType);
|
|
400
|
+
if (isNumericField) {
|
|
401
|
+
const numericPattern = /^-?\d+(\.\d+)?$/;
|
|
402
|
+
if (numericPattern.test(value)) {
|
|
403
|
+
const numericValue = Number(value);
|
|
404
|
+
if (!isNaN(numericValue)) {
|
|
405
|
+
return numericValue;
|
|
406
|
+
}
|
|
396
407
|
}
|
|
397
408
|
}
|
|
398
409
|
return 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.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.
|
|
41
|
+
"@nestledjs/shared-components": "^0.1.24",
|
|
42
42
|
"react": "^19.0.0",
|
|
43
43
|
"react-router": "^7.0.0"
|
|
44
44
|
},
|