Compare commits
No commits in common. "53b92624d18111049788298f2ce20ccfbb5ffdcf" and "38389f6fd790eea6eeb1d9392673f47394fec363" have entirely different histories.
53b92624d1
...
38389f6fd7
|
@ -1 +1 @@
|
|||
Subproject commit 3f8687f95163c418e6c8c67d913961339a5e4426
|
||||
Subproject commit e62934504bf2d33b65d0282a8d311df9cecb178e
|
|
@ -4,10 +4,8 @@ namespace Silva\Adrema\Components;
|
|||
|
||||
use Cms\Classes\ComponentBase;
|
||||
use Cms\Classes\Page;
|
||||
use FetchAllEvents;
|
||||
use Silva\Adrema\Exceptions\ComponentException;
|
||||
use Silva\Adrema\Models\Settings;
|
||||
use Silva\Adrema\Support\FetchAllEvents as SupportFetchAllEvents;
|
||||
|
||||
class EventIndex extends ComponentBase
|
||||
{
|
||||
|
@ -15,9 +13,7 @@ class EventIndex extends ComponentBase
|
|||
public $settings;
|
||||
|
||||
/** @var string The active event */
|
||||
public ?string $eventSlug;
|
||||
public ?array $event;
|
||||
public string $currentUrl;
|
||||
public ?string $event;
|
||||
|
||||
public function componentDetails()
|
||||
{
|
||||
|
@ -30,22 +26,12 @@ class EventIndex extends ComponentBase
|
|||
public function onRun()
|
||||
{
|
||||
$this->addJs('assets/vendor/adrema-form/dist/main.js');
|
||||
$this->currentUrl = url()->current();
|
||||
// $this->addJs('http://localhost:5174/src/main.js', ['type' => 'module']);
|
||||
|
||||
$this->settings = [
|
||||
'primary_color' => Settings::get('primary_color'),
|
||||
...$this->resolvePageUrls(),
|
||||
];
|
||||
$this->eventSlug = $this->property('eventSlug');
|
||||
|
||||
if ($this->eventSlug) {
|
||||
$events = data_get(app(SupportFetchAllEvents::class)->run(), 'data');
|
||||
throw_if(is_null($events), ComponentException::class, 'event_fetching_failed');
|
||||
|
||||
$this->event = collect($events)->first(fn ($event) => $event['slug'] === $this->eventSlug);
|
||||
$this->page->title = $this->event['name'];
|
||||
}
|
||||
$this->event = $this->property('event');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -95,8 +81,8 @@ class EventIndex extends ComponentBase
|
|||
'type' => 'dropdown',
|
||||
'default' => null,
|
||||
],
|
||||
'eventSlug' => [
|
||||
'title' => __('properties.event_slug_title'),
|
||||
'event' => [
|
||||
'title' => __('properties.event_title'),
|
||||
'type' => 'text',
|
||||
'default' => null,
|
||||
],
|
||||
|
|
|
@ -1,18 +1,8 @@
|
|||
{% if __SELF__.event %}
|
||||
{% put metatags %}
|
||||
<meta property="og:title" content="{{__SELF__.event.name}}">
|
||||
<meta property="og:url" content="{{__SELF__.currentUrl}}">
|
||||
<meta property="og:description" content="{{__SELF__.event.excerpt}}">
|
||||
<meta property="og:image" content="{{__SELF__.event.image}}">
|
||||
<meta property="og:type" content="article">
|
||||
{% endput %}
|
||||
{% endif %}
|
||||
|
||||
<event-index
|
||||
style="--primary: {{__SELF__.settings.primary_color}}; --primaryfg: #d1f8ff; --secondary: #800a19; --font: hsl(181, 84%, 78%); --circle: hsl(181, 86%, 16%)"
|
||||
index-url="{{__SELF__.settings.indexUrl}}"
|
||||
single-url="{{__SELF__.settings.singleUrl}}"
|
||||
register-url="{{__SELF__.settings.registerUrl}}"
|
||||
url="/api/silva_adrema_event_overview"
|
||||
{% if __SELF__.event %} event="{{__SELF__.event.slug }}" {% endif %}
|
||||
{% if __SELF__.event %} event="{{__SELF__.event }}" {% endif %}
|
||||
></event-index>
|
||||
|
|
|
@ -5,5 +5,5 @@
|
|||
"properties.index_page_title": "Seite für Übersicht",
|
||||
"properties.single_page_title": "Seite für Einzelansicht",
|
||||
"properties.register_page_title": "Seite zum anmelden",
|
||||
"properties.event_slug_title": "Veranstaltung slug"
|
||||
"properties.event_title": "Veranstaltung slug"
|
||||
}
|
||||
|
|
|
@ -5,9 +5,8 @@
|
|||
"properties.index_page_title": "Page for overview",
|
||||
"properties.single_page_title": "Page for single view",
|
||||
"properties.register_page_title": "Page for registration",
|
||||
"properties.event_slug_title": "Event slug",
|
||||
"properties.event_title": "Event slug",
|
||||
"errors.not_all_pages_set": "You didn't assign all pages. Please edit your components.",
|
||||
"errors.page_not_found": "One page cannot be found. Event component cannot be rendered.",
|
||||
"errors.slug_not_found": "You need to set a placeholder in page urls to set the event slug (\":slug\")",
|
||||
"errors.event_fetching_failed": "Failed to fetch event."
|
||||
"errors.slug_not_found": "You need to set a placeholder in page urls to set the event slug (\":slug\")"
|
||||
}
|
||||
|
|
|
@ -1,13 +1,14 @@
|
|||
<?php
|
||||
|
||||
use Silva\Adrema\Support\FetchAllEvents;
|
||||
use Silva\Adrema\Models\Settings;
|
||||
|
||||
Route::get('/api/silva_adrema_event_overview', function () {
|
||||
$events = app(FetchAllEvents::class)->run();
|
||||
$baseUrl = Settings::get('base_url');
|
||||
$response = Http::get($baseUrl . '/api/form');
|
||||
|
||||
if (is_null($events)) {
|
||||
if (!$response->ok()) {
|
||||
return Response::json(['message' => 'Fehler beim Laden der Veranstaltungen'], 422);
|
||||
}
|
||||
|
||||
return Response::json($events);
|
||||
return Response::json($response->json());
|
||||
})->middleware('api');
|
||||
|
|
|
@ -1,21 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Silva\Adrema\Support;
|
||||
|
||||
use Silva\Adrema\Models\Settings;
|
||||
use Http;
|
||||
|
||||
class FetchAllEvents
|
||||
{
|
||||
public function run(): ?array
|
||||
{
|
||||
$baseUrl = Settings::get('base_url');
|
||||
$response = Http::get($baseUrl . '/api/form');
|
||||
|
||||
if (!$response->ok()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $response->json();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue