Skip to content

Commit 601ffc7

Browse files
Redesign empty schedule view
- Add `empty-notice` and `Add Rotation` button under `.day-header` - Hide clock
1 parent ddf4e54 commit 601ffc7

File tree

2 files changed

+107
-15
lines changed

2 files changed

+107
-15
lines changed

library/Notifications/Widget/Timeline.php

Lines changed: 37 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,42 @@ 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+
'span',
360+
new Attributes(['class' => 'empty-state-notice']),
361+
new Icon('info-circle'),
362+
new Text($this->translate(
363+
'With schedules Contacts can rotate in recurring shifts. You can add'
364+
.' multiple rotation layers to a schedule.'
365+
))
366+
));
367+
368+
$this->getGrid()
369+
->addAttributes(['class' => 'empty'])
370+
->addHtml(new HtmlElement(
371+
'div',
372+
new Attributes(['class' => 'btn-container']),
373+
$emptyNotice,
374+
(new ButtonLink(
375+
$this->translate('Add your first Rotation'),
376+
Links::rotationAdd(Url::fromRequest()->getParam('id')),
377+
'plus'
378+
))->openInModal()
379+
));
380+
}
381+
}
382+
361383
$this->addHtml(
362384
$this->getGrid(),
363385
$this->getStyle()

public/css/timeline.less

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

8+
.empty-state-notice {
9+
display: flex;
10+
justify-content: center;
11+
align-items: center;
12+
position: relative;
13+
height: 4em;
14+
margin-bottom: 2em;
15+
color: @text-color-light;
16+
border: 1px solid @gray-light;
17+
.rounded-corners();
18+
19+
.icon {
20+
position: absolute;
21+
left: 1em;
22+
font-size: 1.75em;
23+
}
24+
}
25+
826
.time-grid {
927
--sidebarWidth: 12em;
1028
--stepRowHeight: 4em;
@@ -46,6 +64,14 @@
4664
}
4765
}
4866

67+
.btn-container {
68+
display: flex;
69+
justify-content: center;
70+
align-items: center;
71+
text-align: center;
72+
height: var(--primaryRowHeight);
73+
}
74+
4975
.overlay .entry {
5076
margin-top: 1em;
5177
margin-bottom: 1em;
@@ -205,6 +231,24 @@
205231
}
206232
}
207233

234+
.btn-container {
235+
background-color: @gray-lighter;
236+
237+
.empty-notice {
238+
margin-right: 1em;
239+
color: @text-color-light;
240+
}
241+
242+
.button-link {
243+
border: 1px solid;
244+
245+
&:hover {
246+
color: @text-color-on-icinga-blue;
247+
background-color: @icinga-blue;
248+
}
249+
}
250+
}
251+
208252
.entry .icon {
209253
font-size: .75em;
210254
opacity: .8;
@@ -230,3 +274,29 @@
230274
.days-header .column-title .date {
231275
font-size: .75em;
232276
}
277+
278+
.time-grid.empty {
279+
.btn-container {
280+
grid-area: ~"3 / 1 / 3 / 3";
281+
}
282+
283+
// .empty-state is placed under the .days-header, Everything below .empty-state element must slide down one row
284+
// so the grid-row-start and grid-row-end is increased by 1
285+
.sidebar {
286+
grid-area: ~"4 / 1 / 5 / 2";
287+
}
288+
289+
.grid,
290+
.overlay {
291+
grid-area: ~"4 / 2 / 5 / 3";
292+
}
293+
294+
.timescale {
295+
grid-area: ~"5 / 2 / 5 / 3";
296+
}
297+
298+
.clock {
299+
display: none;
300+
}
301+
}
302+

0 commit comments

Comments
 (0)