Skip to content

Commit

Permalink
Merge pull request #14347 from snipe/feature/sc-24856_requestable_page
Browse files Browse the repository at this point in the history
Dynamically show models/assets on requestable page
  • Loading branch information
snipe authored Feb 28, 2024
2 parents a494103 + 3da47cd commit b1cd443
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 12 deletions.
1 change: 1 addition & 0 deletions app/Http/Controllers/Api/AssetsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ public function index(Request $request, $audit = null)
'requests_counter',
'byod',
'asset_eol_date',
'requestable',
];

$filter = [];
Expand Down
1 change: 1 addition & 0 deletions app/Http/Transformers/AssetsTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public function transformAsset(Asset $asset)
'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,
Expand Down
8 changes: 8 additions & 0 deletions app/Presenters/AssetPresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,14 @@ public static function dataTableLayout()
'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,
Expand Down
1 change: 1 addition & 0 deletions resources/lang/en-US/general.php
Original file line number Diff line number Diff line change
Expand Up @@ -516,5 +516,6 @@
'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.',

];
37 changes: 25 additions & 12 deletions resources/views/account/requestable-assets.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -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">
Expand Down Expand Up @@ -76,16 +93,15 @@ class="table table-striped snipe-table"
</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"
Expand Down Expand Up @@ -145,18 +161,15 @@ class="table table-striped snipe-table"
</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
Expand Down

0 comments on commit b1cd443

Please sign in to comment.