diff --git a/app/Presenters/MaintenanceTypePresenter.php b/app/Presenters/MaintenanceTypePresenter.php index bd2b83e1c4..cc4f6af1be 100644 --- a/app/Presenters/MaintenanceTypePresenter.php +++ b/app/Presenters/MaintenanceTypePresenter.php @@ -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', diff --git a/app/Presenters/MaintenancesPresenter.php b/app/Presenters/MaintenancesPresenter.php index 3d4a9fb979..11348de6dc 100644 --- a/app/Presenters/MaintenancesPresenter.php +++ b/app/Presenters/MaintenancesPresenter.php @@ -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 + * " - " 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; + } }