2020-06-16 07:06:45 +00:00
|
|
|
@extends("admin.layout.base")
|
|
|
|
@extends("admin.layout.header")
|
|
|
|
|
|
|
|
@section("title")
|
2020-06-24 12:19:55 +00:00
|
|
|
Vaskemaskine - Rediger
|
2020-06-16 07:06:45 +00:00
|
|
|
@endsection
|
|
|
|
|
|
|
|
@section("path")
|
2020-07-01 08:30:28 +00:00
|
|
|
<a href="{{ route('washing-machines.edit', ['washing_machine' => $machine]) }}" class="text-white">Rediger Vaskemaskiner</a> /
|
2020-06-16 07:06:45 +00:00
|
|
|
@endsection
|
|
|
|
|
|
|
|
@section("content")
|
2020-07-01 08:30:28 +00:00
|
|
|
<form method="post" action="{{ route("washing-machines.update", [ 'washing_machine' => $machine]) }}">
|
2020-06-24 12:19:55 +00:00
|
|
|
@csrf
|
2020-07-01 08:30:28 +00:00
|
|
|
@method("put")
|
2020-06-24 12:19:55 +00:00
|
|
|
<label for="name_first">Vaskemaskine Navn:</label>
|
2020-08-17 09:07:26 +00:00
|
|
|
<label hidden id="error" for="errormesseages">Vaskemaskinen med den lokation findes allerede</label>
|
2020-09-07 10:44:24 +00:00
|
|
|
<input type="text" name="name" id="name" max="60" placeholder="Vaskemaskine nr. 1" value="{{$machine->name}}" required>
|
|
|
|
<label for="location_id">Lokation:</label>
|
2020-08-06 06:37:16 +00:00
|
|
|
<select class="w-100" name="location_id" id="location_id" class="mb-2" required>
|
|
|
|
<option disabled> -- Vælg Lokation -- </option>
|
|
|
|
@foreach($locations as $location)
|
|
|
|
{{ $selected = "" }}
|
|
|
|
@if($machine->location_id == $location->id)
|
|
|
|
{{ $selected = "selected" }}
|
|
|
|
@endif
|
|
|
|
<option {{ $selected }} value="{{ $location->id }}">{{ $location->name }}</option>
|
|
|
|
@endforeach
|
|
|
|
</select>
|
2020-08-17 09:07:26 +00:00
|
|
|
<input type="submit" id="disable" class="btn btn-dark text-white" value="Rediger">
|
2020-06-24 12:19:55 +00:00
|
|
|
</form>
|
2020-06-16 07:06:45 +00:00
|
|
|
@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 09:07:26 +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('washing-machines.nameCheckUpdate')}}',
|
|
|
|
data: {'nameCheck':$value, 'location': $('#location_id').val(), 'id': {{$machine->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('washing-machines.nameCheckUpdate')}}',
|
|
|
|
data: {'nameCheck':$value, 'location': $('#location_id').val(), 'id': {{$machine->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);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
})
|
|
|
|
|
|
|
|
$('#location_id').on('change', function () {
|
|
|
|
$value = $('#name').val();
|
|
|
|
$.ajax({
|
|
|
|
type: 'get',
|
|
|
|
url: '{{route('washing-machines.nameCheckUpdate')}}',
|
|
|
|
data: {'nameCheck':$value, 'location': $('#location_id').val(), 'id': {{$machine->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
|