feat: group resources into rooms on the floor plan
This commit is contained in:
1 parent
faef4d70a8
commit
8caf618950
14 files changed
+653
-34
No files matched your search
@@ -1,32 +1,47 @@
|
||||
{#
|
||||
The office. Hand-authored geometry: `svgElementId` on each Resource is the key that ties a
|
||||
database row to a shape here, so a resource whose id is missing from the map is simply not
|
||||
drawn (and vice versa) -- app:seed and this map have to agree.
|
||||
The office. Hand-authored geometry in two maps: `rooms` is keyed by ResourceGroup.svgElementId
|
||||
and `geometry` by Resource.svgElementId, so a row whose id is missing from its map is simply
|
||||
not drawn (and vice versa) -- app:seed and these maps have to agree.
|
||||
|
||||
Box height is set by what goes inside it, not by taste: _spot.html.twig puts the label at
|
||||
+18 and up to three lines at +34, +47 and +60, so 86 leaves a comfortable margin below the
|
||||
last one. Changing MAX_LINES there means changing the height here.
|
||||
|
||||
A room band is 118 high: 16 of margin, an 86-high desk, 16 again. The 30 between two bands is
|
||||
what the next room's caption sits in, since room() draws it above the rect. Moving a desk
|
||||
between rooms therefore means moving its y here as well as its group in the database -- the
|
||||
drawing is artwork, and no amount of indirection changes that.
|
||||
|
||||
Found by convention from ResourceType::DESK->value, see board/_floorplan.html.twig.
|
||||
#}
|
||||
{% import 'board/plan/_spot.html.twig' as plan %}
|
||||
|
||||
{% set rooms = {
|
||||
'room-01': { x: 10, y: 22, width: 500, height: 118 },
|
||||
'room-02': { x: 10, y: 170, width: 500, height: 118 },
|
||||
'room-03': { x: 10, y: 318, width: 500, height: 118 },
|
||||
'room-04': { x: 10, y: 466, width: 500, height: 118 }
|
||||
} %}
|
||||
|
||||
{% set geometry = {
|
||||
'desk-01': { x: 40, y: 50 }, 'desk-02': { x: 200, y: 50 }, 'desk-03': { x: 360, y: 50 },
|
||||
'desk-04': { x: 40, y: 155 }, 'desk-05': { x: 200, y: 155 }, 'desk-06': { x: 360, y: 155 },
|
||||
'desk-07': { x: 40, y: 260 }, 'desk-08': { x: 200, y: 260 }, 'desk-09': { x: 360, y: 260 },
|
||||
'desk-10': { x: 40, y: 365 }, 'desk-11': { x: 200, y: 365 }, 'desk-12': { x: 360, y: 365 }
|
||||
'desk-01': { x: 40, y: 38 }, 'desk-02': { x: 200, y: 38 }, 'desk-03': { x: 360, y: 38 },
|
||||
'desk-04': { x: 40, y: 186 }, 'desk-05': { x: 200, y: 186 }, 'desk-06': { x: 360, y: 186 },
|
||||
'desk-07': { x: 40, y: 334 }, 'desk-08': { x: 200, y: 334 }, 'desk-09': { x: 360, y: 334 },
|
||||
'desk-10': { x: 40, y: 482 }, 'desk-11': { x: 200, y: 482 }, 'desk-12': { x: 360, y: 482 }
|
||||
} %}
|
||||
{% set time_params = selected_time.allDay ? {} : { from: selected_time.start, to: selected_time.end } %}
|
||||
|
||||
<svg viewBox="0 0 520 486" class="w-full h-auto" role="group" aria-label="Raumplan Büro">
|
||||
<rect x="10" y="18" width="500" height="448" rx="8" class="fill-white stroke-gray-300" stroke-width="2"></rect>
|
||||
<text x="20" y="12" class="fill-gray-400 text-xs font-semibold">Büro</text>
|
||||
|
||||
{% for resource in resources %}
|
||||
{% if resource.svgElementId and geometry[resource.svgElementId] is defined %}
|
||||
{{ plan.spot(spots[resource.id], geometry[resource.svgElementId], 140, 86,
|
||||
selected_date, is_past, time_params) }}
|
||||
<svg viewBox="0 0 520 594" class="w-full h-auto" role="group" aria-label="Raumplan Büro">
|
||||
{% for spot_group in spot_groups %}
|
||||
{% if spot_group.group and rooms[spot_group.group.svgElementId] is defined %}
|
||||
{{ plan.room(spot_group.group.label, rooms[spot_group.group.svgElementId], spot_group.freeCount) }}
|
||||
{% endif %}
|
||||
|
||||
{% for spot in spot_group.spots %}
|
||||
{% if spot.resource.svgElementId and geometry[spot.resource.svgElementId] is defined %}
|
||||
{{ plan.spot(spot, geometry[spot.resource.svgElementId], 140, 86,
|
||||
selected_date, is_past, time_params) }}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
</svg>
|
||||
@@ -16,10 +16,17 @@
|
||||
{# The lane between the two rows. #}
|
||||
<line x1="265" y1="36" x2="265" y2="310" class="stroke-gray-200" stroke-width="2" stroke-dasharray="6 6"></line>
|
||||
|
||||
{% for resource in resources %}
|
||||
{% if resource.svgElementId and geometry[resource.svgElementId] is defined %}
|
||||
{{ plan.spot(spots[resource.id], geometry[resource.svgElementId], 200, 78,
|
||||
selected_date, is_past, time_params) }}
|
||||
{% endif %}
|
||||
{#
|
||||
The car park is one area, so nothing here is grouped and every spot arrives in the single
|
||||
null-group entry -- which is why this plan keeps drawing its own frame above instead of
|
||||
letting room() do it. See board/plan/_desk.html.twig for the grouped case.
|
||||
#}
|
||||
{% for spot_group in spot_groups %}
|
||||
{% for spot in spot_group.spots %}
|
||||
{% if spot.resource.svgElementId and geometry[spot.resource.svgElementId] is defined %}
|
||||
{{ plan.spot(spot, geometry[spot.resource.svgElementId], 200, 78,
|
||||
selected_date, is_past, time_params) }}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
</svg>
|
||||
@@ -15,8 +15,29 @@
|
||||
Clicking always opens a modal: the create modal when anything is still free, the edit modal
|
||||
when it is yours (which is where changing the times and releasing live). Nothing else is
|
||||
clickable, so the SVG carries no confirm dialogs or inline CSRF tokens.
|
||||
|
||||
room() lives here for the same reason spot() does: a plan that frames its shapes into rooms
|
||||
and one that does not must otherwise draw their borders in two places and drift apart.
|
||||
#}
|
||||
|
||||
{#
|
||||
The frame around one room, captioned with its name and how many of its spots are still free
|
||||
for the whole of the board's span.
|
||||
|
||||
The caption sits above the rect rather than inside it, so it never collides with a spot box,
|
||||
and the geometry only has to say where the room is.
|
||||
#}
|
||||
{% macro room(label, geometry, free) %}
|
||||
<rect x="{{ geometry.x }}" y="{{ geometry.y }}"
|
||||
width="{{ geometry.width }}" height="{{ geometry.height }}" rx="8"
|
||||
class="fill-white stroke-gray-300" stroke-width="2"></rect>
|
||||
<text x="{{ geometry.x + 10 }}" y="{{ geometry.y - 6 }}" class="fill-gray-400 text-xs font-semibold">
|
||||
{{- label -}}
|
||||
{%- if free > 0 %} <tspan class="fill-emerald-600">· {{ free }} frei</tspan>
|
||||
{%- else %} <tspan class="fill-gray-400">· belegt</tspan>{% endif -%}
|
||||
</text>
|
||||
{% endmacro %}
|
||||
|
||||
{% macro spot(spot, geometry, width, height, selected_date, is_past, time_params) %}
|
||||
{% set MAX_LINES = 3 %}
|
||||
{% set state = spot.state.name %}
|
||||
|
||||
Reference in new issue
Block a user