phpvms/resources/views/admin/subfleets/script.blade.php

129 lines
3.6 KiB
PHP
Raw Normal View History

@section('scripts')
<script>
function setEditable() {
const token = $('meta[name="csrf-token"]').attr('content');
$('#aircraft_fares a').editable({
type: 'text',
mode: 'inline',
emptytext: 'inherited',
url: '{{ url('/admin/subfleets/'.$subfleet->id.'/fares') }}',
title: 'Enter override value',
ajaxOptions: {
type: 'post',
headers: {
'x-api-key': '{{ Auth::user()->api_key }}',
'X-CSRF-TOKEN': token,
}
},
params: function (params) {
return {
_method: 'put',
fare_id: params.pk,
name: params.name,
value: params.value
}
}
});
$('#subfleet_ranks a').editable({
type: 'text',
mode: 'inline',
emptytext: 'inherited',
url: '{{ url('/admin/subfleets/'.$subfleet->id.'/ranks') }}',
title: 'Enter override value',
ajaxOptions: {
type: 'post',
headers: {
'x-api-key': '{{ Auth::user()->api_key }}',
'X-CSRF-TOKEN': token,
}
},
params: function (params) {
return {
_method: 'put',
rank_id: params.pk,
name: params.name,
value: params.value
}
}
});
$('#subfleet-expenses a.text').editable({
emptytext: '0',
url: '{{ url('/admin/subfleets/'.$subfleet->id.'/expenses') }}',
title: 'Enter override value',
ajaxOptions: {
type: 'post',
headers: {
'x-api-key': '{{ Auth::user()->api_key }}',
'X-CSRF-TOKEN': token,
}
},
params: function (params) {
return {
_method: 'put',
expense_id: params.pk,
name: params.name,
value: params.value
}
}
});
$('#subfleet-expenses a.dropdown').editable({
type: 'select',
emptytext: '0',
source: {!! json_encode(list_to_editable(\App\Models\Enums\ExpenseType::select())) !!},
url: '{{ url('/admin/subfleets/'.$subfleet->id.'/expenses') }}',
title: 'Enter override value',
ajaxOptions: {
type: 'post',
headers: {
'x-api-key': '{{ Auth::user()->api_key }}',
'X-CSRF-TOKEN': token,
}
},
params: function (params) {
console.log(params);
return {
_method: 'put',
expense_id: params.pk,
name: params.name,
value: params.value
}
}
});
}
$(document).ready(function() {
setEditable();
$(document).on('submit', 'form.rm_fare', function(event) {
event.preventDefault();
2017-12-31 03:39:56 +08:00
console.log(event);
$.pjax.submit(event, '#aircraft_fares_wrapper', {push: false});
setEditable();
});
2017-11-23 01:52:02 +08:00
$(document).on('submit', 'form.modify_rank', function (event) {
event.preventDefault();
console.log(event);
$.pjax.submit(event, '#subfleet_ranks_wrapper', {push: false});
});
$(document).on('submit', 'form.modify_expense', function (event) {
event.preventDefault();
console.log(event);
$.pjax.submit(event, '#subfleet-expenses-wrapper', {push: false});
});
2017-11-23 01:52:02 +08:00
$(document).on('pjax:complete', function() {
$(".select2").select2();
setEditable();
2017-11-23 01:52:02 +08:00
});
});
</script>
@endsection