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.
This commit is contained in:
parent
a06060eb9f
commit
35150e73ac
3 changed files with 28 additions and 1 deletions
|
|
@ -87,6 +87,10 @@ export const Assets: CollectionConfig = {
|
||||||
label: "Bipod",
|
label: "Bipod",
|
||||||
value: "bipod",
|
value: "bipod",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
label: "Accessory (flashlight / laser)",
|
||||||
|
value: "accessory",
|
||||||
|
},
|
||||||
{
|
{
|
||||||
label: "Uniform",
|
label: "Uniform",
|
||||||
value: "uniform",
|
value: "uniform",
|
||||||
|
|
@ -181,7 +185,7 @@ export const Assets: CollectionConfig = {
|
||||||
hasMany: true,
|
hasMany: true,
|
||||||
filterOptions: {
|
filterOptions: {
|
||||||
assetType: {
|
assetType: {
|
||||||
in: "optic,muzzle,bipod",
|
in: "optic,muzzle,bipod,accessory",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -98,6 +98,8 @@ export function getAssetTypeLabel(assetType: Asset["assetType"]): string {
|
||||||
return "Muzzle";
|
return "Muzzle";
|
||||||
case "bipod":
|
case "bipod":
|
||||||
return "Bipod";
|
return "Bipod";
|
||||||
|
case "accessory":
|
||||||
|
return "Accessory";
|
||||||
case "uniform":
|
case "uniform":
|
||||||
return "Uniform";
|
return "Uniform";
|
||||||
case "vest":
|
case "vest":
|
||||||
|
|
@ -133,6 +135,7 @@ const ASSET_TYPE_COLORS: Record<Asset["assetType"], string> = {
|
||||||
optic: "oklch(0.45 0.1 250)",
|
optic: "oklch(0.45 0.1 250)",
|
||||||
muzzle: "oklch(0.45 0.1 200)",
|
muzzle: "oklch(0.45 0.1 200)",
|
||||||
bipod: "oklch(0.45 0.1 160)",
|
bipod: "oklch(0.45 0.1 160)",
|
||||||
|
accessory: "oklch(0.5 0.13 60)",
|
||||||
uniform: "oklch(0.4 0.09 130)",
|
uniform: "oklch(0.4 0.09 130)",
|
||||||
vest: "oklch(0.42 0.09 110)",
|
vest: "oklch(0.42 0.09 110)",
|
||||||
backpack: "oklch(0.42 0.09 75)",
|
backpack: "oklch(0.42 0.09 75)",
|
||||||
|
|
|
||||||
20
src/migrations/20261002_180000_add_asset_type_accessory.ts
Normal file
20
src/migrations/20261002_180000_add_asset_type_accessory.ts
Normal file
|
|
@ -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<void> {
|
||||||
|
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<void> {
|
||||||
|
// Postgres cannot remove a value from an enum type; reversing this would
|
||||||
|
// mean recreating the type and every dependent column.
|
||||||
|
void db;
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue