67 lines
2.0 KiB
TypeScript
67 lines
2.0 KiB
TypeScript
import { CRUD } from "@sealcode/crud-ui";
|
|
import type { CollectionItem } from "sealious";
|
|
import type { ListFilterRender } from "@sealcode/sealgen";
|
|
import { Controls, DefaultListFilters, Fields } from "@sealcode/sealgen";
|
|
import { NavbarLinks } from "src/back/collections/collections.js";
|
|
import html from "src/back/html.js";
|
|
|
|
export const actionName = "NavbarLinksCRUD";
|
|
|
|
const edit_fields = <const>{
|
|
label: new Fields.CollectionField(
|
|
NavbarLinks.fields.label.required,
|
|
NavbarLinks.fields.label
|
|
),
|
|
href: new Fields.CollectionField(
|
|
NavbarLinks.fields.href.required,
|
|
NavbarLinks.fields.href
|
|
),
|
|
};
|
|
|
|
const edit_controls = [
|
|
new Controls.SimpleInput(edit_fields.label, { label: "label" }),
|
|
new Controls.SimpleInput(edit_fields.href, { label: "href" }),
|
|
];
|
|
|
|
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
const fields_for_display = [
|
|
{ field: "label", label: "label" },
|
|
{ field: "href", label: "href" },
|
|
] as {
|
|
field: keyof (typeof NavbarLinks)["fields"];
|
|
label: string;
|
|
format?: (
|
|
value: unknown,
|
|
item: CollectionItem<typeof NavbarLinks>
|
|
) => string | Promise<string>;
|
|
}[];
|
|
|
|
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
const fields_for_filters = [
|
|
{ field: "label", ...DefaultListFilters["text"] },
|
|
{ field: "href", ...DefaultListFilters["text"] },
|
|
] as {
|
|
field: keyof (typeof NavbarLinks)["fields"];
|
|
render?: ListFilterRender;
|
|
prepareValue?: (filter_value: unknown) => unknown; // set this function to change what filter value is passed to Sealious
|
|
}[];
|
|
|
|
export default new CRUD({
|
|
collection: NavbarLinks,
|
|
nice_collection_name: "NavbarLinks",
|
|
fields_for_display,
|
|
fields_for_filters,
|
|
html,
|
|
list_title: "NavbarLinks list",
|
|
edit_title: "Edit",
|
|
edit_button_text: "Edit",
|
|
delete_button_text: "Delete",
|
|
back_to_list_button_text: "← Back to NavbarLinks list",
|
|
edit_fields,
|
|
edit_controls,
|
|
form_value_to_sealious_value: {},
|
|
sealious_value_to_form_value: {},
|
|
post_edit: async () => {},
|
|
post_create: async () => {},
|
|
});
|