Skip to content

Commit ad9a0cd

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

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 Locale;
2930
use SplObjectStorage;
@@ -293,21 +294,6 @@ protected function assembleSidebarEntry(Rotation $rotation): BaseHtmlElement
293294

294295
protected function assemble()
295296
{
296-
if (empty($this->rotations)) {
297-
$emptyNotice = new HtmlElement(
298-
'div',
299-
Attributes::create(['class' => 'empty-notice']),
300-
Text::create($this->translate('No rotations configured'))
301-
);
302-
303-
if ($this->minimalLayout) {
304-
$this->getAttributes()->add(['class' => 'minimal-layout']);
305-
$this->addHtml($emptyNotice);
306-
} else {
307-
$this->getGrid()->addToSideBar($emptyNotice);
308-
}
309-
}
310-
311297
if (! $this->minimalLayout) {
312298
$this->getGrid()->addToSideBar(
313299
new HtmlElement(
@@ -354,6 +340,42 @@ protected function assemble()
354340
->addHtml($clock);
355341
}
356342

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

public/css/timeline.less

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,24 @@
44
display: flex;
55
flex-direction: column;
66

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

52+
.btn-container {
53+
display: flex;
54+
justify-content: center;
55+
align-items: center;
56+
text-align: center;
57+
height: var(--primaryRowHeight);
58+
}
59+
3460
.overlay .entry {
3561
margin-top: 1em;
3662
margin-bottom: 1em;
@@ -167,6 +193,24 @@
167193
}
168194
}
169195

196+
.btn-container {
197+
background-color: @gray-lighter;
198+
199+
.empty-notice {
200+
margin-right: 1em;
201+
color: @text-color-light;
202+
}
203+
204+
.button-link {
205+
border: 1px solid;
206+
207+
&:hover {
208+
color: @text-color-on-icinga-blue;
209+
background-color: @icinga-blue;
210+
}
211+
}
212+
}
213+
170214
.entry .icon {
171215
font-size: .75em;
172216
opacity: .8;
@@ -195,3 +239,29 @@
195239
.days-header .column-title .date {
196240
font-size: .75em;
197241
}
242+
243+
.time-grid.empty {
244+
.btn-container {
245+
grid-area: ~"3 / 1 / 3 / 3";
246+
}
247+
248+
// .empty-state is placed under the .days-header, Everything below .empty-state element must slide down one row
249+
// so the grid-row-start and grid-row-end is increased by 1
250+
.sidebar {
251+
grid-area: ~"4 / 1 / 5 / 2";
252+
}
253+
254+
.grid,
255+
.overlay {
256+
grid-area: ~"4 / 2 / 5 / 3";
257+
}
258+
259+
.timescale {
260+
grid-area: ~"5 / 2 / 5 / 3";
261+
}
262+
263+
.clock {
264+
display: none;
265+
}
266+
}
267+

0 commit comments

Comments
 (0)