From b1b96ad080097f672390664c3d27ef81ceeb0e64 Mon Sep 17 00:00:00 2001 From: frederikpyt Date: Tue, 11 Aug 2020 15:08:09 +0200 Subject: [PATCH] v0.7.6 - Added snackbar --- .../app/Http/Controllers/EventController.php | 12 ++-- .../Http/Controllers/UserEventController.php | 34 ++++++++++ skolehjem/public/css/webapp.css | 68 +++++++++++++++++++ skolehjem/public/css/webappdark.css | 68 +++++++++++++++++++ skolehjem/resources/sass/webapp/_default.scss | 40 +++++++++++ .../resources/views/app/layout/base.blade.php | 21 +++--- .../resources/views/app/news/index.blade.php | 28 +++++++- skolehjem/routes/web.php | 1 + 8 files changed, 253 insertions(+), 19 deletions(-) diff --git a/skolehjem/app/Http/Controllers/EventController.php b/skolehjem/app/Http/Controllers/EventController.php index c6076ac..fa772f2 100644 --- a/skolehjem/app/Http/Controllers/EventController.php +++ b/skolehjem/app/Http/Controllers/EventController.php @@ -82,11 +82,11 @@ class EventController extends Controller $news->name = "Ny aktivitet"; $news->subname = $event->name; - $news->content = "

" . $this->closetags(substr($event->description, 0, 300)) . "

" . - '
'. - ' $event->id ]) .'">Tilmeld'. + $news->content = "

" . $this->closetags(substr($event->description, 0, 300)). "

" . + '
'. //route("userevents.createajax", ["event_id" => $event->id ]) + 'Tilmeld'. ' $event->id ]) .'">Læs mere'. - ' $event->id ]) .'">Se deltagere'. + ' $event->id ]) .'">Se deltagere'. '
'; $news->save(); } @@ -180,8 +180,8 @@ class EventController extends Controller $news->name = "Aktivitet opdateret"; $news->subname = $event->name; $news->content = "

" . $this->closetags(substr($event->description, 0, 300)). "

