Hero-admin: foto klikbaar voor de uitsnede, direct voorbeeld na Toepassen, Opslaan uitgegrijsd zonder wijzigingen
- De thumbnail is de knop 'Uitsnede aanpassen' (hint bij hover/focus, kleine crop-icoon altijd zichtbaar voor touch); losse focusknop vervalt - Na Toepassen toont de thumbnail direct de nieuwe uitsnede (zelfde rekenlogica als de host) met 'Focus gewijzigd, nog niet opgeslagen' - Opslaan is uitgeschakeld (aria-disabled) zolang er niets te bewaren is, bezig-indicator tijdens opslaan, weer uit na opslaan - Test van de keten: Toepassen, Opslaan (imageFocus in de PUT), 'Nieuwe uitsnede wordt gemaakt', 'Verwerking afgerond'; backend: PUT-body bindt, status direct pending, renderer klaar - Logregel 'recut superseded' als een nieuwere focus de lopende uitsnede overneemt Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -4,7 +4,7 @@ import { useFieldArray, useForm, useWatch } from 'react-hook-form';
|
||||
import { zodResolver } from '@hookform/resolvers/zod';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { toast } from 'sonner';
|
||||
import { ArrowDown, ArrowUp, Crosshair, ImagePlus, Trash2 } from 'lucide-react';
|
||||
import { ArrowDown, ArrowUp, ImagePlus, Trash2 } from 'lucide-react';
|
||||
import { DndContext, KeyboardSensor, PointerSensor, closestCenter, useSensor, useSensors, type DragEndEvent } from '@dnd-kit/core';
|
||||
import { SortableContext, sortableKeyboardCoordinates, verticalListSortingStrategy } from '@dnd-kit/sortable';
|
||||
import { Badge } from '@/components/ui/badge';
|
||||
@@ -15,7 +15,8 @@ import { FieldError } from '@/components/ui/FieldError';
|
||||
import { FormErrorBanner } from '@/components/ui/FormErrorBanner';
|
||||
import { NetworkError, ProblemDetailsError } from '@/lib/api-client';
|
||||
import { FocusDialog } from '../components/FocusDialog';
|
||||
import { DoneStatus, PhotoPlaceholder, ProcessingStatus, RecutThumbnail } from '../components/ProcessingStatus';
|
||||
import { CropThumbnail } from '../components/CropThumbnail';
|
||||
import { DoneStatus, PhotoPlaceholder, ProcessingStatus, RecutThumbnail, Spinner } from '../components/ProcessingStatus';
|
||||
import { SlideSwitch } from '../components/SlideSwitch';
|
||||
import { SortableSlide } from '../components/SortableSlide';
|
||||
import { UnsavedChangesGuard } from '../components/UnsavedChangesGuard';
|
||||
@@ -472,7 +473,13 @@ function HeroEditor({ hero }: { hero: HeroAdminDto }) {
|
||||
) : image?.processing ? (
|
||||
<RecutThumbnail src={thumbnail(image)} failed={image.failed} testId={`hero-slide-${index}-recut`} step={image.renderTotal ? { done: image.renderDone ?? 0, total: image.renderTotal } : null} />
|
||||
) : image ? (
|
||||
<img src={thumbnail(image)} alt="" className="h-20 w-28 rounded object-cover" />
|
||||
<CropThumbnail
|
||||
image={image}
|
||||
savedSrc={thumbnail(image)}
|
||||
edit={focusEdits[field.imageId]}
|
||||
onClick={() => setFocusImageId(field.imageId)}
|
||||
testId={`hero-slide-${index}-focus`}
|
||||
/>
|
||||
) : (
|
||||
<div className="flex h-20 w-28 items-center justify-center rounded bg-muted text-xs">?</div>
|
||||
)}
|
||||
@@ -486,9 +493,6 @@ function HeroEditor({ hero }: { hero: HeroAdminDto }) {
|
||||
<Input id={`hero-slide-${index}-alt`} maxLength={300} disabled={decorative} aria-describedby={`hero-slide-${index}-alt-hint`} data-testid={`hero-slide-${index}-alt`} {...register(`slides.${index}.alt` as const)} />
|
||||
<p id={`hero-slide-${index}-alt-hint`} className="text-xs text-muted-foreground">{t('hero.slides.altHint')}</p>
|
||||
<FieldError message={err(heroErrors.slides?.[index]?.alt?.message)} testId={`hero-slide-${index}-alt-error`} />
|
||||
{focusEdits[field.imageId] && (
|
||||
<p className="text-xs font-medium" data-testid={`hero-slide-${index}-focus-pending`}>{t('hero.slides.focusPending')}</p>
|
||||
)}
|
||||
<label className="flex items-center gap-2 text-sm">
|
||||
<input type="checkbox" className="size-4 rounded border-input" data-testid={`hero-slide-${index}-decorative`} {...register(`slides.${index}.decorative` as const)} />
|
||||
{t('hero.slides.decorative')}
|
||||
@@ -507,9 +511,6 @@ function HeroEditor({ hero }: { hero: HeroAdminDto }) {
|
||||
<Button type="button" variant="outline" size="icon" aria-label={t('hero.slides.down')} disabled={index === slides.fields.length - 1} onClick={() => slides.move(index, index + 1)} data-testid={`hero-slide-${index}-down`}>
|
||||
<ArrowDown className="size-4" aria-hidden="true" />
|
||||
</Button>
|
||||
<Button type="button" variant={focusEdits[field.imageId] ? 'default' : 'outline'} size="icon" aria-label={t('hero.slides.focus')} disabled={!image || image.variants.length === 0} onClick={() => setFocusImageId(field.imageId)} data-testid={`hero-slide-${index}-focus`}>
|
||||
<Crosshair className="size-4" aria-hidden="true" />
|
||||
</Button>
|
||||
<Button type="button" variant="destructive" size="icon" aria-label={t('hero.slides.remove')} title={t('hero.slides.remove')} onClick={() => slides.remove(index)} data-testid={`hero-slide-${index}-remove`}>
|
||||
<Trash2 className="size-4" aria-hidden="true" />
|
||||
</Button>
|
||||
@@ -537,8 +538,22 @@ function HeroEditor({ hero }: { hero: HeroAdminDto }) {
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
<Button type="submit" disabled={save.isPending} className={hasUnsaved ? 'ring-2 ring-primary ring-offset-2' : undefined} data-testid="hero-save">
|
||||
{save.isPending ? '…' : t('common.save')}
|
||||
<Button
|
||||
type="submit"
|
||||
disabled={save.isPending || !hasUnsaved}
|
||||
aria-disabled={save.isPending || !hasUnsaved}
|
||||
aria-busy={save.isPending}
|
||||
className={hasUnsaved && !save.isPending ? 'ring-2 ring-primary ring-offset-2' : undefined}
|
||||
data-testid="hero-save"
|
||||
>
|
||||
{save.isPending ? (
|
||||
<>
|
||||
<Spinner className="mr-2 size-4" />
|
||||
{t('hero.saving')}
|
||||
</>
|
||||
) : (
|
||||
t('common.save')
|
||||
)}
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user