Promotion service lib, ceiling field on Ranks, permission gate, migration, and GM promote button with tests. Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
49 lines
1 KiB
TypeScript
49 lines
1 KiB
TypeScript
import { CollectionConfig } from "payload";
|
|
import { requirePermission } from "@/utils/access-control/hasPermission";
|
|
|
|
export const Ranks: CollectionConfig = {
|
|
slug: "ranks",
|
|
access: {
|
|
create: requirePermission("ranks:create"),
|
|
update: requirePermission("ranks:update"),
|
|
delete: requirePermission("ranks:delete"),
|
|
},
|
|
admin: {
|
|
useAsTitle: "name",
|
|
group: "Users",
|
|
},
|
|
orderable: true,
|
|
fields: [
|
|
{
|
|
name: "name",
|
|
type: "text",
|
|
required: true,
|
|
unique: true,
|
|
},
|
|
{
|
|
name: "abbreviation",
|
|
type: "text",
|
|
required: true,
|
|
unique: true,
|
|
},
|
|
{
|
|
name: "description",
|
|
type: "text",
|
|
required: true,
|
|
},
|
|
{
|
|
name: "insignia",
|
|
type: "upload",
|
|
relationTo: "media",
|
|
},
|
|
{
|
|
name: "promotionCeiling",
|
|
type: "relationship",
|
|
relationTo: "ranks",
|
|
admin: {
|
|
description:
|
|
"Holders of this rank may promote members up to and including this rank. Leave empty for no promotion authority.",
|
|
},
|
|
},
|
|
],
|
|
};
|