2018-03-07 07:32:56 +08:00
|
|
|
@section('scripts')
|
|
|
|
<script>
|
|
|
|
function setEditable() {
|
|
|
|
@if(isset($aircraft))
|
|
|
|
$('#expenses a.text').editable({
|
|
|
|
emptytext: '0',
|
2018-03-13 06:58:12 +08:00
|
|
|
url: '{{ url('/admin/aircraft/'.$aircraft->id.'/expenses') }}',
|
2018-03-07 07:32:56 +08:00
|
|
|
title: 'Enter override value',
|
|
|
|
ajaxOptions: {'type': 'put'},
|
|
|
|
params: function (params) {
|
|
|
|
return {
|
|
|
|
expense_id: params.pk,
|
|
|
|
name: params.name,
|
|
|
|
value: params.value
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
$('#expenses a.dropdown').editable({
|
|
|
|
type: 'select',
|
|
|
|
emptytext: '0',
|
2018-03-13 06:58:12 +08:00
|
|
|
source: {{ json_encode(list_to_editable(\App\Models\Enums\ExpenseType::select())) }},
|
|
|
|
url: '{{ url('/admin/aircraft/'.$aircraft->id.'/expenses') }}',
|
2018-03-07 07:32:56 +08:00
|
|
|
title: 'Enter override value',
|
|
|
|
ajaxOptions: {'type': 'put'},
|
|
|
|
params: function (params) {
|
|
|
|
return {
|
|
|
|
expense_id: params.pk,
|
|
|
|
name: params.name,
|
|
|
|
value: params.value
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
@endif
|
|
|
|
}
|
|
|
|
|
|
|
|
$(document).ready(function() {
|
|
|
|
|
|
|
|
setEditable();
|
|
|
|
|
|
|
|
$(document).on('submit', 'form.modify_expense', function (event) {
|
|
|
|
event.preventDefault();
|
|
|
|
console.log(event);
|
|
|
|
$.pjax.submit(event, '#expenses-wrapper', {push: false});
|
|
|
|
});
|
|
|
|
|
|
|
|
$(document).on('pjax:complete', function () {
|
|
|
|
$(".select2").select2();
|
|
|
|
setEditable();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
@endsection
|