Record actions and timeline
Buttons on a record open a dialog with options, a comment and more fields; the handler may refuse with a message. The timeline shows what happened.
- "Change status" to Done is refused while tasks are open.
Try it: log in with the demo account
Email demo@frontdesk-demo.test · Password Try-Frontdesk-2026
Everyone shares this account. You may change anything – all data is reset every night.
The code
app/src/Controllers/ProjectController.php – defineRecordActions()
whole file
protected function defineRecordActions(DataObject $record): array
{
if (!$this->canEdit()) {
return [];
}
/** @var Project $record */
$statuses = Project::STATUSES;
unset($statuses[$record->Status]);
return [
RecordAction::create('status', 'Change status')
->options($statuses)
->withComment('Comment')
->handle(function (Project $project, ?string $status, string $comment) {
if ($status === 'done' && $project->Tasks()->exclude('Status', 'done')->exists()) {
throw new ActionException('Finish the open tasks first.');
}
$old = $project->getStatusLabel();
$project->Status = (string) $status;
$project->write();
$this->note($project, 'status', $old . ' → ' . $project->getStatusLabel()
. ($comment !== '' ? ': ' . $comment : ''));
return 'Status changed to ' . $project->getStatusLabel() . '.';
}),
RecordAction::create('note', 'Add note')
->withComment('Note', true)
->input('followup', 'Follow up on', 'date')
->handle(function (Project $project, ?string $option, string $comment, array $values) {
$date = (string) ($values['followup'] ?? '');
$this->note($project, 'note', $comment . ($date !== '' ? ' (follow up on ' . $date . ')' : ''));
return 'Note added.';
}),
];
}
private function note(Project $project, string $kind, string $text): void
{
ProjectNote::create([
'ProjectID' => $project->ID,
'Kind' => $kind,
'Text' => $text,
'AuthorID' => (int) Security::getCurrentUser()?->ID,
])->write();
}
app/src/Controllers/ProjectController.php – defineTimeline()
whole file
protected function defineTimeline(DataObject $record): ?ArrayList
{
/** @var Project $record */
$entries = ArrayList::create([
TimelineEntry::create((string) $record->Created, 'Project created', '', '', 'created'),
]);
$titles = ['status' => 'Status changed', 'note' => 'Note', 'feedback' => 'Client feedback'];
foreach ($record->Notes() as $note) {
$entries->push(TimelineEntry::create(
(string) $note->Created,
$titles[$note->Kind] ?? 'Note',
(string) $note->Text,
$note->Author()->exists() ? (string) $note->Author()->getName() : '',
(string) $note->Kind
));
}
return $entries;
}
protected function timelineTitle(): string
{
return 'History';
}