mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-24 21:24:13 -08:00
Handle checking and unchecking for bulk actions
Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
parent
52ea172e5d
commit
52caee2a9f
|
@ -116,7 +116,7 @@ class AssetsTransformer
|
|||
$permissions_array['available_actions'] = [
|
||||
'checkout' => Gate::allows('checkout', Asset::class),
|
||||
'checkin' => Gate::allows('checkin', Asset::class),
|
||||
'clone' => Gate::allows('create', Asset::class),
|
||||
'clone' => false,
|
||||
'restore' => false,
|
||||
'update' => (bool) Gate::allows('update', Asset::class),
|
||||
'delete' => ($asset->assigned_to=='' && Gate::allows('delete', Asset::class)),
|
||||
|
|
|
@ -57,23 +57,29 @@
|
|||
<div class="col-md-12">
|
||||
<div class="box">
|
||||
<div class="box-body">
|
||||
{{ Form::open([
|
||||
'method' => 'POST',
|
||||
'route' => ['hardware/bulkedit'],
|
||||
'class' => 'form-inline',
|
||||
'id' => 'bulkForm']) }}
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
@if (Request::get('status')!='Deleted')
|
||||
<div id="toolbar">
|
||||
<label for="bulk_actions"><span class="sr-only">Bulk Actions</span></label>
|
||||
<select name="bulk_actions" class="form-control select2" aria-label="bulk_actions">
|
||||
<option value="edit">{{ trans('button.edit') }}</option>
|
||||
<option value="delete">{{ trans('button.delete') }}</option>
|
||||
<option value="labels">{{ trans_choice('button.generate_labels', 2) }}</option>
|
||||
</select>
|
||||
<button class="btn btn-primary" id="bulkEdit" disabled>Go</button>
|
||||
</div>
|
||||
{{ Form::open([
|
||||
'method' => 'POST',
|
||||
'route' => ['hardware/bulkedit'],
|
||||
'class' => 'form-inline',
|
||||
'id' => 'bulkForm']) }}
|
||||
<div id="toolbar">
|
||||
|
||||
<label for="bulk_actions"><span class="sr-only">Bulk Actions</span></label>
|
||||
<select name="bulk_actions" class="form-control select2" aria-label="bulk_actions">
|
||||
<option value="edit">{{ trans('button.edit') }}</option>
|
||||
<option value="delete">{{ trans('button.delete') }}</option>
|
||||
<option value="labels">{{ trans_choice('button.generate_labels', 2) }}</option>
|
||||
</select>
|
||||
|
||||
<button class="btn btn-primary" id="bulkEdit" disabled>Go</button>
|
||||
|
||||
</div>
|
||||
{{ Form::close() }}
|
||||
|
||||
@endif
|
||||
|
||||
<table
|
||||
|
@ -107,7 +113,7 @@
|
|||
|
||||
</div><!-- /.col -->
|
||||
</div><!-- /.row -->
|
||||
{{ Form::close() }}
|
||||
|
||||
</div><!-- ./box-body -->
|
||||
</div><!-- /.box -->
|
||||
</div>
|
||||
|
|
|
@ -81,6 +81,18 @@
|
|||
}
|
||||
|
||||
});
|
||||
|
||||
$('.snipe-table').on('check.bs.table .btSelectItem', function (row, $element) {
|
||||
$('#bulkEdit').before('<input id="checkbox_' + $element.id + '" type="hidden" name="ids[]" value="' + $element.id + '">');
|
||||
});
|
||||
|
||||
|
||||
$('.snipe-table').on('uncheck.bs.table .btSelectItem', function (row, $element) {
|
||||
$( "#checkbox_" + $element.id).remove();
|
||||
});
|
||||
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
@ -209,7 +221,7 @@
|
|||
}
|
||||
|
||||
if ((row.available_actions) && (row.available_actions.update === true)) {
|
||||
actions += '<a href="{{ url('/') }}/' + dest + '/' + row.id + '/edit" class="btn btn-sm btn-warning" data-tooltip="true" title="Update Item"><i class="fa fa-pencil" aria-hidden="true"></i><span class="sr-only">Update</span></a> ';
|
||||
actions += '<a href="{{ url('/') }}/' + dest + '/' + row.id + '/edit" class="btn btn-sm btn-warning" data-tooltip="true" title="{{ trans('general.update') }}"><i class="fa fa-pencil" aria-hidden="true"></i><span class="sr-only">{{ trans('general.update') }}</span></a> ';
|
||||
}
|
||||
|
||||
if ((row.available_actions) && (row.available_actions.delete === true)) {
|
||||
|
@ -218,13 +230,17 @@
|
|||
+ ' data-toggle="modal" '
|
||||
+ ' data-content="{{ trans('general.sure_to_delete') }} ' + row.name + '?" '
|
||||
+ ' data-title="{{ trans('general.delete') }}" onClick="return false;">'
|
||||
+ '<i class="fa fa-trash" aria-hidden="true"></i><span class="sr-only">Delete</span></a> ';
|
||||
+ '<i class="fa fa-trash" aria-hidden="true"></i><span class="sr-only">{{ trans('general.delete') }}</span></a> ';
|
||||
} else {
|
||||
actions += '<a class="btn btn-danger btn-sm delete-asset disabled" onClick="return false;"><i class="fa fa-trash"></i></a> ';
|
||||
}
|
||||
|
||||
|
||||
if ((row.available_actions) && (row.available_actions.restore === true)) {
|
||||
actions += '<a href="{{ url('/') }}/' + dest + '/' + row.id + '/restore" class="btn btn-sm btn-warning" data-toggle="tooltip" title="Restore"><i class="fa fa-retweet"></i></a> ';
|
||||
actions += '<form style="display: inline;" method="POST" action="{{ url('/') }}/' + dest + '/' + row.id + '/restore"> ';
|
||||
actions += '@csrf';
|
||||
actions += '<button class="btn btn-sm btn-warning" data-toggle="tooltip" title="{{ trans('general.restore') }}">';
|
||||
actions += '<i class="fa fa-retweet" aria-hidden="true"></i><span class="sr-only">{{ trans('general.restore') }}</span></button></form> ';
|
||||
}
|
||||
|
||||
actions +='</nobr>';
|
||||
|
|
Loading…
Reference in a new issue