2018-01-07 22:58:57 +08:00
|
|
|
@section('scripts')
|
|
|
|
<script>
|
2018-01-08 00:38:16 +08:00
|
|
|
|
2018-03-21 02:47:47 +08:00
|
|
|
const setEditable = () =>
|
|
|
|
{
|
2018-03-13 14:55:14 +08:00
|
|
|
const api_key = $('meta[name="api-key"]').attr('content');
|
2018-03-15 07:14:35 +08:00
|
|
|
const csrf_token = $('meta[name="csrf-token"]').attr('content');
|
2018-03-13 14:55:14 +08:00
|
|
|
|
2018-01-08 00:38:16 +08:00
|
|
|
$('#flight_fares a').editable({
|
|
|
|
type: 'text',
|
|
|
|
mode: 'inline',
|
|
|
|
emptytext: 'inherited',
|
2018-03-13 06:58:12 +08:00
|
|
|
url: '{{ url('/admin/flights/'.$flight->id.'/fares') }}',
|
2018-01-08 00:38:16 +08:00
|
|
|
title: 'Enter override value',
|
2018-03-13 14:48:47 +08:00
|
|
|
ajaxOptions: {
|
|
|
|
type: 'post',
|
|
|
|
headers: {
|
2018-03-13 14:55:14 +08:00
|
|
|
'x-api-key': api_key,
|
|
|
|
'X-CSRF-TOKEN': csrf_token
|
2018-03-13 14:48:47 +08:00
|
|
|
}
|
|
|
|
},
|
2018-01-08 00:38:16 +08:00
|
|
|
params: function (params) {
|
|
|
|
return {
|
2018-03-13 14:48:47 +08:00
|
|
|
_method: 'put',
|
2018-01-08 00:38:16 +08:00
|
|
|
fare_id: params.pk,
|
|
|
|
name: params.name,
|
|
|
|
value: params.value
|
2018-01-07 22:58:57 +08:00
|
|
|
}
|
2018-01-08 00:38:16 +08:00
|
|
|
}
|
|
|
|
});
|
2018-03-21 02:47:47 +08:00
|
|
|
};
|
2018-01-07 22:58:57 +08:00
|
|
|
|
2018-03-21 02:47:47 +08:00
|
|
|
const setFieldsEditable = () =>
|
|
|
|
{
|
2018-03-13 14:55:14 +08:00
|
|
|
const api_key = $('meta[name="api-key"]').attr('content');
|
2018-03-21 02:47:47 +08:00
|
|
|
const csrf_token = $('meta[name="csrf-token"]').attr('content');
|
2018-01-08 00:38:16 +08:00
|
|
|
|
|
|
|
$('#flight_fields_wrapper a.inline').editable({
|
|
|
|
type: 'text',
|
|
|
|
mode: 'inline',
|
2018-03-21 02:47:47 +08:00
|
|
|
emptytext: 'no value',
|
2018-03-15 07:14:35 +08:00
|
|
|
url: '{{ url('/admin/flights/'.$flight->id.'/fields') }}',
|
2018-03-13 14:48:47 +08:00
|
|
|
ajaxOptions: {
|
|
|
|
type: 'post',
|
|
|
|
headers: {
|
2018-03-13 14:55:14 +08:00
|
|
|
'x-api-key': api_key,
|
|
|
|
'X-CSRF-TOKEN': csrf_token
|
2018-03-13 14:48:47 +08:00
|
|
|
}
|
|
|
|
},
|
2018-01-08 00:38:16 +08:00
|
|
|
params: function (params) {
|
|
|
|
return {
|
2018-03-13 14:48:47 +08:00
|
|
|
_method: 'put',
|
2018-01-08 00:38:16 +08:00
|
|
|
field_id: params.pk,
|
|
|
|
name: params.name,
|
|
|
|
value: params.value
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2018-03-21 02:47:47 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
$(document).ready(function () {
|
|
|
|
|
|
|
|
setEditable();
|
|
|
|
setFieldsEditable();
|
2018-01-07 22:58:57 +08:00
|
|
|
|
2018-03-24 04:02:26 +08:00
|
|
|
/*new Pjax({
|
|
|
|
elements: 'form[action].pjax_subfleet_form',
|
|
|
|
selectors: ['div#subfleet_flight_wrapper'],
|
|
|
|
history: false,
|
|
|
|
});
|
|
|
|
|
|
|
|
new Pjax({
|
|
|
|
elements: 'form[action].pjax_flight_fields',
|
|
|
|
selectors: ['div#flight_fields_wrapper'],
|
|
|
|
history: false
|
2018-03-24 03:10:18 +08:00
|
|
|
});*/
|
|
|
|
|
2018-01-08 00:38:16 +08:00
|
|
|
$(document).on('submit', 'form.pjax_flight_fields', function (event) {
|
|
|
|
event.preventDefault();
|
|
|
|
$.pjax.submit(event, '#flight_fields_wrapper', {push: false});
|
|
|
|
});
|
|
|
|
|
|
|
|
$(document).on('submit', 'form.pjax_subfleet_form', function (event) {
|
|
|
|
event.preventDefault();
|
|
|
|
$.pjax.submit(event, '#subfleet_flight_wrapper', {push: false});
|
|
|
|
});
|
|
|
|
|
|
|
|
$(document).on('submit', 'form.pjax_fares_form', function (event) {
|
|
|
|
event.preventDefault();
|
|
|
|
$.pjax.submit(event, '#flight_fares_wrapper', {push: false});
|
|
|
|
});
|
2018-01-07 22:58:57 +08:00
|
|
|
|
2018-01-08 00:38:16 +08:00
|
|
|
$(document).on('pjax:complete', function () {
|
2018-04-07 06:10:45 +08:00
|
|
|
initPlugins();
|
2018-01-08 00:38:16 +08:00
|
|
|
setEditable();
|
2018-03-21 02:47:47 +08:00
|
|
|
setFieldsEditable();
|
2018-01-07 22:58:57 +08:00
|
|
|
});
|
2018-01-08 00:38:16 +08:00
|
|
|
});
|
2018-01-07 22:58:57 +08:00
|
|
|
</script>
|
|
|
|
@endsection
|