feat(sacred-valley): drag-to-reorder with server-persisted layout

Adds HTML5 drag-to-reorder for .sv-card elements in Sacred Valley. The
pure moveId helper is unit-tested. Drop calls PUT /api/dashboard/layout
to persist the new card_order; DOM reflects the new order immediately.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
root
2026-06-02 22:39:57 +10:00
parent 01177a2cbd
commit e368ea41d8
4 changed files with 53 additions and 1 deletions

View File

@@ -0,0 +1,14 @@
import { describe, it, expect } from 'vitest';
import { moveId } from '../../public/components/sv_reorder.js';
describe('moveId', () => {
it('moves an id before a target', () => {
expect(moveId(['a', 'b', 'c'], 'c', 'a')).toEqual(['c', 'a', 'b']);
});
it('moving onto itself is a no-op', () => {
expect(moveId(['a', 'b', 'c'], 'b', 'b')).toEqual(['a', 'b', 'c']);
});
it('moving to end when target is null appends', () => {
expect(moveId(['a', 'b', 'c'], 'a', null)).toEqual(['b', 'c', 'a']);
});
});