feat(applications): drag-to-reorder on the public site
Editors can now control the order applications appear in, the same way they already reorder Hero slides. - Application gains an `order Int @default(0)` column (additive migration 20260605120000_add_application_order, IF NOT EXISTS, safe for deploy) plus an (isActive, order) index. - New reorderApplications(orderedSlugs) server action — single $transaction renumbering, mirrors reorderHeroSlides. - HQ applications panel: rows are now draggable by a grip handle (HTML5 DnD, optimistic local reorder, persisted on drop, toast feedback). - All public-facing queries now order by [order asc, createdAt asc]: home ApplicationsDashboard + GlobalOperations, the footer apps list, and the HQ list itself. Existing rows default to 0 so current order is preserved until the editor drags something. Verified: production build compiles, TypeScript clean. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
-- ─────────────────────────────────────────────────────────────────────────
|
||||
-- ADDITIVE MIGRATION — adds a manual `order` column to Application so the
|
||||
-- editor can drag-to-reorder applications on the public site (same pattern
|
||||
-- as HeroSlide). Existing rows default to 0 and keep their creation order
|
||||
-- as a tiebreaker. Safe for `migrate deploy`. Idempotent.
|
||||
-- ─────────────────────────────────────────────────────────────────────────
|
||||
|
||||
ALTER TABLE "Application" ADD COLUMN IF NOT EXISTS "order" INTEGER NOT NULL DEFAULT 0;
|
||||
|
||||
CREATE INDEX IF NOT EXISTS "Application_isActive_order_idx" ON "Application" ("isActive", "order");
|
||||
@@ -89,6 +89,9 @@ model Application {
|
||||
dashboardMetricsJson String? @default("[]")
|
||||
isActive Boolean @default(true) // 🔥 NUEVO: Para poder ocultarlas
|
||||
|
||||
// 🔥 NUEVO: Orden manual para drag-to-reorder en el frontend (como HeroSlide)
|
||||
order Int @default(0)
|
||||
|
||||
// 🌍 MOTOR DE TRADUCCIONES
|
||||
translationsJson String? @default("{}")
|
||||
|
||||
@@ -97,6 +100,7 @@ model Application {
|
||||
|
||||
@@index([isActive])
|
||||
@@index([category])
|
||||
@@index([isActive, order])
|
||||
}
|
||||
|
||||
// ------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user