Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make rotation title clickable and editable #296

Merged
merged 3 commits into from
Mar 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading