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,178 +15,212 @@
<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">
<h2 class="box-title">{{ trans('general.users') }}</h2> <i class="fas fa-info-circle fa-2x"></i>
</div> </span>
</div> <span class="hidden-xs hidden-sm">
<div class="box-body"> {{ trans('general.users') }}
{!! (($location->users) && ($location->users->count() > 0 )) ? '<badge class="badge badge-secondary">'.$location->users->count().'</badge>' : '' !!}
<div class="table table-responsive"> </span>
</a>
</li>
<table <li>
data-columns="{{ \App\Presenters\UserPresenter::dataTableLayout() }}" <a href="#assets" data-toggle="tab">
data-cookie-id-table="usersTable" <span class="hidden-lg hidden-md">
data-pagination="true" <i class="fas fa-barcode fa-2x" aria-hidden="true"></i>
data-id-table="usersTable" </span>
data-search="true" <span class="hidden-xs hidden-sm">
data-side-pagination="server" {{ trans('general.assets') }}
data-show-columns="true" {!! (($location->assets) && ($location->assets->count() > 0 )) ? '<badge class="badge badge-secondary">'.$location->assets->count().'</badge>' : '' !!}
data-show-export="true" </span>
data-show-refresh="true" </a>
data-sort-order="asc" </li>
id="usersTable"
class="table table-striped snipe-table" <li>
data-url="{{route('api.users.index', ['location_id' => $location->id])}}" <a href="#accessories" data-toggle="tab">
data-export-options='{ <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>
<div class="table table-responsive">
@include('partials.users-bulk-actions')
<table
data-columns="{{ \App\Presenters\UserPresenter::dataTableLayout() }}"
data-cookie-id-table="usersTable"
data-pagination="true"
data-id-table="usersTable"
data-search="true"
data-side-pagination="server"
data-show-columns="true"
data-show-export="true"
data-show-refresh="true"
data-sort-order="asc"
data-toolbar="#toolbar"
id="usersTable"
class="table table-striped snipe-table"
data-url="{{route('api.users.index', ['location_id' => $location->id])}}"
data-export-options='{
"fileName": "export-locations-{{ str_slug($location->name) }}-users-{{ date('Y-m-d') }}", "fileName": "export-locations-{{ str_slug($location->name) }}-users-{{ date('Y-m-d') }}",
"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="tab-pane" id="assets">
<div class="box-header with-border"> <h2 class="box-title">{{ trans('general.assets') }}</h2>
<div class="box-heading">
<h2 class="box-title">{{ trans('general.assets') }}</h2>
</div>
</div>
<div class="box-body">
<div class="table table-responsive">
@include('partials.asset-bulk-actions') @include('partials.asset-bulk-actions')
<table
<div class="table table-responsive"> data-columns="{{ \App\Presenters\AssetPresenter::dataTableLayout() }}"
data-cookie-id-table="assetsListingTable"
<table data-pagination="true"
data-columns="{{ \App\Presenters\AssetPresenter::dataTableLayout() }}" data-id-table="assetsListingTable"
data-cookie-id-table="assetsListingTable" data-search="true"
data-pagination="true" data-side-pagination="server"
data-id-table="assetsListingTable" data-show-columns="true"
data-search="true" data-show-export="true"
data-side-pagination="server" data-show-refresh="true"
data-show-columns="true" data-sort-order="asc"
data-show-export="true" data-toolbar="#toolbar"
data-show-refresh="true" id="assetsListingTable"
data-sort-order="asc" class="table table-striped snipe-table"
id="assetsListingTable" data-url="{{route('api.assets.index', ['location_id' => $location->id]) }}"
class="table table-striped snipe-table" data-export-options='{
data-url="{{route('api.assets.index', ['location_id' => $location->id]) }}"
data-export-options='{
"fileName": "export-locations-{{ str_slug($location->name) }}-assets-{{ date('Y-m-d') }}", "fileName": "export-locations-{{ str_slug($location->name) }}-assets-{{ date('Y-m-d') }}",
"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="box-heading">
<h2 class="box-title">{{ trans('general.accessories') }}</h2>
</div>
</div>
<div class="box-body">
<div class="table table-responsive">
<table
data-columns="{{ \App\Presenters\AccessoryPresenter::dataTableLayout() }}" <div class="tab-pane" id="accessories">
data-cookie-id-table="accessoriesListingTable" <h2 class="box-title">{{ trans('general.accessories') }}</h2>
data-pagination="true" <div class="table table-responsive">
data-id-table="accessoriesListingTable" <table
data-search="true" data-columns="{{ \App\Presenters\AccessoryPresenter::dataTableLayout() }}"
data-side-pagination="server" data-cookie-id-table="accessoriesListingTable"
data-show-columns="true" data-pagination="true"
data-show-export="true" data-id-table="accessoriesListingTable"
data-show-refresh="true" data-search="true"
data-sort-order="asc" data-side-pagination="server"
id="accessoriesListingTable" data-show-columns="true"
class="table table-striped snipe-table" data-show-export="true"
data-url="{{route('api.accessories.index', ['location_id' => $location->id]) }}" data-show-refresh="true"
data-export-options='{ data-sort-order="asc"
id="accessoriesListingTable"
class="table table-striped snipe-table"
data-url="{{route('api.accessories.index', ['location_id' => $location->id]) }}"
data-export-options='{
"fileName": "export-locations-{{ str_slug($location->name) }}-accessories-{{ date('Y-m-d') }}", "fileName": "export-locations-{{ str_slug($location->name) }}-accessories-{{ date('Y-m-d') }}",
"ignoreColumn": ["actions","image","change","checkbox","checkincheckout","icon"] "ignoreColumn": ["actions","image","change","checkbox","checkincheckout","icon"]
}'> }'>
</table> </table>
</div><!-- /.table-responsive -->
</div><!-- /.tab-pane -->
</div><!-- /.table-responsive -->
</div><!-- /.box-body -->
</div> <!--/.box-->
<div class="box box-default"> <div class="tab-pane" id="consumables">
<div class="box-header with-border"> <div class="table table-responsive">
<div class="box-heading"> <table
<h2 class="box-title">{{ trans('general.consumables') }}</h2> data-columns="{{ \App\Presenters\ConsumablePresenter::dataTableLayout() }}"
</div> data-cookie-id-table="consumablesListingTable"
</div> data-pagination="true"
<div class="box-body"> data-id-table="consumablesListingTable"
<div class="table table-responsive"> data-search="true"
data-side-pagination="server"
<table data-show-columns="true"
data-columns="{{ \App\Presenters\ConsumablePresenter::dataTableLayout() }}" data-show-export="true"
data-cookie-id-table="consumablesListingTable" data-show-refresh="true"
data-pagination="true" data-sort-order="asc"
data-id-table="consumablesListingTable" id="consumablesListingTable"
data-search="true" class="table table-striped snipe-table"
data-side-pagination="server" data-url="{{route('api.consumables.index', ['location_id' => $location->id]) }}"
data-show-columns="true" data-export-options='{
data-show-export="true"
data-show-refresh="true"
data-sort-order="asc"
id="consumablesListingTable"
class="table table-striped snipe-table"
data-url="{{route('api.consumables.index', ['location_id' => $location->id]) }}"
data-export-options='{
"fileName": "export-locations-{{ str_slug($location->name) }}-consumables-{{ date('Y-m-d') }}", "fileName": "export-locations-{{ str_slug($location->name) }}-consumables-{{ date('Y-m-d') }}",
"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="tab-pane" id="components">
<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">
<table <div class="table table-responsive">
data-columns="{{ \App\Presenters\ComponentPresenter::dataTableLayout() }}"
data-cookie-id-table="componentsTable" <table
data-pagination="true" data-columns="{{ \App\Presenters\ComponentPresenter::dataTableLayout() }}"
data-id-table="componentsTable" data-cookie-id-table="componentsTable"
data-search="true" data-pagination="true"
data-side-pagination="server" data-id-table="componentsTable"
data-show-columns="true" data-search="true"
data-show-export="true" data-side-pagination="server"
data-show-refresh="true" data-show-columns="true"
data-sort-order="asc" data-show-export="true"
id="componentsTable" data-show-refresh="true"
class="table table-striped snipe-table" data-sort-order="asc"
data-url="{{route('api.components.index', ['location_id' => $location->id])}}" id="componentsTable"
data-export-options='{ class="table table-striped snipe-table"
data-url="{{route('api.components.index', ['location_id' => $location->id])}}"
data-export-options='{
"fileName": "export-locations-{{ str_slug($location->name) }}-components-{{ date('Y-m-d') }}", "fileName": "export-locations-{{ str_slug($location->name) }}-components-{{ date('Y-m-d') }}",
"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><!--/.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"