- Table floor_plans (tenant_id, one per apartment, picture = website photo, rooms as JSON with corners in percent of the picture), model FloorPlan with BelongsToTenant, Property::floorPlan() - Admin › Webseite › Grundriss: room list with name, description, photos, equipment (from the equipment list), accessibility hint, visibility, and an area editor (click the corners on the picture) - Section floor_plan: base view without JavaScript (areas jump to the room list), Seebad view with room buttons, highlighted area and a cartouche per room (theme.js initFloorPlans) - Tests: tenant inheritance, point parsing, website output, admin create incl. validation; the render test for all themes now includes the floor plan - Docs: THEMES §5, ZUSAMMENARBEIT §6, STATUS §6 (incl. note for tenancy phase 5) - styles/grundriss: revised rendering, WebP renditions, room areas of the Stommer flat in percent Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
53 lines
3.8 KiB
PHP
53 lines
3.8 KiB
PHP
{{--
|
|
Room area editor (FloorPlanForm): click the corners of a room on the plan picture; stored as "x,y x,y …" in
|
|
percent of the picture. The other rooms are shown as blue outlines for orientation.
|
|
--}}
|
|
@php
|
|
$planPhoto = \App\Models\Photo::query()->find($get('../../photo_id'));
|
|
$currentRoomId = $get('id');
|
|
$otherAreas = collect($get('../../rooms') ?? [])
|
|
->reject(fn ($room): bool => ($room['id'] ?? null) === $currentRoomId)
|
|
->map(fn ($room): string => collect(\App\Models\FloorPlan::points($room['points'] ?? null))->map(fn ($point): string => $point[0].','.$point[1])->implode(' '))
|
|
->filter()
|
|
->values();
|
|
@endphp
|
|
<x-dynamic-component :component="$getFieldWrapperView()" :field="$field">
|
|
@if (! $planPhoto)
|
|
<p style="padding:.75rem 1rem;border-radius:.5rem;background:#fef3c7;color:#92400e">Bitte oben zuerst das Grundriss-Bild wählen.</p>
|
|
@else
|
|
<div
|
|
x-data="{
|
|
state: $wire.$entangle('{{ $getStatePath() }}'),
|
|
points() { return String(this.state ?? '').trim().split(/\s+/).filter((pair) => /^\d+(\.\d+)?,\d+(\.\d+)?$/.test(pair)) },
|
|
add(event) {
|
|
const box = this.$refs.plan.getBoundingClientRect()
|
|
const x = Math.min(100, Math.max(0, Math.round((event.clientX - box.left) / box.width * 1000) / 10))
|
|
const y = Math.min(100, Math.max(0, Math.round((event.clientY - box.top) / box.height * 1000) / 10))
|
|
this.state = [...this.points(), x + ',' + y].join(' ')
|
|
},
|
|
undo() { this.state = this.points().slice(0, -1).join(' ') },
|
|
clear() { this.state = '' },
|
|
}"
|
|
>
|
|
<div x-ref="plan" x-on:click="add($event)" style="position:relative;cursor:crosshair;user-select:none;border:1px solid #e4e4e7;border-radius:.5rem;overflow:hidden">
|
|
<img src="{{ $planPhoto->url('lg') }}" alt="" draggable="false" style="display:block;width:100%;height:auto">
|
|
<svg viewBox="0 0 100 100" preserveAspectRatio="none" style="position:absolute;inset:0;width:100%;height:100%;pointer-events:none" aria-hidden="true">
|
|
@foreach ($otherAreas as $area)
|
|
<polygon points="{{ $area }}" fill="rgba(37,99,235,.10)" stroke="#2563eb" stroke-width="1.5" vector-effect="non-scaling-stroke" />
|
|
@endforeach
|
|
<polygon x-bind:points="points().join(' ')" fill="rgba(217,119,6,.28)" stroke="#d97706" stroke-width="2.5" vector-effect="non-scaling-stroke" />
|
|
</svg>
|
|
<template x-for="(point, index) in points()" x-bind:key="index">
|
|
<span x-bind:style="`position:absolute;left:${point.split(',')[0]}%;top:${point.split(',')[1]}%;width:12px;height:12px;margin:-6px 0 0 -6px;background:#fff;border:2px solid #d97706;border-radius:2px`"></span>
|
|
</template>
|
|
</div>
|
|
<div style="display:flex;flex-wrap:wrap;align-items:center;gap:.5rem;margin-top:.5rem">
|
|
<span style="font-size:.875rem;color:#52525b" x-text="points().length + (points().length === 1 ? ' Eckpunkt' : ' Eckpunkte')"></span>
|
|
<x-filament::button size="sm" color="gray" x-on:click="undo()" x-bind:disabled="points().length === 0">Letzten Punkt entfernen</x-filament::button>
|
|
<x-filament::button size="sm" color="danger" outlined x-on:click="clear()" x-bind:disabled="points().length === 0">Fläche leeren</x-filament::button>
|
|
</div>
|
|
<p style="margin-top:.25rem;font-size:.875rem;color:#71717a">Klicken Sie nacheinander die Ecken des Raums auf dem Bild an, im Uhrzeigersinn. Blau umrandet: die anderen Räume.</p>
|
|
</div>
|
|
@endif
|
|
</x-dynamic-component>
|