Skip to content

Commit

Permalink
Bootstrap 5 layout fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
sudippalash committed Oct 28, 2024
1 parent b624898 commit dd55ebf
Show file tree
Hide file tree
Showing 11 changed files with 495 additions and 8 deletions.
25 changes: 17 additions & 8 deletions src/Traits/RoleCrud.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,8 @@ public function index(Request $request)

$cssClass = $this->cssGenerate();
$routeName = $this->routeName;
$blade = config('role-creator.bootstrap_v') == 3 ? 'role-creator::bootstrap3' : 'role-creator::bootstrap';

return view($blade . '.index', compact('records', 'routeName', 'cssClass'));
return view($this->getBladeName() . '.index', compact('records', 'routeName', 'cssClass'));
}

public function create()
Expand All @@ -59,9 +58,8 @@ public function create()

$cssClass = $this->cssGenerate();
$routeName = $this->routeName;
$blade = config('role-creator.bootstrap_v') == 3 ? 'role-creator::bootstrap3' : 'role-creator::bootstrap';

return view($blade . '.create', compact('permissioDone', 'permissionArr', 'routeName', 'cssClass'));
return view($this->getBladeName() . '.create', compact('permissioDone', 'permissionArr', 'routeName', 'cssClass'));
}

public function store(Request $request)
Expand Down Expand Up @@ -93,9 +91,8 @@ public function show(Request $request, $id)

$cssClass = $this->cssGenerate();
$routeName = $this->routeName;
$blade = config('role-creator.bootstrap_v') == 3 ? 'role-creator::bootstrap3' : 'role-creator::bootstrap';

return view($blade . '.show', compact('data', 'permissioDone', 'routeName', 'cssClass'));
return view($this->getBladeName() . '.show', compact('data', 'permissioDone', 'routeName', 'cssClass'));
}

public function edit(Request $request, $id)
Expand All @@ -120,9 +117,8 @@ public function edit(Request $request, $id)

$cssClass = $this->cssGenerate();
$routeName = $this->routeName;
$blade = config('role-creator.bootstrap_v') == 3 ? 'role-creator::bootstrap3' : 'role-creator::bootstrap';

return view($blade . '.edit', compact('data', 'permissioDone', 'permissionArr', 'routeName', 'cssClass'));
return view($this->getBladeName() . '.edit', compact('data', 'permissioDone', 'permissionArr', 'routeName', 'cssClass'));
}

public function update(Request $request, $id)
Expand Down Expand Up @@ -166,4 +162,17 @@ private function hideRoleArray()
return [$this->hideRoles];
}
}

private function getBladeName()
{
if (config('role-creator.bootstrap_v') == 3) {
$blade = 'role-creator::bootstrap3';
} elseif (config('role-creator.bootstrap_v') == 4) {
$blade = 'role-creator::bootstrap4';
} else {
$blade = 'role-creator::bootstrap5';
}

return $blade;
}
}
25 changes: 25 additions & 0 deletions src/resources/views/bootstrap4/create.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
@extends(config('role-creator.layout_name'))

@section(config('role-creator.section_name'))
<section class="{{ $cssClass['container'] }}">
<div class="{{ $cssClass['card'] }}">
<div class="card-header">
<div class="d-flex justify-content-between">
<h4 class="m-0">{{ trans('role-creator::sp_role_creator.role_create') }}</h4>
<a class="btn {{ $cssClass['btn'] }}" href="{{ route($routeName . '.index') }}">{{ trans('role-creator::sp_role_creator.back_to_list') }}</a>
</div>
</div>

<div class="card-body">
<form method="POST" action="{{ route($routeName . '.store') }}">
@csrf

@include('role-creator::bootstrap4.form')

<hr>
<button type="submit" id="submit" class="btn {{ $cssClass['btn'] }} float-right">{{ trans('role-creator::sp_role_creator.save') }}</button>
</form>
</div>
</div>
</section>
@endsection
26 changes: 26 additions & 0 deletions src/resources/views/bootstrap4/edit.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
@extends(config('role-creator.layout_name'))

@section(config('role-creator.section_name'))
<section class="{{ $cssClass['container'] }}">
<div class="{{ $cssClass['card'] }}">
<div class="card-header">
<div class="d-flex justify-content-between">
<h4 class="m-0">{{ trans('role-creator::sp_role_creator.role_edit') }}</h4>
<a class="btn {{ $cssClass['btn'] }}" href="{{ route($routeName . '.index') }}">{{ trans('role-creator::sp_role_creator.back_to_list') }}</a>
</div>
</div>

<div class="card-body">
<form method="POST" action="{{ route($routeName . '.update', $data->id) }}">
@csrf
@method('PUT')

@include('role-creator::bootstrap4.form')

