diff --git a/source/changelog.txt b/source/changelog.txt index d29676b..4f00a24 100644 --- a/source/changelog.txt +++ b/source/changelog.txt @@ -1,5 +1,6 @@ ### [Unreleased] #### Added +- Display "Show more events" button below the events list #### Changed #### Deprecated #### Removed diff --git a/source/connector-mobilizon.php b/source/connector-mobilizon.php index c90a4d0..6c9097a 100644 --- a/source/connector-mobilizon.php +++ b/source/connector-mobilizon.php @@ -56,7 +56,8 @@ final class Mobilizon_Connector { $settings = array( 'isShortOffsetNameShown' => MobilizonConnector\Settings::isShortOffsetNameShown(), 'locale' => str_replace('_', '-', get_locale()), - 'timeZone' => wp_timezone_string() + 'timeZone' => wp_timezone_string(), + 'url' => MobilizonConnector\Settings::getUrl() ); wp_add_inline_script($scriptName, 'var MOBILIZON_CONNECTOR = ' . json_encode($settings), 'before'); } diff --git a/source/front/blocks/events-list/edit.js b/source/front/blocks/events-list/edit.js index f8de8a3..e1c28e9 100644 --- a/source/front/blocks/events-list/edit.js +++ b/source/front/blocks/events-list/edit.js @@ -1,3 +1,4 @@ +/* eslint-disable jsx-a11y/anchor-is-valid */ /* eslint-disable @wordpress/i18n-ellipsis */ import { clearEventsList, @@ -30,9 +31,12 @@ export default ({ attributes, setAttributes }) => { clearEventsList(container) showLoadingIndicator(container) let url = `/wp-json/connector-mobilizon/v1/events?eventsCount=${eventsCount}` + let showMoreUrl = window.MOBILIZON_CONNECTOR.url if (groupName) { + showMoreUrl += '/@' + groupName + '/events' url += `&groupName=${groupName}` } + container.querySelector('a').href = showMoreUrl await fetch(url) .then((response) => response.text()) .then((data) => { @@ -55,7 +59,9 @@ export default ({ attributes, setAttributes }) => { }, []) function updateEventsCount(event) { let newValue = Number(event.target.value) - if (newValue < 1) newValue = 1 + if (newValue < 1) { + newValue = 1 + } setAttributes({ eventsCount: newValue }) reloadEventList(newValue, attributes.groupName) } @@ -108,6 +114,13 @@ export default ({ attributes, setAttributes }) => { {__('Loading...', '')} + + {__('Show more events', '')} + , ] } diff --git a/source/includes/EventsListBlock.php b/source/includes/EventsListBlock.php index c130cf5..3bdd25b 100644 --- a/source/includes/EventsListBlock.php +++ b/source/includes/EventsListBlock.php @@ -43,8 +43,10 @@ class EventsListBlock { ob_start(); try { + $showMoreUrl = Settings::getUrl(); if ($groupName) { $events = GraphQlClient::get_upcoming_events_by_group_name($url, (int) $eventsCount, $groupName); + $showMoreUrl .= '/@' . $groupName . '/events'; } else { $events = GraphQlClient::get_upcoming_events($url, (int) $eventsCount); } diff --git a/source/includes/EventsListShortcut.php b/source/includes/EventsListShortcut.php index 0a2024d..742e132 100644 --- a/source/includes/EventsListShortcut.php +++ b/source/includes/EventsListShortcut.php @@ -26,8 +26,10 @@ class EventsListShortcut { ob_start(); try { + $showMoreUrl = Settings::getUrl(); if ($groupName) { $events = GraphQlClient::get_upcoming_events_by_group_name($url, (int) $eventsCount, $groupName); + $showMoreUrl .= '/@' . $groupName . '/events'; } else { $events = GraphQlClient::get_upcoming_events($url, (int) $eventsCount); } diff --git a/source/includes/EventsListWidget.php b/source/includes/EventsListWidget.php index 68876ab..0726a7b 100644 --- a/source/includes/EventsListWidget.php +++ b/source/includes/EventsListWidget.php @@ -26,8 +26,10 @@ class EventsListWidget extends \WP_Widget { $classNamePrefix = NAME; try { + $showMoreUrl = Settings::getUrl(); if ($groupName) { $events = GraphQlClient::get_upcoming_events_by_group_name($url, (int) $eventsCount, $groupName); + $showMoreUrl .= '/@' . $groupName . '/events'; } else { $events = GraphQlClient::get_upcoming_events($url, (int) $eventsCount); } diff --git a/source/view/events-list.php b/source/view/events-list.php index 356628e..b7e4a66 100644 --- a/source/view/events-list.php +++ b/source/view/events-list.php @@ -23,4 +23,7 @@ if (!defined('ABSPATH')) { + + +