Merge pull request #11253 from snipe/features/nicer_locations_ui

Nicer locations UI
This commit is contained in:
snipe 2022-06-06 10:23:04 -07:00 committed by GitHub
commit f7449921e9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 282 additions and 196 deletions

View file

@ -103,6 +103,7 @@ class Location extends SnipeModel
return $this->hasMany(\App\Models\User::class, 'location_id');
}
public function assets()
{
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');
}
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()
{
return $this->belongsTo(self::class, 'parent_id', 'id')

View file

@ -47,7 +47,9 @@
data-show-refresh="true"
data-sort-order="asc"
data-sort-name="name"
data-toolbar="#toolbar"
data-toolbar="#assetsBulkEditToolbar"
data-bulk-button-id="#bulkAssetEditButton"
data-bulk-form-id="#assetsBulkForm"
id="assetsListingTable"
class="table table-striped snipe-table"
data-url="{{ route('api.assets.requestable', ['requestable' => true]) }}">

View file

@ -21,7 +21,6 @@
<table
data-columns="{{ \App\Presenters\ComponentPresenter::dataTableLayout() }}"
data-cookie-id-table="componentsTable"
data-toolbar="#toolbar"
data-pagination="true"
data-id-table="componentsTable"
data-search="true"

View file

@ -43,7 +43,9 @@
data-show-refresh="true"
data-sort-order="asc"
data-sort-name="name"
data-toolbar="#toolbar"
data-toolbar="#assetsBulkEditToolbar"
data-bulk-button-id="#bulkAssetEditButton"
data-bulk-form-id="#assetsBulkForm"
id="assetsAuditListingTable"
class="table table-striped snipe-table"
data-url="{{ route('api.asset.to-audit', ['audit' => 'due']) }}"

View file

@ -23,11 +23,7 @@
<div class="col-md-12">
<div class="box">
<div class="box-body">
{{ Form::open([
'method' => 'POST',
'route' => ['hardware/bulkedit'],
'class' => 'form-inline',
'id' => 'bulkForm']) }}
@include('partials.asset-bulk-actions')
<div class="row">
<div class="col-md-12">
@ -45,7 +41,9 @@
data-show-refresh="true"
data-sort-order="asc"
data-sort-name="name"
data-toolbar="#toolbar"
data-toolbar="#assetsBulkEditToolbar"
data-bulk-button-id="#bulkAssetEditButton"
data-bulk-form-id="#assetsBulkForm"
id="assetsAuditListingTable"
class="table table-striped snipe-table"
data-url="{{ route('api.asset.to-audit', ['audit' => 'overdue']) }}"

View file

@ -84,7 +84,9 @@
data-show-refresh="true"
data-sort-order="asc"
data-sort-name="name"
data-toolbar="#toolbar"
data-toolbar="#assetsBulkEditToolbar"
data-bulk-button-id="#bulkAssetEditButton"
data-bulk-form-id="#assetsBulkForm"
id="assetsListingTable"
class="table table-striped snipe-table"
data-url="{{ route('api.assets.index',

View file

@ -15,178 +15,218 @@
<div class="row">
<div class="col-md-9">
<div class="nav-tabs-custom">
<ul class="nav nav-tabs hidden-print">
<div class="box box-default">
<div class="box-header with-border">
<div class="box-heading">
<h2 class="box-title">{{ trans('general.users') }}</h2>
</div>
</div>
<div class="box-body">
<li class="active">
<a href="#users" data-toggle="tab">
<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>' : '' !!}
<div class="table table-responsive">
</span>
</a>
</li>
<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"
id="usersTable"
class="table table-striped snipe-table"
data-url="{{route('api.users.index', ['location_id' => $location->id])}}"
data-export-options='{
<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>
<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="#userBulkEditToolbar"
data-bulk-button-id="#bulkUserEditButton"
data-bulk-form-id="#usersBulkForm"
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') }}",
"ignoreColumn": ["actions","image","change","checkbox","checkincheckout","icon"]
}'>
</table>
</div><!-- /.table-responsive -->
</div><!-- /.box-body -->
</div> <!--/.box-->
</table>
</div><!-- /.table-responsive -->
</div><!-- /.tab-pane -->
<div class="box box-default">
<div class="box-header with-border">
<div class="box-heading">
<h2 class="box-title">{{ trans('general.assets') }}</h2>
</div>
</div>
<div class="box-body">
<div class="tab-pane" id="assets">
<h2 class="box-title">{{ trans('general.assets') }}</h2>
@include('partials.asset-bulk-actions')
<div class="table table-responsive">
<table
data-columns="{{ \App\Presenters\AssetPresenter::dataTableLayout() }}"
data-cookie-id-table="assetsListingTable"
data-pagination="true"
data-id-table="assetsListingTable"
data-search="true"
data-side-pagination="server"
data-show-columns="true"
data-show-export="true"
data-show-refresh="true"
data-sort-order="asc"
id="assetsListingTable"
class="table table-striped snipe-table"
data-url="{{route('api.assets.index', ['location_id' => $location->id]) }}"
data-export-options='{
<div class="table table-responsive">
@include('partials.asset-bulk-actions')
<table
data-columns="{{ \App\Presenters\AssetPresenter::dataTableLayout() }}"
data-cookie-id-table="assetsListingTable"
data-pagination="true"
data-id-table="assetsListingTable"
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="#assetsBulkEditToolbar"
data-bulk-button-id="#bulkAssetEditButton"
data-bulk-form-id="#assetsBulkForm"
id="assetsListingTable"
class="table table-striped snipe-table"
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') }}",
"ignoreColumn": ["actions","image","change","checkbox","checkincheckout","icon"]
}'>
</table>
</table>
</div><!-- /.table-responsive -->
</div><!-- /.box-body -->
</div> <!--/.box-->
</div><!-- /.table-responsive -->
</div><!-- /.tab-pane -->
<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() }}"
data-cookie-id-table="accessoriesListingTable"
data-pagination="true"
data-id-table="accessoriesListingTable"
data-search="true"
data-side-pagination="server"
data-show-columns="true"
data-show-export="true"
data-show-refresh="true"
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='{
<div class="tab-pane" id="accessories">
<h2 class="box-title">{{ trans('general.accessories') }}</h2>
<div class="table table-responsive">
<table
data-columns="{{ \App\Presenters\AccessoryPresenter::dataTableLayout() }}"
data-cookie-id-table="accessoriesListingTable"
data-pagination="true"
data-id-table="accessoriesListingTable"
data-search="true"
data-side-pagination="server"
data-show-columns="true"
data-show-export="true"
data-show-refresh="true"
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') }}",
"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="box-header with-border">
<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="tab-pane" id="consumables">
<h2 class="box-title">{{ trans('general.consumables') }}</h2>
<table
data-columns="{{ \App\Presenters\ConsumablePresenter::dataTableLayout() }}"
data-cookie-id-table="consumablesListingTable"
data-pagination="true"
data-id-table="consumablesListingTable"
data-search="true"
data-side-pagination="server"
data-show-columns="true"
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='{
<div class="table table-responsive">
<table
data-columns="{{ \App\Presenters\ConsumablePresenter::dataTableLayout() }}"
data-cookie-id-table="consumablesListingTable"
data-pagination="true"
data-id-table="consumablesListingTable"
data-search="true"
data-side-pagination="server"
data-show-columns="true"
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') }}",
"ignoreColumn": ["actions","image","change","checkbox","checkincheckout","icon"]
}'>
</table>
</table>
</div><!-- /.table-responsive -->
</div><!-- /.box-body -->
</div> <!--/.box-->
</div><!-- /.table-responsive -->
</div><!-- /.tab-pane -->
<div class="box box-default">
<div class="box-header with-border">
<div class="box-heading">
<div class="tab-pane" id="components">
<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
data-columns="{{ \App\Presenters\ComponentPresenter::dataTableLayout() }}"
data-cookie-id-table="componentsTable"
data-pagination="true"
data-id-table="componentsTable"
data-search="true"
data-side-pagination="server"
data-show-columns="true"
data-show-export="true"
data-show-refresh="true"
data-sort-order="asc"
id="componentsTable"
class="table table-striped snipe-table"
data-url="{{route('api.components.index', ['location_id' => $location->id])}}"
data-export-options='{
<table
data-columns="{{ \App\Presenters\ComponentPresenter::dataTableLayout() }}"
data-cookie-id-table="componentsTable"
data-pagination="true"
data-id-table="componentsTable"
data-search="true"
data-side-pagination="server"
data-show-columns="true"
data-show-export="true"
data-show-refresh="true"
data-sort-order="asc"
id="componentsTable"
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') }}",
"ignoreColumn": ["actions","image","change","checkbox","checkincheckout","icon"]
}'>
</table>
</div><!-- /.table-responsive -->
</div><!-- /.box-body -->
</div> <!--/.box-->
</table>
</div><!-- /.table-responsive -->
</div><!-- /.tab-pane -->
</div><!--/.col-md-9-->
</div><!--/.col-md-9-->
</div><!--/.col-md-9-->
<div class="col-md-3">

