diff --git a/app/Livewire/OnlineCalendar.php b/app/Livewire/OnlineCalendar.php index c3f5ec418..90af0cd58 100644 --- a/app/Livewire/OnlineCalendar.php +++ b/app/Livewire/OnlineCalendar.php @@ -41,46 +41,46 @@ public function mount() $this->selectedLanguage = strtolower(App::getLocale()); $this->selectedYear = Carbon::now()->year; $this->selectedMonth = Carbon::now()->month; + $this->selectedDate = $this->selectedMonth.'/'.$this->selectedYear; - $byMonths = Event::selectRaw( - 'year(start_date) year, month(start_date) month, monthname(start_date) monthname, count(*) data' - ) - ->where($this->whereClause) - ->where('start_date', '>=', \Carbon\Carbon::now()->firstOfMonth()) - ->groupBy('year', 'month','monthname') - ->orderBy('year', 'asc') - ->orderBy('month', 'asc') - ->get(); - - // Format months as objects - $this->months = $byMonths->map(function ($result) { - return [ - 'id' => $result->month.'/'.$result->year, - 'name' => $result->monthname.' '.$result->year - ]; - })->toArray(); - - // Update logic for accessing first item - if (!empty($this->months)) { - $firstMonthId = $this->months[0]['id']; - $parts = explode('/', $firstMonthId); - if ($parts[0] !== $this->selectedMonth) { - $this->selectedMonth = $parts[0]; - } + $this->months = Event::where($this->whereClause) + ->where('start_date', '>=', Carbon::now()->firstOfMonth()) + ->orderBy('start_date') + ->get(['start_date']) + ->groupBy(function ($event) { + $date = Carbon::parse($event->start_date); + + return $date->month.'/'.$date->year; + }) + ->map(function ($group, $id) { + $date = Carbon::parse($group->first()->start_date); + + return [ + 'id' => $id, + 'name' => $date->format('F').' '.$date->year, + ]; + }) + ->values() + ->toArray(); + + if (! empty($this->months)) { + $parts = explode('/', $this->months[0]['id']); + $this->selectedMonth = (int) $parts[0]; + $this->selectedYear = (int) ($parts[1] ?? $this->selectedYear); $this->selectedDate = $this->selectedMonth.'/'.$this->selectedYear; } } public function render() { - $parts = explode('/', $this->selectedDate); - $this->selectedMonth = $parts[0]; - $this->selectedYear = $parts[1] ?? null; + $parts = explode('/', (string) $this->selectedDate); + $this->selectedMonth = (int) ($parts[0] ?: $this->selectedMonth); + $this->selectedYear = (int) ($parts[1] ?? $this->selectedYear); $this->events = Event::where($this->whereClause) ->whereMonth('start_date', $this->selectedMonth) ->whereYear('start_date', $this->selectedYear) - ->where('start_date', '>=', \Carbon\Carbon::now()->firstOfMonth()) + ->where('start_date', '>=', Carbon::now()->firstOfMonth()) ->orderBy('start_date') ->get(); diff --git a/app/Livewire/OnlineEventCard.php b/app/Livewire/OnlineEventCard.php index 538378e05..84d7e5495 100644 --- a/app/Livewire/OnlineEventCard.php +++ b/app/Livewire/OnlineEventCard.php @@ -37,7 +37,8 @@ public function promote() $this->authorize('promote', $this->event); Log::info('going to promote'); - return $this->event->promote(); + $this->event->promote(); + $this->event->refresh(); } public function feature() @@ -45,7 +46,8 @@ public function feature() $this->authorize('feature', $this->event); Log::info('going to feature'); - return $this->event->feature(); + $this->event->feature(); + $this->event->refresh(); } public function setLanguage($language) diff --git a/app/Queries/CountriesQuery.php b/app/Queries/CountriesQuery.php index 94d904837..a34036c75 100644 --- a/app/Queries/CountriesQuery.php +++ b/app/Queries/CountriesQuery.php @@ -54,7 +54,7 @@ public static function withOnlineEvents($highlighted_status){ ->select('events.country_iso as iso', 'countries.name', DB::raw('count(events.id) as total'), DB::raw('MIN(events.start_date) as start_date')) ->join('countries', 'events.country_iso', '=', 'countries.iso') ->where('events.status', '=', 'APPROVED') - ->where('events.highlighted_status', '=', $highlighted_status) + ->where('events.highlighted_status', '=', strtoupper($highlighted_status)) ->whereNull('events.deleted_at') ->where('events.activity_type', 'open-online') ->where('events.start_date', '>=', Carbon::now()->subDays(15)) diff --git a/resources/lang/en/snippets.php b/resources/lang/en/snippets.php index c8c649fb4..87da6c6e8 100644 --- a/resources/lang/en/snippets.php +++ b/resources/lang/en/snippets.php @@ -3,6 +3,7 @@ return [ 'featured-activities' => 'Here are upcoming EU Code Week featured activities that welcome online participants. You can filter by language and month and, by clicking on “view” you’ll access all details on the activity and the contacts of the organisers. Enjoy!', + 'no-featured-activities' => 'No upcoming featured online activities at the moment.', 'learn_and_teach_1' => 'A repository of resources to start or continue your coding journey and develop digital and technical skills – all available at no cost.', 'learn_and_teach_2' => 'Coding and programming are key competences that are increasingly in demand in every field, and EU Code Week wants to support you in your teaching & learning! Browse our repository and find the perfect resource to start or to continue your coding journey. All these resources are free of charge. Don’t forget that you can filter your search by title, resource type, skill level, programming language, subject, category and language.', 'teach_1' => 'Coding and programming are key competences which will open new possibilities to your students and children. Do you want to teach coding at home,in the classroom or code club?', diff --git a/resources/views/layout/anti-fouc.blade.php b/resources/views/layout/anti-fouc.blade.php new file mode 100644 index 000000000..3ce67dfd2 --- /dev/null +++ b/resources/views/layout/anti-fouc.blade.php @@ -0,0 +1,13 @@ +{{-- + Hide dropdown panels only. Superfish adds .sub-menu to the top-level
  • s, + so a bare .sub-menu { display:none } hides the whole header nav. +--}} + diff --git a/resources/views/layout/base.blade.php b/resources/views/layout/base.blade.php index 0f71d048b..84aef73a5 100644 --- a/resources/views/layout/base.blade.php +++ b/resources/views/layout/base.blade.php @@ -1,7 +1,6 @@ - @include('layout.analytics') @@ -12,6 +11,8 @@ + @include('layout.anti-fouc') + @vite(['resources/assets/sass/app.scss', 'resources/js/app.js']) @@ -19,11 +20,7 @@ @stack('extra-css') @yield('extra-css') - - -{{-- @vite('resources/css/app.css')--}} - @vite(['resources/assets/sass/app.scss', 'resources/js/app.js']) -{{-- @vite(['resources/css/app.css', 'resources/js/app.js'])--}} + @include('layout.analytics') @@ -117,7 +114,6 @@ }(document, 'script', 'facebook-jssdk')); -@vite('resources/js/app.js') {{----}} diff --git a/resources/views/layout/guest.blade.php b/resources/views/layout/guest.blade.php index 32cccf7ee..a998fa43f 100644 --- a/resources/views/layout/guest.blade.php +++ b/resources/views/layout/guest.blade.php @@ -1,7 +1,6 @@ - @include('layout.analytics') @@ -12,6 +11,8 @@ + @include('layout.anti-fouc') + @vite(['resources/assets/sass/app.scss', 'resources/js/app.js']) @@ -19,11 +20,7 @@ @stack('extra-css') @yield('extra-css') - - - {{-- @vite('resources/css/app.css')--}} - @vite(['resources/assets/sass/app.scss', 'resources/js/app.js']) - {{-- @vite(['resources/css/app.css', 'resources/js/app.js'])--}} + @include('layout.analytics') diff --git a/resources/views/layout/menu-profile-dropdown.blade.php b/resources/views/layout/menu-profile-dropdown.blade.php index b3df4fd99..b0aac6e3e 100644 --- a/resources/views/layout/menu-profile-dropdown.blade.php +++ b/resources/views/layout/menu-profile-dropdown.blade.php @@ -32,7 +32,7 @@ @role('super admin')
  • - + @lang('menu.online_events')
  • diff --git a/resources/views/layout/new_base.blade.php b/resources/views/layout/new_base.blade.php index 3d92cc44c..740e21c88 100644 --- a/resources/views/layout/new_base.blade.php +++ b/resources/views/layout/new_base.blade.php @@ -1,7 +1,6 @@ - @include('layout.analytics') @@ -12,6 +11,8 @@ + @include('layout.anti-fouc') + @vite(['resources/assets/sass/app.scss', 'resources/js/app.js']) @@ -20,10 +21,7 @@ @stack('extra-css') - - {{-- @vite('resources/css/app.css')--}} - @vite(['resources/assets/sass/app.scss', 'resources/js/app.js']) - {{-- @vite(['resources/css/app.css', 'resources/js/app.js'])--}} + @include('layout.analytics')