Added selectable field on languages

This commit is contained in:
DrMint 2024-06-30 13:21:57 +02:00
parent 3f478580d3
commit 3ca42c5705
2 changed files with 23 additions and 7 deletions

View File

@ -2,6 +2,7 @@ import { text } from "payload/dist/fields/validations";
import { mustBeAdmin } from "../../accesses/collections/mustBeAdmin";
import { shownOnlyToAdmin } from "../../accesses/collections/shownOnlyToAdmin";
import { CollectionGroups, Collections } from "../../constants";
import { rowField } from "../../fields/rowField/rowField";
import { buildCollectionConfig } from "../../utils/collectionConfig";
import { getAllEndpoint } from "./endpoints/getAllEndpoint";
import { importFromStrapi } from "./endpoints/importFromStrapi";
@ -9,6 +10,7 @@ import { importFromStrapi } from "./endpoints/importFromStrapi";
const fields = {
id: "id",
name: "name",
selectable: "selectable",
} as const satisfies Record<string, string>;
export const Languages = buildCollectionConfig({
@ -20,7 +22,7 @@ export const Languages = buildCollectionConfig({
defaultSort: fields.name,
admin: {
useAsTitle: fields.name,
defaultColumns: [fields.name, fields.id],
defaultColumns: [fields.name, fields.id, fields.selectable],
disableDuplicate: true,
group: CollectionGroups.Meta,
pagination: { defaultLimit: 100 },
@ -43,11 +45,24 @@ export const Languages = buildCollectionConfig({
return text(value, options);
},
},
rowField([
{
name: fields.name,
type: "text",
unique: true,
required: true,
},
{
name: fields.selectable,
type: "checkbox",
defaultValue: false,
required: true,
admin: {
description:
"Check this box to make the language available to visitors on the website.\
Make sure wordings have been translated in that language before making it selectable.",
},
},
]),
],
});

View File

@ -227,6 +227,7 @@ export interface Image {
export interface Language {
id: string;
name: string;
selectable: boolean;
}
/**
* This interface was referenced by `Config`'s JSON-Schema