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
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;
use Illuminate\Support\Facades\View;
use Laracasts\Flash\Flash;
use Modules\Core\Http\Controllers\Admin\AdminBaseController;
use Modules\Core\Permissions\PermissionManager;
use Modules\User\Http\Requests\CreateUserRequest;
use Modules\User\Http\Requests\UpdateUserRequest;
class UserController extends AdminBaseController
{
/**
* @var PermissionManager
*/
private $permissions;
/**
* @var \Modules\Session\Entities\User
*/
......@@ -20,7 +26,7 @@ class UserController extends AdminBaseController
*/
protected $roles;
public function __construct()
public function __construct(PermissionManager $permissions)
{
parent::__construct();
......@@ -28,6 +34,7 @@ class UserController extends AdminBaseController
$this->users = Sentinel::getUserRepository();
$this->roles = Sentinel::getRoleRepository()->createModel();
$this->permissions = $permissions;
}
/**
......@@ -109,7 +116,8 @@ class UserController extends AdminBaseController
public function update($id, UpdateUserRequest $request)
{
$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);
......
......@@ -47,7 +47,7 @@
</div>
</div>
<div class="tab-pane" id="tab_2-2">
@include('user::admin.partials.permissions-create')
@include('user::admin.roles.partials.permissions-create')
</div>
<div class="box-footer">
<button type="submit" class="btn btn-primary btn-flat">Create</button>
......
......@@ -50,7 +50,7 @@
</div>
</div><!-- /.tab-pane -->
<div class="tab-pane" id="tab_2-2">
@include('user::admin.partials.permissions')
@include('user::admin.roles.partials.permissions')
</div><!-- /.tab-pane -->
<div class="tab-pane" id="tab_3-3">
<div class="box-body">
......
......@@ -11,57 +11,85 @@
</ol>
@stop
@section('styles')
<link href="{{{ core_asset('css/vendor/iCheck/flat/blue.css') }}}" rel="stylesheet" type="text/css" />
@stop
@section('content')
{!! Form::open(['route' => ['dashboard.user.update', $user->id], 'method' => 'put']) !!}
<div class="row">
<div class="col-md-12">
<div class="box box-<?php echo $errors->first() ? 'danger' : 'info'; ?>">
{!! Form::open(['route' => ['dashboard.user.update', $user->id], 'method' => 'put']) !!}
<div class="box-body">
<div class="row">
@include('flash::message')
</div>
<div class="row">
<div class="col-sm-4">
<div class="form-group{{ $errors->has('first_name') ? ' has-error' : '' }}">
{!! Form::label('first_name', 'First name:') !!}
{!! Form::text('first_name', Input::old('first_name', $user->first_name), ['class' => 'form-control', 'placeholder' => 'First name']) !!}
{!! $errors->first('first_name', '<span class="help-block">:message</span>') !!}
<div class="nav-tabs-custom">
<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="row">
@include('flash::message')
</div>
</div>
<div class="col-sm-4">
<div class="form-group{{ $errors->has('last_name') ? ' has-error' : '' }}">
{!! Form::label('last_name', 'Last name:') !!}
{!! Form::text('last_name', Input::old('last_name', $user->last_name), ['class' => 'form-control', 'placeholder' => 'Last name']) !!}
{!! $errors->first('last_name', '<span class="help-block">:message</span>') !!}
<div class="row">
<div class="col-sm-4">
<div class="form-group{{ $errors->has('first_name') ? ' has-error' : '' }}">
{!! Form::label('first_name', 'First name:') !!}
{!! Form::text('first_name', Input::old('first_name', $user->first_name), ['class' => 'form-control', 'placeholder' => 'First name']) !!}
{!! $errors->first('first_name', '<span class="help-block">:message</span>') !!}
</div>
</div>
<div class="col-sm-4">
<div class="form-group{{ $errors->has('last_name') ? ' has-error' : '' }}">
{!! Form::label('last_name', 'Last name:') !!}
{!! Form::text('last_name', Input::old('last_name', $user->last_name), ['class' => 'form-control', 'placeholder' => 'Last name']) !!}
{!! $errors->first('last_name', '<span class="help-block">:message</span>') !!}
</div>
</div>
<div class="col-sm-4">
<div class="form-group{{ $errors->has('email') ? ' has-error' : '' }}">
{!! Form::label('email', 'Email:') !!}
{!! Form::email('email', Input::old('email', $user->email), ['class' => 'form-control', 'placeholder' => 'Email address']) !!}
{!! $errors->first('email', '<span class="help-block">:message</span>') !!}
</div>
</div>
</div>
</div>
<div class="col-sm-4">
<div class="form-group{{ $errors->has('email') ? ' has-error' : '' }}">
{!! Form::label('email', 'Email:') !!}
{!! Form::email('email', Input::old('email', $user->email), ['class' => 'form-control', 'placeholder' => 'Email address']) !!}
{!! $errors->first('email', '<span class="help-block">:message</span>') !!}
<div class="row">
<div class="col-md-6">
<div class="form-group">
<label>Role(s)</label>
<select multiple="" class="form-control" name="roles[]">
<?php foreach($roles as $role): ?>
<option value="{{ $role->id }}" <?php echo $user->roles()->whereId($role->id)->count() >= 1 ? 'selected' : '' ?>>{{ $role->name }}</option>
<?php endforeach; ?>
</select>
</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-6">
<div class="form-group">
<label>Role(s)</label>
<select multiple="" class="form-control" name="roles[]">
<?php foreach($roles as $role): ?>
<option value="{{ $role->id }}" <?php echo $user->roles()->whereId($role->id)->count() >= 1 ? 'selected' : '' ?>>{{ $role->name }}</option>
<?php endforeach; ?>
</select>
</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">
<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>
</div>
</div>
<div class="box-footer">
<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>
</div>
{!! Form::close() !!}
</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
\ 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
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');
\ No newline at end of file
View::composer([
'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