<hr>
<button type="submit" id="submit" class="btn {{ $cssClass['btn'] }} float-right">{{ trans('role-creator::sp_role_creator.update') }}</button>
</form>
</div>
</div>
</section>
@endsection
60 changes: 60 additions & 0 deletions src/resources/views/bootstrap4/form.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<div class="form-group">
<label>{{ trans('role-creator::sp_role_creator.name') }} <span class="text-danger">*</span></label>
<input type="text" class="form-control" name="name" value="{{ old('name', isset($data) ? $data->name : '') }}" required>

@if ($errors->has('name'))
<span class="invalid-feedback d-block">{{ $errors->first('name') }}</span>
@endif
</div>

<div class="form-group">
<h6>{{ trans('role-creator::sp_role_creator.assign_role_permission') }}</h6>
<table class="table table-striped mb-0">
<thead>
<tr>
<th>{{ trans('role-creator::sp_role_creator.module') }}</th>
<th>{{ trans('role-creator::sp_role_creator.permissions') }}</th>
</tr>
</thead>
<tbody>
@if (!empty($permissionArr))
@php($i = 1)
@foreach($permissionArr as $module => $moduleArr)
<tr>
<td>
<div class="custom-control custom-switch">
<input type="checkbox" class="custom-control-input" id="module{{ $i }}" onclick="moduleCheck({{ $i }})"{{ (array_key_exists($module, $permissioDone)) ? ' checked' : '' }}>
<label class="custom-control-label" for="module{{ $i }}">{{ $moduleArr[0]->module }}</label>
</div>
</td>
<td>
<div class="row" id="moduleContent{{ $i }}">
@foreach($moduleArr as $md)
<div class="col-sm-2 custom-control custom-checkbox">
<input type="checkbox" class="custom-control-input" id="permission{{ $md->id }}" name="permissions[]" value="{{ $md->name }}"{{ (isset($permissioDone[$module]) && in_array($md->name, $permissioDone[$module])) ? ' checked' : '' }}>
<label class="custom-control-label" for="permission{{ $md->id }}">{{ $md->label }}</label><br>
</div>
@endforeach
</div>
</td>
</tr>
@php($i++)
@endforeach
@else
<tr>
<td colspan="2" class="text-center">{{ trans('role-creator::sp_role_creator.permission_not_found') }}</td>
</tr>
@endif
</tbody>
</table>
</div>

<script>
function moduleCheck(k) {
if (document.getElementById('module'+k).checked == true) {
$('#moduleContent'+k+' input').prop('checked', true);
} else {
$('#moduleContent'+k+' input').prop('checked', false);
}
}
</script>
62 changes: 62 additions & 0 deletions src/resources/views/bootstrap4/index.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
@extends(config('role-creator.layout_name'))

@section(config('role-creator.section_name'))
<section class="{{ $cssClass['container'] }}">
<div class="{{ $cssClass['card'] }}">
<div class="card-header">
<div class="d-flex justify-content-between">
<h4 class="m-0">{{ trans('role-creator::sp_role_creator.role') }}</h4>
<a class="btn {{ $cssClass['btn'] }}" href="{{ route($routeName . '.create') }}">{{ trans('role-creator::sp_role_creator.create') }}</a>
</div>
</div>

<div class="card-body">
<div class="table-responsive">
<table class="table {{ $cssClass['table'] }}">
<thead>
<tr>
<th>{{ trans('role-creator::sp_role_creator.id') }}</th>
<th>{{ trans('role-creator::sp_role_creator.name') }}</th>
<th>{{ trans('role-creator::sp_role_creator.guard') }}</th>
<th>{{ trans('role-creator::sp_role_creator.created_at') }}</th>
<th class="{{ $cssClass['table_action_col_width'] }}"></th>
</tr>
</thead>

<tbody>
@if($records->count() > 0)
@foreach($records as $val)
<tr>
<td>{{ $val->id }}</td>
<td>{{ $val->name }}</td>
<td>{{ $val->guard_name }}</td>
<td>{{ $val->created_at }}</td>
<td>
<div class="btn-group">
<button type="button" class="btn {{ $cssClass['table_action_btn'] }} btn-sm dropdown-toggle" data-toggle="dropdown" data-display="static">{{ trans('role-creator::sp_role_creator.action') }}</button>
<div class="dropdown-menu dropdown-menu-sm dropdown-menu-lg-right">
<a class="dropdown-item" href="{{ route($routeName . '.show', $val->id) }}">{{ trans('role-creator::sp_role_creator.show') }}</a>
<a class="dropdown-item" href="{{ route($routeName . '.edit', $val->id) }}">{{ trans('role-creator::sp_role_creator.edit') }}</a>
<a class="dropdown-item" href="javascript:void(0)" onclick="if (confirm('Are you sure to delete this role?')) { event.preventDefault(); document.getElementById('role-delete-form{{ $val->id }}').submit(); } else { event.stopPropagation(); event.preventDefault(); };">{{ trans('role-creator::sp_role_creator.destroy') }}</a>
</div>
</div>

