Skip to content

Commit

Permalink
Admin page has multiselect for dropdown filters
Browse files Browse the repository at this point in the history
  • Loading branch information
otrok7 committed Dec 9, 2023
1 parent 66375f4 commit bfbff27
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
37 changes: 37 additions & 0 deletions crouton.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -735,6 +755,18 @@ public function adminOptionsPage()
</div>
</div>
</div>
<div style="padding: 0 15px;" class="postbox">
<h3><a id="config-select-dropdown-filters" class="anchor"></a>Select Dropdown Filters</h3>
<div class="inside">

<select class="chosen-select" style="width: 100%;" data-placeholder="select filters" id="select_filters" name="select_filters[]" multiple="multiple"><?php
foreach ($this->hasFilters as $hasFilter) {?>
<option <?php echo empty($this->options[$hasFilter]) ? "" : "selected='selected' "?> value="<?php echo $hasFilter;?>"><?php echo $hasFilter;?></option>
<?php
}?>
</select>
</div>
</div>
<div style="padding: 0 15px;" class="postbox">
<h3><a id="config-custom-query" class="anchor"></a>Custom Query</h3>
<p>This will allow to specify a custom BMLT query. This will override any other filtering including service bodies.</p>
Expand Down Expand Up @@ -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.
Expand Down
4 changes: 4 additions & 0 deletions js/bmlt_tabs_admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -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%",
Expand Down

0 comments on commit bfbff27

Please sign in to comment.