From 1e00538db3ac661a0fa8a29ab75919db1192c895 Mon Sep 17 00:00:00 2001 From: zurdi Date: Tue, 16 Jun 2026 17:33:25 +0200 Subject: [PATCH] feat: enhance selection bar and game action button for status toggling --- .../v2/components/Gallery/SelectionBar.vue | 117 +++++++++++++----- .../components/GameActions/GameActionBtn.vue | 11 +- 2 files changed, 87 insertions(+), 41 deletions(-) diff --git a/frontend/src/v2/components/Gallery/SelectionBar.vue b/frontend/src/v2/components/Gallery/SelectionBar.vue index bc9dca449..c3c0e7bf8 100644 --- a/frontend/src/v2/components/Gallery/SelectionBar.vue +++ b/frontend/src/v2/components/Gallery/SelectionBar.vue @@ -56,6 +56,7 @@ import { useSnackbar } from "@/v2/composables/useSnackbar"; import storeGallerySelection from "@/v2/stores/gallerySelection"; import { ENUM_KEYS, + FLAG_KEYS, PLAY_FLAG_KEYS, STATUS_ICONS, type StatusFlagKey, @@ -127,13 +128,43 @@ async function bulkFavorite() { } } -// Bulk status — applies one play-status change to every selected ROM. -// Unlike the per-ROM menu (GameActionBtn) these are *set* operations, -// not toggles: a heterogeneous selection has no single "current" state -// to flip, so the menu items read as "mark all as X". The per-rom -// `updateUserRomProps` is the only endpoint (no bulk variant), so we -// fan out one request per ROM, optimistically write the store, and -// revert only the ROMs whose request failed. +// Bulk status — toggles one play-status across the whole selection, +// mirroring the favourite button's all-or-nothing model: a status reads +// as "active" only when *every* selected ROM already has it. Clicking an +// active status clears it on all; clicking an inactive one (at least one +// ROM is missing it) sets it on all. The per-rom `updateUserRomProps` is +// the only endpoint (no bulk variant), so we fan out one request per ROM, +// optimistically write the store, and revert only the ROMs whose request +// failed. +// +// `enumAllActive` / `flagAllActive` mirror `allFavorited`: keyed by +// status so each menu row can paint its active state and decide its +// toggle direction. +const enumAllActive = computed>(() => { + const roms = selection.roms; + const out = {} as Record; + for (const key of ENUM_KEYS) { + out[key] = roms.length > 0 && roms.every((r) => r.rom_user?.status === key); + } + return out; +}); +const flagAllActive = computed>(() => { + const roms = selection.roms; + const out = {} as Record; + for (const key of FLAG_KEYS) { + out[key] = roms.length > 0 && roms.every((r) => Boolean(r.rom_user?.[key])); + } + return out; +}); +const hasAnyStatus = computed(() => { + const roms = selection.roms; + return roms.some( + (r) => + Boolean(r.rom_user?.status) || + FLAG_KEYS.some((key) => Boolean(r.rom_user?.[key])), + ); +}); + async function applyStatus(data: Partial) { const roms = selection.roms; if (roms.length === 0) return; @@ -170,12 +201,12 @@ async function applyStatus(data: Partial) { } } -function setEnumStatus(status: RomUserStatus) { - void applyStatus({ status }); +function toggleEnumStatus(key: RomUserStatus) { + void applyStatus({ status: enumAllActive.value[key] ? null : key }); } -function setFlagStatus(key: StatusFlagKey) { - void applyStatus({ [key]: true }); +function toggleFlagStatus(key: StatusFlagKey) { + void applyStatus({ [key]: !flagAllActive.value[key] }); } function clearStatus() { @@ -290,13 +321,20 @@ function clear() { - - + + - + {{ t(romStatusMap[key].i18nKey) }} - + {{ t(romStatusMap[key].i18nKey) }} + @@ -336,20 +383,26 @@ function clear() { v-for="key in VISIBILITY_FLAG_KEYS" :key="key" :icon="STATUS_ICONS[key]" - @click="setFlagStatus(key)" + :text-color="flagAllActive[key] ? 'brand-primary' : undefined" + :icon-color="flagAllActive[key] ? 'brand-primary' : undefined" + @click="toggleFlagStatus(key)" > {{ t(romStatusMap[key].i18nKey) }} + - - - - {{ t("rom.clear-all") }} - + diff --git a/frontend/src/v2/components/GameActions/GameActionBtn.vue b/frontend/src/v2/components/GameActions/GameActionBtn.vue index ab3dde922..6e3b16018 100644 --- a/frontend/src/v2/components/GameActions/GameActionBtn.vue +++ b/frontend/src/v2/components/GameActions/GameActionBtn.vue @@ -400,7 +400,7 @@ function onClick(e: MouseEvent) { > {{ t(romStatusMap[key].i18nKey) }} @@ -418,7 +418,7 @@ function onClick(e: MouseEvent) { > {{ t(romStatusMap[key].i18nKey) }} @@ -688,11 +688,4 @@ function onClick(e: MouseEvent) { .r-v2-game-btn--multi-status.r-v2-game-btn--orient-vertical.r-v2-game-btn--x-large { padding: 14px 4px; } - -/* Trailing check on the flag rows of the status menu — signals the - boolean is on. Brand color so it pops against the neutral row. */ -.r-v2-status-menu__check { - font-size: 12px; - color: var(--r-color-brand-primary); -}