feat: per-pool automatic file sorting
deploy / deploy (push) Successful in 2s

Pools now store a sort setting (sort_key + sort_order). "manual" keeps the
user-arranged order in file_pool.position and allows drag-to-reorder; any
other key (content_datetime, created, original_name) sorts the pool's files
automatically server-side, in which case reordering is rejected. Manual
order is always ascending by position — direction does not apply.

Backend: add the columns (sort_key defaults to 'manual'), generalise the
pool-files keyset cursor to page by the active sort, persist the setting on
create/update, and guard reorder against non-manual pools.

Frontend: a sort dropdown (+ direction toggle) on the pool page that PATCHes
the pool and reloads; drag-to-reorder is disabled unless the pool is manual.

Closes the "automatic sorting in pools" requirement (REQUIREMENTS.md §4.6.5).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-07-03 08:36:12 +03:00
parent 28f5b5d150
commit 4b6db84afc
9 changed files with 445 additions and 33 deletions
+10 -1
View File
@@ -76,8 +76,17 @@ CREATE TABLE data.pools (
creator_id smallint NOT NULL REFERENCES core.users(id)
ON UPDATE CASCADE ON DELETE RESTRICT,
is_public boolean NOT NULL DEFAULT false,
-- File ordering within the pool. 'manual' keeps the user-defined order in
-- data.file_pool.position (drag-to-reorder); any other key sorts the pool's
-- files automatically by that file field, in which case reordering is disabled.
sort_key varchar(32) NOT NULL DEFAULT 'manual',
sort_order varchar(4) NOT NULL DEFAULT 'asc',
CONSTRAINT uni__pools__name UNIQUE (name)
CONSTRAINT uni__pools__name UNIQUE (name),
CONSTRAINT chk__pools__sort_key
CHECK (sort_key IN ('manual', 'content_datetime', 'created', 'original_name')),
CONSTRAINT chk__pools__sort_order
CHECK (sort_order IN ('asc', 'desc'))
);
-- `position` uses integer with gaps (e.g. 1000, 2000, 3000) to allow