fix(manager): UI review pass 5 small fixes (fee tabs, category actions and drop line, card buttons, floor plan chips, staff buttons)
- Tabs inset: no line under the strip, the labels level with the end button. - Products: a chosen category's actions share the width equally, toned (quiet, coloured on hover); the drop line shows above / below the row by the pointer's half and the category lands exactly there (moveIdTo); grid cards' edit and archive centred. - Floor plans: the plan chips as tall as "New floor plan". - Staff: PIN and password toned like the other row buttons; toned buttons light up (soft background) under the pointer. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -39,7 +39,7 @@ export default function FloorPlansTab() {
|
||||
<div className="flex flex-wrap gap-1.5">
|
||||
{z.plans.map(p => (
|
||||
<button key={p.id} type="button" onClick={() => setChosen(p.id)} aria-current={plan?.id === p.id ? 'true' : undefined} data-testid="floor-plan-item" data-name={p.name}
|
||||
className={cx('px-3 py-1.5 rounded-control border text-label font-medium transition-colors duration-fast text-left',
|
||||
className={cx('inline-flex items-center h-control-sm px-3 rounded-control border text-label font-medium transition-colors duration-fast text-left',
|
||||
plan?.id === p.id ? 'border-accent bg-accent-soft text-accent-ink' : 'border-line bg-surface hover:bg-surface-2 text-ink')}>
|
||||
{p.name}
|
||||
<span className="ml-2 text-caption text-ink-3 font-normal">{t('floor.tableCount', { count: data.tables.filter(x => x.plan_id === p.id).length })}</span>
|
||||
|
||||
@@ -7,7 +7,7 @@ import { useRef, useState } from 'react'
|
||||
import { Archive, ArrowRightLeft, ChevronDown, ChevronRight, Folder, GripVertical, Pencil, Plus, Trash2, Truck } from 'lucide-react'
|
||||
import { useTranslation } from '@xenia/i18n'
|
||||
import { IconButton, Pane, SearchInput, cx } from '@xenia/ui'
|
||||
import { SCOPES, countIn, isArchived, moveId, subsOf, topLevel } from './productsLogic'
|
||||
import { SCOPES, countIn, isArchived, moveIdTo, subsOf, topLevel } from './productsLogic'
|
||||
|
||||
export function Dot({ cat, size = 'w-2 h-2' }) {
|
||||
// a category's colour is the venue's choice (data)
|
||||
@@ -27,31 +27,39 @@ export default function CategoryTree({ categories, products, scope, onScope, onA
|
||||
const dnd = (cat, level, parent) => ({
|
||||
draggable: true,
|
||||
onDragStart: e => { drag.current = { id: cat.id, level, parent }; e.dataTransfer.effectAllowed = 'move' },
|
||||
onDragOver: e => { e.preventDefault(); if (drag.current && drag.current.id !== cat.id && drag.current.level === level && drag.current.parent === parent) setDropAt(cat.id) },
|
||||
// the line shows where it lands: above the row under the pointer's upper half, below it for the lower half
|
||||
onDragOver: e => {
|
||||
e.preventDefault()
|
||||
if (!drag.current || drag.current.id === cat.id || drag.current.level !== level || drag.current.parent !== parent) return
|
||||
const r = e.currentTarget.getBoundingClientRect()
|
||||
const after = e.clientY > r.top + r.height / 2
|
||||
setDropAt(d => (d?.id === cat.id && d.after === after ? d : { id: cat.id, after }))
|
||||
},
|
||||
onDragLeave: () => setDropAt(null),
|
||||
onDrop: e => {
|
||||
e.preventDefault()
|
||||
const after = dropAt?.id === cat.id ? dropAt.after : false
|
||||
setDropAt(null)
|
||||
const d = drag.current
|
||||
drag.current = null
|
||||
if (!d || d.level !== level || d.parent !== parent) return
|
||||
const siblings = (level === 'top' ? topLevel(categories) : subsOf(categories, parent)).map(c => c.id)
|
||||
const next = moveId(siblings, d.id, cat.id)
|
||||
const next = moveIdTo(siblings, d.id, cat.id, after)
|
||||
if (next) onReorder(level, next)
|
||||
},
|
||||
})
|
||||
|
||||
const row = (cat, depth, parent) => (
|
||||
<div key={cat.id} {...dnd(cat, depth ? 'sub' : 'top', parent)} className={cx(dropAt === cat.id && 'border-t-2 border-accent')}>
|
||||
<div key={cat.id} {...dnd(cat, depth ? 'sub' : 'top', parent)} className={cx('border-y-2 border-transparent', dropAt?.id === cat.id && (dropAt.after ? '!border-b-accent' : '!border-t-accent'))}>
|
||||
<Row label={cat.name} count={countIn(products, categories, cat.id)} active={scope === cat.id} onClick={() => onScope(cat.id)} depth={depth}
|
||||
dot={<Dot cat={cat} />} drag testId={`category-${cat.id}`}
|
||||
caret={!depth && subsOf(categories, cat.id).length > 0 ? (open.has(cat.id) || !!q) : null}
|
||||
onCaret={() => setOpen(s => { const n = new Set(s); if (n.has(cat.id)) n.delete(cat.id); else n.add(cat.id); return n })}
|
||||
actions={<>
|
||||
{!depth && <IconButton size="sm" variant="ghost" label={t('products.category.newSub')} onClick={() => onAdd(cat.id)}><Plus size={14} /></IconButton>}
|
||||
<IconButton size="sm" variant="ghost" label={t('products.category.moveTitle')} onClick={() => onMove(cat)}><ArrowRightLeft size={14} /></IconButton>
|
||||
<IconButton size="sm" variant="ghost" label={t('products.category.edit')} onClick={() => onEdit(cat)}><Pencil size={14} /></IconButton>
|
||||
<IconButton size="sm" variant="ghost" tone="danger" label={t('products.category.delete')} onClick={() => onDelete(cat)}><Trash2 size={14} /></IconButton>
|
||||
{!depth && <IconButton size="sm" tone="success" className="!w-full" label={t('products.category.newSub')} onClick={() => onAdd(cat.id)}><Plus size={16} /></IconButton>}
|
||||
<IconButton size="sm" tone="info" className="!w-full" label={t('products.category.moveTitle')} onClick={() => onMove(cat)}><ArrowRightLeft size={16} /></IconButton>
|
||||
<IconButton size="sm" tone="accent" className="!w-full" label={t('products.category.edit')} onClick={() => onEdit(cat)}><Pencil size={16} /></IconButton>
|
||||
<IconButton size="sm" tone="danger" className="!w-full" label={t('products.category.delete')} onClick={() => onDelete(cat)}><Trash2 size={16} /></IconButton>
|
||||
</>} />
|
||||
</div>
|
||||
)
|
||||
@@ -100,7 +108,8 @@ function Row({ label, count, active, onClick, dot, depth = 0, caret = null, onCa
|
||||
<button type="button" className={cx('flex-1 min-w-0 truncate text-left text-body', active && 'font-semibold')} data-testid={testId}>{label}</button>
|
||||
{/* a category's own actions show on its row once it's chosen (touch screens have no hover) */}
|
||||
<span className="px-1.5 rounded-full bg-surface-2 text-caption text-ink-2 tabular-nums shrink-0">{count}</span>
|
||||
{actions && active && <span className="w-full flex justify-end gap-0.5" onClick={e => e.stopPropagation()} data-testid="category-actions">{actions}</span>}
|
||||
{/* the chosen category's actions share the row's width equally (2026-11-21) */}
|
||||
{actions && active && <span className="w-full grid grid-flow-col auto-cols-fr gap-1 pt-1" onClick={e => e.stopPropagation()} data-testid="category-actions">{actions}</span>}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -162,8 +162,11 @@ function Card({ p, categories, selected, onSelect, onEdit, onRemove, onToggle })
|
||||
<div className={cx('group rounded-card border bg-surface overflow-hidden flex flex-col', selected ? 'border-accent shadow-focus' : 'border-line hover:shadow-raised')} data-testid="product-card" data-name={p.name}>
|
||||
<div className="relative h-36">
|
||||
<Photo product={p} className="w-full h-full text-display" />
|
||||
<span className="absolute top-2 left-2 flex gap-1 opacity-0 group-hover:opacity-100 focus-within:opacity-100">
|
||||
<span className="absolute top-2 left-2 flex opacity-0 group-hover:opacity-100 focus-within:opacity-100">
|
||||
<input type="checkbox" className="w-5 h-5 accent-[var(--x-accent)]" checked={selected} onChange={() => onSelect(p.id)} aria-label={t('products.select', { name: p.name })} />
|
||||
</span>
|
||||
{/* edit and archive / delete: centred on the card (2026-11-21) */}
|
||||
<span className="absolute inset-x-0 top-2 flex justify-center gap-2 opacity-0 group-hover:opacity-100 focus-within:opacity-100">
|
||||
<IconButton size="sm" variant="secondary" label={t('products.edit')} onClick={() => onEdit(p)}><Pencil size={14} /></IconButton>
|
||||
<IconButton size="sm" variant="secondary" tone="danger" label={archived ? t('products.delete') : t('products.archive')} onClick={() => onRemove(p)}>{archived ? <Trash2 size={14} /> : <Archive size={14} />}</IconButton>
|
||||
</span>
|
||||
|
||||
@@ -123,6 +123,15 @@ export function moveId(ids, fromId, toId) {
|
||||
return next
|
||||
}
|
||||
|
||||
/** Move `fromId` to just before (or, `after`, just after) `toId`: where the drop line showed. */
|
||||
export function moveIdTo(ids, fromId, toId, after = false) {
|
||||
if (fromId === toId || !ids.includes(fromId) || !ids.includes(toId)) return null
|
||||
const rest = ids.filter(id => id !== fromId)
|
||||
const at = rest.indexOf(toId) + (after ? 1 : 0)
|
||||
const next = [...rest.slice(0, at), fromId, ...rest.slice(at)]
|
||||
return next.every((id, i) => id === ids[i]) ? null : next
|
||||
}
|
||||
|
||||
/** What it costs the venue (the breakdown's sum, else the simple cost) and the margin; null without a cost. */
|
||||
export function costOf(p) {
|
||||
const cost = p.cost_breakdown?.length ? p.cost_breakdown.reduce((s, e) => s + (Number(e.amount) || 0), 0)
|
||||
|
||||
@@ -108,8 +108,8 @@ export default function StaffPage() {
|
||||
{!support && (
|
||||
<span className="flex gap-1.5 ml-auto">
|
||||
<IconButton size="sm" variant="ghost" tone="accent" label={t('staff.edit', { name: displayName(m) })} onClick={() => open('edit', m)}><Pencil size={15} /></IconButton>
|
||||
<IconButton size="sm" variant="ghost" label={t('staff.pin', { name: displayName(m) })} onClick={() => open('pin', m)} data-testid="staff-pin"><KeyRound size={15} /></IconButton>
|
||||
<IconButton size="sm" variant="ghost" label={t('staff.password', { name: displayName(m) })} onClick={() => open('password', m)} data-testid="staff-password"><LockKeyhole size={15} /></IconButton>
|
||||
<IconButton size="sm" variant="ghost" tone="special" label={t('staff.pin', { name: displayName(m) })} onClick={() => open('pin', m)} data-testid="staff-pin"><KeyRound size={15} /></IconButton>
|
||||
<IconButton size="sm" variant="ghost" tone="special" label={t('staff.password', { name: displayName(m) })} onClick={() => open('password', m)} data-testid="staff-password"><LockKeyhole size={15} /></IconButton>
|
||||
<IconButton size="sm" variant="ghost" tone="info" label={t('staff.zonesOf', { name: displayName(m) })} onClick={() => open('zones', m)}><MapPin size={15} /></IconButton>
|
||||
{m.id !== me?.id && (<>
|
||||
<IconButton size="sm" variant="ghost" tone={m.is_active ? 'warning' : 'success'} label={t(m.is_active ? 'staff.block' : 'staff.unblock', { name: displayName(m) })}
|
||||
|
||||
@@ -131,3 +131,12 @@ test('the editor: every text per language; "Default" is the venue language (owne
|
||||
assert.equal(canSave({ ...f, names: {}, name: '' }, 'el'), false)
|
||||
assert.deepEqual(cleanTexts({ el: ' ', en: ' x ', fr: 'y' }), { en: 'x' })
|
||||
})
|
||||
|
||||
test('a category dropped above or below a row lands where the line showed (2026-11-21)', async () => {
|
||||
const { moveIdTo } = await import('../src/pages/products/productsLogic.js')
|
||||
assert.deepEqual(moveIdTo([1, 2, 3, 4], 1, 3, false), [2, 1, 3, 4]) // above 3
|
||||
assert.deepEqual(moveIdTo([1, 2, 3, 4], 1, 3, true), [2, 3, 1, 4]) // below 3
|
||||
assert.deepEqual(moveIdTo([1, 2, 3, 4], 4, 2, false), [1, 4, 2, 3])
|
||||
assert.equal(moveIdTo([1, 2, 3], 1, 2, false), null) // already there
|
||||
assert.equal(moveIdTo([1, 2, 3], 2, 2, true), null)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user