Skip to content

Commit

Permalink
Make rotation title clickable and editable (#296)
Browse files Browse the repository at this point in the history
resolves #279
  • Loading branch information
sukhwinder33445 authored Mar 3, 2025
2 parents abf448f + f000268 commit 41595b9
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 8 deletions.
6 changes: 5 additions & 1 deletion library/Notifications/Widget/Timeline.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
use ipl\Web\Style;
use ipl\Web\Url;
use ipl\Web\Widget\Icon;
use ipl\Web\Widget\Link;
use SplObjectStorage;
use Traversable;

Expand Down Expand Up @@ -281,7 +282,10 @@ protected function assembleSidebarEntry(Rotation $rotation): BaseHtmlElement
$entry->addHtml(
$form,
new Icon('bars', ['data-drag-initiator' => true]),
new HtmlElement('span', null, Text::create($rotation->getName()))
(new Link(
[new HtmlElement('span', null, Text::create($rotation->getName())), new Icon('cog')],
Links::rotationSettings($rotation->getId(), $rotation->getScheduleId())
))->openInModal()
);

return $entry;
Expand Down
14 changes: 12 additions & 2 deletions library/Notifications/Widget/Timeline/Rotation.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,16 @@ public function getId(): int
return $this->model->id;
}

/**
* Get the schedule ID of the rotation
*
* @return int
*/
public function getScheduleId(): int
{
return $this->model->schedule_id;
}

/**
* Get the name of the rotation
*
Expand Down Expand Up @@ -137,7 +147,7 @@ public function fetchTimeperiodEntries(DateTime $after, DateTime $until): Genera
->setMember($member)
->setStart($recurrence)
->setEnd($recurrenceEnd)
->setUrl(Links::rotationSettings($this->model->id, $this->model->schedule_id));
->setUrl(Links::rotationSettings($this->getId(), $this->getScheduleId()));

yield $occurrence;
}
Expand All @@ -146,7 +156,7 @@ public function fetchTimeperiodEntries(DateTime $after, DateTime $until): Genera
->setMember($member)
->setStart($timeperiodEntry->start_time)
->setEnd($timeperiodEntry->end_time)
->setUrl(Links::rotationSettings($this->model->id, $this->model->schedule_id));
->setUrl(Links::rotationSettings($this->getId(), $this->getScheduleId()));

yield $entry;
}
Expand Down
39 changes: 35 additions & 4 deletions public/css/timeline.less
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,20 @@
margin-left: .5em;
.text-ellipsis();
}

> a {
display: flex;
width: 100%;
align-items: baseline;
margin-left: .5em;

span {
width: 0;
flex: 1 0 auto;
margin-right: 0.25em;
.text-ellipsis();
}
}
}

.overlay .entry {
Expand Down Expand Up @@ -80,13 +94,14 @@
.rotation-name {
font-size: 1.25em;
font-weight: bold;
cursor: grab;

[data-drag-initiator] {
color: @gray-light;
}
&:hover [data-drag-initiator] {
color: @text-color;

&:hover {
cursor: grab;
color: @list-item-title-hover-color;
}
}

// :not(:empty) is only necessary to increase specificity
Expand All @@ -97,6 +112,22 @@
&.sortable-ghost {
opacity: .5;
}

> a {
text-decoration: none;

i {
display: none;
}

&:hover {
color: @list-item-title-hover-color;

i {
display: inline-block;
}
}
}
}

.entry .icon {
Expand Down
3 changes: 2 additions & 1 deletion public/js/schedule.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@
Sortable.create(sideBar, {
scroll: true,
direction: 'vertical',
draggable: '.rotation-name'
draggable: '.rotation-name',
handle: '.rotation-name > i[data-drag-initiator]'
});
}

Expand Down

0 comments on commit 41595b9

Please sign in to comment.