Merge pull request #14347 from snipe/feature/sc-24856_requestable_page

Dynamically show models/assets on requestable page
This commit is contained in:
snipe 2024-02-28 15:04:48 +00:00 committed by GitHub
commit b1cd44341b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 36 additions and 12 deletions

View file

@ -111,6 +111,7 @@ class AssetsController extends Controller
'requests_counter',
'byod',
'asset_eol_date',
'requestable',
];
$filter = [];

View file

@ -37,6 +37,7 @@ class AssetsTransformer
'name'=> e($asset->model->name),
] : null,
'byod' => ($asset->byod ? true : false),
'requestable' => ($asset->requestable ? true : false),
'model_number' => (($asset->model) && ($asset->model->model_number)) ? e($asset->model->model_number) : null,
'eol' => (($asset->asset_eol_date != '') && ($asset->purchase_date != '')) ? Carbon::parse($asset->asset_eol_date)->diffInMonths($asset->purchase_date).' months' : null,

View file

@ -195,6 +195,14 @@ class AssetPresenter extends Presenter
'visible' => false,
'title' => trans('admin/hardware/form.warranty_expires'),
'formatter' => 'dateDisplayFormatter',
], [
'field' => 'requestable',
'searchable' => false,
'sortable' => true,
'visible' => false,
'title' => trans('admin/hardware/general.requestable'),
'formatter' => 'trueFalseFormatter',
], [
'field' => 'notes',
'searchable' => true,

View file

@ -516,5 +516,6 @@ return [
'partial' => 'Deleted :success_count :object_type, but :error_count :object_type could not be deleted',
],
],
'no_requestable' => 'There are no requestable assets or asset models.',
];

View file

@ -16,20 +16,37 @@
<div class="row">
<div class="col-md-12">
@if (($assets->count() < 1) && ($models->count() < 1))
<div class="col-md-12">
<div class="alert alert-info fade in">
<i class="fas fa-info-circle faa-pulse animated"></i>
<strong>{{ trans('general.notification_info') }}: </strong>
{{ trans('general.no_requestable') }}
</div>
</div>
@else
<div class="nav-tabs-custom">
<ul class="nav nav-tabs">
@if ($assets->count() > 0)
<li class="active">
<a href="#assets" data-toggle="tab" title="{{ trans('general.assets') }}">{{ trans('general.assets') }}
<badge class="badge badge-secondary"> {{ $assets->count()}}</badge>
</a>
</li>
@endif
@if ($models->count() > 0)
<li>
<a href="#models" data-toggle="tab" title="{{ trans('general.asset_models') }}">{{ trans('general.asset_models') }}
<badge class="badge badge-secondary"> {{ $models->count()}}</badge>
</a>
</li>
@endif
</ul>
<div class="tab-content">
@if ($assets->count() > 0)
<div class="tab-pane fade in active" id="assets">
<div class="row">
<div class="col-md-12">
@ -76,16 +93,15 @@
</thead>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
@endif
<div class="tab-pane fade" id="models">
@if ($models->count() > 0)
<div class="tab-pane fade in {{ ($assets->count() == 0) ? 'active' : '' }}" id="models">
<div class="row">
<div class="col-md-12">
@if ($models->count() > 0)
<h2>{{ trans('general.requestable_models') }}</h2>
<table
name="requested-assets"
data-toolbar="#toolbar"
@ -145,18 +161,15 @@
</tbody>
</table>
@else
<div class="alert alert-info alert-block">
<i class="fas fa-info-circle"></i>
{{ trans('general.no_results') }}
</div>
@endif
</div>
</div>
</div>
@endif
</div> <!-- .tab-content-->
</div> <!-- .nav-tabs-custom -->
@endif
</div> <!-- .col-md-12> -->
</div> <!-- .row -->
@stop