update patch 1
This commit is contained in:
@@ -0,0 +1,115 @@
|
||||
@extends('layouts.app')
|
||||
|
||||
@section('title')
|
||||
{{ $pageInfo['title'] }}
|
||||
@endsection
|
||||
|
||||
@section('styles')
|
||||
<style>
|
||||
.form-check-label {
|
||||
text-transform: capitalize;
|
||||
}
|
||||
</style>
|
||||
@endsection
|
||||
|
||||
|
||||
@section('admin-content')
|
||||
<section class="content-header">
|
||||
<div class="container-fluid">
|
||||
<div class="row mb-2">
|
||||
<div class="col-sm-6">
|
||||
<h1>{{ $pageInfo['title'] }}</h1>
|
||||
</div>
|
||||
<div class="col-sm-6">
|
||||
<ol class="breadcrumb float-sm-right">
|
||||
<li class="breadcrumb-item"><a href="{{ route('admin.dashboard') }}">{{ __('Dashboard') }}</a></li>
|
||||
<li class="breadcrumb-item active"><a href="{{ $pageInfo['path'] }}">{{ $pageInfo['title'] }}</a>
|
||||
</li>
|
||||
</ol>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="content">
|
||||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
<div class="col-12 mt-5">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<form action="{{ route('admin.roles.store') }}" method="POST">
|
||||
@csrf
|
||||
<div class="row mb-2">
|
||||
<div class="col-md-6">
|
||||
<h4 class="header-title">Create New Role</h4>
|
||||
</div>
|
||||
<div class="col-md-6 text-right">
|
||||
<button type="submit" class="btn btn-primary pr-4 pl-4">Save</button>
|
||||
</div>
|
||||
</div>
|
||||
@include('backend.layouts.partials.messages')
|
||||
<div class="form-group">
|
||||
<label for="name">Role Name</label>
|
||||
<input type="text" class="form-control" id="name" name="name"
|
||||
placeholder="Enter a Role Name" required autofocus value="{{ old('name') }}">
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="name">Permissions</label>
|
||||
|
||||
<div class="form-check">
|
||||
<input type="checkbox" class="form-check-input" id="checkPermissionAll"
|
||||
value="1">
|
||||
<label class="form-check-label" for="checkPermissionAll">All</label>
|
||||
</div>
|
||||
<hr>
|
||||
@php $i = 1; @endphp
|
||||
@foreach ($permission_groups as $group)
|
||||
<div class="row">
|
||||
<div class="col-3">
|
||||
<div class="form-check">
|
||||
<input type="checkbox" class="form-check-input"
|
||||
id="{{ $i }}Management" value="{{ $group->name }}"
|
||||
onclick="checkPermissionByGroup('role-{{ $i }}-management-checkbox', this)">
|
||||
<label class="form-check-label"
|
||||
for="checkPermission">{{ $group->name }}</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-9 role-{{ $i }}-management-checkbox">
|
||||
@php
|
||||
$permissions = App\User::getpermissionsByGroupName($group->name);
|
||||
$j = 1;
|
||||
@endphp
|
||||
@foreach ($permissions as $permission)
|
||||
<div class="form-check">
|
||||
<input type="checkbox" class="form-check-input" name="permissions[]"
|
||||
id="checkPermission{{ $permission->id }}"
|
||||
value="{{ $permission->name }}">
|
||||
<label class="form-check-label"
|
||||
for="checkPermission{{ $permission->id }}">{{ $permission->name }}</label>
|
||||
</div>
|
||||
@php $j++; @endphp
|
||||
@endforeach
|
||||
<br>
|
||||
</div>
|
||||
</div>
|
||||
@php $i++; @endphp
|
||||
@endforeach
|
||||
</div>
|
||||
|
||||
<button type="submit" class="btn btn-primary mt-4 pr-4 pl-4">Save</button>
|
||||
<a href="{{ route('admin.roles.index') }}" class="btn btn-secondary mt-4 pr-4 pl-4">
|
||||
Back</a>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
@endsection
|
||||
|
||||
@section('scripts')
|
||||
@include('backend.pages.roles.partials.scripts')
|
||||
@endsection
|
||||
@@ -0,0 +1,125 @@
|
||||
@extends('layouts.app')
|
||||
|
||||
@section('title')
|
||||
{{ $pageInfo['title'] }}
|
||||
@endsection
|
||||
|
||||
@section('styles')
|
||||
<style>
|
||||
.form-check-label {
|
||||
text-transform: capitalize;
|
||||
}
|
||||
</style>
|
||||
@endsection
|
||||
|
||||
|
||||
@section('admin-content')
|
||||
<section class="content-header">
|
||||
<div class="container-fluid">
|
||||
<div class="row mb-2">
|
||||
<div class="col-sm-6">
|
||||
<h1>{{ $pageInfo['title'] }}</h1>
|
||||
</div>
|
||||
<div class="col-sm-6">
|
||||
<ol class="breadcrumb float-sm-right">
|
||||
<li class="breadcrumb-item"><a href="{{ route('admin.dashboard') }}">{{ __('Dashboard') }}</a></li>
|
||||
<li class="breadcrumb-item active"><a href="{{ $pageInfo['path'] }}">{{ $pageInfo['title'] }}</a>
|
||||
</li>
|
||||
</ol>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
|
||||
<section class="content">
|
||||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
<div class="col-12 mt-5">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<form action="{{ route('admin.roles.update', $role->id) }}" method="POST">
|
||||
@method('PUT')
|
||||
@csrf
|
||||
<div class="row mb-2">
|
||||
<div class="col-md-6">
|
||||
<h4 class="header-title">Role Edit - {{ $role->name }}</h4>
|
||||
</div>
|
||||
<div class="col-md-6 text-right">
|
||||
<button type="submit" class="btn btn-primary pr-4 pl-4">Save</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@include('backend.layouts.partials.messages')
|
||||
<div class="form-group">
|
||||
<label for="name">Role Name</label>
|
||||
<input type="text" class="form-control" id="name" value="{{ $role->name }}"
|
||||
name="name" placeholder="Enter a Role Name" required autofocus>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="name">Permissions</label>
|
||||
|
||||
<div class="form-check">
|
||||
<input type="checkbox" class="form-check-input" id="checkPermissionAll"
|
||||
value="1"
|
||||
{{ App\User::roleHasPermissions($role, $all_permissions) ? 'checked' : '' }}>
|
||||
<label class="form-check-label" for="checkPermissionAll">All</label>
|
||||
</div>
|
||||
<hr>
|
||||
@php $i = 1; @endphp
|
||||
@foreach ($permission_groups as $group)
|
||||
<div class="row">
|
||||
@php
|
||||
$permissions = App\User::getpermissionsByGroupName($group->name);
|
||||
$j = 1;
|
||||
@endphp
|
||||
|
||||
<div class="col-3">
|
||||
<div class="form-check">
|
||||
<input type="checkbox" class="form-check-input"
|
||||
id="{{ $i }}Management" value="{{ $group->name }}"
|
||||
onclick="checkPermissionByGroup('role-{{ $i }}-management-checkbox', this)"
|
||||
{{ App\User::roleHasPermissions($role, $permissions) ? 'checked' : '' }}>
|
||||
<label class="form-check-label"
|
||||
for="checkPermission">{{ $group->name }}</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-9 role-{{ $i }}-management-checkbox">
|
||||
@foreach ($permissions as $permission)
|
||||
<div class="form-check">
|
||||
<input type="checkbox" class="form-check-input"
|
||||
onclick="checkSinglePermission('role-{{ $i }}-management-checkbox', '{{ $i }}Management', {{ count($permissions) }})"
|
||||
name="permissions[]"
|
||||
{{ $role->hasPermissionTo($permission->name) ? 'checked' : '' }}
|
||||
id="checkPermission{{ $permission->id }}"
|
||||
value="{{ $permission->name }}">
|
||||
<label class="form-check-label"
|
||||
for="checkPermission{{ $permission->id }}">{{ $permission->name }}</label>
|
||||
</div>
|
||||
@php $j++; @endphp
|
||||
@endforeach
|
||||
<br>
|
||||
</div>
|
||||
</div>
|
||||
@php $i++; @endphp
|
||||
@endforeach
|
||||
</div>
|
||||
|
||||
<button type="submit" class="btn btn-primary mt-4 pr-4 pl-4">Save</button>
|
||||
<a href="{{ route('admin.roles.index') }}"
|
||||
class="btn btn-secondary mt-4 pr-4 pl-4">Cancel</a>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
@endsection
|
||||
|
||||
|
||||
@section('scripts')
|
||||
@include('backend.pages.roles.partials.scripts')
|
||||
@endsection
|
||||
@@ -0,0 +1,97 @@
|
||||
@extends('layouts.app')
|
||||
|
||||
@section('title')
|
||||
{{ $pageInfo['title'] }}
|
||||
@endsection
|
||||
|
||||
|
||||
@section('admin-content')
|
||||
<section class="content-header">
|
||||
<div class="container-fluid">
|
||||
<div class="row mb-2">
|
||||
<div class="col-sm-6">
|
||||
<h1>{{ $pageInfo['title'] }}</h1>
|
||||
</div>
|
||||
<div class="col-sm-6">
|
||||
<ol class="breadcrumb float-sm-right">
|
||||
<li class="breadcrumb-item"><a href="{{ route('admin.dashboard') }}">{{ __('Dashboard') }}</a></li>
|
||||
<li class="breadcrumb-item active"><a href="{{ $pageInfo['path'] }}">{{ $pageInfo['title'] }}</a>
|
||||
</li>
|
||||
</ol>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="content">
|
||||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
<div class="col-12 mt-5">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<h4 class="header-title float-left">{{ $pageInfo['sub_title'] }}</h4>
|
||||
<p class="float-right mb-2">
|
||||
@if (Auth::user()->can('role.create'))
|
||||
<a class="btn btn-primary text-white" href="{{ route('admin.roles.create') }}">Create
|
||||
New Role</a>
|
||||
@endif
|
||||
</p>
|
||||
<div class="clearfix"></div>
|
||||
<div class="dataTables_wrapper dt-bootstrap4">
|
||||
@include('backend.layouts.partials.messages')
|
||||
<table id="dataTable"
|
||||
class="table table-bordered table-striped table-head-fixed dataTable dtr-inline"
|
||||
style="width:100%">
|
||||
<thead class="bg-light text-capitalize">
|
||||
<tr>
|
||||
<th width="5%">{{ __('Sl') }}</th>
|
||||
<th width="10%">{{ __('Role Name') }}</th>
|
||||
<th width="30%">{{ __('Permission List') }}</th>
|
||||
<th width="10%">{{ __('Action') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach ($roles as $role)
|
||||
<tr>
|
||||
<td>{{ $loop->index + 1 }}</td>
|
||||
<td>{{ $role->name }}</td>
|
||||
<td>
|
||||
@foreach ($role->permissions as $permission)
|
||||
<span class="badge badge-info mr-1">
|
||||
{{ $permission->name }}
|
||||
</span>
|
||||
@endforeach
|
||||
</td>
|
||||
<td>
|
||||
@if (auth::user()->can('admin.edit'))
|
||||
<a class="btn btn-success btn-sm text-white"
|
||||
href="{{ route('admin.roles.edit', $role->id) }}">Edit</a>
|
||||
@endif
|
||||
<a class="btn btn-primary btn-sm text-white"
|
||||
href="{{ route('auth.menurole.index', $role->id) }}">Assign
|
||||
Menus</a>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</section>
|
||||
@endsection
|
||||
|
||||
@section('scripts')
|
||||
<script>
|
||||
if ($('#dataTable').length) {
|
||||
$('#dataTable').DataTable({
|
||||
responsive: false
|
||||
});
|
||||
}
|
||||
</script>
|
||||
@endsection
|
||||
@@ -0,0 +1,55 @@
|
||||
<script>
|
||||
/**
|
||||
* Check all the permissions
|
||||
*/
|
||||
$("#checkPermissionAll").click(function(){
|
||||
if($(this).is(':checked')){
|
||||
// check all the checkbox
|
||||
$('input[type=checkbox]').prop('checked', true);
|
||||
}else{
|
||||
// un check all the checkbox
|
||||
$('input[type=checkbox]').prop('checked', false);
|
||||
}
|
||||
});
|
||||
|
||||
function checkPermissionByGroup(className, checkThis){
|
||||
const groupIdName = $("#"+checkThis.id);
|
||||
const classCheckBox = $('.'+className+' input');
|
||||
|
||||
if(groupIdName.is(':checked')){
|
||||
classCheckBox.prop('checked', true);
|
||||
}else{
|
||||
classCheckBox.prop('checked', false);
|
||||
}
|
||||
implementAllChecked();
|
||||
}
|
||||
|
||||
function checkSinglePermission(groupClassName, groupID, countTotalPermission) {
|
||||
const classCheckbox = $('.'+groupClassName+ ' input');
|
||||
const groupIDCheckBox = $("#"+groupID);
|
||||
|
||||
// if there is any occurance where something is not selected then make selected = false
|
||||
if($('.'+groupClassName+ ' input:checked').length == countTotalPermission){
|
||||
groupIDCheckBox.prop('checked', true);
|
||||
}else{
|
||||
groupIDCheckBox.prop('checked', false);
|
||||
}
|
||||
implementAllChecked();
|
||||
}
|
||||
|
||||
function implementAllChecked() {
|
||||
const countPermissions = {{ count($all_permissions) }};
|
||||
const countPermissionGroups = {{ count($permission_groups) }};
|
||||
|
||||
// console.log((countPermissions + countPermissionGroups));
|
||||
// console.log($('input[type="checkbox"]:checked').length);
|
||||
|
||||
if($('input[type="checkbox"]:checked').length >= (countPermissions + countPermissionGroups)){
|
||||
$("#checkPermissionAll").prop('checked', true);
|
||||
}else{
|
||||
$("#checkPermissionAll").prop('checked', false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
Reference in New Issue
Block a user