Commit 32d1da3b authored by Nicolas Widart's avatar Nicolas Widart

Moving the permissions partials to the roles folder.

Adding a new permissions partials folder to the users folder.
Adding permissions edition in the user edit view.
parent 7d5e5d40
...@@ -88,7 +88,7 @@ class RolesController extends AdminBaseController ...@@ -88,7 +88,7 @@ class RolesController extends AdminBaseController
return Redirect::to('user::admin.roles.index'); return Redirect::to('user::admin.roles.index');
} }
return View::make('user::admin.roles.edit', compact('role', 'permissions')); return View::make('user::admin.roles.edit', compact('role'));
} }
/** /**
......
...@@ -6,11 +6,17 @@ use Illuminate\Support\Facades\Redirect; ...@@ -6,11 +6,17 @@ use Illuminate\Support\Facades\Redirect;
use Illuminate\Support\Facades\View; use Illuminate\Support\Facades\View;
use Laracasts\Flash\Flash; use Laracasts\Flash\Flash;
use Modules\Core\Http\Controllers\Admin\AdminBaseController; use Modules\Core\Http\Controllers\Admin\AdminBaseController;
use Modules\Core\Permissions\PermissionManager;
use Modules\User\Http\Requests\CreateUserRequest; use Modules\User\Http\Requests\CreateUserRequest;
use Modules\User\Http\Requests\UpdateUserRequest; use Modules\User\Http\Requests\UpdateUserRequest;
class UserController extends AdminBaseController class UserController extends AdminBaseController
{ {
/**
* @var PermissionManager
*/
private $permissions;
/** /**
* @var \Modules\Session\Entities\User * @var \Modules\Session\Entities\User
*/ */
...@@ -20,7 +26,7 @@ class UserController extends AdminBaseController ...@@ -20,7 +26,7 @@ class UserController extends AdminBaseController
*/ */
protected $roles; protected $roles;
public function __construct() public function __construct(PermissionManager $permissions)
{ {
parent::__construct(); parent::__construct();
...@@ -28,6 +34,7 @@ class UserController extends AdminBaseController ...@@ -28,6 +34,7 @@ class UserController extends AdminBaseController
$this->users = Sentinel::getUserRepository(); $this->users = Sentinel::getUserRepository();
$this->roles = Sentinel::getRoleRepository()->createModel(); $this->roles = Sentinel::getRoleRepository()->createModel();
$this->permissions = $permissions;
} }
/** /**
...@@ -109,7 +116,8 @@ class UserController extends AdminBaseController ...@@ -109,7 +116,8 @@ class UserController extends AdminBaseController
public function update($id, UpdateUserRequest $request) public function update($id, UpdateUserRequest $request)
{ {
$user = $this->users->createModel()->find($id); $user = $this->users->createModel()->find($id);
$this->users->update($user, $request->all()); $data = array_merge($request->all(), ['permissions' => $this->permissions->clean($request->permissions)]);
$this->users->update($user, $data);
$user->roles()->sync($request->roles); $user->roles()->sync($request->roles);
......
...@@ -47,7 +47,7 @@ ...@@ -47,7 +47,7 @@
</div> </div>
</div> </div>
<div class="tab-pane" id="tab_2-2"> <div class="tab-pane" id="tab_2-2">
@include('user::admin.partials.permissions-create') @include('user::admin.roles.partials.permissions-create')
</div> </div>
<div class="box-footer"> <div class="box-footer">
<button type="submit" class="btn btn-primary btn-flat">Create</button> <button type="submit" class="btn btn-primary btn-flat">Create</button>
......
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
</div> </div>
</div><!-- /.tab-pane --> </div><!-- /.tab-pane -->
<div class="tab-pane" id="tab_2-2"> <div class="tab-pane" id="tab_2-2">
@include('user::admin.partials.permissions') @include('user::admin.roles.partials.permissions')
</div><!-- /.tab-pane --> </div><!-- /.tab-pane -->
<div class="tab-pane" id="tab_3-3"> <div class="tab-pane" id="tab_3-3">
<div class="box-body"> <div class="box-body">
......
...@@ -11,11 +11,21 @@ ...@@ -11,11 +11,21 @@
</ol> </ol>
@stop @stop
@section('styles')
<link href="{{{ core_asset('css/vendor/iCheck/flat/blue.css') }}}" rel="stylesheet" type="text/css" />
@stop
@section('content') @section('content')
{!! Form::open(['route' => ['dashboard.user.update', $user->id], 'method' => 'put']) !!}
<div class="row"> <div class="row">
<div class="col-md-12"> <div class="col-md-12">
<div class="box box-<?php echo $errors->first() ? 'danger' : 'info'; ?>"> <div class="nav-tabs-custom">
{!! Form::open(['route' => ['dashboard.user.update', $user->id], 'method' => 'put']) !!} <ul class="nav nav-tabs">
<li class="active"><a href="#tab_1-1" data-toggle="tab">Data</a></li>
<li class=""><a href="#tab_2-2" data-toggle="tab">Permissions</a></li>
</ul>
<div class="tab-content">
<div class="tab-pane active" id="tab_1-1">
<div class="box-body"> <div class="box-body">
<div class="row"> <div class="row">
@include('flash::message') @include('flash::message')
...@@ -56,12 +66,30 @@ ...@@ -56,12 +66,30 @@
</div> </div>
</div> </div>
</div> </div>
</div>
<div class="tab-pane" id="tab_2-2">
<div class="box-body">
@include('user::admin.users.partials.permissions')
</div>
</div>
<div class="box-footer"> <div class="box-footer">
<button type="submit" class="btn btn-primary btn-flat">Update</button> <button type="submit" class="btn btn-primary btn-flat">Update</button>
<a class="btn btn-danger pull-right btn-flat" href="{{ URL::route('dashboard.user.index')}}"><i class="fa fa-times"></i> Cancel</a> <a class="btn btn-danger pull-right btn-flat" href="{{ URL::route('dashboard.user.index')}}"><i class="fa fa-times"></i> Cancel</a>
</div> </div>
{!! Form::close() !!} </div>
</div> </div>
</div> </div>
</div> </div>
{!! Form::close() !!}
@stop
@section('scripts')
<script>
$( document ).ready(function() {
$('input[type="checkbox"].flat-blue, input[type="radio"].flat-blue').iCheck({
checkboxClass: 'icheckbox_flat-blue',
radioClass: 'iradio_flat-blue'
});
});
</script>
@stop @stop
\ No newline at end of file
<div class="box-body">
<div class="row">
<div class="col-md-12">
<?php foreach($permissions as $name => $value): ?>
<h3>{{ $name }} Module</h3>
<?php foreach($value as $subPermissionTitle => $permissionName): ?>
<h4>{{ ucfirst($subPermissionTitle) }}</h4>
<?php foreach($permissionName as $permissionAction): ?>
<div class="checkbox">
<label for="<?php echo "$subPermissionTitle.$permissionAction" ?>">
<input id="<?php echo "$subPermissionTitle.$permissionAction" ?>" name="permissions[<?php echo "$subPermissionTitle.$permissionAction" ?>]" type="checkbox" class="flat-blue" value="true" /> {{ ucfirst($permissionAction) }}
</label>
</div>
<?php endforeach; ?>
<?php endforeach; ?>
<?php endforeach; ?>
</div>
</div>
</div>
\ No newline at end of file
<div class="box-body">
<div class="row">
<div class="col-md-12">
<?php foreach($permissions as $name => $value): ?>
<h3>{{ $name }} Module</h3>
<?php foreach($value as $subPermissionTitle => $permissionName): ?>
<h4>{{ ucfirst($subPermissionTitle) }}</h4>
<?php foreach($permissionName as $permissionAction): ?>
<div class="checkbox">
<label for="<?php echo "$subPermissionTitle.$permissionAction" ?>">
<input id="<?php echo "$subPermissionTitle.$permissionAction" ?>" name="permissions[<?php echo "$subPermissionTitle.$permissionAction" ?>]" type="checkbox" class="flat-blue" <?php echo $user->hasAccess("$subPermissionTitle.$permissionAction") ? 'checked' : '' ?> value="true" /> {{ ucfirst($permissionAction) }}
</label>
</div>
<?php endforeach; ?>
<?php endforeach; ?>
<?php endforeach; ?>
</div>
</div>
</div>
\ No newline at end of file
<?php <?php
View::composer('core::partials.sidebar-nav', 'Modules\User\Composers\SidebarViewComposer'); View::composer('core::partials.sidebar-nav', 'Modules\User\Composers\SidebarViewComposer');
View::composer(['user::admin.partials.permissions', 'user::admin.partials.permissions-create'], 'Modules\User\Composers\PermissionsViewComposer'); View::composer([
\ No newline at end of file 'user::admin.roles.partials.permissions',
'user::admin.roles.partials.permissions-create',
'user::admin.users.partials.permissions',
'user::admin.users.partials.permissions-create',
], 'Modules\User\Composers\PermissionsViewComposer');
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment