mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-25 13:44:06 -08:00
Tweaks to status labelas listing display
This commit is contained in:
parent
7642d17fb8
commit
7086ac8a8b
|
@ -7,7 +7,7 @@ use App\Http\Controllers\Controller;
|
|||
use App\Helpers\Helper;
|
||||
use App\Models\Statuslabel;
|
||||
use App\Models\Asset;
|
||||
use App\Http\Transformers\DatatablesTransformer;
|
||||
use App\Http\Transformers\StatuslabelsTransformer;
|
||||
use App\Http\Transformers\AssetsTransformer;
|
||||
use PhpParser\Node\Expr\Cast\Bool_;
|
||||
|
||||
|
@ -25,8 +25,7 @@ class StatuslabelsController extends Controller
|
|||
$this->authorize('view', Statuslabel::class);
|
||||
$allowed_columns = ['id','name','created_at'];
|
||||
|
||||
$statuslabels = Statuslabel::select(['id','name','deployable','pending','archived','color','show_in_nav','created_at'])
|
||||
->withCount('assets');
|
||||
$statuslabels = Statuslabel::withCount('assets');
|
||||
|
||||
if ($request->has('search')) {
|
||||
$statuslabels = $statuslabels->TextSearch($request->input('search'));
|
||||
|
@ -40,7 +39,7 @@ class StatuslabelsController extends Controller
|
|||
|
||||
$total = $statuslabels->count();
|
||||
$statuslabels = $statuslabels->skip($offset)->take($limit)->get();
|
||||
return (new DatatablesTransformer)->transformDatatables($statuslabels, $total);
|
||||
return (new StatuslabelsTransformer)->transformStatuslabels($statuslabels, $total);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -22,8 +22,9 @@ class StatuslabelsTransformer
|
|||
'id' => e($statuslabel->id),
|
||||
'name' => e($statuslabel->name),
|
||||
'type' => $statuslabel->getStatuslabelType(),
|
||||
'color' => e($statuslabel->color),
|
||||
'color' => ($statuslabel->color) ? e($statuslabel->color) : null,
|
||||
'show_in_nav' => ($statuslabel->show_in_nav=='1') ? true : false,
|
||||
'notes' => e($statuslabel->notes),
|
||||
'created_at' => $statuslabel->created_at,
|
||||
'updated_at' => $statuslabel->updated_at,
|
||||
];
|
||||
|
@ -31,10 +32,6 @@ class StatuslabelsTransformer
|
|||
return $array;
|
||||
}
|
||||
|
||||
public function transformStatuslabelsDatatable($users) {
|
||||
return (new DatatablesTransformer)->transformDatatables($users);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -27,8 +27,7 @@
|
|||
data-url="{{route('api.categories.index') }}"
|
||||
data-cookie="true"
|
||||
data-click-to-select="true"
|
||||
data-cookie-id-table="categoriesTable-{{ config('version.hash_version') }}"
|
||||
>
|
||||
data-cookie-id-table="categoriesTable-{{ config('version.hash_version') }}">
|
||||
<thead>
|
||||
<tr>
|
||||
<th data-sortable="true" data-field="id" data-visible="false">{{ trans('general.id') }}</th>
|
||||
|
|
|
@ -152,9 +152,9 @@ $('.snipe-table').bootstrapTable({
|
|||
|
||||
function trueFalseFormatter(value, row) {
|
||||
if ((value) && ((value == 'true') || (value == '1'))) {
|
||||
return '<i class="fa fa-check"></i>';
|
||||
return '<i class="fa fa-check text-success"></i>';
|
||||
} else {
|
||||
return '<i class="fa fa-times"></i>';
|
||||
return '<i class="fa fa-times text-danger"></i>';
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -31,9 +31,9 @@
|
|||
<tr>
|
||||
<th data-sortable="true" data-field="id" data-visible="false">{{ trans('general.id') }}</th>
|
||||
<th data-sortable="true" data-field="name">{{ trans('admin/statuslabels/table.name') }}</th>
|
||||
<th data-sortable="false" data-field="type">{{ trans('admin/statuslabels/table.status_type') }}</th>
|
||||
<th data-sortable="false" data-field="color">{{ trans('admin/statuslabels/table.color') }}</th>
|
||||
<th data-sortable="true" data-field="show_in_nav">{{ trans('admin/statuslabels/table.show_in_nav') }}</th>
|
||||
<th data-sortable="false" data-field="type" data-formatter="undeployableFormatter">{{ trans('admin/statuslabels/table.status_type') }}</th>
|
||||
<th data-sortable="false" data-field="color" data-formatter="colorSqFormatter">{{ trans('admin/statuslabels/table.color') }}</th>
|
||||
<th class="text-center" data-sortable="true" data-field="show_in_nav" data-formatter="trueFalseFormatter">{{ trans('admin/statuslabels/table.show_in_nav') }}</th>
|
||||
<th data-switchable="false" data-formatter="statuslabelsActionsFormatter" data-searchable="false" data-sortable="false" data-field="actions">{{ trans('table.actions') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
@ -53,4 +53,20 @@
|
|||
|
||||
@section('moar_scripts')
|
||||
@include ('partials.bootstrap-table', ['exportFile' => 'statuslabels-export', 'search' => true])
|
||||
|
||||
<script>
|
||||
function colorSqFormatter(value, row) {
|
||||
if (value) {
|
||||
return '<span class="label" style="background-color: ' + value + ';"> </span> ' + value;
|
||||
}
|
||||
}
|
||||
|
||||
function undeployableFormatter(value, row) {
|
||||
if ((value) && (value!='deployable')) {
|
||||
return '<span class="text-danger">' + value + '</span> ';
|
||||
} else {
|
||||
return '<span class="text-success">' + value + '</span> ';
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@stop
|
||||
|
|
Loading…
Reference in a new issue