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

Schedule redesign #183

Merged
merged 36 commits into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
7390022
BaseGrid: Don't try to use all available space if not required
nilmerg Apr 18, 2024
1b848f6
css: Describe concrete grids using variables
nilmerg Apr 19, 2024
7d72996
BaseGrid: Automatically generate an entry's color based on its attend…
nilmerg Apr 23, 2024
0495cbc
DayGrid: Fix incorrect step interval
nilmerg Apr 24, 2024
0457c1f
BaseGrid: Move extra entry assembly to the base grid
nilmerg Apr 24, 2024
b7a0936
Add interface `EntryProvider` and use it for the `Calendar` widget
nilmerg Apr 24, 2024
c84fc0a
Move style initialization to the schedule widget
nilmerg Apr 24, 2024
5c53b18
BaseGrid: Allow grids to have an infinite number of rows
nilmerg Apr 25, 2024
52c92f1
BaseGrid: Provide base implementation for `getGridArea()`
nilmerg Apr 25, 2024
38c68b2
Introduce new class `DynamicGrid`
nilmerg Apr 25, 2024
6047ee9
BaseGrid: Split up entry placement and assembly
nilmerg Apr 26, 2024
00a95d6
BaseGrid: Add support for a fixed layout
nilmerg Apr 26, 2024
efacb56
img: Add mode pictograms
flourish86 May 15, 2024
ee9d008
Introduce new form `RotationConfigForm`
nilmerg May 2, 2024
23a043d
Model: Change as needed for the new rotations
nilmerg May 7, 2024
3716c4a
RotationConfigForm: Implement methods to persist changes in database
nilmerg May 7, 2024
2ffbf48
Drop the term `calendar-grid`, replace it with `time-grid`
nilmerg May 9, 2024
c758627
BaseGrid: Always open step or entry URLs inside a modal
nilmerg May 9, 2024
0f4df09
Links: Add urls to add and edit rotations
nilmerg May 9, 2024
e2990de
Introduce Timeline widget
nilmerg May 9, 2024
de4c5c4
schedule: Update detail to reflect the new redesign
nilmerg May 9, 2024
d448ee3
schedule: Implement Drag&Drop to allow reorder of rotations
nilmerg May 10, 2024
7212a56
BaseGrid: Don't render an entry's description if there's none
nilmerg May 14, 2024
bd1218a
css: Fix overflow handling in the time-grid
nilmerg May 14, 2024
61edf1c
Util: Implement roundToNearestThirtyMinutes()
nilmerg May 17, 2024
ed1c839
BaseGrid: Move entry assembly to class `Entry`
nilmerg May 23, 2024
54a768e
Schedule: Allow to remove schedule
sukhwinder33445 May 28, 2024
2291e8f
ScheduleController: Remove legacy calendar entry actions
nilmerg May 28, 2024
7fb7790
Drop class `EntryForm`
nilmerg May 28, 2024
32396ea
Cleanup namespaces
nilmerg May 29, 2024
9df0285
Timeline\Entry: Implement `assembleContainer`
nilmerg May 29, 2024
13aeb7a
ui: Highlight related entries on the timeline upon hover
nilmerg May 29, 2024
bb87a0f
Timeline: Disable smart next handoff defaults
nilmerg May 29, 2024
0cc55f9
TimeGrid: Let entry providers calculate repeating occurrences
nilmerg Jun 11, 2024
18663f4
TimeGrid\Util: Throw in diffHours if $to is smaller than $from
nilmerg Jun 11, 2024
9247d7c
TimeGrid\Util: Enhance entry color variation, somewhat
nilmerg Jun 12, 2024
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
109 changes: 58 additions & 51 deletions application/controllers/ScheduleController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@

use Icinga\Module\Notifications\Common\Database;
use Icinga\Module\Notifications\Common\Links;
use Icinga\Module\Notifications\Forms\EntryForm;
use Icinga\Module\Notifications\Forms\MoveRotationForm;
use Icinga\Module\Notifications\Forms\RotationConfigForm;
use Icinga\Module\Notifications\Forms\ScheduleForm;
use Icinga\Module\Notifications\Model\Schedule;
use Icinga\Module\Notifications\Widget\Calendar\Controls;
use Icinga\Module\Notifications\Widget\RecipientSuggestions;
use Icinga\Module\Notifications\Widget\Schedule as ScheduleWidget;
use ipl\Html\Form;
Expand Down Expand Up @@ -37,20 +37,30 @@ public function indexAction(): void
$this->addTitleTab(sprintf(t('Schedule: %s'), $schedule->name));

$this->controls->addHtml(
Html::tag('h2', null, $schedule->name),
(new ButtonLink(
null,
Links::scheduleSettings($id),
'cog'
))->openInModal(),
(new ButtonLink(
$this->translate('Add Rotation'),
Links::rotationAdd($id),
'plus'
))->openInModal()
);

$this->controls->addAttributes(['class' => 'schedule-controls']);
$this->controls->addAttributes(['class' => 'schedule-detail-controls']);

$calendarControls = (new Controls())
$scheduleControls = (new ScheduleWidget\Controls())
->setAction(Url::fromRequest()->getAbsoluteUrl())
->populate(['mode' => $this->params->get('mode')])
->on(Form::ON_SUCCESS, function (ScheduleWidget\Controls $controls) use ($id) {
$this->redirectNow(Links::schedule($id)->with(['mode' => $controls->getMode()]));
})
->handleRequest($this->getServerRequest());

$this->addContent(new ScheduleWidget($calendarControls, $schedule));
$this->addContent(new ScheduleWidget($schedule, $scheduleControls));
}

