Skip to content

Commit ac2b977

Browse files
Redesign empty schedule view
- Add `empty-notice` and `Add Rotation` button under `.day-header` - Hide clock
1 parent 4cd1af7 commit ac2b977

File tree

2 files changed

+116
-18
lines changed

2 files changed

+116
-18
lines changed

library/Notifications/Widget/Timeline.php

Lines changed: 41 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
use ipl\I18n\Translation;
2525
use ipl\Web\Style;
2626
use ipl\Web\Url;
27+
use ipl\Web\Widget\ButtonLink;
2728
use ipl\Web\Widget\Icon;
2829
use ipl\Web\Widget\Link;
2930
use Locale;
@@ -303,21 +304,6 @@ protected function assembleSidebarEntry(Rotation $rotation): BaseHtmlElement
303304

304305
protected function assemble()
305306
{
306-
if (empty($this->rotations)) {
307-
$emptyNotice = new HtmlElement(
308-
'div',
309-
Attributes::create(['class' => 'empty-notice']),
310-
Text::create($this->translate('No rotations configured'))
311-
);
312-
313-
if ($this->minimalLayout) {
314-
$this->getAttributes()->add(['class' => 'minimal-layout']);
315-
$this->addHtml($emptyNotice);
316-
} else {
317-
$this->getGrid()->addToSideBar($emptyNotice);
318-
}
319-
}
320-
321307
if (! $this->minimalLayout) {
322308
$this->getGrid()->addToSideBar(
323309
new HtmlElement(
@@ -364,6 +350,46 @@ protected function assemble()
364350
->addHtml($clock);
365351
}
366352

353+
if (! $this->rotations) {
354+
$emptyNotice = new HtmlElement(
355+
'div',
356+
Attributes::create(['class' => 'empty-notice']),
357+
Text::create($this->translate('No rotations configured, yet.'))
358+
);
359+
360+
if ($this->minimalLayout) {
361+
$this->getAttributes()->add(['class' => 'minimal-layout']);
362+
$this->addHtml($emptyNotice);
363+
} else {
364+
$this->addHtml(new HtmlElement(
365+
'div',
366+
new Attributes(['class' => 'empty-state-notice']),
367+
new Icon('info-circle'),
368+
new HtmlElement(
369+
'span',
370+
null,
371+
new Text($this->translate(
372+
'With schedules Contacts can rotate in recurring shifts. You can add'
373+
. ' multiple rotation layers to a schedule.'
374+
))
375+
)
376+
));
377+
378+
$this->getGrid()
379+
->addAttributes(['class' => 'empty'])
380+
->addHtml(new HtmlElement(
381+
'div',
382+
new Attributes(['class' => 'btn-container']),
383+
$emptyNotice,
384+
(new ButtonLink(
385+
$this->translate('Add your first Rotation'),
386+
Links::rotationAdd(Url::fromRequest()->getParam('id')),
387+
'plus'
388+
))->openInModal()
389+
));
390+
}
391+
}
392+
367393
$this->addHtml(
368394
$this->getGrid(),
369395
$this->getStyle()

public/css/timeline.less

Lines changed: 75 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,27 @@
55
flex-direction: column;
66
overflow: hidden;
77

8+
.empty-state-notice {
9+
display: flex;
10+
justify-content: space-between;
11+
align-items: center;
12+
padding: 1em;
13+
margin-bottom: 2em;
14+
border: 1px solid @gray-light;
15+
.rounded-corners();
16+
color: @text-color-light;
17+
18+
.icon {
19+
font-size: 1.75em;
20+
}
21+
22+
> span {
23+
padding-left: 0.5em;
24+
flex-grow: 1;
25+
text-align: center;
26+
}
27+
}
28+
829
.time-grid {
930
--sidebarWidth: 12em;
1031
--stepRowHeight: 4em;
@@ -44,6 +65,14 @@
4465
}
4566
}
4667

68+
.btn-container {
69+
display: flex;
70+
justify-content: center;
71+
align-items: center;
72+
text-align: center;
73+
height: var(--primaryRowHeight);
74+
}
75+
4776
.overlay .entry {
4877
margin-top: 1em;
4978
margin-bottom: 1em;
@@ -68,8 +97,8 @@
6897
position: absolute;
6998
right: 0;
7099
left: 0;
71-
// -1 to exclude result row
72-
top: ~"calc((var(--stepRowHeight) * calc(var(--primaryRows) - 1)) + var(--daysHeaderHeight))";
100+
// -1 to exclude result row, max to have minimum 1 row
101+
top: ~"calc(var(--stepRowHeight) * max(calc(var(--primaryRows) - 1), 1) + var(--daysHeaderHeight))";
73102
}
74103

75104
.timescale {
@@ -204,6 +233,24 @@
204233
}
205234
}
206235

236+
.btn-container {
237+
background-color: fade(@gray-light, 25%);
238+
239+
.empty-notice {
240+
margin-right: 1em;
241+
color: @text-color-light;
242+
}
243+
244+
.button-link {
245+
border: 1px solid;
246+
247+
&:hover {
248+
color: @text-color-on-icinga-blue;
249+
background-color: @icinga-blue;
250+
}
251+
}
252+
}
253+
207254
.entry .icon {
208255
font-size: .75em;
209256
opacity: .8;
@@ -231,6 +278,31 @@
231278
color: @text-color-light;
232279
}
233280

281+
.time-grid.empty {
282+
.btn-container {
283+
grid-area: ~"3 / 1 / 3 / 3";
284+
}
285+
286+
// .empty-state is placed under the .days-header, Everything below .empty-state element must slide down one row
287+
// so the grid-row-start and grid-row-end is increased by 1
288+
.sidebar {
289+
grid-area: ~"4 / 1 / 5 / 2";
290+
}
291+
292+
.grid,
293+
.overlay {
294+
grid-area: ~"4 / 2 / 5 / 3";
295+
}
296+
297+
.timescale {
298+
grid-area: ~"5 / 2 / 5 / 3";
299+
}
300+
301+
.clock {
302+
grid-area: ~"3 / 2 / 5 / 3";
303+
}
304+
}
305+
234306
#layout.twocols:not(.wide-layout) .days-header .column-title {
235307
display: flex;
236308
flex-direction: column;
@@ -239,6 +311,6 @@
239311
padding-bottom: .25em;
240312
}
241313

242-
#layout.twocols .schedule-detail .timescale:has(:nth-child(n+62)) { // month view (--timestampsPerDay * --primaryColumns = 62)
314+
#layout.twocols .schedule .timescale:has(:nth-child(n+62)) { // month view (--timestampsPerDay * --primaryColumns = 62)
243315
display: none;
244316
}

0 commit comments

Comments
 (0)