feat(web): self person Ich badge + profile photo with crop dialog (spec 057) #1150
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/057-self-person-frontend"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary (spec 057, frontend lane S057T005–T006)
API client (
apps/web/src/lib/api/self-person.ts, mirrorsdiscovery.tsstyle)getSelfPerson(),claimSelfPerson(classInstanceId),unclaimSelfPerson(),setSelfPersonPhoto(mediaItemId, {x,y,size}),selfPersonPhotoUrl(size, version?)claimConflictDisplayName(error)(409 holder name, flat body or ProblemDetaildetailJSON),isClaimConflict(error),withPhotoCacheBust(url, version)selfPersonClaim?: { state: 'none'|'self'|'other', claimedByDisplayName? }on bothClassInstanceBrowseView(the list read path the person page actually loads) andPersonDetailView(getPersonDetail), optional/defensive for older API builds.Person detail page (
DiscoveryInstanceDetail.svelte)state=self.state=otherrenders a disabled entry "Bereits von {claimedByDisplayName} als Ich markiert".selfPersonClaimif the API sends it (list row orgetPersonDetail); otherwise falls back toGET /profile/self-person(derivesself/none). Hidden until resolved — never a guessed action.describeApiErrortoast.Profile page (
/profile, Konto tab)SelfPersonSectioncard ("Ich" / "Mein Personenprofil"): avatar with fallback chain profile photo → representative thumbnail → initials, person name + "Ich" chip, link to/discovery/domains/people/instances/{id}, actions "Person auswählen/ändern", "Profilbild ändern", "Verknüpfung entfernen".getAllPeople()mapped into the existingPersonTargetPickercomponent; 409 shows the hint inline in the picker and refreshes the list.getPersonDetail(selfPerson).mediafiltered to photos → tile grid (skeleton, empty state, "Weitere Fotos anzeigen").SelfPersonCropDialog): square viewport = the crop frame, cover-fit image, drag to pan (pointer + touch,touch-action: none), wheel/slider/keyboard (+/-, arrows) to zoom about the center, rule-of-thirds guides + emerald corner brackets, live circular preview of the final avatar, German hints, Escape/Abbrechen/Schließen to close, busy state + inline save error (400/422), "Anderes Foto" back action.SelfPersonAvatar).Crop math (
apps/web/src/lib/utils/selfPersonCrop.ts) is pure + unit-tested (15 cases): cover scale, clamping, center-stable zoom, normalized crop output.Contract notes for the backend/worker lanes
GET/PUT/DELETE /api/profile/self-person,PUT /api/profile/self-person/photo {mediaItemId, crop},GET /api/profile/self-person/photo?size=256.x = left / imageWidth,y = top / imageHeight,size = squareSide / imageWidth(width-anchored: worker doesside_px = size * width,left = x * width,top = y * height). The UI only ever emitssize ≤ min(W,H)/W, so the square always fits. If the worker instead anchorssizetomin(width, height), tell me — it's a one-line change incomputeCrop.selfPersonClaimis read from whichever endpoint carries it; the person page works today with either the class-instance list payload orgetPersonDetail(it falls back to the other automatically), and degrades tononeif neither sends it yet.?v=<timestamp>after a re-crop (cache bust) — the extra query param must be ignored by the photo endpoint (Spring binds only what it knows).Validation (apps/web)
npm run check→ 0 errors, 21 warnings in 7 files — all warnings pre-existing in untouched files (baseline before my change was the same 21; my files contribute none).npm run test:unit→ 151 tests passed (21 files), includes the newselfPersonCrop.spec.ts(15) andself-person.spec.ts(9).npm run build→ success (vite + adapter-node), exit 0.origin/mainbefore push; check/tests/build re-run green afterwards.Scope: only
apps/web. No API/worker changes, no KNOWN_ISSUES.md edit, not merged.b1b91e60c0e0332e683bb3174a4eafb18dae283b