public function settingsAction(): void
Expand Down Expand Up @@ -99,24 +109,15 @@ public function addAction(): void
$this->addContent($form);
}

public function addEntryAction(): void
public function addRotationAction(): void
{
$scheduleId = (int) $this->params->getRequired('schedule');
$start = $this->params->get('start');

$form = new EntryForm();
$form->setAction($this->getRequest()->getUrl()->getAbsoluteUrl());
$form = new RotationConfigForm($scheduleId, Database::get());
$form->setAction($this->getRequest()->getUrl()->setParam('showCompact')->getAbsoluteUrl());
$form->setSuggestionUrl(Url::fromPath('notifications/schedule/suggest-recipient'));
$form->populate(['when' => ['start' => $start]]);
$form->on(EntryForm::ON_SUCCESS, function ($form) use ($scheduleId) {
$form->addEntry($scheduleId);
$this->sendExtraUpdates(['#col2']);
$this->redirectNow('__CLOSE__');
});
$form->on(EntryForm::ON_SENT, function () use ($form) {
if ($form->hasBeenCancelled()) {
$this->redirectNow('__CLOSE__');
} elseif (! $form->hasBeenSubmitted()) {
$form->on(RotationConfigForm::ON_SENT, function ($form) {
if (! $form->hasBeenSubmitted()) {
foreach ($form->getPartUpdates() as $update) {
if (! is_array($update)) {
$update = [$update];
Expand All @@ -126,44 +127,42 @@ public function addEntryAction(): void
}
}
});
$form->on(RotationConfigForm::ON_SUCCESS, function (RotationConfigForm $form) use ($scheduleId) {
$form->addRotation();
$this->closeModalAndRefreshRelatedView(Links::schedule($scheduleId));
});

$form->handleRequest($this->getServerRequest());

if (empty($this->parts)) {
$this->addPart(Html::tag(
'div',
['id' => $this->getRequest()->getHeader('X-Icinga-Container')],
[
Html::tag('h2', null, $this->translate('Add Entry')),
$form
]
));
$this->setTitle($this->translate('Add Rotation'));
$this->addContent($form);
}
}

public function editEntryAction(): void
public function editRotationAction(): void
{
$entryId = (int) $this->params->getRequired('id');
$id = (int) $this->params->getRequired('id');
$scheduleId = (int) $this->params->getRequired('schedule');

$form = new EntryForm();
$form = new RotationConfigForm($scheduleId, Database::get());
$form->disableModeSelection();
$form->setShowRemoveButton();
$form->loadEntry($scheduleId, $entryId);
$form->loadRotation($id);
$form->setSubmitLabel($this->translate('Save Changes'));
$form->setAction($this->getRequest()->getUrl()->getAbsoluteUrl());
$form->setAction($this->getRequest()->getUrl()->setParam('showCompact')->getAbsoluteUrl());
$form->setSuggestionUrl(Url::fromPath('notifications/schedule/suggest-recipient'));
$form->on(EntryForm::ON_SUCCESS, function () use ($form, $entryId, $scheduleId) {
$form->editEntry($scheduleId, $entryId);
$this->sendExtraUpdates(['#col2']);
$this->redirectNow('__CLOSE__');
$form->on(RotationConfigForm::ON_SUCCESS, function (RotationConfigForm $form) use ($id, $scheduleId) {
$form->editRotation($id);
$this->closeModalAndRefreshRelatedView(Links::schedule($scheduleId));
});
$form->on(EntryForm::ON_SENT, function ($form) use ($entryId, $scheduleId) {
if ($form->hasBeenCancelled()) {
$this->redirectNow('__CLOSE__');
} elseif ($form->hasBeenRemoved()) {
$form->removeEntry($scheduleId, $entryId);
$this->sendExtraUpdates(['#col2']);
$this->redirectNow('__CLOSE__');
$form->on(RotationConfigForm::ON_SENT, function (RotationConfigForm $form) use ($id, $scheduleId) {
if ($form->hasBeenRemoved()) {
$form->removeRotation($id);
$this->closeModalAndRefreshRelatedView(Links::schedule($scheduleId));
} elseif ($form->hasBeenWiped()) {
$form->wipeRotation();
$this->closeModalAndRefreshRelatedView(Links::schedule($scheduleId));
} elseif (! $form->hasBeenSubmitted()) {
foreach ($form->getPartUpdates() as $update) {
if (! is_array($update)) {
Expand All @@ -178,17 +177,25 @@ public function editEntryAction(): void
$form->handleRequest($this->getServerRequest());

if (empty($this->parts)) {
$this->addPart(Html::tag(
'div',
['id' => $this->getRequest()->getHeader('X-Icinga-Container')],
[
Html::tag('h2', null, $this->translate('Edit Entry')),
$form
]
));
$this->setTitle($this->translate('Edit Rotation'));
$this->addContent($form);
}
}

public function moveRotationAction(): void
{
$this->assertHttpMethod('POST');

$form = new MoveRotationForm(Database::get());
$form->on(MoveRotationForm::ON_SUCCESS, function (MoveRotationForm $form) {
$this->redirectNow(Links::schedule($form->getScheduleId()));
});

$form->handleRequest($this->getServerRequest());

$this->addContent($form);
}

public function suggestRecipientAction(): void
{
$suggestions = new RecipientSuggestions();
Expand Down
2 changes: 1 addition & 1 deletion application/controllers/SchedulesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function indexAction(): void
$this->addControl($sortControl);
$this->addControl($limitControl);
$this->addControl($searchBar);
$this->addControl(
$this->addContent(
(new ButtonLink(
t('New Schedule'),
Links::scheduleAdd(),
Expand Down
Loading
Loading