Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Platform
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Platform
Commits
a387c6be
Commit
a387c6be
authored
Sep 26, 2014
by
Nicolas Widart
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
reorginising the create role view. Adding permissions to new role
parent
fa719211
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
114 additions
and
48 deletions
+114
-48
PermissionsViewComposer.php
Composers/PermissionsViewComposer.php
+22
-0
RolesController.php
Http/Controllers/Admin/RolesController.php
+2
-4
permissions-create.blade.php
Resources/views/admin/partials/permissions-create.blade.php
+19
-0
permissions.blade.php
Resources/views/admin/partials/permissions.blade.php
+19
-0
create.blade.php
Resources/views/admin/roles/create.blade.php
+49
-23
edit.blade.php
Resources/views/admin/roles/edit.blade.php
+1
-20
composers.php
composers.php
+2
-1
No files found.
Composers/PermissionsViewComposer.php
0 → 100644
View file @
a387c6be
<?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
Http/Controllers/Admin/RolesController.php
View file @
a387c6be
...
...
@@ -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'
));
}
...
...
Resources/views/admin/partials/permissions-create.blade.php
0 → 100644
View file @
a387c6be
<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
Resources/views/admin/partials/permissions.blade.php
0 → 100644
View file @
a387c6be
<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
Resources/views/admin/roles/create.blade.php
View file @
a387c6be
...
...
@@ -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
Resources/views/admin/roles/edit.blade.php
View file @
a387c6be
...
...
@@ -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() !!}
...
...
composers.php
View file @
a387c6be
<?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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment