diff --git a/apps/app/src/i18n.ts b/apps/app/src/i18n.ts
index bb4d831..b98c22f 100644
--- a/apps/app/src/i18n.ts
+++ b/apps/app/src/i18n.ts
@@ -100,6 +100,9 @@ export const t = {
starsAtLeast: "Estrelas (pelo menos)",
starsOrMore: (n: number) => (n === 1 ? "1 estrela ou mais" : `${n} estrelas ou mais`),
colorLabel: "Cor",
+ markColor: "Marcar",
+ colorOnly: (name: string) => `Só ${name.toLowerCase()}`,
+ colorWithout: (name: string) => `Sem ${name.toLowerCase()}`,
colors: { RED: "Vermelho", YELLOW: "Amarelo", GREEN: "Verde", BLUE: "Azul", PURPLE: "Roxo" },
deliveryFilter: "Envio:",
deliveryStates: { any: "Todas", unsent: "Por enviar", queued: "A enviar", sent: "Enviadas", failed: "Com erro" },
diff --git a/apps/app/src/library/FilterBar.tsx b/apps/app/src/library/FilterBar.tsx
index 2b3662f..c50d958 100644
--- a/apps/app/src/library/FilterBar.tsx
+++ b/apps/app/src/library/FilterBar.tsx
@@ -1,7 +1,7 @@
import type { ColorLabel } from "@photoreport/contracts";
import { t } from "../i18n.js";
import { LABEL_COLOR } from "./Grid.js";
-import { ALL_PHOTOS, isAll, type LibraryFilter } from "./store.js";
+import { ALL_PHOTOS, cycleColor, isAll, type LibraryFilter } from "./store.js";
const FLAGS: LibraryFilter["flag"][] = ["all", "PICK", "UNFLAGGED", "UNREJECTED", "REJECT"];
const DELIVERY: LibraryFilter["delivery"][] = ["any", "unsent", "queued", "sent", "failed"];
@@ -40,17 +40,23 @@ export function FilterBar(props: { filter: LibraryFilter; onChange: (f: LibraryF
))}
- {COLORS.map((c) => (
-
{!compact && |}
{!compact && (
diff --git a/apps/app/src/library/active.ts b/apps/app/src/library/active.ts
index 3ea32d6..85e5e22 100644
--- a/apps/app/src/library/active.ts
+++ b/apps/app/src/library/active.ts
@@ -54,6 +54,7 @@ export function savedFilter(orgId: string): LibraryFilter {
flag: FLAGS.includes(v.flag as string) ? v.flag! : "all",
minRating: Number.isInteger(v.minRating) && v.minRating! >= 0 && v.minRating! <= 5 ? v.minRating! : 0,
color: COLORS.includes(v.color as string) ? v.color! : null,
+ withoutColor: v.withoutColor === true && COLORS.includes(v.color as string),
delivery: DELIVERY.includes(v.delivery as string) ? v.delivery! : "any",
noPlayers: v.noPlayers === true,
};
diff --git a/apps/app/src/library/store.test.ts b/apps/app/src/library/store.test.ts
index 46c636a..b54358f 100644
--- a/apps/app/src/library/store.test.ts
+++ b/apps/app/src/library/store.test.ts
@@ -1,6 +1,6 @@
import type { PhotoSummary } from "@photoreport/contracts";
import { describe, expect, it } from "vitest";
-import { ALL_PHOTOS, initialLibrary, type LibraryFilter, libraryReducer, matchesFilter, patchForKey } from "./store.js";
+import { ALL_PHOTOS, cycleColor, initialLibrary, type LibraryFilter, libraryReducer, matchesFilter, patchForKey } from "./store.js";
const photo = (id: string, capturedAt: string, extra: Partial = {}): PhotoSummary => ({
id,
@@ -72,6 +72,12 @@ describe("library store", () => {
expect(matchesFilter(photo("a", "", { flag: "PICK", rating: 1 }), toSend)).toBe(false);
expect(matchesFilter(photo("a", "", { flag: "NONE", rating: 5 }), toSend)).toBe(false);
expect(matchesFilter(photo("a", "", { colorLabel: "RED" }), { ...ALL_PHOTOS, color: "GREEN" })).toBe(false);
+ const hideRed = { ...ALL_PHOTOS, ...cycleColor(cycleColor(ALL_PHOTOS, "RED"), "RED") };
+ expect(hideRed).toEqual({ ...ALL_PHOTOS, color: "RED", withoutColor: true });
+ expect(matchesFilter(photo("a", "", { colorLabel: "RED" }), hideRed)).toBe(false);
+ expect(matchesFilter(photo("a", "", { colorLabel: "NONE" }), hideRed)).toBe(true);
+ expect(matchesFilter(photo("a", "", { colorLabel: "GREEN" }), hideRed)).toBe(true);
+ expect(cycleColor(hideRed, "RED")).toEqual({ color: null, withoutColor: false });
expect(matchesFilter(photo("a", "", { delivery: "FAILED" }), { ...ALL_PHOTOS, delivery: "failed" })).toBe(true);
});
diff --git a/apps/app/src/library/store.ts b/apps/app/src/library/store.ts
index d3ffd59..e95e154 100644
--- a/apps/app/src/library/store.ts
+++ b/apps/app/src/library/store.ts
@@ -213,14 +213,23 @@ export interface LibraryFilter {
flag: "all" | "PICK" | "UNREJECTED" | "REJECT" | "UNFLAGGED";
minRating: number;
color: ColorLabel | null;
+ /** When set with `color`, hide photos that wear it and keep the rest. */
+ withoutColor: boolean;
delivery: "any" | "unsent" | "queued" | "sent" | "failed";
noPlayers: boolean;
}
-export const ALL_PHOTOS: LibraryFilter = { flag: "all", minRating: 0, color: null, delivery: "any", noPlayers: false };
+export const ALL_PHOTOS: LibraryFilter = { flag: "all", minRating: 0, color: null, withoutColor: false, delivery: "any", noPlayers: false };
export function isAll(f: LibraryFilter): boolean {
- return f.flag === "all" && !f.minRating && !f.color && f.delivery === "any" && !f.noPlayers;
+ return f.flag === "all" && !f.minRating && !f.color && !f.withoutColor && f.delivery === "any" && !f.noPlayers;
+}
+
+/** Colour chip: first click keeps that colour, second click hides it, third click clears. */
+export function cycleColor(f: LibraryFilter, color: ColorLabel): Pick {
+ if (f.color !== color) return { color, withoutColor: false };
+ if (!f.withoutColor) return { color, withoutColor: true };
+ return { color: null, withoutColor: false };
}
export function matchesFilter(photo: PhotoSummary, f: LibraryFilter): boolean {
@@ -229,7 +238,8 @@ export function matchesFilter(photo: PhotoSummary, f: LibraryFilter): boolean {
if (f.flag === "UNREJECTED" && photo.flag === "REJECT") return false;
if (f.flag === "UNFLAGGED" && photo.flag !== "NONE") return false;
if (f.minRating && photo.rating < f.minRating) return false;
- if (f.color && photo.colorLabel !== f.color) return false;
+ if (f.color && f.withoutColor && photo.colorLabel === f.color) return false;
+ if (f.color && !f.withoutColor && photo.colorLabel !== f.color) return false;
const d = photo.delivery ?? "NONE";
if (f.delivery === "unsent" && d !== "NONE") return false;
if (f.delivery === "queued" && d !== "QUEUED") return false;
diff --git a/apps/app/src/pages/LibraryPage.tsx b/apps/app/src/pages/LibraryPage.tsx
index 71ab9d9..ee58ccb 100644
--- a/apps/app/src/pages/LibraryPage.tsx
+++ b/apps/app/src/pages/LibraryPage.tsx
@@ -18,7 +18,7 @@ import { beginDropWait, folderDropPath, folderMeta, htmlDropIsFolder, mergeFolde
import { finishMergedJpeg } from "../library/finishMergedJpeg.js";
import { mergeFolderNative } from "../library/folderMerge.js";
import { MERGE_EDGE } from "../library/mergeStacks.js";
-import { Grid, Loupe, type LoupeFace } from "../library/Grid.js";
+import { Grid, LABEL_COLOR, Loupe, type LoupeFace } from "../library/Grid.js";
import { InfoPanel } from "../library/InfoPanel.js";
import { IptcInfo } from "../library/IptcInfo.js";
import { useLibraryLive } from "../library/realtime.js";
@@ -606,6 +606,25 @@ export function LibraryPage() {
{canCull && openEvent && (
setEvents((list) => list.map((x) => (x.id === e.id ? e : x)))} />
)}
+ {canCull && !sheet && selection.length > 0 && (
+
+ {t.markColor}
+ {(["RED", "YELLOW", "GREEN", "BLUE", "PURPLE"] as const).map((c) => (
+ {
+ const clearing = selection.every((p) => p.colorLabel === c);
+ void patch(selection.map((p) => p.id), { colorLabel: clearing ? "NONE" : c });
+ }}
+ />
+ ))}
+
+ )}
{canCull && !sheet && selection.length > 0 && (