Fixed deleted users/restore users view

This commit is contained in:
snipe 2017-09-06 17:11:43 -07:00
parent 472658b2fe
commit 47909b93f7
4 changed files with 15 additions and 4 deletions

View file

@ -52,6 +52,12 @@ class UsersController extends Controller
$users = $users->TextSearch($request->input('search')); $users = $users->TextSearch($request->input('search'));
} }
if (($request->has('deleted')) && ($request->input('deleted')=='true')) {
$users = $users->GetDeleted();
}
if ($request->has('company_id')) { if ($request->has('company_id')) {
$users = $users->where('company_id', '=', $request->input('company_id')); $users = $users->where('company_id', '=', $request->input('company_id'));
} }

View file

@ -56,9 +56,10 @@ class UsersTransformer
]; ];
$permissions_array['available_actions'] = [ $permissions_array['available_actions'] = [
'update' => Gate::allows('update', User::class) ? true : false, 'update' => (Gate::allows('update', User::class) && ($user->deleted_at=='')) ? true : false,
'delete' => Gate::allows('delete', User::class) ? true : false, 'delete' => (Gate::allows('delete', User::class) && ($user->deleted_at=='')) ? true : false,
'clone' => Gate::allows('create', User::class) ? true : false, 'clone' => (Gate::allows('create', User::class) && ($user->deleted_at=='')) ,
'restore' => (Gate::allows('create', User::class) && ($user->deleted_at!='')) ? true : false,
]; ];
$array += $permissions_array; $array += $permissions_array;

View file

@ -167,6 +167,10 @@ $('.snipe-table').bootstrapTable({
+ ' data-title="{{ trans('general.delete') }}" onClick="return false;">' + ' data-title="{{ trans('general.delete') }}" onClick="return false;">'
+ '<i class="fa fa-trash"></i></a></nobr>'; + '<i class="fa fa-trash"></i></a></nobr>';
} }
if ((row.available_actions) && (row.available_actions.restore === true)) {
actions += '<a href="{{ url('/') }}/' + destination + '/' + row.id + '/restore" class="btn btn-sm btn-warning" data-tooltip="true" title="Restore"><i class="fa fa-retweet"></i></a>&nbsp;';
}
return actions; return actions;
}; };

View file

@ -64,7 +64,7 @@
class="table table-striped snipe-table" class="table table-striped snipe-table"
id="table" id="table"
data-url="{{ route('api.users.index', data-url="{{ route('api.users.index',
array(''=>e(Input::get('status')),'company_id'=>e(Input::get('company_id')))) }}" array('deleted'=> (Input::get('status')=='deleted') ? 'true' : 'false','company_id'=>e(Input::get('company_id')))) }}"
data-cookie="true" data-cookie="true"
data-click-to-select="true" data-click-to-select="true"
data-cookie-id-table="userTableDisplay-{{ config('version.hash_version') }}"> data-cookie-id-table="userTableDisplay-{{ config('version.hash_version') }}">