From bfbff2743e7cc39e21aa6ec215040564bb975f9b Mon Sep 17 00:00:00 2001 From: otrok7 <50595291+otrok7@users.noreply.github.com> Date: Sat, 9 Dec 2023 18:48:57 +0100 Subject: [PATCH] Admin page has multiselect for dropdown filters --- crouton.php | 37 +++++++++++++++++++++++++++++++++++++ js/bmlt_tabs_admin.js | 4 ++++ 2 files changed, 41 insertions(+) diff --git a/crouton.php b/crouton.php index f808e75..ae92cfb 100644 --- a/crouton.php +++ b/crouton.php @@ -110,6 +110,22 @@ class Crouton "has_meeting_count" => false, "google_api_key" => "" ); + private $hasFilters = [ + "has_days", + "has_groups", + "has_areas", + "has_regions", + "has_cities", + "has_formats", + "has_locations", + "has_sub_province", + "has_neighborhoods", + "has_states", + "has_languages", + "has_zip_codes", + "has_venues", + "has_common_needs" + ]; private MeetingMap\Controller $meetingMapController; public function __construct() { @@ -516,6 +532,10 @@ public function adminOptionsPage() $this->options['meetingpage_contents_template'] = isset($_POST['meetingpage_contents_template']) ? str_replace('\\', '', $_POST['meetingpage_contents_template']) : ""; $this->options['theme'] = $_POST['theme']; $this->options['recurse_service_bodies'] = isset($_POST['recurse_service_bodies']) ? $_POST['recurse_service_bodies'] : "0"; + $postFilters = isset($_POST['select_filters']) ? $_POST['select_filters'] : array(); + foreach ($this->hasFilters as $hasFilter) { + $this->options[$hasFilter] = in_array($hasFilter, $postFilters); + } $this->options['extra_meetings'] = isset($_POST['extra_meetings']) ? $_POST['extra_meetings'] : array(); $this->options['extra_meetings_enabled'] = isset($_POST['extra_meetings_enabled']) ? intval($_POST['extra_meetings_enabled']) : "0"; $this->meetingMapController->processUpdate($this->options); @@ -735,6 +755,18 @@ public function adminOptionsPage() +
+

Select Dropdown Filters

+
+ + +
+

Custom Query

This will allow to specify a custom BMLT query. This will override any other filtering including service bodies.

@@ -898,6 +930,11 @@ private function getOptions() $this->options['meeting_data_template'] = str_replace('{{this.meeting_name}}', "{{> meetingLink this}}", $this->options['meeting_data_template']); } } + foreach ($this->hasFilters as $hasFilter) { + if (!isset($this->options[$hasFilter])) { + $this->options[$hasFilter] = $this->shortCodeOptions[$hasFilter]; + } + } } /** * Saves the admin options to the database. diff --git a/js/bmlt_tabs_admin.js b/js/bmlt_tabs_admin.js index 4ff844e..5f71011 100644 --- a/js/bmlt_tabs_admin.js +++ b/js/bmlt_tabs_admin.js @@ -55,6 +55,10 @@ jQuery(document).ready(function($) { inherit_select_classes: true, width: "20%" }); + $("#select_filters").chosen({ + inherit_select_classes: true, + width: "60%" + }); $("#extra_meetings").chosen({ no_results_text: "Oops, nothing found!", width: "60%",