69 lines
1.7 KiB
TypeScript
69 lines
1.7 KiB
TypeScript
import type { CollectionConfig } from "payload";
|
|
import { hasPermission } from "@/utils/access-control/hasPermission";
|
|
|
|
export const Sprints: CollectionConfig = {
|
|
slug: "sprints",
|
|
admin: {
|
|
group: "Projects",
|
|
useAsTitle: "name",
|
|
defaultColumns: ["name", "project", "status", "startDate", "endDate"],
|
|
},
|
|
access: {
|
|
read: ({ req }) => !!req.user,
|
|
create: async ({ req }) => {
|
|
if (!req.user) return false;
|
|
return await hasPermission(req.payload, req.user, "sprints:create");
|
|
},
|
|
update: async ({ req }) => {
|
|
if (!req.user) return false;
|
|
return await hasPermission(req.payload, req.user, "sprints:update");
|
|
},
|
|
delete: async ({ req }) => {
|
|
if (!req.user) return false;
|
|
return await hasPermission(req.payload, req.user, "sprints:delete");
|
|
},
|
|
},
|
|
fields: [
|
|
{
|
|
name: "name",
|
|
type: "text",
|
|
required: true,
|
|
},
|
|
{
|
|
name: "project",
|
|
type: "relationship",
|
|
relationTo: "projects",
|
|
required: true,
|
|
index: true,
|
|
},
|
|
{
|
|
name: "goal",
|
|
type: "text",
|
|
},
|
|
{
|
|
name: "startDate",
|
|
type: "date",
|
|
admin: { date: { pickerAppearance: "dayAndTime" } },
|
|
},
|
|
{
|
|
name: "endDate",
|
|
type: "date",
|
|
admin: { date: { pickerAppearance: "dayAndTime" } },
|
|
},
|
|
{
|
|
name: "status",
|
|
type: "select",
|
|
defaultValue: "planning",
|
|
options: [
|
|
{ label: "Planning", value: "planning" },
|
|
{ label: "Active", value: "active" },
|
|
{ label: "Completed", value: "completed" },
|
|
],
|
|
},
|
|
{
|
|
name: "capacity",
|
|
type: "number",
|
|
admin: { description: "Story point capacity for this sprint." },
|
|
},
|
|
],
|
|
};
|