Skip to content

A free open source IT asset/license management system

Updated groups index to use new components

snipeb7ee3a2f1d04
diff --git a/app/Presenters/GroupPresenter.php b/app/Presenters/GroupPresenter.php
new file mode 100644
index 0000000000..697ae5f161
--- /dev/null
+++ b/app/Presenters/GroupPresenter.php
@@ -0,0 +1,124 @@
+<?php
+
+namespace App\Presenters;
+
+/**
+ * Class LocationPresenter
+ */
+class GroupPresenter extends Presenter
+{
+ /**
+ * Json Column Layout for bootstrap table
+ */
+ public static function dataTableLayout()
+ {
+ $layout = [
+ [
+ 'field' => 'id',
+ 'searchable' => false,
+ 'sortable' => true,
+ 'switchable' => true,
+ 'title' => trans('general.id'),
+ 'visible' => false,
+ ],
+ [
+ 'field' => 'name',
+ 'searchable' => true,
+ 'sortable' => true,
+ 'switchable' => false,
+ 'title' => trans('general.name'),
+ 'visible' => true,
+ 'formatter' => 'groupsAdminLinkFormatter',
+ ],
+ [
+ 'field' => 'users_count',
+ 'searchable' => false,
+ 'sortable' => true,
+ 'switchable' => true,
+ 'title' => trans('admin/groups/table.users'),
+ 'visible' => true,
+ 'class' => 'css-users',
+ ], [
+ 'field' => 'notes',
+ 'searchable' => true,
+ 'sortable' => true,
+ 'visible' => true,
+ 'title' => trans('general.notes'),
+ ], [
+ 'field' => 'created_by',
+ 'searchable' => true,
+ 'sortable' => true,
+ 'switchable' => true,
+ 'title' => trans('general.created_by'),
+ 'visible' => true,
+ 'formatter' => 'usersLinkObjFormatter',
+ ], [
+ 'field' => 'updated_at',
+ 'searchable' => true,
+ 'sortable' => true,
+ 'switchable' => true,
+ 'title' => trans('general.updated_at'),
+ 'visible' => true,
+ 'formatter' => 'dateDisplayFormatter',
+ ], [
+ 'field' => 'actions',
+ 'searchable' => false,
+ 'sortable' => false,
+ 'switchable' => false,
+ 'title' => trans('table.actions'),
+ 'visible' => true,
+ 'formatter' => 'groupsActionsFormatter',
+ 'printIgnore' => true,
+ ],
+ ];
+
+ return json_encode($layout);
+ }
+
+
+ /**
+ * Link to this supplier name
+ * @return string
+ */
+ public function nameUrl()
+ {
+ return (string) link_to_route('suppliers.show', $this->name, $this->id);
+ }
+
+ /**
+ * Getter for Polymorphism.
+ * @return mixed
+ */
+ public function name()
+ {
+ return $this->model->name;
+ }
+
+ /**
+ * Url to view this item.
+ * @return string
+ */
+ public function viewUrl()
+ {
+ return route('suppliers.show', $this->id);
+ }
+
+ public function glyph()
+ {
+ return '<x-icon type="suppliers" />';
+ }
+
+ public function fullName()
+ {
+ return $this->name;
+ }
+
+ public function formattedNameLink() {
+
+ if (auth()->user()->can('view', ['\App\Models\Supplier', $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> " : '').$this->name;
+ }
+}
diff --git a/resources/views/groups/index.blade.php b/resources/views/groups/index.blade.php
index c235563b35..d45cf414b8 100755
--- a/resources/views/groups/index.blade.php
+++ b/resources/views/groups/index.blade.php
@@ -15,35 +15,17 @@
@section('content')
<x-container>
<x-box>
- <table
- data-cookie-id-table="groupsTable"
- data-side-pagination="server"
- data-sort-order="asc"
- data-sort-name="name"
- id="groupsTable"
- data-buttons="groupButtons"
- class="table table-striped snipe-table"
- data-url="{{ route('api.groups.index') }}"
- data-export-options='{
- "fileName": "export-groups-{{ date('Y-m-d') }}",
- "ignoreColumn": ["actions","image","change","checkbox","checkincheckout","icon"]
- }'>
- <thead>
- <tr>
- <th data-switchable="true" data-sortable="true" data-field="id" data-visible="false">{{ trans('general.id') }}</th>
- <th data-switchable="true" data-sortable="true" data-field="name" data-formatter="groupsAdminLinkFormatter" data-visible="true">{{ trans('admin/groups/table.name') }}</th>
- <th data-switchable="true" data-sortable="true" data-field="users_count" data-visible="true"><x-icon type="user" /><span class="sr-only">{{ trans('admin/groups/table.users') }}</span></th>
- <th data-switchable="true" data-sortable="true" data-field="notes" data-visible="true">{{ trans('general.notes') }}</th>
- <th data-switchable="true" data-sortable="true" data-field="created_at" data-visible="true" data-formatter="dateDisplayFormatter">{{ trans('general.created_at') }}</th>
- <th data-switchable="false" data-searchable="false" data-sortable="true" data-field="created_by" data-formatter="usersLinkObjFormatter">{{ trans('general.created_by') }}</th>
- <th data-switchable="false" data-searchable="false" data-sortable="true" data-field="created_at" data-formatter="dateDisplayFormatter">{{ trans('general.created_at') }}</th>
- <th data-switchable="false" data-searchable="false" data-sortable="true" data-field="updated_at" data-formatter="dateDisplayFormatter">{{ trans('general.updated_at') }}</th>
- <th data-switchable="false" data-searchable="false" data-sortable="false" data-field="actions" data-formatter="groupsActionsFormatter">{{ trans('table.actions') }}</th>
-
- </tr>
- </thead>
- </table>
+ <x-table
+ name="groups"
+ buttons="groupButtons"
+ fixed_right_number="1"
+ fixed_number="1"
+ api_url="{{ route('api.groups.index') }}"
+ :presenter="\App\Presenters\GroupPresenter::dataTableLayout()"
+ export_filename="export-groups-{{ date('Y-m-d') }}"
+ />
+
</x-box>
</x-container>
@stop
diff --git a/resources/views/statuslabels/index.blade.php b/resources/views/statuslabels/index.blade.php
index 04758b38af..2ab5cf6de8 100755
--- a/resources/views/statuslabels/index.blade.php
+++ b/resources/views/statuslabels/index.blade.php
@@ -14,13 +14,13 @@
<x-box>
<x-table
- name="statuslabel"
- buttons="statuslabelButtons"
- fixed_right_number="1"
- fixed_number="1"
- api_url="{{ route('api.statuslabels.index') }}"
- :presenter="\App\Presenters\StatusLabelPresenter::dataTableLayout()"
- export_filename="export-statuslabels-{{ date('Y-m-d') }}"
+ name="statuslabel"
+ buttons="statuslabelButtons"
+ fixed_right_number="1"
+ fixed_number="1"
+ api_url="{{ route('api.statuslabels.index') }}"
+ :presenter="\App\Presenters\StatusLabelPresenter::dataTableLayout()"
+ export_filename="export-statuslabels-{{ date('Y-m-d') }}"
/>
</x-box>