working sorting key
This commit is contained in:
@@ -15,7 +15,7 @@ export const entityConfigSchema = s
|
|||||||
name: s.string(),
|
name: s.string(),
|
||||||
name_singular: s.string(),
|
name_singular: s.string(),
|
||||||
description: s.string(),
|
description: s.string(),
|
||||||
sort_field: s.string({ default: config.data.default_primary_field }),
|
sort_field: s.string(),
|
||||||
sort_dir: s.string({ enum: ["asc", "desc"], default: "asc" }),
|
sort_dir: s.string({ enum: ["asc", "desc"], default: "asc" }),
|
||||||
primary_format: s.string({ enum: primaryFieldTypes }),
|
primary_format: s.string({ enum: primaryFieldTypes }),
|
||||||
},
|
},
|
||||||
@@ -82,6 +82,10 @@ export class Entity<
|
|||||||
fields.forEach((field) => this.addField(field));
|
fields.forEach((field) => this.addField(field));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!this.config.sort_field) {
|
||||||
|
this.config.sort_field = this.getPrimaryField().name;
|
||||||
|
}
|
||||||
|
|
||||||
if (type) this.type = type;
|
if (type) this.type = type;
|
||||||
this[ENTITY_SYMBOL] = true;
|
this[ENTITY_SYMBOL] = true;
|
||||||
}
|
}
|
||||||
@@ -115,7 +119,7 @@ export class Entity<
|
|||||||
|
|
||||||
getDefaultSort() {
|
getDefaultSort() {
|
||||||
return {
|
return {
|
||||||
by: this.config.sort_field ?? "id",
|
by: this.config.sort_field ?? this.getPrimaryField().name,
|
||||||
dir: this.config.sort_dir ?? "asc",
|
dir: this.config.sort_dir ?? "asc",
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user