2020-08-06 06:37:16 +00:00
|
|
|
@extends("admin.layout.base")
|
|
|
|
@extends("admin.layout.header")
|
|
|
|
|
|
|
|
@section("title")
|
|
|
|
Lokation - Rediger
|
|
|
|
@endsection
|
|
|
|
|
|
|
|
@section("path")
|
|
|
|
<a href="{{route('locations.edit', ['location' => $location ])}}" class="text-white">Rediger lokation</a> /
|
|
|
|
@endsection
|
|
|
|
|
|
|
|
@section("content")
|
|
|
|
<h1>Rediger Lokation</h1>
|
|
|
|
<form method="post" action="{{ route("locations.update", ['location' => $location ]) }}">
|
|
|
|
@csrf
|
|
|
|
@method("put")
|
|
|
|
<label for="name">Lokationsnavn:</label>
|
2020-08-17 08:43:52 +00:00
|
|
|
<label hidden id="error" for="errormesseages">Lokation findes allerede</label>
|
2020-08-06 06:37:16 +00:00
|
|
|
<input type="text" name="name" id="name" value="{{ $location->name }}" required>
|
2020-08-17 08:43:52 +00:00
|
|
|
<input type="submit" id="disable" class="btn btn-dark text-white" value="Rediger">
|
2020-08-06 06:37:16 +00:00
|
|
|
</form>
|
|
|
|
@endsection
|
2020-08-11 08:54:01 +00:00
|
|
|
@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.'
|
|
|
|
}
|
|
|
|
);
|
|
|
|
});
|
2020-08-17 08:43:52 +00:00
|
|
|
|
|
|
|
//Dont delete me, if the user reloads the pages with text in the text-box this code runs.
|
|
|
|
$(document).ready(function () {
|
|
|
|
$value = $('#name').val();
|
|
|
|
$.ajax({
|
|
|
|
type: 'get',
|
|
|
|
url: '{{route('locations.nameCheckUpdate')}}',
|
|
|
|
data: {'nameCheck':$value, 'id':{{$location->id}}},
|
|
|
|
success:function (data) {
|
|
|
|
console.log(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('locations.nameCheckUpdate')}}',
|
|
|
|
data: {'nameCheck':$value, 'id':{{$location->id}}},
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
})
|
2020-08-11 08:54:01 +00:00
|
|
|
</script>
|
|
|
|
@endsection
|