Commit a387c6be authored by Nicolas Widart's avatar Nicolas Widart

reorginising the create role view. Adding permissions to new role

parent fa719211
<?php namespace Modules\User\Composers;
use Modules\Core\Permissions\PermissionManager;
class PermissionsViewComposer
{
/**
* @var PermissionManager
*/
private $permissions;
public function __construct(PermissionManager $permissions)
{
$this->permissions = $permissions;
}
public function compose($view)
{
// Get all permissions
$view->permissions = $this->permissions->all();
}
}
\ No newline at end of file
......@@ -58,7 +58,8 @@ class RolesController extends AdminBaseController
*/
public function store(CreateRolesRequest $request)
{
$this->roles->create($request->all());
$data = array_merge($request->all(), ['permissions' => $this->permissions->clean($request->permissions)]);
$this->roles->create($data);
Flash::success('Role created');
......@@ -87,9 +88,6 @@ class RolesController extends AdminBaseController
return Redirect::to('user::admin.roles.index');
}
// Get all permissions
$permissions = $this->permissions->all();
return View::make('user::admin.roles.edit', compact('role', 'permissions'));
}
......
<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 $role->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
......@@ -11,38 +11,64 @@
</ol>
@stop
@section('styles')
<link href="{{{ core_asset('css/vendor/iCheck/flat/blue.css') }}}" rel="stylesheet" type="text/css" />
@stop
@section('content')
<div class="row">
<div class="col-md-12">
<div class="box box-<?php echo $errors->first() ? 'danger' : 'info'; ?>">
{!! Form::open(['route' => 'dashboard.role.store', 'method' => 'post']) !!}
<div class="box-body">
<div class="row">
@include('flash::message')
</div>
<div class="row">
<div class="col-sm-6">
<div class="form-group{{ $errors->has('name') ? ' has-error' : '' }}">
{!! Form::label('name', 'Role name:') !!}
{!! Form::text('name', Input::old('name'), ['class' => 'form-control', 'placeholder' => 'First name']) !!}
{!! $errors->first('name', '<span class="help-block">:message</span>') !!}
{!! Form::open(['route' => 'dashboard.role.store', 'method' => 'post']) !!}
<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-6">
<div class="form-group{{ $errors->has('slug') ? ' has-error' : '' }}">
{!! Form::label('slug', 'Role slug:') !!}
{!! Form::text('slug', Input::old('slug'), ['class' => 'form-control', 'placeholder' => 'Last name']) !!}
{!! $errors->first('slug', '<span class="help-block">:message</span>') !!}
<div class="row">
<div class="col-sm-6">
<div class="form-group{{ $errors->has('name') ? ' has-error' : '' }}">
{!! Form::label('name', 'Role name:') !!}
{!! Form::text('name', Input::old('name'), ['class' => 'form-control', 'placeholder' => 'First name']) !!}
{!! $errors->first('name', '<span class="help-block">:message</span>') !!}
</div>
</div>
<div class="col-sm-6">
<div class="form-group{{ $errors->has('slug') ? ' has-error' : '' }}">
{!! Form::label('slug', 'Role slug:') !!}
{!! Form::text('slug', Input::old('slug'), ['class' => 'form-control', 'placeholder' => 'Last name']) !!}
{!! $errors->first('slug', '<span class="help-block">:message</span>') !!}
</div>
</div>
</div>
</div>
</div>
<div class="tab-pane" id="tab_2-2">
@include('user::admin.partials.permissions-create')
</div>
<div class="box-footer">
<button type="submit" class="btn btn-primary btn-flat">Create</button>
<a class="btn btn-danger pull-right btn-flat" href="{{ URL::route('dashboard.role.index')}}"><i class="fa fa-times"></i> Cancel</a>
</div>
</div>
<div class="box-footer">
<button type="submit" class="btn btn-primary btn-flat">Create</button>
<a class="btn btn-danger pull-right btn-flat" href="{{ URL::route('dashboard.role.index')}}"><i class="fa fa-times"></i> Cancel</a>
</div>
{!! Form::close() !!}
</div>
{!! Form::close() !!}
</div>
</div>
@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
......@@ -50,25 +50,7 @@
</div>
</div><!-- /.tab-pane -->
<div class="tab-pane" id="tab_2-2">
<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 $role->hasAccess("$subPermissionTitle.$permissionAction") ? 'checked' : '' ?> value="true" /> {{ ucfirst($permissionAction) }}
</label>
</div>
<?php endforeach; ?>
<?php endforeach; ?>
<?php endforeach; ?>
</div>
</div>
</div>
@include('user::admin.partials.permissions')
</div><!-- /.tab-pane -->
<div class="tab-pane" id="tab_3-3">
<div class="box-body">
......@@ -89,7 +71,6 @@
<button type="submit" class="btn btn-primary btn-flat">Update</button>
<a class="btn btn-danger pull-right btn-flat" href="{{ URL::route('dashboard.role.index')}}"><i class="fa fa-times"></i> Cancel</a>
<div class="clearfix"></div>
</div><!-- /.tab-content -->
</div>
{!! Form::close() !!}
......
<?php
View::composer('core::partials.sidebar-nav', 'Modules\User\Composers\SidebarViewComposer');
\ No newline at end of file
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
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