1
0
Fork 0
polaris-task-force/src/collections/intelligence/MissionMapMarkers.ts
Z8MB1E 1f230c0868 feat(missions): add a per-mission planning map with Arma markers
- New mission-map-markers collection (permission-gated, removed with its
  mission via a Missions beforeDelete hook) plus an opt-in
  classification.planningMapEnabled flag on missions.
- The mission page gains a planning section: place and edit Arma markers
  (icons, ellipses, rectangles, polylines) with debounced saves, an SQF copy
  export, and an Arma grid readout. Everyone who can read the mission sees the
  plan once enabled; editing requires missions:update or mission ownership.
- Base layers come from GET /api/map-features?layers=base, which skips the
  structure, node and shipment queries; marker icons render tinted by color
  exactly like in-game.
- Includes the hand-written migration, the missionMap service lib, server
  actions emitting mission:map-marker-* events, and integration plus e2e
  coverage.
2026-10-04 02:53:21 -04:00

111 lines
3.3 KiB
TypeScript

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",
},
],
};