Ekapp/skolehjem/resources/views/admin/roles/create.blade.php

354 lines
19 KiB
PHP

@extends("admin.layout.base")
@extends("admin.layout.header")
@section("title")
Rolle - Opret
@endsection
@section("path")
<a href="{{ route('roles.create') }}" class="text-white">Opret Rolle</a> /
@endsection
@section("content")
<style>
td > p, td > input {
margin: 0;
}
small {
font-size: 16px;
}
.form-text {
display: block;
}
.text-muted {
color: #6c757d !important;
}
</style>
<h1 id="errormesseages" >Opret Rolle:</h1>
<form method="post" action="{{ route("roles.store") }}">
@csrf
<label for="name">Navn:</label>
<label hidden id="error" for="errormesseages">Rolle navnet findes allerede</label>
<input type="text" name="name" id="name" placeholder="Admin" required>
<label for="name">Beskrivelse:</label>
<input type="text" name="description" id="description" placeholder="Admin rollen bruges til administratorene" required>
<div class="mb-2" style="width: 100%;">
<button id="kontoButton" type="button" class="btn btn-sde-blue mb-1 mr-1" value="konto">Konto rettigheder</button>
<button id="adminButton" type="button" class="btn btn-sde-blue mb-1">Admin rettigheder</button>
</div>
<div id="konto">
<small class="form-text text-muted">Her kan alle basale rettigheder for appens forbrugere slås til eller fra.</small>
<table class="tbl mb-2">
<tr>
<th>Konto</th>
<th>Beskrivelse</th>
<th>Create</th>
<th>Read</th>
<th>Delete</th>
</tr>
<tr>
<td>Konto</td>
<td><p>Egen bruger</p></td>
<td></td>
<td><input type="checkbox" name="value[]" value="ownuser.edit"></td>
<td></td>
</tr>
<tr>
<td>Nyheder</td>
<td><p>Empty</p></td>
<td></td>
<td><input id="NewsRAccount" onclick="if ($('#NewsR').prop('checked') == false) $('#NewsR').prop('checked', true); else $('#NewsR').prop('checked', false);" type="checkbox" name="value[]" value="news.show"></td>
<td></td>
</tr>
<tr>
<td>Menuplan</td>
<td><p>Empty</p></td>
<td></td>
<td><input id="MenuRAccount" onclick="if ($('#MenuR').prop('checked') == false) $('#MenuR').prop('checked', true); else $('#MenuR').prop('checked', false);" type="checkbox" name="value[]" value="menuplan.show"></td>
<td></td>
</tr>
<tr>
<td>Aktiviteter</td>
<td><p>Empty</p></td>
<td></td>
<td><input id="EventRAccount" onclick="if ($('#EventR').prop('checked') == false) $('#EventR').prop('checked', true); else $('#EventR').prop('checked', false);" type="checkbox" name="value[]" value="event.show"></td>
<td></td>
</tr>
<tr>
<td>Reservationer</td>
<td>Empty</td>
<td><input id="ReservationCAccount" onclick="if ($('#ReservationC').prop('checked') == false) $('#ReservationC').prop('checked', true); else $('#ReservationC').prop('checked', false);" type="checkbox" name="value[]" value="washing.machine.reservation.create"></td>
<td><input id="ReservationRAccount" onclick="if ($('#ReservationR').prop('checked') == false) $('#ReservationR').prop('checked', true); else $('#ReservationR').prop('checked', false);" type="checkbox" name="value[]" value="washing.machine.reservation.show"></td>
<td><input id="ReservationDAccount" onclick="if ($('#ReservationD').prop('checked') == false) $('#ReservationD').prop('checked', true); else $('#ReservationD').prop('checked', false);" type="checkbox" name="value[]" value="washing.machine.reservation.delete"></td>
</tr>
<tr>
<td>Kontakter</td>
<td><p>Empty</p></td>
<td></td>
<td><input id="ContactRAccount" onclick="if ($('#ContactR').prop('checked') == false) $('#ContactR').prop('checked', true); else $('#ContactR').prop('checked', false);" type="checkbox" name="value[]" value="contact.show"></td>
<td></td>
</tr>
<tr>
<td>Vejledning</td>
<td><p>Empty</p></td>
<td></td>
<td><input id="GuideRAccount" onclick="if ($('#GuideR').prop('checked') == false) $('#GuideR').prop('checked', true); else $('#GuideR').prop('checked', false);" type="checkbox" name="value[]" value="guides.show"></td>
<td></td>
</tr>
<tr>
<td>Feedback</td>
<td>Empty</td>
<td><input id="FeedbackCAccount" onclick="if ($('#FeedbackC').prop('checked') == false) $('#FeedbackC').prop('checked', true); else $('#FeedbackC').prop('checked', false);" type="checkbox" name="value[]" value="feedback.create"></td>
<td><input id="FeedbackRAccount" onclick="if ($('#FeedbackR').prop('checked') == false) $('#FeedbackR').prop('checked', true); else $('#FeedbackR').prop('checked', false);" type="checkbox" name="value[]" value="feedback.show"></td>
<td></td>
</tr>
</table>
</div>
<div id="admin">
<small class="form-text text-muted">Her kan alle rettigheder for administrationssiden slås til eller fra.</small>
<table class="tbl mb-2" >
<tr><!--Header Start-->
<th>Side</th>
<th>Beskrivelse</th>
<th>Create</th>
<th>Read</th>
<th>Update</th>
<th>Delete</th>
<th>Fuld Kontrol</th>
</tr><!--Header Slut-->
<tr>
<td>Admin Panel</td>
<td><p>Adgang til admin panelet</p></td>
<td></td>
<td><input type="checkbox" name="value[]" value="admin.panel.show"></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr><!--Bruger Start-->
<td>Brugere</td>
<td><p>Empty</p></td>
<td><input id="UserC" type="checkbox" name="value[]" value="user.create"></td>
<td><input id="UserR" type="checkbox" name="value[]" value="user.show"></td>
<td><input id="UserU" type="checkbox" name="value[]" value="user.edit"></td>
<td><input id="UserD" type="checkbox" name="value[]" value="user.delete"></td>
<td><input id="User" type="checkbox" onclick="FullControl(this)"></td>
</tr><!--Bruger Start-->
<tr>
<td>Roller</td>
<td><p>Empty</p></td>
<td><input id="RoleC" type="checkbox" name="value[]" value="roles.create"></td>
<td><input id="RoleR" type="checkbox" name="value[]" value="roles.show"></td>
<td><input id="RoleU" type="checkbox" name="value[]" value="roles.edit"></td>
<td><input id="RoleD" type="checkbox" name="value[]" value="roles.delete"></td>
<td><input id="Role" type="checkbox" onclick="FullControl(this)"></td>
</tr>
<tr>
<td>Nyheder</td>
<td><p>Empty</p></td>
<td><input id="NewsC" type="checkbox" name="value[]" value="news.create"></td>
<td><input id="NewsR" onclick="if ($('#NewsRAccount').prop('checked') == false) $('#NewsRAccount').prop('checked', true); else $('#NewsRAccount').prop('checked', false);" type="checkbox" name="value[]" value="news.show"></td>
<td><input id="NewsU" type="checkbox" name="value[]" value="news.edit"></td>
<td><input id="NewsD" type="checkbox" name="value[]" value="news.delete"></td>
<td><input id="News" type="checkbox" onclick="FullControl(this)"></td>
</tr>
<tr>
<td>Menuplan</td>
<td><p>Empty</p></td>
<td><input id="MenuC" type="checkbox" name="value[]" value="menuplan.create"></td>
<td><input id="MenuR" onclick="if ($('#MenuRAccount').prop('checked') == false) $('#MenuRAccount').prop('checked', true); else $('#MenuRAccount').prop('checked', false);" type="checkbox" name="value[]" value="menuplan.show"></td>
<td><input id="MenuU" type="checkbox" name="value[]" value="menuplan.edit"></td>
<td><input id="MenuD" type="checkbox" name="value[]" value="menuplan.delete"></td>
<td><input id="Menu" type="checkbox" onclick="FullControl(this)"></td>
</tr>
<tr>
<td>Aktiviteter</td>
<td><p>Empty</p></td>
<td><input id="EventC" type="checkbox" name="value[]" value="event.create"></td>
<td><input id="EventR" onclick="if ($('#EventRAccount').prop('checked') == false) $('#EventRAccount').prop('checked', true); else $('#EventRAccount').prop('checked', false);" type="checkbox" name="value[]" value="event.show"></td>
<td><input id="EventU" type="checkbox" name="value[]" value="event.edit"></td>
<td><input id="EventD" type="checkbox" name="value[]" value="event.delete"></td>
<td><input id="Event" type="checkbox" onclick="FullControl(this)"></td>
</tr>
<tr>
<td>Lokation</td>
<td><p>Empty</p></td>
<td><input id="LocationC" type="checkbox" name="value[]" value="locations.create"></td>
<td><input id="LocationR" type="checkbox" name="value[]" value="locations.show"></td>
<td><input id="LocationU" type="checkbox" name="value[]" value="locations.edit"></td>
<td><input id="LocationD" type="checkbox" name="value[]" value="locations.delete"></td>
<td><input id="Location" type="checkbox" onclick="FullControl(this)"></td>
</tr>
<tr>
<td>Vaskemaskiner</td>
<td><p>Empty</p></td>
<td><input id="WashingMachineC" type="checkbox" name="value[]" value="washing.machine.create"></td>
<td><input id="WashingMachineR" type="checkbox" name="value[]" value="washing.machine.show"></td>
<td><input id="WashingMachineU" type="checkbox" name="value[]" value="washing.machine.edit"></td>
<td><input id="WashingMachineD" type="checkbox" name="value[]" value="washing.machine.delete"></td>
<td><input id="WashingMachine" type="checkbox" onclick="FullControl(this)"></td>
</tr>
<tr>
<td>Reservationer</td>
<td>Empty</td>
<td><input id="ReservationC" onclick="if ($('#ReservationCAccount').prop('checked') == false) $('#ReservationCAccount').prop('checked', true); else $('#ReservationCAccount').prop('checked', false);" type="checkbox" name="value[]" value="washing.machine.reservation.create"></td>
<td><input id="ReservationR" onclick="if ($('#ReservationRAccount').prop('checked') == false) $('#ReservationRAccount').prop('checked', true); else $('#ReservationRAccount').prop('checked', false);" type="checkbox" name="value[]" value="washing.machine.reservation.show"></td>
<td><input id="ReservationU" type="checkbox" name="value[]" value="washing.machine.reservation.edit"></td>
<td><input id="ReservationD" onclick="if ($('#ReservationCAccount').prop('checked') == false) $('#ReservationDAccount').prop('checked', true); else $('#ReservationDAccount').prop('checked', false);" type="checkbox" name="value[]" value="washing.machine.reservation.delete"></td>
<td><input id="Reservation" type="checkbox" onclick="FullControl(this)"></td>
</tr>
<tr>
<td>Kontakter</td>
<td><p>Empty</p></td>
<td><input id="ContactC" type="checkbox" name="value[]" value="contact.create"></td>
<td><input id="ContactR" onclick="if ($('#ContactRAccount').prop('checked') == false) $('#ContactRAccount').prop('checked', true); else $('#ContactRAccount').prop('checked', false);" type="checkbox" name="value[]" value="contact.show"></td>
<td><input id="ContactU" type="checkbox" name="value[]" value="contact.edit"></td>
<td><input id="ContactD" type="checkbox" name="value[]" value="contact.delete"></td>
<td><input id="Contact" type="checkbox" onclick="FullControl(this)"></td>
</tr>
<tr>
<td>Vejledning</td>
<td><p>Empty</p></td>
<td><input id="GuideC" type="checkbox" name="value[]" value="guides.create"></td>
<td><input id="GuideR" onclick="if ($('#GuideRRAccount').prop('checked') == false) $('#GuideRAccount').prop('checked', true); else $('#GuideRAccount').prop('checked', false);" type="checkbox" name="value[]" value="guides.show"></td>
<td><input id="GuideU" type="checkbox" name="value[]" value="guides.edit"></td>
<td><input id="GuideD" type="checkbox" name="value[]" value="guides.delete"></td>
<td><input id="Guide" type="checkbox" onclick="FullControl(this)"></td>
</tr>
<tr>
<td>Feedback</td>
<td><p>Empty</p></td>
<td><input id="FeedbackC" onclick="if ($('#FeedbackCAccount').prop('checked') == false) $('#FeedbackCAccount').prop('checked', true); else $('#FeedbackCAccount').prop('checked', false);" type="checkbox" name="value[]" value="feedback.create"></td>
<td><input id="FeedbackR" onclick="if ($('#FeedbackRAccount').prop('checked') == false) $('#FeedbackRAccount').prop('checked', true); else $('#FeedbackRAccount').prop('checked', false);" type="checkbox" name="value[]" value="feedback.show"></td>
<td><input id="FeedbackU" type="checkbox" name="value[]" value="feedback.edit"></td>
<td><input id="FeedbackD" type="checkbox" name="value[]" value="feedback.delete"></td>
<td><input id="Feedback" type="checkbox" onclick="FullControl(this)"></td>
</tr>
</table>
</div>
<input type="submit" id="disable" class="btn btn-dark text-white" value="Opret">
</form>
@endsection
@section("scripts")
<script>
$(function() {
$('form').areYouSure(
{
message: 'It looks like you have been editing something. '
+ 'If you leave before saving, your changes will be lost.'
}
);
});
$(document).ready(function () {
$value = $('#name').val();
$.ajax({
type: 'get',
url: '{{route('roles.nameCheck')}}',
data: {'nameCheck':$value},
success:function (data) {
if(data){
$("#error").show(100);
$("#error").css('color', 'red');
$("#disable").prop('disabled', true);
$('#disable').css('cursor','not-allowed');
}else{
$("#error").hide();
$("#disable").prop('disabled', false);
$('#disable').css('cursor','pointer');
}
},
error:function (data) {
console.log(data);
}
});
});
$('#name').on('keyup', function () {
$value = $(this).val();
$.ajax({
type: 'get',
url: '{{route('roles.nameCheck')}}',
data: {'nameCheck':$value},
success:function (data) {
if(data){
$("#error").show(100);
$("#error").css('color', 'red');
$("#disable").prop('disabled', true);
$('#disable').css('cursor','not-allowed');
}else{
$("#error").hide();
$("#disable").prop('disabled', false);
$('#disable').css('cursor','pointer');
}
},
error:function (data) {
console.log(data);
}
});
})
// hide permissions
$('#konto').hide();
$('#admin').hide();
//Show konto settings
$("#kontoButton").click(function(){
var value = $('#kontoButton').text();
if(value === 'Konto rettigheder'){
$('#konto').slideDown('slow');
$('#kontoButton').html('Luk konto rettigheder')
}else{
$('#konto').slideUp('slow');
$('#kontoButton').html('Konto rettigheder')
}
});
//Show admin permissions
$("#adminButton").click(function(){
var value = $('#adminButton').text();
if(value === 'Admin rettigheder'){
$('#admin').slideDown('slow');
$('#adminButton').html('Luk admin rettigheder')
}else{
$('#admin').slideUp('slow');
$('#adminButton').html('Admin rettigheder')
}
});
function FullControl(FC) { //FC == Full Controll
var Create = $(FC).attr('id') + 'C'; // Takes FC's ID Name and puts C at the back of it
var Read = $(FC).attr('id') + 'R'; // Takes FC's ID Name and puts R at the back of it
var Update = $(FC).attr('id') + 'U'; // Takes FC's ID Name and puts U at the back of it
var Delete = $(FC).attr('id') + 'D'; // Takes FC's ID Name and puts D at the back of it
if ($(FC).prop('checked') == false) {
$('#' + Create).prop('checked', false);
$('#' + Read).prop('checked', false);
$('#' + Update).prop('checked', false);
$('#' + Delete).prop('checked', false);
} else {
$('#' + Create).prop('checked', true);
$('#' + Read).prop('checked', true);
$('#' + Update).prop('checked', true);
$('#' + Delete).prop('checked', true);
}
}
</script>
@endsection