3
0
mirror of https://github.com/snipe/snipe-it.git synced 2026-08-18 11:15:42 +00:00

Updated presenters

This commit is contained in:
snipe
2026-08-14 13:43:10 +01:00
parent 7da0bb454d
commit 3ebbef1018
2 changed files with 70 additions and 2 deletions

View File

@ -8,6 +8,13 @@ class MaintenanceTypePresenter extends Presenter
{
$layout = [
[
'field' => 'checkbox',
'scope' => 'col',
'checkbox' => true,
'titleTooltip' => trans('general.select_all_none'),
'printIgnore' => true,
'class' => 'hidden-print',
], [
'field' => 'id',
'scope' => 'col',
'searchable' => false,
@ -23,6 +30,30 @@ class MaintenanceTypePresenter extends Presenter
'switchable' => false,
'title' => trans('general.name'),
'visible' => true,
// maintenanceTypesLinkFormatter is auto-generated from
// the formatters array in bootstrap-table.blade.php and
// renders the row's tag_color as a leading colored
// square, matching how categories and other tag-colored
// entities read on their index tables.
'formatter' => 'maintenanceTypesLinkFormatter',
], [
'field' => 'maintenances_count',
'scope' => 'col',
'searchable' => false,
'sortable' => true,
'switchable' => true,
'title' => trans('admin/maintenances/general.maintenances'),
'visible' => true,
'class' => 'text-right',
], [
'field' => 'created_by',
'scope' => 'col',
'searchable' => false,
'sortable' => true,
'switchable' => true,
'title' => trans('general.created_by'),
'visible' => false,
'formatter' => 'usersLinkObjFormatter',
], [
'field' => 'created_at',
'scope' => 'col',

View File

@ -133,13 +133,14 @@ class MaintenancesPresenter extends Presenter
'title' => trans('general.location'),
'formatter' => 'locationsLinkObjFormatter',
], [
'field' => 'maintenance_type',
'field' => 'maintenance_type_details',
'scope' => 'col',
'searchable' => true,
'sortable' => true,
'switchable' => true,
'title' => trans('admin/maintenances/form.asset_maintenance_type'),
'visible' => true,
'formatter' => 'maintenanceTypesLinkObjFormatter',
], [
'field' => 'responsible_party',
'scope' => 'col',
@ -356,13 +357,14 @@ class MaintenancesPresenter extends Presenter
'sortable' => true,
'title' => trans('general.location'),
], [
'field' => 'maintenance_type',
'field' => 'maintenance_type_details',
'scope' => 'col',
'searchable' => true,
'sortable' => true,
'switchable' => true,
'title' => trans('admin/maintenances/form.asset_maintenance_type'),
'visible' => true,
'formatter' => 'maintenanceTypesLinkObjFormatter',
], [
'field' => 'responsible_party',
'scope' => 'col',
@ -476,4 +478,39 @@ class MaintenancesPresenter extends Presenter
return json_encode($layout);
}
/**
* Display name for the unified calendar. Renders as
* "<maintenance name> - <asset name or unknown>" so the event
* tile carries enough context to identify what and where without
* clicking through.
*/
public function name()
{
$itemLabel = $this->model->item
? ($this->model->item->display_name ?? $this->model->item->name ?? '')
: trans('general.unknown');
return sprintf('%s - %s', $this->model->name, $itemLabel);
}
/**
* Deep link used by the calendar event tile. Routes to the
* maintenance show page.
*/
public function calendarUrl(): ?string
{
return route('maintenances.show', $this->model->id);
}
/**
* Color precedence for the calendar tile: maintenance type's
* tag_color when the admin has set one so tenants can color-code
* by "recall vs upgrade vs routine service". Otherwise null and
* the frontend paints from a per-event_type CSS palette.
*/
public function calendarColor(): ?string
{
return $this->model->maintenanceType?->tag_color;
}
}