Set the baseURL for ajax requests (#373)
* Set the baseURL for ajax requests * Use async/await on AJAX calls * Add mix_public() cache generated asset cache busting * Move storage container into separate class * Fix some styling
This commit is contained in:
@@ -6,9 +6,11 @@
|
||||
<meta content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0, shrink-to-fit=no' name='viewport'/>
|
||||
|
||||
<title>@yield('title') - {{ config('app.name') }}</title>
|
||||
|
||||
{{-- Start of required lines block. DON'T REMOVE THESE LINES! They're required or might break things --}}
|
||||
<meta name="csrf-token" content="{{ csrf_token() }}">
|
||||
<meta name="api-key" content="{{ Auth::check() ? Auth::user()->api_key: '' }}">
|
||||
<meta name="base-url" content="{!! url('') !!}">
|
||||
<meta name="api-key" content="{!! Auth::check() ? Auth::user()->api_key: '' !!}">
|
||||
<meta name="csrf-token" content="{!! csrf_token() !!}">
|
||||
{{-- End the required lines block --}}
|
||||
|
||||
<link rel="shortcut icon" type="image/png" href="{{ public_asset('/assets/img/favicon.png') }}"/>
|
||||
@@ -18,7 +20,7 @@
|
||||
<link href="{{ public_asset('/assets/frontend/css/styles.css') }}" rel="stylesheet"/>
|
||||
|
||||
{{-- Start of the required files in the head block --}}
|
||||
<link href="{{ public_asset('/assets/global/css/vendor.css') }}" rel="stylesheet"/>
|
||||
<link href="{{ mix_public('/assets/global/css/vendor.css') }}" rel="stylesheet"/>
|
||||
<style type="text/css">
|
||||
@yield('css')
|
||||
</style>
|
||||
@@ -82,8 +84,8 @@
|
||||
<script defer src="https://use.fontawesome.com/releases/v5.0.6/js/all.js"></script>
|
||||
|
||||
{{-- Start of the required tags block. Don't remove these or things will break!! --}}
|
||||
<script src="{{ public_asset('/assets/global/js/vendor.js') }}"></script>
|
||||
<script src="{{ public_asset('/assets/frontend/js/app.js') }}"></script>
|
||||
<script src="{{ mix_public('/assets/global/js/vendor.js') }}"></script>
|
||||
<script src="{{ mix_public('/assets/frontend/js/app.js') }}"></script>
|
||||
@yield('scripts')
|
||||
|
||||
{{--
|
||||
|
||||
@@ -1,41 +1,26 @@
|
||||
@section('scripts')
|
||||
<script>
|
||||
$(document).ready(function () {
|
||||
$("button.save_flight").click(function (e) {
|
||||
$("button.save_flight").click(async function (e) {
|
||||
e.preventDefault();
|
||||
|
||||
const btn = $(this);
|
||||
const class_name = btn.attr('x-saved-class'); // classname to use is set on the element
|
||||
const flight_id = btn.attr('x-id');
|
||||
|
||||
let params = {
|
||||
url: '{{ url('/api/user/bids') }}',
|
||||
data: {
|
||||
'flight_id': btn.attr('x-id')
|
||||
}
|
||||
};
|
||||
if (!btn.hasClass(class_name)) {
|
||||
await phpvms.bids.addBid(flight_id);
|
||||
|
||||
if (btn.hasClass(class_name)) {
|
||||
params.method = 'DELETE';
|
||||
console.log('successfully saved flight');
|
||||
btn.addClass(class_name);
|
||||
alert('@lang("flights.bidadded")');
|
||||
} else {
|
||||
params.method = 'POST';
|
||||
await phpvms.bids.removeBid(flight_id);
|
||||
|
||||
console.log('successfully removed flight');
|
||||
btn.removeClass(class_name);
|
||||
alert('@lang("flights.bidremoved")');
|
||||
}
|
||||
|
||||
axios(params).then(response => {
|
||||
console.log('save bid response', response);
|
||||
|
||||
if(params.method === 'DELETE') {
|
||||
console.log('successfully removed flight');
|
||||
btn.removeClass(class_name);
|
||||
alert('@lang("flights.bidremoved")');
|
||||
} else {
|
||||
console.log('successfully saved flight');
|
||||
btn.addClass(class_name);
|
||||
alert('@lang("flights.bidadded")');
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('Error saving bid status', params, error);
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user