A free open source IT asset/license management system
Updated presenters
snipebe70b217d9a9
diff --git a/app/Presenters/AssetModelPresenter.php b/app/Presenters/AssetModelPresenter.phpindex ac9aa5e661..b92530e8c6 100644--- a/app/Presenters/AssetModelPresenter.php+++ b/app/Presenters/AssetModelPresenter.php@@ -301,4 +301,13 @@ class AssetModelPresenter extends Presenter{return route('models.show', $this->id);}++ public function formattedNameLink() {++ if (auth()->user()->can('models.view', $this)) {+ return '<a href="'.route('models.show', e($this->id)).'">'.e($this->name).'</a>';+ }++ return $this->name;+ }}diff --git a/app/Presenters/CategoryPresenter.php b/app/Presenters/CategoryPresenter.phpindex c5ca0a5308..46eec96cf5 100644--- a/app/Presenters/CategoryPresenter.php+++ b/app/Presenters/CategoryPresenter.php@@ -154,7 +154,7 @@ class CategoryPresenter extends Presenterpublic function formattedNameLink() {if (auth()->user()->can('category.view', $this)) {- return ($this->tag_color ? "<i class='fa-solid fa-fw fa-square' style='color: ".e($this->tag_color)."' aria-hidden='true'></i> " : '').' <a href="'.route('categories.show', e($this->id)).'">'.e($this->name).'</a>';+ return ($this->tag_color ? "<i class='fa-solid fa-fw fa-square' style='color: ".e($this->tag_color)."' aria-hidden='true'></i>" : '').'<a href="'.route('categories.show', e($this->id)).'">'.e($this->name).'</a>';}return ($this->tag_color ? "<i class='fa-solid fa-fw fa-square' style='color: ".e($this->tag_color)."' aria-hidden='true'></i> " : '').$this->name;diff --git a/app/Presenters/CompanyPresenter.php b/app/Presenters/CompanyPresenter.phpindex e1df745529..6ccdf57f50 100644--- a/app/Presenters/CompanyPresenter.php+++ b/app/Presenters/CompanyPresenter.php@@ -179,9 +179,9 @@ class CompanyPresenter extends Presenterpublic function formattedNameLink() {if (auth()->user()->can('company.view', $this)) {- return ($this->tag_color ? "<i class='fa-solid fa-fw fa-square' style='color: ".e($this->tag_color)."' aria-hidden='true'></i> " : '').' <a href="'.route('companies.show', e($this->id)).'">'.e($this->name).'</a>';+ return ($this->tag_color ? "<i class='fa-solid fa-fw fa-square' style='color: ".e($this->tag_color)."' aria-hidden='true'></i>" : '').'<a href="'.route('companies.show', e($this->id)).'">'.e($this->name).'</a>';}- return ($this->tag_color ? "<i class='fa-solid fa-fw fa-square' style='color: ".e($this->tag_color)."' aria-hidden='true'></i> " : '').$this->name;+ return ($this->tag_color ? "<i class='fa-solid fa-fw fa-square' style='color: ".e($this->tag_color)."' aria-hidden='true'></i>" : '').$this->name;}}diff --git a/app/Presenters/DepartmentPresenter.php b/app/Presenters/DepartmentPresenter.phpindex 7aaf93904e..ff223405fc 100644--- a/app/Presenters/DepartmentPresenter.php+++ b/app/Presenters/DepartmentPresenter.php@@ -8,11 +8,105 @@ namespace App\Presenters;class DepartmentPresenter extends Presenter{+ /**+ * Json Column Layout for bootstrap table+ * @return string+ */+ public static function dataTableLayout()+ {+ $layout = [+ [+ 'field' => 'id',+ 'searchable' => false,+ 'sortable' => true,+ 'switchable' => true,+ 'title' => trans('general.id'),+ 'visible' => false,+ ],+ [+ 'field' => 'company',+ 'searchable' => true,+ 'sortable' => true,+ 'switchable' => true,+ 'title' => trans('general.company'),+ 'visible' => false,+ 'formatter' => 'companiesLinkObjFormatter'+ ],+ [+ 'field' => 'name',+ 'searchable' => true,+ 'sortable' => true,+ 'switchable' => false,+ 'title' => trans('general.name'),+ 'visible' => true,+ 'formatter' => 'departmentsLinkFormatter',+ ], [+ 'field' => 'image',+ 'searchable' => false,+ 'sortable' => true,+ 'switchable' => true,+ 'title' => trans('general.image'),+ 'visible' => true,+ 'formatter' => 'imageFormatter',+ ], [+ 'field' => 'users_count',+ 'searchable' => false,+ 'sortable' => true,+ 'switchable' => true,+ 'title' => trans('general.people'),+ 'titleTooltip' => trans('general.people'),+ 'visible' => true,+ 'class' => 'css-house-user',+ ], [+ 'field' => 'tag_color',+ 'searchable' => true,+ 'sortable' => true,+ 'switchable' => true,+ 'title' => trans('general.tag_color'),+ 'visible' => false,+ 'formatter' => 'colorTagFormatter',+ ], [+ 'field' => 'notes',+ 'searchable' => true,+ 'sortable' => true,+ 'visible' => false,+ 'title' => trans('general.notes'),+ ], [+ 'field' => 'created_at',+ 'searchable' => true,+ 'sortable' => true,+ 'switchable' => true,+ 'title' => trans('general.created_at'),+ 'visible' => false,+ 'formatter' => 'dateDisplayFormatter',+ ],+ [+ 'field' => 'created_by',+ 'searchable' => true,+ 'sortable' => true,+ 'switchable' => true,+ 'title' => trans('general.created_by'),+ 'visible' => false,+ 'formatter' => 'usersLinkObjFormatter',+ ],[+ 'field' => 'actions',+ 'searchable' => false,+ 'sortable' => false,+ 'switchable' => false,+ 'title' => trans('table.actions'),+ 'visible' => true,+ 'formatter' => 'locationsActionsFormatter',+ ],+ ];++ return json_encode($layout);+ }+public function formattedNameLink() {if (auth()->user()->can('department.view', $this)) {- return ($this->tag_color ? "<i class='fa-solid fa-fw fa-square' style='color: ".e($this->tag_color)."' aria-hidden='true'></i> " : '').' <a href="'.route('departments.show', e($this->id)).'">'.e($this->name).'</a>';+ return ($this->tag_color ? "<i class='fa-solid fa-fw fa-square' style='color: ".e($this->tag_color)."' aria-hidden='true'></i>" : '').'<a href="'.route('departments.show', e($this->id)).'">'.e($this->name).'</a>';}return ($this->tag_color ? "<i class='fa-solid fa-fw fa-square' style='color: ".e($this->tag_color)."' aria-hidden='true'></i> " : '').$this->name;diff --git a/app/Presenters/LocationPresenter.php b/app/Presenters/LocationPresenter.phpindex 0eca03ee94..aa3dfe30c6 100644--- a/app/Presenters/LocationPresenter.php+++ b/app/Presenters/LocationPresenter.php@@ -379,7 +379,7 @@ class LocationPresenter extends Presenterpublic function formattedNameLink() {if (auth()->user()->can('location.view', $this)) {- return ($this->tag_color ? "<i class='fa-solid fa-fw fa-square' style='color: ".e($this->tag_color)."' aria-hidden='true'></i> " : '').' <a href="'.route('locations.show', e($this->id)).'">'.e($this->name).'</a>';+ return ($this->tag_color ? "<i class='fa-solid fa-fw fa-square' style='color: ".e($this->tag_color)."' aria-hidden='true'></i>" : '').'<a href="'.route('locations.show', e($this->id)).'">'.e($this->name).'</a>';}return ($this->tag_color ? "<i class='fa-solid fa-fw fa-square' style='color: ".e($this->tag_color)."' aria-hidden='true'></i> " : '').$this->name;diff --git a/app/Presenters/ManufacturerPresenter.php b/app/Presenters/ManufacturerPresenter.phpindex bc1390a6e9..5ae47da53b 100644--- a/app/Presenters/ManufacturerPresenter.php+++ b/app/Presenters/ManufacturerPresenter.php@@ -195,7 +195,7 @@ class ManufacturerPresenter extends Presenterpublic function formattedNameLink() {if (auth()->user()->can('manufacturer.view', $this)) {- return ($this->tag_color ? "<i class='fa-solid fa-fw fa-square' style='color: ".e($this->tag_color)."' aria-hidden='true'></i> " : '').' <a href="'.route('manufacturers.show', e($this->id)).'">'.e($this->name).'</a>';+ return ($this->tag_color ? "<i class='fa-solid fa-fw fa-square' style='color: ".e($this->tag_color)."' aria-hidden='true'></i>" : '').'<a href="'.route('manufacturers.show', e($this->id)).'">'.e($this->name).'</a>';}return ($this->tag_color ? "<i class='fa-solid fa-fw fa-square' style='color: ".e($this->tag_color)."' aria-hidden='true'></i> " : '').$this->name;diff --git a/app/Presenters/SupplierPresenter.php b/app/Presenters/SupplierPresenter.phpindex 9dea1f4e9d..6bedcafa7d 100644--- a/app/Presenters/SupplierPresenter.php+++ b/app/Presenters/SupplierPresenter.php@@ -241,7 +241,7 @@ class SupplierPresenter extends Presenterpublic function formattedNameLink() {if (auth()->user()->can('supplier.view', $this)) {- return ($this->tag_color ? "<i class='fa-solid fa-fw fa-square' style='color: ".e($this->tag_color)."' aria-hidden='true'></i> " : '').' <a href="'.route('suppliers.show', e($this->id)).'">'.e($this->name).'</a>';+ return ($this->tag_color ? "<i class='fa-solid fa-fw fa-square' style='color: ".e($this->tag_color)."' aria-hidden='true'></i>" : '').'<a href="'.route('suppliers.show', e($this->id)).'">'.e($this->name).'</a>';}return ($this->tag_color ? "<i class='fa-solid fa-fw fa-square' style='color: ".e($this->tag_color)."' aria-hidden='true'></i> " : '').$this->name;