From 35150e73ac70f7edcac0936fca46b1b8801b8228 Mon Sep 17 00:00:00 2001 From: Z8MB1E Date: Sat, 3 Oct 2026 03:30:34 -0400 Subject: [PATCH] feat(logistics): add the accessory asset type Adds an "accessory" asset type for flashlights and lasers, allowed on the same equipment slots as optics, muzzles, and bipods, with a locker label and colour. --- src/collections/logistics/Assets.ts | 6 +++++- src/lib/locker/index.ts | 3 +++ ...0261002_180000_add_asset_type_accessory.ts | 20 +++++++++++++++++++ 3 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 src/migrations/20261002_180000_add_asset_type_accessory.ts diff --git a/src/collections/logistics/Assets.ts b/src/collections/logistics/Assets.ts index cf4f692..5741ef0 100644 --- a/src/collections/logistics/Assets.ts +++ b/src/collections/logistics/Assets.ts @@ -87,6 +87,10 @@ export const Assets: CollectionConfig = { label: "Bipod", value: "bipod", }, + { + label: "Accessory (flashlight / laser)", + value: "accessory", + }, { label: "Uniform", value: "uniform", @@ -181,7 +185,7 @@ export const Assets: CollectionConfig = { hasMany: true, filterOptions: { assetType: { - in: "optic,muzzle,bipod", + in: "optic,muzzle,bipod,accessory", }, }, }, diff --git a/src/lib/locker/index.ts b/src/lib/locker/index.ts index af8ed83..386faea 100644 --- a/src/lib/locker/index.ts +++ b/src/lib/locker/index.ts @@ -98,6 +98,8 @@ export function getAssetTypeLabel(assetType: Asset["assetType"]): string { return "Muzzle"; case "bipod": return "Bipod"; + case "accessory": + return "Accessory"; case "uniform": return "Uniform"; case "vest": @@ -133,6 +135,7 @@ const ASSET_TYPE_COLORS: Record = { optic: "oklch(0.45 0.1 250)", muzzle: "oklch(0.45 0.1 200)", bipod: "oklch(0.45 0.1 160)", + accessory: "oklch(0.5 0.13 60)", uniform: "oklch(0.4 0.09 130)", vest: "oklch(0.42 0.09 110)", backpack: "oklch(0.42 0.09 75)", diff --git a/src/migrations/20261002_180000_add_asset_type_accessory.ts b/src/migrations/20261002_180000_add_asset_type_accessory.ts new file mode 100644 index 0000000..2c099a7 --- /dev/null +++ b/src/migrations/20261002_180000_add_asset_type_accessory.ts @@ -0,0 +1,20 @@ +import { MigrateDownArgs, MigrateUpArgs, sql } from "@payloadcms/db-postgres"; + +/** + * Adds the "accessory" asset type (rail flashlights and lasers such as + * acc_flashlight / acc_pointer_IR). These import as their own type so the + * Weapon Configuration > compatibleAttachments relationship can link them, + * instead of leaving them as "miscellaneous" and skipping them. + */ +export async function up({ db }: MigrateUpArgs): Promise { + await db.execute(sql` + ALTER TYPE "public"."enum_assets_asset_type" + ADD VALUE IF NOT EXISTS 'accessory' BEFORE 'uniform'; + `); +} + +export async function down({ db }: MigrateDownArgs): Promise { + // Postgres cannot remove a value from an enum type; reversing this would + // mean recreating the type and every dependent column. + void db; +}