View file

@ -35,22 +35,23 @@
<div class="col-md-12">
<div class="box box-default">
<div class="box-body">
{{ Form::open([
'method' => 'POST',
'route' => ['models.bulkedit.index'],
'class' => 'form-inline',
'id' => 'bulkForm']) }}
'id' => 'modelsBulkForm']) }}
<div class="row">
<div class="col-md-12">
@if (Request::get('status')!='deleted')
<div id="toolbar">
<div id="modelBulkEditToolbar">
<label for="bulk_actions" class="sr-only">{{ trans('general.bulk_actions') }}</label>
<select id="bulk_actions" name="bulk_actions" class="form-control select2" aria-label="bulk_actions" style="width: 300px;">
<option value="edit">{{ trans('general.bulk_edit') }}</option>
<option value="delete">{{ trans('general.bulk_delete') }}</option>
</select>
<button class="btn btn-primary" id="bulkEdit" disabled>Go</button>
<button class="btn btn-primary" id="bulkModelsEditButton" disabled>{{ trans('button.go') }}</button>
</div>
@endif
<div class="table-responsive">
@ -63,7 +64,9 @@
data-show-footer="true"
data-side-pagination="server"
data-show-columns="true"
data-toolbar="#toolbar"
data-toolbar="#modelsBulkEditToolbar"
data-bulk-button-id="#bulkModelsEditButton"
data-bulk-form-id="#modelsBulkForm"
data-show-export="true"
data-show-refresh="true"
data-sort-order="asc"

