Initial rework of locations display

Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
snipe 2022-06-05 18:08:15 -07:00
parent 711c713ab8
commit 7c77e03c5a
5 changed files with 214 additions and 161 deletions

View file

@ -103,6 +103,7 @@ class Location extends SnipeModel
return $this->hasMany(\App\Models\User::class, 'location_id'); return $this->hasMany(\App\Models\User::class, 'location_id');
} }
public function assets() public function assets()
{ {
return $this->hasMany(\App\Models\Asset::class, 'location_id') return $this->hasMany(\App\Models\Asset::class, 'location_id')
@ -129,6 +130,23 @@ class Location extends SnipeModel
return $this->hasMany(\App\Models\Asset::class, 'rtd_location_id'); return $this->hasMany(\App\Models\Asset::class, 'rtd_location_id');
} }
public function consumables()
{
return $this->hasMany(\App\Models\Consumable::class, 'location_id');
}
public function components()
{
return $this->hasMany(\App\Models\Component::class, 'location_id');
}
public function accessories()
{
return $this->hasMany(\App\Models\Accessory::class, 'location_id');
}
public function parent() public function parent()
{ {
return $this->belongsTo(self::class, 'parent_id', 'id') return $this->belongsTo(self::class, 'parent_id', 'id')

View file

@ -15,17 +15,77 @@
<div class="row"> <div class="row">
<div class="col-md-9"> <div class="col-md-9">
<div class="nav-tabs-custom">
<ul class="nav nav-tabs hidden-print">
<div class="box box-default"> <li class="active">
<div class="box-header with-border"> <a href="#users" data-toggle="tab">
<div class="box-heading"> <span class="hidden-lg hidden-md">
<i class="fas fa-info-circle fa-2x"></i>
</span>
<span class="hidden-xs hidden-sm">
{{ trans('general.users') }}
{!! (($location->users) && ($location->users->count() > 0 )) ? '<badge class="badge badge-secondary">'.$location->users->count().'</badge>' : '' !!}
</span>
</a>
</li>
<li>
<a href="#assets" data-toggle="tab">
<span class="hidden-lg hidden-md">
<i class="fas fa-barcode fa-2x" aria-hidden="true"></i>
</span>
<span class="hidden-xs hidden-sm">
{{ trans('general.assets') }}
{!! (($location->assets) && ($location->assets->count() > 0 )) ? '<badge class="badge badge-secondary">'.$location->assets->count().'</badge>' : '' !!}
</span>
</a>
</li>
<li>
<a href="#accessories" data-toggle="tab">
<span class="hidden-lg hidden-md">
<i class="fas fa-barcode fa-2x" aria-hidden="true"></i>
</span>
<span class="hidden-xs hidden-sm">
{{ trans('general.accessories') }}
{!! (($location->accessories) && ($location->accessories->count() > 0 )) ? '<badge class="badge badge-secondary">'.$location->accessories->count().'</badge>' : '' !!}
</span>
</a>
</li>
<li>
<a href="#consumables" data-toggle="tab">
<span class="hidden-lg hidden-md">
<i class="fas fa-barcode fa-2x" aria-hidden="true"></i>
</span>
<span class="hidden-xs hidden-sm">
{{ trans('general.consumables') }}
{!! (($location->consumables) && ($location->consumables->count() > 0 )) ? '<badge class="badge badge-secondary">'.$location->consumables->count().'</badge>' : '' !!}
</span>
</a>
</li>
<li>
<a href="#components" data-toggle="tab">
<span class="hidden-lg hidden-md">
<i class="fas fa-barcode fa-2x" aria-hidden="true"></i>
</span>
<span class="hidden-xs hidden-sm">
{{ trans('general.components') }}
{!! (($location->components) && ($location->components->count() > 0 )) ? '<badge class="badge badge-secondary">'.$location->components->count().'</badge>' : '' !!}
</span>
</a>
</li>
</ul>
<div class="tab-content">
<div class="tab-pane active" id="users">
<h2 class="box-title">{{ trans('general.users') }}</h2> <h2 class="box-title">{{ trans('general.users') }}</h2>
</div>
</div>
<div class="box-body">
<div class="table table-responsive"> <div class="table table-responsive">
@include('partials.users-bulk-actions')
<table <table
data-columns="{{ \App\Presenters\UserPresenter::dataTableLayout() }}" data-columns="{{ \App\Presenters\UserPresenter::dataTableLayout() }}"
data-cookie-id-table="usersTable" data-cookie-id-table="usersTable"
@ -37,6 +97,7 @@
data-show-export="true" data-show-export="true"
data-show-refresh="true" data-show-refresh="true"
data-sort-order="asc" data-sort-order="asc"
data-toolbar="#toolbar"
id="usersTable" id="usersTable"
class="table table-striped snipe-table" class="table table-striped snipe-table"
data-url="{{route('api.users.index', ['location_id' => $location->id])}}" data-url="{{route('api.users.index', ['location_id' => $location->id])}}"
@ -47,22 +108,13 @@
</table> </table>
</div><!-- /.table-responsive --> </div><!-- /.table-responsive -->
</div><!-- /.box-body --> </div><!-- /.tab-pane -->
</div> <!--/.box-->
<div class="box box-default"> <div class="tab-pane" id="assets">
<div class="box-header with-border">
<div class="box-heading">
<h2 class="box-title">{{ trans('general.assets') }}</h2> <h2 class="box-title">{{ trans('general.assets') }}</h2>
</div>
</div>
<div class="box-body">
@include('partials.asset-bulk-actions')
<div class="table table-responsive"> <div class="table table-responsive">
@include('partials.asset-bulk-actions')
<table <table
data-columns="{{ \App\Presenters\AssetPresenter::dataTableLayout() }}" data-columns="{{ \App\Presenters\AssetPresenter::dataTableLayout() }}"
data-cookie-id-table="assetsListingTable" data-cookie-id-table="assetsListingTable"
@ -74,6 +126,7 @@
data-show-export="true" data-show-export="true"
data-show-refresh="true" data-show-refresh="true"
data-sort-order="asc" data-sort-order="asc"
data-toolbar="#toolbar"
id="assetsListingTable" id="assetsListingTable"
class="table table-striped snipe-table" class="table table-striped snipe-table"
data-url="{{route('api.assets.index', ['location_id' => $location->id]) }}" data-url="{{route('api.assets.index', ['location_id' => $location->id]) }}"
@ -84,18 +137,13 @@
</table> </table>
</div><!-- /.table-responsive --> </div><!-- /.table-responsive -->
</div><!-- /.box-body --> </div><!-- /.tab-pane -->
</div> <!--/.box-->
<div class="box box-default">
<div class="box-header with-border">
<div class="box-heading"> <div class="tab-pane" id="accessories">
<h2 class="box-title">{{ trans('general.accessories') }}</h2> <h2 class="box-title">{{ trans('general.accessories') }}</h2>
</div>
</div>
<div class="box-body">
<div class="table table-responsive"> <div class="table table-responsive">
<table <table
data-columns="{{ \App\Presenters\AccessoryPresenter::dataTableLayout() }}" data-columns="{{ \App\Presenters\AccessoryPresenter::dataTableLayout() }}"
data-cookie-id-table="accessoriesListingTable" data-cookie-id-table="accessoriesListingTable"
@ -115,20 +163,12 @@
"ignoreColumn": ["actions","image","change","checkbox","checkincheckout","icon"] "ignoreColumn": ["actions","image","change","checkbox","checkincheckout","icon"]
}'> }'>
</table> </table>
</div><!-- /.table-responsive --> </div><!-- /.table-responsive -->
</div><!-- /.box-body --> </div><!-- /.tab-pane -->
</div> <!--/.box-->
<div class="box box-default">
<div class="box-header with-border"> <div class="tab-pane" id="consumables">
<div class="box-heading">
<h2 class="box-title">{{ trans('general.consumables') }}</h2>
</div>
</div>
<div class="box-body">
<div class="table table-responsive"> <div class="table table-responsive">
<table <table
data-columns="{{ \App\Presenters\ConsumablePresenter::dataTableLayout() }}" data-columns="{{ \App\Presenters\ConsumablePresenter::dataTableLayout() }}"
data-cookie-id-table="consumablesListingTable" data-cookie-id-table="consumablesListingTable"
@ -150,16 +190,10 @@
</table> </table>
</div><!-- /.table-responsive --> </div><!-- /.table-responsive -->
</div><!-- /.box-body --> </div><!-- /.tab-pane -->
</div> <!--/.box-->
<div class="tab-pane" id="components">
<div class="box box-default">
<div class="box-header with-border">
<div class="box-heading">
<h2 class="box-title">{{ trans('general.components') }}</h2>
</div>
</div>
<div class="box-body">
<div class="table table-responsive"> <div class="table table-responsive">
<table <table
@ -183,11 +217,11 @@
</table> </table>
</div><!-- /.table-responsive --> </div><!-- /.table-responsive -->
</div><!-- /.box-body --> </div><!-- /.tab-pane -->
</div> <!--/.box-->
</div><!--/.col-md-9--> </div><!--/.col-md-9-->
</div><!--/.col-md-9-->
</div><!--/.col-md-9-->
<div class="col-md-3"> <div class="col-md-3">

View file

@ -1,4 +1,4 @@
<div id="toolbar"> <div id="assets-toolbar">
{{ Form::open([ {{ Form::open([
'method' => 'POST', 'method' => 'POST',
'route' => ['hardware/bulkedit'], 'route' => ['hardware/bulkedit'],

View file

@ -0,0 +1,19 @@
{{ Form::open([
'method' => 'POST',
'route' => ['users/bulkedit'],
'class' => 'form-inline',
'id' => 'bulkForm']) }}
@if (request('status')!='deleted')
@can('delete', \App\Models\User::class)
<div id="users-toolbar">
<label for="bulk_actions" class="sr-only">{{ trans('general.bulk_actions') }}</label>
<select name="bulk_actions" class="form-control select2" style="width: 200px;" aria-label="bulk_actions">
<option value="delete">{!! trans('general.bulk_checkin_delete') !!}</option>
<option value="edit">{{ trans('general.bulk_edit') }}</option>
<option value="bulkpasswordreset">{{ trans('button.send_password_link') }}</option>
</select>
<button class="btn btn-default" id="bulkEdit" disabled>{{ trans('button.go') }}</button>
</div>
@endcan
@endif

View file

@ -38,26 +38,8 @@
<div class="col-md-12"> <div class="col-md-12">
<div class="box box-default"> <div class="box box-default">
<div class="box-body"> <div class="box-body">
{{ Form::open([
'method' => 'POST',
'route' => ['users/bulkedit'],
'class' => 'form-inline',
'id' => 'bulkForm']) }}
@if (request('status')!='deleted')
@can('delete', \App\Models\User::class)
<div id="toolbar">
<label for="bulk_actions" class="sr-only">{{ trans('general.bulk_actions') }}</label>
<select name="bulk_actions" class="form-control select2" style="width: 200px;" aria-label="bulk_actions">
<option value="delete">{!! trans('general.bulk_checkin_delete') !!}</option>
<option value="edit">{{ trans('general.bulk_edit') }}</option>
<option value="bulkpasswordreset">{{ trans('button.send_password_link') }}</option>
</select>
<button class="btn btn-default" id="bulkEdit" disabled>{{ trans('button.go') }}</button>
</div>
@endcan
@endif
@include('partials.users-bulk-actions')
<table <table
data-click-to-select="true" data-click-to-select="true"