mirror of
https://github.com/snipe/snipe-it.git
synced 2025-02-21 03:15:45 -08:00
Fixes #906 - groups view
This commit is contained in:
parent
665a113ed8
commit
c069829b33
|
@ -57,7 +57,6 @@ class UsersController extends Controller
|
|||
$users = $users->GetDeleted();
|
||||
}
|
||||
|
||||
|
||||
if ($request->has('company_id')) {
|
||||
$users = $users->where('company_id', '=', $request->input('company_id'));
|
||||
}
|
||||
|
@ -65,6 +64,10 @@ class UsersController extends Controller
|
|||
if ($request->has('location_id')) {
|
||||
$users = $users->where('location_id', '=', $request->input('location_id'));
|
||||
}
|
||||
|
||||
if ($request->has('group_id')) {
|
||||
$users = $users->ByGroup($request->has('group_id'));
|
||||
}
|
||||
|
||||
if ($request->has('department_id')) {
|
||||
$users = $users->where('department_id','=',$request->input('department_id'));
|
||||
|
|
|
@ -87,10 +87,15 @@ class GroupsController extends Controller
|
|||
public function edit($id = null)
|
||||
{
|
||||
$group = Group::find($id);
|
||||
$permissions = config('permissions');
|
||||
$groupPermissions = $group->decodePermissions();
|
||||
$selected_array = Helper::selectedPermissionsArray($permissions, $groupPermissions);
|
||||
return view('groups.edit', compact('group', 'permissions', 'selected_array', 'groupPermissions'));
|
||||
|
||||
if ($group) {
|
||||
$permissions = config('permissions');
|
||||
$groupPermissions = $group->decodePermissions();
|
||||
$selected_array = Helper::selectedPermissionsArray($permissions, $groupPermissions);
|
||||
return view('groups.edit', compact('group', 'permissions', 'selected_array', 'groupPermissions'));
|
||||
}
|
||||
|
||||
return redirect()->route('groups.index')->with('error', trans('admin/groups/message.group_not_found', compact('id')));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -142,4 +147,24 @@ class GroupsController extends Controller
|
|||
return redirect()->route('groups.index')->with('error', trans('general.feature_disabled'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a view that invokes the ajax tables which actually contains
|
||||
* the content for the group detail page.
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @param int $locationId
|
||||
* @since [v4.0.11]
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
$group = Group::find($id);
|
||||
|
||||
if ($group) {
|
||||
return view('groups/view', compact('group'));
|
||||
}
|
||||
|
||||
return redirect()->route('groups.index')->with('error', trans('admin/groups/message.group_not_found', compact('id')));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -378,6 +378,14 @@ class User extends SnipeModel implements AuthenticatableContract, CanResetPasswo
|
|||
return json_decode($this->permissions, true);
|
||||
}
|
||||
|
||||
|
||||
public function scopeByGroup($query, $id) {
|
||||
return $query->whereHas('groups', function ($query) use ($id) {
|
||||
$query->where('id', '=', $id);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Query builder scope to search on text
|
||||
*
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
<thead>
|
||||
<tr>
|
||||
<th data-switchable="true" data-sortable="false" data-field="id" data-visible="false">{{ trans('general.id') }}</th>
|
||||
<th data-switchable="true" data-sortable="true" data-field="name" data-visible="true">{{ trans('admin/groups/table.name') }}</th>
|
||||
<th data-switchable="true" data-sortable="true" data-field="name" data-formatter="groupsAdminLinkFormatter" data-visible="true">{{ trans('admin/groups/table.name') }}</th>
|
||||
<th data-switchable="true" data-sortable="false" data-field="users_count" data-visible="true">{{ trans('admin/groups/table.users') }}</th>
|
||||
<th data-switchable="true" data-sortable="true" data-field="created_at" data-visible="true" data-formatter="dateDisplayFormatter">{{ trans('general.created_at') }}</th>
|
||||
<th data-switchable="false" data-searchable="false" data-sortable="false" data-field="actions" data-formatter="groupsActionsFormatter">{{ trans('table.actions') }}</th>
|
||||
|
|
|
@ -2,56 +2,63 @@
|
|||
|
||||
{{-- Page title --}}
|
||||
@section('title')
|
||||
{{ trans('admin/groups/table.view') }} -
|
||||
{{ $group->name }}
|
||||
@parent
|
||||
{{ $group->name }}
|
||||
@parent
|
||||
@stop
|
||||
|
||||
@section('header_right')
|
||||
<a href="{{ route('groups.edit', ['group' => $group->id]) }}" class="btn btn-sm btn-primary pull-right">{{ trans('admin/groups/titles.update') }} </a>
|
||||
<a href="{{ route('groups.index') }}" class="btn btn-default pull-right">{{ trans('general.back') }}</a>
|
||||
@stop
|
||||
|
||||
|
||||
|
||||
{{-- Page content --}}
|
||||
@section('content')
|
||||
|
||||
<div class="row header">
|
||||
<div class="col-md-12">
|
||||
<a href="{{ route('update/group', $group->id) }}" class="btn-flat white pull-right">
|
||||
{{ trans('admin/groups/table.update') }}
|
||||
</a>
|
||||
<a href="{{ url('admin/groups') }}" class="btn-flat gray pull-right" style="margin-right:5px;">
|
||||
<i class="fa fa-arrow-left icon-white"></i> {{ trans('general.back') }}
|
||||
</a>
|
||||
<h3 class="name"> {{ trans('admin/groups/titles.group_management') }} - {{ $group->name }}</h3>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-9">
|
||||
<div class="box box-default">
|
||||
<div class="box-body">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="table table-responsive">
|
||||
<table
|
||||
name="groups_users"
|
||||
id="table-users"
|
||||
class="table table-striped snipe-table"
|
||||
data-url="{{ route('api.users.index',['group_id'=> $group->id]) }}"
|
||||
data-cookie="true"
|
||||
data-click-to-select="true"
|
||||
data-cookie-id-table="groups_usersDetailTable">
|
||||
<thead>
|
||||
|
||||
<div class="user-profile">
|
||||
<div class="row profile">
|
||||
<div class="col-md-12 bio">
|
||||
@if (count($users) > 0)
|
||||
<table id="example">
|
||||
<thead>
|
||||
<tr role="row">
|
||||
<th class="col-md-3">{{ trans('admin/groups/table.name') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach ($users as $user)
|
||||
<tr>
|
||||
<td>
|
||||
<a href="{{ route('users.show', $user->id) }}">{{ $user->first_name }} {{ $user->last_name }}</a>
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
@else
|
||||
<div class="col-md-12">
|
||||
<div class="alert alert-info alert-block">
|
||||
<i class="fa fa-info-circle"></i>
|
||||
{{ trans('general.no_results') }}
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
</div> <!--.col-md-12-->
|
||||
</div> <!--.user-profile-->
|
||||
<div class="col-md-3">
|
||||
|
||||
<ul class="list-unstyled">
|
||||
@foreach ($group->decodePermissions() as $permission_name => $permission)
|
||||
<li>{!! ($permission == '1') ? '<i class="fa fa-check text-success"></i>' : '<i class="fa fa-times text-danger"></i>' !!} {{ e(str_replace('.', ': ', ucwords($permission_name))) }} </li>
|
||||
@endforeach
|
||||
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@stop
|
||||
|
||||
@section('moar_scripts')
|
||||
@include ('partials.bootstrap-table', [
|
||||
'exportFile' => 'groups-export',
|
||||
'search' => true,
|
||||
'columns' => \App\Presenters\UserPresenter::dataTableLayout()
|
||||
])
|
||||
|
||||
@stop
|
||||
|
|
|
@ -332,6 +332,21 @@ $('.snipe-table').bootstrapTable({
|
|||
}
|
||||
}
|
||||
|
||||
function groupsFormatter(value) {
|
||||
|
||||
if (value) {
|
||||
var groups = '';
|
||||
for (var index in value.rows) {
|
||||
groups += '<a href="{{ url('/') }}/admin/groups/' + value.rows[index].id + '" class="label label-default"> ' + value.rows[index].name + '</a> ';
|
||||
}
|
||||
return groups;
|
||||
}
|
||||
}
|
||||
|
||||
function groupsAdminLinkFormatter(value, row) {
|
||||
return '<a href="{{ url('/') }}/admin/groups/' + row.id + '"> ' + value + '</a>';
|
||||
}
|
||||
|
||||
function trueFalseFormatter(value, row) {
|
||||
if ((value) && ((value == 'true') || (value == '1'))) {
|
||||
return '<i class="fa fa-check text-success"></i>';
|
||||
|
|
|
@ -86,20 +86,5 @@
|
|||
'columns' => \App\Presenters\UserPresenter::dataTableLayout()
|
||||
])
|
||||
|
||||
<script nonce="{{ csrf_token() }}">
|
||||
|
||||
function groupsFormatter(value) {
|
||||
|
||||
if (value) {
|
||||
var groups = '';
|
||||
for (var index in value.rows) {
|
||||
groups += '<a href="#" class="label label-default"> ' + value.rows[index].name + '</a> ';
|
||||
}
|
||||
return groups;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
@stop
|
||||
|
|
|
@ -536,7 +536,6 @@ $(function () {
|
|||
$('.progress-checkmark').fadeIn('fast').html('<i class="fa fa-check fa-3x icon-white" style="color: green"></i>');
|
||||
$.each(data.result.file, function (index, file) {
|
||||
$('<tr><td>' + file.notes + '</td><<td>' + file.name + '</td><td>Just now</td><td>' + file.filesize + '</td><td><a class="btn btn-info btn-sm hidden-print" href="import/process/' + file.name + '"><i class="fa fa-spinner process"></i> Process</a></td></tr>').prependTo("#upload-table > tbody");
|
||||
//$('<tr><td>').text(file.name).appendTo(document.body);
|
||||
});
|
||||
}
|
||||
$('#progress').removeClass('active');
|
||||
|
|
|
@ -190,7 +190,10 @@ Route::group([ 'prefix' => 'admin','middleware' => ['authorize:superuser']], fun
|
|||
Route::get('requests', [ 'as' => 'requests', 'middleware' => 'authorize:admin', 'uses' => 'ViewAssetsController@getRequestedIndex']);
|
||||
|
||||
|
||||
|
||||
Route::resource('groups', 'GroupsController', [
|
||||
'middleware' => ['auth'],
|
||||
'parameters' => ['group' => 'group_id']
|
||||
]);
|
||||
|
||||
Route::get('/', ['as' => 'settings.index', 'uses' => 'SettingsController@index' ]);
|
||||
|
||||
|
@ -198,10 +201,7 @@ Route::group([ 'prefix' => 'admin','middleware' => ['authorize:superuser']], fun
|
|||
});
|
||||
|
||||
|
||||
Route::resource('groups', 'GroupsController', [
|
||||
'middleware' => ['auth'],
|
||||
'parameters' => ['group' => 'group_id']
|
||||
]);
|
||||
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
Loading…
Reference in a new issue