View file

@ -56,7 +56,9 @@
data-search="true"
data-side-pagination="server"
data-show-columns="true"
data-toolbar="#toolbar"
data-toolbar="#assetsBulkEditToolbar"
data-bulk-button-id="#bulkAssetEditButton"
data-bulk-form-id="#assetsBulkForm"
data-show-export="true"
data-show-refresh="true"
data-sort-order="asc"

View file

@ -1,9 +1,9 @@
<div id="toolbar">
<div id="assetsBulkEditToolbar" style="min-width:400px">
{{ Form::open([
'method' => 'POST',
'route' => ['hardware/bulkedit'],
'class' => 'form-inline',
'id' => 'bulkForm']) }}
'id' => 'assetsBulkForm']) }}
<label for="bulk_actions">
@ -21,6 +21,6 @@
<option value="labels">{{ trans_choice('button.generate_labels', 2) }}</option>
</select>
<button class="btn btn-primary" id="bulkEdit" disabled>{{ trans('button.go') }}</button>
<button class="btn btn-primary" id="bulkAssetEditButton" disabled>{{ trans('button.go') }}</button>
{{ Form::close() }}
</div>

View file

@ -114,8 +114,12 @@
// These methods dynamically add/remove hidden input values in the bulk actions form
$('.snipe-table').on('check.bs.table .btSelectItem', function (row, $element) {
$('#bulkEdit').removeAttr('disabled');
$('#bulkEdit').prepend('<input id="checkbox_' + $element.id + '" type="hidden" name="ids[]" value="' + $element.id + '">');
var buttonName = $(this).data('bulk-button-id');
var formName = $(this).data('bulk-form-id');
var tableId = $(this).data('id-table');
$(buttonName).removeAttr('disabled');
$(formName).prepend('<input id="' + tableId + '_checkbox_' + $element.id + '" type="hidden" name="ids[]" value="' + $element.id + '">');
});
$('.snipe-table').on('uncheck.bs.table .btSelectItem', function (row, $element) {
@ -123,33 +127,42 @@
});
$('.snipe-table').on('check-all.bs.table', function (event, rowsAfter, rowsBefore) {
var buttonName = $(this).data('bulk-button-id');
$(buttonName).removeAttr('disabled');
var formName = $(this).data('bulk-form-id');
var tableId = $(this).data('id-table');
for (var i in rowsAfter) {
$(formName).prepend('<input id="' + tableId + '_checkbox_' + rowsAfter[i].id + '" type="hidden" name="ids[]" value="' + rowsAfter[i].id + '">');
}
});
// Handle whether or not the edit button should be disabled
$('.snipe-table').on('uncheck.bs.table', function () {
if ($('.snipe-table').bootstrapTable('getSelections').length == 0) {
$('#bulkEdit').attr('disabled', 'disabled');
var buttonName = $(this).data('bulk-button-id');
if ($(this).bootstrapTable('getSelections').length == 0) {
$(buttonName).attr('disabled', 'disabled');
}
});
$('.snipe-table').on('uncheck-all.bs.table', function (event, rowsAfter, rowsBefore) {
$('#bulkEdit').attr('disabled', 'disabled');
//console.dir(rowsBefore);
var buttonName = $(this).data('bulk-button-id');
$(buttonName).attr('disabled', 'disabled');
var tableId = $(this).data('id-table');
for (var i in rowsBefore) {
$( "#checkbox_" + rowsBefore[i].id).remove();
$( tableId + "_checkbox_" + rowsBefore[i].id).remove();
}
});
$('.snipe-table').on('check-all.bs.table', function (event, rowsAfter, rowsBefore) {
$('#bulkEdit').removeAttr('disabled');
//console.dir(rowsAfter);
for (var i in rowsAfter) {
// console.log(rowsAfter[i].id);
$('#bulkEdit').prepend('<input id="checkbox_' + rowsAfter[i].id + '" type="hidden" name="ids[]" value="' + rowsAfter[i].id + '">');
}
});

View file

@ -0,0 +1,22 @@
<div id="userBulkEditToolbar">
{{ Form::open([
'method' => 'POST',
'route' => ['users/bulkedit'],
'class' => 'form-inline',
'id' => 'usersBulkForm']) }}
@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="edit">{{ trans('general.bulk_edit') }}</option>
<option value="delete">{!! trans('general.bulk_checkin_delete') !!}</option>
<option value="bulkpasswordreset">{{ trans('button.send_password_link') }}</option>
</select>
<button class="btn btn-primary" id="bulkUserEditButton" disabled>{{ trans('button.go') }}</button>
</div>
@endcan
@endif
{{ Form::close() }}
</div>

View file

@ -22,7 +22,6 @@
<table
name="assetsReport"
data-toolbar="#toolbar"
class="table table-striped snipe-table"
id="table"
data-url="{{route('api.assets.index', array(''=>e(Request::get('status')),'order_number'=>e(Request::get('order_number')), 'status_id'=>e(Request::get('status_id')), 'report'=>'true'))}}"

View file

@ -38,26 +38,8 @@
<div class="col-md-12">
<div class="box box-default">
<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
data-click-to-select="true"
@ -71,7 +53,9 @@
data-show-export="true"
data-show-refresh="true"
data-sort-order="asc"
data-toolbar="#toolbar"
data-toolbar="#userBulkEditToolbar"
data-bulk-button-id="#bulkUserEditButton"
data-bulk-form-id="#usersBulkForm"
id="usersTable"
class="table table-striped snipe-table"
data-url="{{ route('api.users.index',

View file

@ -591,7 +591,9 @@
data-show-refresh="true"
data-sort-order="asc"
data-sort-name="name"
data-toolbar="#toolbar"
data-toolbar="#assetsBulkEditToolbar"
data-bulk-button-id="#bulkAssetEditButton"
data-bulk-form-id="#assetsBulkForm"
id="userAssetsListingTable"
class="table table-striped snipe-table"
data-url="{{ route('api.assets.index',['assigned_to' => e($user->id), 'assigned_type' => 'App\Models\User']) }}"