Skip to content

Commit 8a93022

Browse files
Redesign empty schedule view
- Add `empty-notice` and `Add Rotation` button under `.day-header` - Hide clock
1 parent 6762542 commit 8a93022

File tree

2 files changed

+115
-17
lines changed

2 files changed

+115
-17
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;
@@ -297,21 +298,6 @@ protected function assembleSidebarEntry(Rotation $rotation): BaseHtmlElement
297298

298299
protected function assemble()
299300
{
300-
if (empty($this->rotations)) {
301-
$emptyNotice = new HtmlElement(
302-
'div',
303-
Attributes::create(['class' => 'empty-notice']),
304-
Text::create($this->translate('No rotations configured'))
305-
);
306-
307-
if ($this->minimalLayout) {
308-
$this->getAttributes()->add(['class' => 'minimal-layout']);
309-
$this->addHtml($emptyNotice);
310-
} else {
311-
$this->getGrid()->addToSideBar($emptyNotice);
312-
}
313-
}
314-
315301
if (! $this->minimalLayout) {
316302
$this->getGrid()->addToSideBar(
317303
new HtmlElement(
@@ -358,6 +344,46 @@ protected function assemble()
358344
->addHtml($clock);
359345
}
360346

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

public/css/timeline.less

Lines changed: 74 additions & 2 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;
@@ -48,6 +69,14 @@
4869
}
4970
}
5071

72+
.btn-container {
73+
display: flex;
74+
justify-content: center;
75+
align-items: center;
76+
text-align: center;
77+
height: var(--primaryRowHeight);
78+
}
79+
5180
.overlay .entry {
5281
margin-top: 1em;
5382
margin-bottom: 1em;
@@ -72,8 +101,8 @@
72101
position: absolute;
73102
right: 0;
74103
left: 0;
75-
// -1 to exclude result row
76-
top: ~"calc((var(--stepRowHeight) * calc(var(--primaryRows) - 1)) + var(--daysHeaderHeight))";
104+
// -1 to exclude result row, max to have minimum 1 row
105+
top: ~"calc(var(--stepRowHeight) * max(calc(var(--primaryRows) - 1), 1) + var(--daysHeaderHeight))";
77106
}
78107

79108
.timescale {
@@ -212,6 +241,24 @@
212241
}
213242
}
214243

244+
.btn-container {
245+
background-color: fade(@gray-light, 25%);
246+
247+
.empty-notice {
248+
margin-right: 1em;
249+
color: @text-color-light;
250+
}
251+
252+
.button-link {
253+
border: 1px solid;
254+
255+
&:hover {
256+
color: @text-color-on-icinga-blue;
257+
background-color: @icinga-blue;
258+
}
259+
}
260+
}
261+
215262
.entry .icon {
216263
font-size: .75em;
217264
opacity: .8;
@@ -238,6 +285,31 @@
238285
font-size: .75em;
239286
}
240287

288+
.time-grid.empty {
289+
.btn-container {
290+
grid-area: ~"3 / 1 / 3 / 3";
291+
}
292+
293+
// .empty-state is placed under the .days-header, Everything below .empty-state element must slide down one row
294+
// so the grid-row-start and grid-row-end is increased by 1
295+
.sidebar {
296+
grid-area: ~"4 / 1 / 5 / 2";
297+
}
298+
299+
.grid,
300+
.overlay {
301+
grid-area: ~"4 / 2 / 5 / 3";
302+
}
303+
304+
.timescale {
305+
grid-area: ~"5 / 2 / 5 / 3";
306+
}
307+
308+
.clock {
309+
grid-area: ~"3 / 2 / 5 / 3";
310+
}
311+
}
312+
241313
#layout.twocols .schedule .timescale:has(:nth-child(n+62)) { // month view (--timestampsPerDay * --primaryColumns = 62)
242314
display: none;
243315
}

0 commit comments

Comments
 (0)