Skip to content

Commit 8c5ab1c

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

File tree

2 files changed

+114
-15
lines changed

2 files changed

+114
-15
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: 73 additions & 0 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;
@@ -46,6 +67,14 @@
4667
}
4768
}
4869

70+
.btn-container {
71+
display: flex;
72+
justify-content: center;
73+
align-items: center;
74+
text-align: center;
75+
height: var(--primaryRowHeight);
76+
}
77+
4978
.overlay .entry {
5079
margin-top: 1em;
5180
margin-bottom: 1em;
@@ -205,6 +234,24 @@
205234
}
206235
}
207236

237+
.btn-container {
238+
background-color: fade(@gray-light, 25%);
239+
240+
.empty-notice {
241+
margin-right: 1em;
242+
color: @text-color-light;
243+
}
244+
245+
.button-link {
246+
border: 1px solid;
247+
248+
&:hover {
249+
color: @text-color-on-icinga-blue;
250+
background-color: @icinga-blue;
251+
}
252+
}
253+
}
254+
208255
.entry .icon {
209256
font-size: .75em;
210257
opacity: .8;
@@ -230,3 +277,29 @@
230277
.days-header .column-title .date {
231278
font-size: .75em;
232279
}
280+
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+
display: none;
303+
}
304+
}
305+

0 commit comments

Comments
 (0)