2017-12-03 14:48:33 +08:00
|
|
|
@section('scripts')
|
|
|
|
<script>
|
|
|
|
function changeStatus(values) {
|
2018-01-04 10:39:24 +08:00
|
|
|
const destContainer = '#pirep_' + values.pirep_id + '_actionbar';
|
2017-12-03 14:48:33 +08:00
|
|
|
$.ajax({
|
2018-01-03 00:59:44 +08:00
|
|
|
url: BASE_URL + '/admin/pireps/' + values.pirep_id + '/status',
|
2017-12-03 14:48:33 +08:00
|
|
|
data: values,
|
|
|
|
type: 'POST',
|
2018-01-03 00:50:41 +08:00
|
|
|
headers: {
|
|
|
|
'x-api-key': PHPVMS_USER_API_KEY
|
|
|
|
},
|
2017-12-03 14:48:33 +08:00
|
|
|
success: function (data) {
|
|
|
|
// console.log(data);
|
2018-01-04 10:39:24 +08:00
|
|
|
$(destContainer).html(data);
|
2017-12-03 14:48:33 +08:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2018-01-03 00:53:25 +08:00
|
|
|
$(document).ready(function() {
|
2018-01-04 05:27:56 +08:00
|
|
|
|
|
|
|
$(document).on('submit', 'form.pjax_form', function (event) {
|
|
|
|
event.preventDefault();
|
|
|
|
$.pjax.submit(event, '#pirep_comments_wrapper', {push: false});
|
|
|
|
});
|
|
|
|
|
|
|
|
$(document).on('pjax:complete', function () {
|
|
|
|
$(".select2").select2();
|
|
|
|
});
|
|
|
|
|
2017-12-03 14:48:33 +08:00
|
|
|
$(document).on('submit', 'form.pirep_submit_status', function (event) {
|
|
|
|
console.log(event);
|
|
|
|
|
|
|
|
event.preventDefault();
|
2018-01-04 10:39:24 +08:00
|
|
|
const values = {
|
2017-12-03 14:48:33 +08:00
|
|
|
pirep_id: $(this).attr('pirep_id'),
|
|
|
|
new_status: $(this).attr('new_status')
|
|
|
|
};
|
|
|
|
|
|
|
|
console.log(values);
|
|
|
|
console.log('Changing PIREP ' + values.pirep_id + ' to state ' + values.new_status);
|
|
|
|
|
|
|
|
changeStatus(values);
|
|
|
|
});
|
2018-01-03 00:53:25 +08:00
|
|
|
});
|
2017-12-03 14:48:33 +08:00
|
|
|
</script>
|
|
|
|
@endsection
|