fixing condition where entity has been created with empty label

This commit is contained in:
dswbx
2024-12-11 18:48:57 +01:00
parent 35959aaf6d
commit 25027429df
2 changed files with 11 additions and 9 deletions

View File

@@ -158,7 +158,7 @@ export class Entity<
}
get label(): string {
return snakeToPascalWithSpaces(this.config.name ?? this.name);
return snakeToPascalWithSpaces(this.config.name || this.name);
}
field(name: string): Field | undefined {

View File

@@ -1,5 +1,5 @@
import { typeboxResolver } from "@hookform/resolvers/typebox";
import type { Static } from "core/utils";
import { type Static, objectCleanEmpty } from "core/utils";
import { type TAppDataEntityFields, entitiesSchema } from "data/data-schema";
import { mergeWith } from "lodash-es";
import { useRef } from "react";
@@ -20,13 +20,15 @@ export function StepEntityFields() {
const entity = state.entities?.create?.[0]!;
const defaultFields = { id: { type: "primary", name: "id" } } as const;
const ref = useRef<EntityFieldsFormRef>(null);
const initial = mergeWith(entity, {
fields: defaultFields,
config: {
sort_field: "id",
sort_dir: "asc"
}
});
const initial = objectCleanEmpty(
mergeWith(entity, {
fields: defaultFields,
config: {
sort_field: "id",
sort_dir: "asc"
}
})
);
const {
control,
formState: { isValid, errors },