" . - '
'. - ' $event->id ]) .'">Tilmeld'. + '
'. //route("userevents.createajax", ["event_id" => $event->id ]) + 'Tilmeld'. ' $event->id ]) .'">Læs mere'. ' $event->id ]) .'">Se deltagere'. '
'; diff --git a/skolehjem/app/Http/Controllers/UserEventController.php b/skolehjem/app/Http/Controllers/UserEventController.php index 0c3b0b2..69d7b2b 100644 --- a/skolehjem/app/Http/Controllers/UserEventController.php +++ b/skolehjem/app/Http/Controllers/UserEventController.php @@ -106,4 +106,38 @@ class UserEventController extends Controller public function update() { } + + public function createajax(Request $request) + { + // Get written data from events.index + $data = $request->validate([ + "event_id" => "required|max:255" + ]); + + // Check the UserEvent table if there is a row that has the user_id AND the event_id + $getTableInfo = UserEvent::where('user_id', auth()->user()->id) + ->where('event_id', $request->event_id)->get(); + + // If the row has both, then go back and show an error - Cause you're not allowed to be on the same event twice. + if (count($getTableInfo) > 0) { + if (request()->cookie('languagesSetting') == "dk") + return '

Du har allerede tilmeldt dig denne Aktivitet!

'; + if (request()->cookie('languagesSetting') == "en") + return '

You are already participating in this event!

'; + + return '

Du har allerede tilmeldt dig denne Aktivitet!

'; + } + + // If not, then it keeps going and saves and shows a success message + $UserEvent = new UserEvent($data); + $UserEvent->user_id = auth()->user()->id; + $UserEvent->save(); + + if (request()->cookie('languagesSetting') == "dk") + return '

Du er hermed tilmeldt denne aktivitet!

'; + if (request()->cookie('languagesSetting') == "en") + return '

You are now participating in this event!

'; + + return '

Du er hermed tilmeldt denne aktivitet!

'; + } } diff --git a/skolehjem/public/css/webapp.css b/skolehjem/public/css/webapp.css index b5c435a..5b62e83 100644 --- a/skolehjem/public/css/webapp.css +++ b/skolehjem/public/css/webapp.css @@ -6977,3 +6977,71 @@ main { display: inline-block; } +#snackbar { + visibility: hidden; + width: calc(90% - 16px); + background-color: #333; + color: #fff; + text-align: center; + border-radius: 2px; + position: fixed; + z-index: 1; + left: calc(5% + 8px); + right: calc(5% + 8px); + bottom: 30px; +} + +#snackbar.show { + visibility: visible; + -webkit-animation: fadein 0.5s, fadeout 0.5s 2.5s; + animation: fadein 0.5s, fadeout 0.5s 2.5s; +} + +@-webkit-keyframes fadein { + from { + bottom: 0; + opacity: 0; + } + + to { + bottom: 30px; + opacity: 1; + } +} + +@keyframes fadein { + from { + bottom: 0; + opacity: 0; + } + + to { + bottom: 30px; + opacity: 1; + } +} + +@-webkit-keyframes fadeout { + from { + bottom: 30px; + opacity: 1; + } + + to { + bottom: 0; + opacity: 0; + } +} + +@keyframes fadeout { + from { + bottom: 30px; + opacity: 1; + } + + to { + bottom: 0; + opacity: 0; + } +} + diff --git a/skolehjem/public/css/webappdark.css b/skolehjem/public/css/webappdark.css index 3a0976f..b3471b3 100644 --- a/skolehjem/public/css/webappdark.css +++ b/skolehjem/public/css/webappdark.css @@ -6977,6 +6977,74 @@ main { display: inline-block; } +#snackbar { + visibility: hidden; + width: calc(90% - 16px); + background-color: #333; + color: #fff; + text-align: center; + border-radius: 2px; + position: fixed; + z-index: 1; + left: calc(5% + 8px); + right: calc(5% + 8px); + bottom: 30px; +} + +#snackbar.show { + visibility: visible; + -webkit-animation: fadein 0.5s, fadeout 0.5s 2.5s; + animation: fadein 0.5s, fadeout 0.5s 2.5s; +} + +@-webkit-keyframes fadein { + from { + bottom: 0; + opacity: 0; + } + + to { + bottom: 30px; + opacity: 1; + } +} + +@keyframes fadein { + from { + bottom: 0; + opacity: 0; + } + + to { + bottom: 30px; + opacity: 1; + } +} + +@-webkit-keyframes fadeout { + from { + bottom: 30px; + opacity: 1; + } + + to { + bottom: 0; + opacity: 0; + } +} + +@keyframes fadeout { + from { + bottom: 30px; + opacity: 1; + } + + to { + bottom: 0; + opacity: 0; + } +} + html, body { background-color: #666666; diff --git a/skolehjem/resources/sass/webapp/_default.scss b/skolehjem/resources/sass/webapp/_default.scss index 0d23f7f..4fdfc07 100644 --- a/skolehjem/resources/sass/webapp/_default.scss +++ b/skolehjem/resources/sass/webapp/_default.scss @@ -485,3 +485,43 @@ $primary-color: $blue; display: inline-block; } } + +#snackbar { + visibility: hidden; + width: calc(90% - 16px); + background-color: #333; + color: #fff; + text-align: center; + border-radius: 2px; + position: fixed; + z-index: 1; + left: calc(5% + 8px); + right: calc(5% + 8px); + bottom: 30px; +} + +#snackbar.show { + visibility: visible; + -webkit-animation: fadein 0.5s, fadeout 0.5s 2.5s; + animation: fadein 0.5s, fadeout 0.5s 2.5s; +} + +@-webkit-keyframes fadein { + from {bottom: 0; opacity: 0;} + to {bottom: 30px; opacity: 1;} +} + +@keyframes fadein { + from {bottom: 0; opacity: 0;} + to {bottom: 30px; opacity: 1;} +} + +@-webkit-keyframes fadeout { + from {bottom: 30px; opacity: 1;} + to {bottom: 0; opacity: 0;} +} + +@keyframes fadeout { + from {bottom: 30px; opacity: 1;} + to {bottom: 0; opacity: 0;} +} diff --git a/skolehjem/resources/views/app/layout/base.blade.php b/skolehjem/resources/views/app/layout/base.blade.php index 44a8999..cb33c2d 100644 --- a/skolehjem/resources/views/app/layout/base.blade.php +++ b/skolehjem/resources/views/app/layout/base.blade.php @@ -8,6 +8,14 @@ @else @endif + +
- @yield("content") - -@yield("scripts") @if(request()->cookie("mode") == "dark") @endif - +@yield("scripts") diff --git a/skolehjem/resources/views/app/news/index.blade.php b/skolehjem/resources/views/app/news/index.blade.php index b2a725e..1561135 100644 --- a/skolehjem/resources/views/app/news/index.blade.php +++ b/skolehjem/resources/views/app/news/index.blade.php @@ -27,7 +27,7 @@ padding-right: 8px; } -
+
@foreach(\App\News::query()->orderBy("created_at", "desc")->get() as $new)
@@ -43,5 +43,31 @@ @if(count(\App\News::query()->orderBy("created_at", "desc")->get()) == 0)

{{__('msg.ingennyheder')}}

@endif +
Some text some message..
@endsection +@section("scripts") + +@endsection diff --git a/skolehjem/routes/web.php b/skolehjem/routes/web.php index 2102495..99bc284 100644 --- a/skolehjem/routes/web.php +++ b/skolehjem/routes/web.php @@ -31,6 +31,7 @@ Route::get("phones", "PhoneController@index")->name("phones.index"); Route::get("/washing-reservationsapi", "WashingReservationController@api")->name("washing-reservations.api"); Route::get("/app/washing-reservations", "WashingReservationController@appindex")->name("washing-reservations.appindex"); Route::get("/settings", "SettingsController@index")->name("settings.index"); +Route::post("/events/signup", "UserEventController@createajax")->name("userevents.createajax"); //Search/Filter Route::get("/contactsapi", "ContactController@search")->name("contacts.search");