import type { CollectionConfig } from "payload"; import { hasPermission } from "@/utils/access-control/hasPermission"; import { MISSION_MARKER_SHAPES } from "@/lib/arma-markers/missionMarkers"; /** * Pre-planning markers on a mission's planning map (Arma 3 marker model: * icon / rectangle / ellipse / polyline + CfgMarkers type, CfgMarkerColors * color, CfgMarkerBrushes brush). Markers belong to exactly one mission and * never appear on the shared world map. * * All frontend reads/writes flow through `src/lib/intelligence/missionMap.ts` * (overrideAccess) behind mission-visibility and mission-editor checks, so the * collection-level access here only governs REST/admin-panel use. */ export const MissionMapMarkers: CollectionConfig = { slug: "mission-map-markers", admin: { group: "Intelligence", useAsTitle: "text", defaultColumns: ["mission", "shape", "markerType", "color", "text", "createdBy"], description: "Planning-map markers for individual missions. Normally edited on the mission page, not here.", }, access: { read: async ({ req }) => hasPermission(req.payload, req.user, "mission-map-markers:read"), create: async ({ req }) => hasPermission(req.payload, req.user, "mission-map-markers:create"), update: async ({ req }) => hasPermission(req.payload, req.user, "mission-map-markers:update"), delete: async ({ req }) => hasPermission(req.payload, req.user, "mission-map-markers:delete"), }, fields: [ { name: "mission", type: "relationship", relationTo: "missions", required: true, index: true, }, { name: "shape", type: "select", required: true, defaultValue: "icon", options: MISSION_MARKER_SHAPES.map((value) => ({ label: value, value })), }, { name: "markerType", type: "text", admin: { description: "CfgMarkers class name (icon markers), e.g. b_inf, mil_objective." }, }, { name: "color", type: "text", required: true, defaultValue: "Default", admin: { description: "CfgMarkerColors class name, e.g. ColorRed, ColorWEST." }, }, { name: "brush", type: "text", admin: { description: "CfgMarkerBrushes class name (area markers), e.g. Solid, Grid." }, }, { name: "text", type: "text", maxLength: 200, }, { name: "position", type: "json", required: true, admin: { description: "[x, y] in map meters (origin top-left, y south). First vertex for lines.", }, }, { name: "sizeA", type: "number", defaultValue: 1, admin: { description: "Area half-width in meters, or icon scale." }, }, { name: "sizeB", type: "number", defaultValue: 1, admin: { description: "Area half-height in meters, or icon scale." }, }, { name: "direction", type: "number", defaultValue: 0, admin: { description: "Degrees clockwise from north." }, }, { name: "alpha", type: "number", defaultValue: 1, min: 0, max: 1, }, { name: "points", type: "json", admin: { description: "Line vertices [[x, y], ...] in map meters (line markers only)." }, }, { name: "createdBy", type: "relationship", relationTo: "users", }, ], };