v1.5.20b You can now cancel a event from view my events
This commit is contained in:
parent
0757f6daef
commit
87006ae54f
skolehjem/resources/views/app/events
|
@ -57,10 +57,10 @@
|
||||||
@endif
|
@endif
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="row justify-content-space">
|
<div class="row justify-content-space">
|
||||||
@if (count(\App\UserEvent::query()->where('event_id', '=', $userevent->id)->where('user_id', '=', Auth::user()->id)->get()) > 0)
|
@if (count(\App\UserEvent::query()->where('event_id', '=', $userevent->id)->where('multiple_event_id', '=', null)->where('user_id', '=', Auth::user()->id)->get()) > 0 || count(\App\UserEvent::query()->where('multiple_event_id', '=', $userevent->id)->where('event_id', '=', null)->where('user_id', '=', Auth::user()->id)->get()) > 0)
|
||||||
<a class="sde-blue text-center m-none p-none bold" href="javascript:void(0);" @if($key == "events") onclick="ajaxCall({{ $userevent->id }}, this)" @elseif($key == "multiple") @endif id="t">{{__('msg.afmeld')}}</a>
|
<a class="sde-blue text-center m-none p-none bold" href="javascript:void(0);" @if($key == "events") onclick="ajaxCall({{ $userevent->id }}, this)" @elseif($key == "multiple") onclick="ajaxMultiCall({{ $userevent->id }}, this)" @endif id="t">{{__('msg.afmeld')}}</a>
|
||||||
@else {{-- ^ If you're already participating in the event, then show a ´cancel´ button - v Else show a ´participate´ button --}}
|
@else {{-- ^ If you're already participating in the event, then show a ´cancel´ button - v Else show a ´participate´ button --}}
|
||||||
<a class="sde-blue text-center m-none p-none bold" href="javascript:void(0);" onclick="ajaxCall({{ $userevent->id }}, this)" >{{__('msg.tilmeld')}}</a>
|
<a class="sde-blue text-center m-none p-none bold" href="javascript:void(0);" @if($key == "events") onclick="ajaxCall({{ $userevent->id }}, this)" @elseif($key == "multiple") onclick="ajaxMultiCall({{ $userevent->id }}, this)" @endif id="f">{{__('msg.tilmeld')}}</a>
|
||||||
@endif
|
@endif
|
||||||
<a class="sde-blue text-center m-none p-none bold" href="{{route("events.show", ["event" => $userevent->id ])}}">{{__('msg.læsmere')}}</a>
|
<a class="sde-blue text-center m-none p-none bold" href="{{route("events.show", ["event" => $userevent->id ])}}">{{__('msg.læsmere')}}</a>
|
||||||
<a class="sde-blue text-center m-none p-none bold" href="{{route("events.accountsignups", ["event" => $userevent->id ])}}">{{__('msg.sedeltagere')}}</a>
|
<a class="sde-blue text-center m-none p-none bold" href="{{route("events.accountsignups", ["event" => $userevent->id ])}}">{{__('msg.sedeltagere')}}</a>
|
||||||
|
@ -88,6 +88,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function ajaxCall(event_id, el) {
|
function ajaxCall(event_id, el) {
|
||||||
|
console.log(el)
|
||||||
if(el.innerHTML === "{{__("msg.tilmeld")}}") {
|
if(el.innerHTML === "{{__("msg.tilmeld")}}") {
|
||||||
axios.post("{{ route("userevents.createajax") }}",
|
axios.post("{{ route("userevents.createajax") }}",
|
||||||
{
|
{
|
||||||
|
@ -119,4 +120,61 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
<script type="text/javascript">
|
||||||
|
function snackbar(data) {
|
||||||
|
var x = document.getElementById("snackbar");
|
||||||
|
x.innerHTML = data;
|
||||||
|
x.className = "show";
|
||||||
|
|
||||||
|
setTimeout(function(){ x.className = x.className.replace("show", ""); }, 3000);
|
||||||
|
}
|
||||||
|
|
||||||
|
function ajaxMultiCall(multiple_event_id, el) {
|
||||||
|
if(el.innerHTML === "{{__("msg.tilmeld")}}") {
|
||||||
|
axios.post("{{ route("multiple-events.createajax") }}",
|
||||||
|
{
|
||||||
|
multiple_event_id: multiple_event_id
|
||||||
|
}
|
||||||
|
).then(function (response) {
|
||||||
|
var data = response.data;
|
||||||
|
console.log(data);
|
||||||
|
|
||||||
|
snackbar(data);
|
||||||
|
|
||||||
|
el.innerHTML = "{{__("msg.afmeld")}}";
|
||||||
|
}).catch(function (error) {
|
||||||
|
console.log(error);
|
||||||
|
});
|
||||||
|
} else if(el.innerHTML === "{{__("msg.afmeld")}}"){
|
||||||
|
axios.post("{{ route("multiple-events.createajaxcancel") }}",
|
||||||
|
{
|
||||||
|
multiple_event_id: multiple_event_id
|
||||||
|
}
|
||||||
|
).then(function (response) {
|
||||||
|
var data = response.data;
|
||||||
|
|
||||||
|
snackbar(data);
|
||||||
|
|
||||||
|
el.innerHTML = "{{__("msg.tilmeld")}}";
|
||||||
|
}).catch(function (error) {
|
||||||
|
console.log(error);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function deleteNotifications(el) {
|
||||||
|
el.remove();
|
||||||
|
}
|
||||||
|
|
||||||
|
window.onload = function () {
|
||||||
|
setMain();
|
||||||
|
axios({
|
||||||
|
method: 'delete',
|
||||||
|
url: '{{route("notifications.delete")}}',
|
||||||
|
data: {
|
||||||
|
user_id: {{ auth()->user()->id }}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
</script>
|
||||||
@endsection
|
@endsection
|
||||||
|
|
Loading…
Reference in New Issue