@nestledjs/data-browser 1.0.12 → 1.0.14
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.
|
@@ -106,7 +106,6 @@ function extractInitialValues(model, item) {
|
|
|
106
106
|
if (!item) {
|
|
107
107
|
return initialValues;
|
|
108
108
|
}
|
|
109
|
-
console.log(`[DataBrowser] Extracting initial values for ${model.name}:`, item);
|
|
110
109
|
const idField = model.fields.find((f) => f.isId);
|
|
111
110
|
if (idField) {
|
|
112
111
|
initialValues[idField.name] = item[idField.name];
|
|
@@ -125,34 +124,20 @@ function extractInitialValues(model, item) {
|
|
|
125
124
|
initialValues[relationFieldName] = processRelationFieldValue(field, item);
|
|
126
125
|
} else {
|
|
127
126
|
const fieldTypeLower = field.type.toLowerCase();
|
|
128
|
-
if (
|
|
127
|
+
if (field.kind === "enum" && field.isList) {
|
|
128
|
+
if (!Array.isArray(value)) {
|
|
129
|
+
value = [];
|
|
130
|
+
}
|
|
131
|
+
value = value.join(",");
|
|
132
|
+
} else if (fieldTypeLower === "datetime" || fieldTypeLower === "date") {
|
|
129
133
|
value = processDateFieldValue(field, value);
|
|
130
134
|
} else {
|
|
131
135
|
value = sanitizeFieldValue(value, field);
|
|
132
136
|
}
|
|
133
|
-
if (field.kind === "enum" && field.isList && Array.isArray(value)) {
|
|
134
|
-
const arrayValue = value;
|
|
135
|
-
value = value.join(",");
|
|
136
|
-
console.log(`[DataBrowser] Enum array field detected - "${field.name}":`, {
|
|
137
|
-
type: field.type,
|
|
138
|
-
arrayValue,
|
|
139
|
-
convertedValue: value
|
|
140
|
-
});
|
|
141
|
-
}
|
|
142
137
|
initialValues[field.name] = value;
|
|
143
|
-
if (value !== null && typeof value === "string" && fieldTypeLower !== "string" && fieldTypeLower !== "datetime" && fieldTypeLower !== "date") {
|
|
144
|
-
console.log(`[DataBrowser] Enum field detected - "${field.name}":`, {
|
|
145
|
-
type: field.type,
|
|
146
|
-
kind: field.kind,
|
|
147
|
-
isList: field.isList,
|
|
148
|
-
extractedValue: value,
|
|
149
|
-
rawValue: item[field.name]
|
|
150
|
-
});
|
|
151
|
-
}
|
|
152
138
|
}
|
|
153
139
|
});
|
|
154
140
|
performFinalSafetyChecks(initialValues, model);
|
|
155
|
-
console.log(`[DataBrowser] Final initial values for ${model.name}:`, initialValues);
|
|
156
141
|
return initialValues;
|
|
157
142
|
}
|
|
158
143
|
const validateId = (id) => {
|
|
@@ -503,7 +488,6 @@ function AdminDataEditPageContent({ model, id, basePath, formTheme, displayField
|
|
|
503
488
|
});
|
|
504
489
|
const initialValues = extractInitialValues(model, item);
|
|
505
490
|
const handleSubmit = async (formData) => {
|
|
506
|
-
console.log(`[DataBrowser] Form submission for ${model.name}:`, formData);
|
|
507
491
|
setSubmissionState({ status: "loading" });
|
|
508
492
|
const result = await executeUpdateMutation(updateMutation, formData, model, id, idVariableName);
|
|
509
493
|
setSubmissionState({
|
|
@@ -512,9 +496,7 @@ function AdminDataEditPageContent({ model, id, basePath, formTheme, displayField
|
|
|
512
496
|
});
|
|
513
497
|
window.scrollTo({ top: 0, behavior: "smooth" });
|
|
514
498
|
if (result.success) {
|
|
515
|
-
|
|
516
|
-
const refetchResult = await refetch();
|
|
517
|
-
console.log(`[DataBrowser] Refetch complete for ${model.name}:`, refetchResult.data);
|
|
499
|
+
await refetch();
|
|
518
500
|
}
|
|
519
501
|
};
|
|
520
502
|
const handleDelete = async () => {
|
|
@@ -191,22 +191,11 @@ function buildFormFields(sdk, model, operation, options = {}) {
|
|
|
191
191
|
default: {
|
|
192
192
|
const enumValues = getEnumValues(sdk, field.type);
|
|
193
193
|
if (enumValues) {
|
|
194
|
-
console.log(`[DataBrowser] Building enum field "${field.name}":`, {
|
|
195
|
-
enumType: field.type,
|
|
196
|
-
availableValues: enumValues,
|
|
197
|
-
currentValue: initialValue,
|
|
198
|
-
operation,
|
|
199
|
-
isList: field.isList
|
|
200
|
-
});
|
|
201
194
|
if (field.isList) {
|
|
202
195
|
let defaultValue = "";
|
|
203
196
|
if (Array.isArray(initialValue) && initialValue.length > 0) {
|
|
204
197
|
defaultValue = initialValue.join(",");
|
|
205
198
|
}
|
|
206
|
-
console.log(`[DataBrowser] Array enum field "${field.name}" converted:`, {
|
|
207
|
-
arrayValue: initialValue,
|
|
208
|
-
stringValue: defaultValue
|
|
209
|
-
});
|
|
210
199
|
const checkboxOptions = enumValues.map((value) => ({
|
|
211
200
|
key: value,
|
|
212
201
|
value,
|
|
@@ -461,7 +450,6 @@ function processNestedObject(value, model) {
|
|
|
461
450
|
}
|
|
462
451
|
function cleanFormInput(input, model) {
|
|
463
452
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
464
|
-
console.log(`[DataBrowser] Cleaning form input for ${model == null ? void 0 : model.name}:`, input);
|
|
465
453
|
const cleaned = {};
|
|
466
454
|
const booleanFields = new Set(
|
|
467
455
|
((_b = (_a = model == null ? void 0 : model.fields) == null ? void 0 : _a.filter((field) => field.type.toLowerCase() === "boolean")) == null ? void 0 : _b.map((field) => field.name)) || []
|
|
@@ -480,10 +468,6 @@ function cleanFormInput(input, model) {
|
|
|
480
468
|
if (enumArrayFields.has(key)) {
|
|
481
469
|
if (typeof value === "string") {
|
|
482
470
|
const arrayValue = value.split(",").filter((v) => v.trim() !== "");
|
|
483
|
-
console.log(`[DataBrowser] Converting enum array "${key}":`, {
|
|
484
|
-
stringValue: value,
|
|
485
|
-
arrayValue
|
|
486
|
-
});
|
|
487
471
|
cleaned[key] = arrayValue;
|
|
488
472
|
continue;
|
|
489
473
|
} else if (Array.isArray(value)) {
|
|
@@ -521,7 +505,6 @@ function cleanFormInput(input, model) {
|
|
|
521
505
|
}
|
|
522
506
|
cleaned[key] = value;
|
|
523
507
|
}
|
|
524
|
-
console.log(`[DataBrowser] Cleaned form input for ${model == null ? void 0 : model.name}:`, cleaned);
|
|
525
508
|
return cleaned;
|
|
526
509
|
}
|
|
527
510
|
export {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nestledjs/data-browser",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.14",
|
|
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.6.3",
|
|
41
|
-
"@nestledjs/shared-components": "^1.0.
|
|
41
|
+
"@nestledjs/shared-components": "^1.0.14",
|
|
42
42
|
"react": "^19.0.0",
|
|
43
43
|
"react-router": "^7.0.0"
|
|
44
44
|
},
|