Merge pull request #12370 from marcusmoore/fix/file-upload-tab-permissions

Fixed file uploads for accessories, components, and consumables
This commit is contained in:
snipe 2023-01-18 16:08:53 -08:00 committed by GitHub
commit 155977de2d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 31 additions and 19 deletions

View file

@ -114,6 +114,24 @@ class AuthServiceProvider extends ServiceProvider
} }
}); });
Gate::define('accessories.files', function ($user) {
if ($user->hasAccess('accessories.files')) {
return true;
}
});
Gate::define('components.files', function ($user) {
if ($user->hasAccess('components.files')) {
return true;
}
});
Gate::define('consumables.files', function ($user) {
if ($user->hasAccess('consumables.files')) {
return true;
}
});
// Can the user import CSVs? // Can the user import CSVs?
Gate::define('import', function ($user) { Gate::define('import', function ($user) {
if ($user->hasAccess('import')) { if ($user->hasAccess('import')) {

View file

@ -84,8 +84,7 @@
</li> </li>
@endcan @endcan
@can('update', Component::class) @can('update', $accessory)
<li class="pull-right"> <li class="pull-right">
<a href="#" data-toggle="modal" data-target="#uploadFileModal"> <a href="#" data-toggle="modal" data-target="#uploadFileModal">
<i class="fas fa-paperclip" aria-hidden="true"></i> {{ trans('button.upload') }} <i class="fas fa-paperclip" aria-hidden="true"></i> {{ trans('button.upload') }}
@ -99,7 +98,7 @@
<div class="tab-pane active" id="checkedout"> <div class="tab-pane active" id="checkedout">
<div class="table table-responsive"> <div class="table table-responsive">
<div class="row"> <div class="row">
<div class="col-md-9"> <div class="col-md-12">
<table <table
data-cookie-id-table="usersTable" data-cookie-id-table="usersTable"
data-pagination="true" data-pagination="true"
@ -136,7 +135,7 @@
<div class="tab-pane fade" id="history"> <div class="tab-pane fade" id="history">
<div class="table table-responsive"> <div class="table table-responsive">
<div class="row"> <div class="row">
<div class="col-md-9"> <div class="col-md-12">
<table <table
class="table table-striped snipe-table" class="table table-striped snipe-table"
data-cookie-id-table="AccessoryHistoryTable" data-cookie-id-table="AccessoryHistoryTable"
@ -266,14 +265,14 @@
</tbody> </tbody>
</table> </table>
</div> </div>
</div>
</div>
</div> <!-- /.tab-pane --> </div> <!-- /.tab-pane -->
@endcan @endcan
</div> </div>
</div> </div>
</div> </div>
</div>
</div>
<!-- side address column --> <!-- side address column -->
@ -345,9 +344,6 @@
</div> </div>
@endcan @endcan
</div><!--col-md-3-->
</div><!--row-->
</div><!--tab-pane details-->
<div class="tab-pane fade" id="history"> <div class="tab-pane fade" id="history">
<div class="row"> <div class="row">
@ -387,8 +383,8 @@
</div> <!-- /.col-md-12--> </div> <!-- /.col-md-12-->
</div> <!-- /.row--> </div> <!-- /.row-->
</div><!--tab history--> </div><!--tab history-->
</div><!--tab-content--> </div><!--col-md-3-->
</div><!--/.nav-tabs-custom--> </div><!--row-->

View file

@ -80,8 +80,7 @@
</li> </li>
@endcan @endcan
@can('update', Component::class) @can('components.files', $component)
<li class="pull-right"> <li class="pull-right">
<a href="#" data-toggle="modal" data-target="#uploadFileModal"> <a href="#" data-toggle="modal" data-target="#uploadFileModal">
<i class="fas fa-paperclip" aria-hidden="true"></i> {{ trans('button.upload') }} <i class="fas fa-paperclip" aria-hidden="true"></i> {{ trans('button.upload') }}

View file

@ -45,8 +45,7 @@
</li> </li>
@endcan @endcan
@can('update', Consumable::class) @can('update', $consumable)
<li class="pull-right"> <li class="pull-right">
<a href="#" data-toggle="modal" data-target="#uploadFileModal"> <a href="#" data-toggle="modal" data-target="#uploadFileModal">
<i class="fas fa-paperclip" aria-hidden="true"></i> {{ trans('button.upload') }} <i class="fas fa-paperclip" aria-hidden="true"></i> {{ trans('button.upload') }}
@ -260,7 +259,7 @@
{{ trans('general.checkout') }} {{ trans('general.checkout') }}
</a> </a>
@else @else
<button style="margin-bottom:10px; width:100%"" class="btn btn-primary btn-sm disabled"> <button style="margin-bottom:10px; width:100%" class="btn btn-primary btn-sm disabled">
{{ trans('general.checkout') }} {{ trans('general.checkout') }}
</button> </button>
@endif @endif