mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-24 21:24:13 -08:00
Nicer groups permission edit UI
This commit is contained in:
parent
f5b3df697c
commit
808cd0f728
|
@ -17,14 +17,7 @@ return array(
|
|||
'label' => '',
|
||||
'note' => 'Determines whether the user has access to most aspects of the admin. ',
|
||||
'display' => true,
|
||||
),
|
||||
|
||||
array(
|
||||
'permission' => 'admin.api_key',
|
||||
'label' => 'Create API Key',
|
||||
'note' => 'Determines whether the user can access the API via API key.',
|
||||
'display' => false,
|
||||
),
|
||||
)
|
||||
),
|
||||
|
||||
'Reports' => array(
|
||||
|
|
|
@ -6,60 +6,178 @@
|
|||
|
||||
])
|
||||
@section('content')
|
||||
<style>
|
||||
label.radio-padding {
|
||||
margin-right: 25px;
|
||||
}
|
||||
</style>
|
||||
|
||||
<style>
|
||||
.form-horizontal .control-label {
|
||||
padding-top: 0px;
|
||||
}
|
||||
|
||||
input[type='text'][disabled], input[disabled], textarea[disabled], input[readonly], textarea[readonly], .form-control[disabled], .form-control[readonly], fieldset[disabled] .form-control {
|
||||
background-color: white;
|
||||
color: #555555;
|
||||
cursor:text;
|
||||
}
|
||||
table.permissions {
|
||||
display:flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.permissions.table > thead, .permissions.table > tbody {
|
||||
margin: 15px;
|
||||
margin-top: 0px;
|
||||
}
|
||||
.permissions.table > tbody+tbody {
|
||||
|
||||
}
|
||||
.header-row {
|
||||
border-bottom: 1px solid #ccc;
|
||||
}
|
||||
|
||||
.header-row h3 {
|
||||
margin:0px;
|
||||
}
|
||||
.permissions-row {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: flex-start;
|
||||
}
|
||||
.table > tbody > tr > td.permissions-item {
|
||||
padding: 1px;
|
||||
padding-left: 8px;
|
||||
}
|
||||
|
||||
.header-name {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
@parent
|
||||
@stop
|
||||
|
||||
@section('inputFields')
|
||||
<!-- Name -->
|
||||
<div class="form-group {{ $errors->has('name') ? ' has-error' : '' }}">
|
||||
<label for="name" class="col-md-3 control-label">{{ trans('admin/groups/titles.group_name') }}
|
||||
<i class='fa fa-asterisk'></i>
|
||||
</label>
|
||||
<label for="name" class="col-md-3 control-label">{{ trans('admin/groups/titles.group_name') }}</label>
|
||||
<div class="col-md-6 required">
|
||||
<input class="form-control" type="text" name="name" id="name" value="{{ Input::old('name', $group->name) }}" />
|
||||
{!! $errors->first('name', '<span class="alert-msg"><i class="fa fa-times"></i> :message</span>') !!}
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-12">
|
||||
|
||||
<table class="table table-striped permissions">
|
||||
<thead>
|
||||
<tr class="permissions-row">
|
||||
<th class="col-md-5">Permission</th>
|
||||
<th class="col-md-1">Grant</th>
|
||||
<th class="col-md-1">Deny</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="permissions-group">
|
||||
@foreach ($permissions as $area => $area_permission)
|
||||
<!-- handle superadmin and reports, and anything else with only one option -->
|
||||
<?php $localPermission = $area_permission[0]; ?>
|
||||
@if (count($area_permission) == 1)
|
||||
|
||||
@foreach ($permissions as $area => $permission)
|
||||
@for ($i = 0; $i < count($permission); $i++)
|
||||
<tr class="header-row permissions-row">
|
||||
<td class="col-md-5 tooltip-base permissions-item"
|
||||
data-toggle="tooltip"
|
||||
data-placement="right"
|
||||
title="{{ $localPermission['note'] }}">
|
||||
<h4>{{ $area . ': ' . $localPermission['label'] }}</h4>
|
||||
</td>
|
||||
<td class="col-md-1 permissions-item">
|
||||
{{ Form::radio('permission['.$localPermission['permission'].']', '1',$groupPermissions[$localPermission['permission'] ] == '1',['value'=>"grant", 'class'=>'minimal']) }}
|
||||
</td>
|
||||
<td class="col-md-1 permissions-item">
|
||||
{{ Form::radio('permission['.$localPermission['permission'].']', '0',$groupPermissions[$localPermission['permission'] ] == '0',['value'=>"grant", 'class'=>'minimal']) }}
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@else
|
||||
|
||||
<?php
|
||||
$permission_name = $permission[$i]['permission'];
|
||||
?>
|
||||
@if ($permission[$i]['display'])
|
||||
<div class="col-md-9 col-md-offset-2">
|
||||
<h3>{{ $area }}: {{ $permission[$i]['label'] }}</h3>
|
||||
<p>{{ $permission[$i]['note'] }}</p>
|
||||
<tr class="header-row permissions-row">
|
||||
<td class="col-md-5 tooltip-base permissions-item header-name"
|
||||
data-toggle="tooltip"
|
||||
data-placement="right"
|
||||
title="{{ $localPermission['note'] }}">
|
||||
<h4>{{ $area . ': ' . $localPermission['label'] }}</h4>
|
||||
<p>{{ $localPermission['note'] }}</p>
|
||||
|
||||
<!-- radio -->
|
||||
<div class="form-group" style="padding-left: 15px;">
|
||||
<label class="radio-padding col-md-3">
|
||||
{{ Form::radio('permission['.$permission_name.']', 1,
|
||||
(is_array($groupPermissions))
|
||||
&& (array_key_exists($permission_name, $groupPermissions)
|
||||
&& $groupPermissions[$permission_name]), ['class' => 'minimal']) }}
|
||||
Grant
|
||||
</label>
|
||||
<label class="radio-padding col-md-3">
|
||||
{{ Form::radio('permission['.$permission_name.']', 0, ((is_array($groupPermissions) && !array_key_exists($permission_name, $groupPermissions)) || !$groupPermissions[$permission_name]), ['class' => 'minimal']) }}
|
||||
Deny
|
||||
</label>
|
||||
</td>
|
||||
<td class="col-md-1 permissions-item" style="vertical-align: bottom">
|
||||
{{ Form::radio("$area", '1',false,['value'=>"grant", 'class'=>'minimal', 'data-checker-group' => str_slug($area)]) }}
|
||||
</td>
|
||||
<td class="col-md-1 permissions-item">
|
||||
{{ Form::radio("$area", '0',false,['value'=>"deny", 'class'=>'minimal', 'data-checker-group' => str_slug($area)]) }}
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</div>
|
||||
<hr>
|
||||
</div>
|
||||
@foreach ($area_permission as $index => $this_permission)
|
||||
@if ($this_permission['display'])
|
||||
<tr class="permissions-row">
|
||||
<td
|
||||
class="col-md-5 tooltip-base permissions-item"
|
||||
data-toggle="tooltip"
|
||||
data-placement="right"
|
||||
title="{{ $this_permission['note'] }}">
|
||||
{{ $this_permission['label'] }}
|
||||
</td>
|
||||
<td class="col-md-1 permissions-item">
|
||||
{{ Form::radio('permission['.$this_permission['permission'].']', '1',$groupPermissions[$this_permission['permission'] ] == '1',['class'=>'minimal radiochecker-'.str_slug($area)]) }}
|
||||
</td>
|
||||
<td class="col-md-1 permissions-item">
|
||||
{{ Form::radio('permission['.$this_permission['permission'].']', '0',$groupPermissions[$this_permission['permission'] ] == '0',['class'=>'minimal radiochecker-'.str_slug($area)]) }}
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
|
||||
@endif
|
||||
@endforeach
|
||||
<tr>
|
||||
<td colspan="3"></td>
|
||||
</tr>
|
||||
@endif
|
||||
@endfor
|
||||
@endforeach
|
||||
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
@stop
|
||||
@section('moar_scripts')
|
||||
|
||||
<script nonce="{{ csrf_token() }}">
|
||||
|
||||
$(document).ready(function(){
|
||||
|
||||
$('.tooltip-base').tooltip({container: 'body'});
|
||||
$(".superuser").change(function() {
|
||||
var perms = $(this).val();
|
||||
if (perms =='1') {
|
||||
$("#nonadmin").hide();
|
||||
} else {
|
||||
$("#nonadmin").show();
|
||||
}
|
||||
});
|
||||
|
||||
// Check/Uncheck all radio buttons in the group
|
||||
$('tr.header-row input:radio').on('ifClicked', function () {
|
||||
value = $(this).attr('value');
|
||||
area = $(this).data('checker-group');
|
||||
console.log('Area selected is ' + area);
|
||||
$('.radiochecker-'+area+'[value='+value+']').iCheck('check');
|
||||
});
|
||||
|
||||
|
||||
$('.header-name').click(function() {
|
||||
$(this).parent().nextUntil('tr.header-row').slideToggle(500);
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
</script>
|
||||
@stop
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
@stop
|
||||
|
||||
@section('header_right')
|
||||
<a href="{{ route('groups.create') }}" class="btn btn-primary pull-right" style="margin-left: 10px;"> {{ trans('general.create') }}</a>
|
||||
<a href="{{ route('settings.index') }}" class="btn btn-default pull-right">{{ trans('general.back') }}</a>
|
||||
<a href="{{ route('groups.create') }}" class="btn btn-primary text-right"> {{ trans('general.create') }}</a>
|
||||
<a href="{{ route('settings.index') }}" class="btn btn-default text-right">{{ trans('general.back') }}</a>
|
||||
@stop
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue