Skip to content

Commit 41595b9

Browse files
Make rotation title clickable and editable (#296)
resolves #279
2 parents abf448f + f000268 commit 41595b9

File tree

4 files changed

+54
-8
lines changed

4 files changed

+54
-8
lines changed

library/Notifications/Widget/Timeline.php

+5-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
use ipl\Web\Style;
2323
use ipl\Web\Url;
2424
use ipl\Web\Widget\Icon;
25+
use ipl\Web\Widget\Link;
2526
use SplObjectStorage;
2627
use Traversable;
2728

@@ -281,7 +282,10 @@ protected function assembleSidebarEntry(Rotation $rotation): BaseHtmlElement
281282
$entry->addHtml(
282283
$form,
283284
new Icon('bars', ['data-drag-initiator' => true]),
284-
new HtmlElement('span', null, Text::create($rotation->getName()))
285+
(new Link(
286+
[new HtmlElement('span', null, Text::create($rotation->getName())), new Icon('cog')],
287+
Links::rotationSettings($rotation->getId(), $rotation->getScheduleId())
288+
))->openInModal()
285289
);
286290

287291
return $entry;

library/Notifications/Widget/Timeline/Rotation.php

+12-2
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,16 @@ public function getId(): int
3939
return $this->model->id;
4040
}
4141

42+
/**
43+
* Get the schedule ID of the rotation
44+
*
45+
* @return int
46+
*/
47+
public function getScheduleId(): int
48+
{
49+
return $this->model->schedule_id;
50+
}
51+
4252
/**
4353
* Get the name of the rotation
4454
*
@@ -137,7 +147,7 @@ public function fetchTimeperiodEntries(DateTime $after, DateTime $until): Genera
137147
->setMember($member)
138148
->setStart($recurrence)
139149
->setEnd($recurrenceEnd)
140-
->setUrl(Links::rotationSettings($this->model->id, $this->model->schedule_id));
150+
->setUrl(Links::rotationSettings($this->getId(), $this->getScheduleId()));
141151

142152
yield $occurrence;
143153
}
@@ -146,7 +156,7 @@ public function fetchTimeperiodEntries(DateTime $after, DateTime $until): Genera
146156
->setMember($member)
147157
->setStart($timeperiodEntry->start_time)
148158
->setEnd($timeperiodEntry->end_time)
149-
->setUrl(Links::rotationSettings($this->model->id, $this->model->schedule_id));
159+
->setUrl(Links::rotationSettings($this->getId(), $this->getScheduleId()));
150160

151161
yield $entry;
152162
}

public/css/timeline.less

+35-4
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,20 @@
2828
margin-left: .5em;
2929
.text-ellipsis();
3030
}
31+
32+
> a {
33+
display: flex;
34+
width: 100%;
35+
align-items: baseline;
36+
margin-left: .5em;
37+
38+
span {
39+
width: 0;
40+
flex: 1 0 auto;
41+
margin-right: 0.25em;
42+
.text-ellipsis();
43+
}
44+
}
3145
}
3246

3347
.overlay .entry {
@@ -80,13 +94,14 @@
8094
.rotation-name {
8195
font-size: 1.25em;
8296
font-weight: bold;
83-
cursor: grab;
8497

8598
[data-drag-initiator] {
8699
color: @gray-light;
87-
}
88-
&:hover [data-drag-initiator] {
89-
color: @text-color;
100+
101+
&:hover {
102+
cursor: grab;
103+
color: @list-item-title-hover-color;
104+
}
90105
}
91106

92107
// :not(:empty) is only necessary to increase specificity
@@ -97,6 +112,22 @@
97112
&.sortable-ghost {
98113
opacity: .5;
99114
}
115+
116+
> a {
117+
text-decoration: none;
118+
119+
i {
120+
display: none;
121+
}
122+
123+
&:hover {
124+
color: @list-item-title-hover-color;
125+
126+
i {
127+
display: inline-block;
128+
}
129+
}
130+
}
100131
}
101132

102133
.entry .icon {

public/js/schedule.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@
4141
Sortable.create(sideBar, {
4242
scroll: true,
4343
direction: 'vertical',
44-
draggable: '.rotation-name'
44+
draggable: '.rotation-name',
45+
handle: '.rotation-name > i[data-drag-initiator]'
4546
});
4647
}
4748

0 commit comments

Comments
 (0)