<form id="role-delete-form{{ $val->id }}" action="{{ route($routeName . '.destroy', $val->id) }}" method="POST" style="display: none;">
@csrf
@method('DELETE')
</form>
</td>
</tr>
@endforeach
@else
<tr>
<td colspan="5" class="text-center">{{ trans('role-creator::sp_role_creator.row_not_found') }}</td>
</tr>
@endif
</tbody>
</table>
</div>
</div>
</div>
</section>
@endsection
63 changes: 63 additions & 0 deletions src/resources/views/bootstrap4/show.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
@extends(config('role-creator.layout_name'))

@section(config('role-creator.section_name'))
<section class="{{ $cssClass['container'] }}">
<div class="{{ $cssClass['card'] }}">
<div class="card-header">
<div class="d-flex justify-content-between">
<h4 class="m-0">{{ trans('role-creator::sp_role_creator.role_show') }}</h4>
<a class="btn {{ $cssClass['btn'] }}" href="{{ route($routeName . '.index') }}">{{ trans('role-creator::sp_role_creator.back_to_list') }}</a>
</div>
</div>

<div class="card-body">
<table class="table browser mt-4 no-border">
<tbody>
<tr>
<td>{{ trans('role-creator::sp_role_creator.name') }}</td>
<td align="right">{{ $data->name }}</td>
</tr>
<tr>
<td>{{ trans('role-creator::sp_role_creator.guard') }}</td>
<td align="right">{{ $data->guard_name }}</td>
</tr>
</tbody>
</table>

<div class="form-group">
<h6>{{ trans('role-creator::sp_role_creator.assign_role_permission') }}</h6>
<table class="table table-striped mb-0">
<thead>
<tr>
<th>{{ trans('role-creator::sp_role_creator.module') }}</th>
<th>{{ trans('role-creator::sp_role_creator.permissions') }}</th>
</tr>
</thead>
<tbody>
@foreach($permissioDone as $module => $moduleArr)
<tr>
<td>
<div class="custom-control custom-switch">
<input type="checkbox" class="custom-control-input" checked disabled>
<label class="custom-control-label">{{ ucfirst($module) }}</label>
</div>
</td>
<td>
<div class="row">
@foreach($moduleArr as $md)
<div class="col-sm-2 custom-control custom-checkbox">
<input class="custom-control-input" type="checkbox" checked disabled>
<label class="custom-control-label">{{ $md }}</label><br>
</div>
@endforeach
</div>
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
</div>
</section>
@endsection
25 changes: 25 additions & 0 deletions src/resources/views/bootstrap5/create.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
@extends(config('role-creator.layout_name'))

@section(config('role-creator.section_name'))
<section class="{{ $cssClass['container'] }}">
<div class="{{ $cssClass['card'] }}">
<div class="card-header">
<div class="d-flex justify-content-between">
<h4 class="m-0">{{ trans('role-creator::sp_role_creator.role_create') }}</h4>
<a class="btn {{ $cssClass['btn'] }}" href="{{ route($routeName . '.index') }}">{{ trans('role-creator::sp_role_creator.back_to_list') }}</a>
</div>
</div>

<div class="card-body">
<form method="POST" action="{{ route($routeName . '.store') }}">
@csrf

@include('role-creator::bootstrap5.form')

<hr>
<button type="submit" id="submit" class="btn {{ $cssClass['btn'] }} float-end">{{ trans('role-creator::sp_role_creator.save') }}</button>
</form>
</div>
</div>
</section>
@endsection
26 changes: 26 additions & 0 deletions src/resources/views/bootstrap5/edit.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
@extends(config('role-creator.layout_name'))

@section(config('role-creator.section_name'))
<section class="{{ $cssClass['container'] }}">
<div class="{{ $cssClass['card'] }}">
<div class="card-header">
<div class="d-flex justify-content-between">
<h4 class="m-0">{{ trans('role-creator::sp_role_creator.role_edit') }}</h4>
<a class="btn {{ $cssClass['btn'] }}" href="{{ route($routeName . '.index') }}">{{ trans('role-creator::sp_role_creator.back_to_list') }}</a>
</div>
</div>

<div class="card-body">
<form method="POST" action="{{ route($routeName . '.update', $data->id) }}">
@csrf
@method('PUT')

@include('role-creator::bootstrap5.form')

<hr>
<button type="submit" id="submit" class="btn {{ $cssClass['btn'] }} float-end">{{ trans('role-creator::sp_role_creator.update') }}</button>
</form>
</div>
</div>
</section>
@endsection
Loading

0 comments on commit dd55ebf

Please sign in to comment.