fix: render shortened names as initial and surname
This commit is contained in:
1 parent
bbb0a8aaa2
commit
09415c4722
2 files changed
+10
-8
No files matched your search
@@ -45,9 +45,10 @@
|
||||
{% if booking.user.id == app.user.id %}
|
||||
{% set who = 'du' %}
|
||||
{% else %}
|
||||
{# "Anna Berger" -> "Anna B." : keeps a card on one line per booking at phone width. #}
|
||||
{# "Anna Berger" -> "A. Berger" : keeps a card on one line per booking at phone width,
|
||||
and the surname tells two Annas apart where the initial would not. #}
|
||||
{% set parts = booking.user.name|split(' ')|filter(part => part is not empty) %}
|
||||
{% set who = parts|length > 1 ? parts|first ~ ' ' ~ parts|last|slice(0, 1) ~ '.' : booking.user.name %}
|
||||
{% set who = parts|length > 1 ? parts|first|slice(0, 1) ~ '. ' ~ parts|last : booking.user.name %}
|
||||
{% endif %}
|
||||
{% set lines = lines|merge([who ~ (booking.timeRange.allDay ? '' : ' ' ~ booking.timeRange)]) %}
|
||||
{% endfor %}
|
||||
|
||||
@@ -56,20 +56,21 @@ class FloorPlanTest extends WebTestCase
|
||||
$this->book($desk, $this->user('[email protected]', 'Bea Kranz'), 540, 780);
|
||||
|
||||
self::assertSame(
|
||||
['Schreibtisch 01', 'Bea K. 09:00–13:00', 'frei ab 13:00'],
|
||||
['Schreibtisch 01', 'B. Kranz 09:00–13:00', 'frei ab 13:00'],
|
||||
$this->linesOf($this->board()),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Full names are shortened so a card stays one line per booking at phone width.
|
||||
* Full names are shortened so a card stays one line per booking at phone width. The surname
|
||||
* survives, not the first name, so two colleagues sharing a first name stay distinguishable.
|
||||
*/
|
||||
public function testALongNameIsShortenedToAFirstNameAndInitial(): void
|
||||
public function testALongNameIsShortenedToAnInitialAndTheSurname(): void
|
||||
{
|
||||
$desk = $this->desk();
|
||||
$this->book($desk, $this->user('[email protected]', 'Maximilian Wolkenstein'), 0, 1440);
|
||||
|
||||
self::assertContains('Maximilian W.', $this->linesOf($this->board()));
|
||||
self::assertContains('M. Wolkenstein', $this->linesOf($this->board()));
|
||||
}
|
||||
|
||||
public function testASingleWordNameIsLeftAlone(): void
|
||||
@@ -94,7 +95,7 @@ class FloorPlanTest extends WebTestCase
|
||||
$desk = $this->desk();
|
||||
$this->book($desk, $this->user('[email protected]', 'Bea Kranz'), 0, 1440);
|
||||
|
||||
self::assertSame(['Schreibtisch 01', 'Bea K.'], $this->linesOf($this->board()));
|
||||
self::assertSame(['Schreibtisch 01', 'B. Kranz'], $this->linesOf($this->board()));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -112,7 +113,7 @@ class FloorPlanTest extends WebTestCase
|
||||
$lines = $this->linesOf($this->board());
|
||||
|
||||
self::assertSame(
|
||||
['Schreibtisch 01', 'Ann A. bis 06:00', 'Bea B. 06:00–12:00', '+2 weitere'],
|
||||
['Schreibtisch 01', 'A. Alpha bis 06:00', 'B. Beta 06:00–12:00', '+2 weitere'],
|
||||
$lines,
|
||||
);
|
||||
// Label plus MAX_LINES, never more.
|
||||
|
||||
Reference in new issue
Block a user