Skip to content

Commit

Permalink
Support grid_view filter on [sr_map_search] shortcode
Browse files Browse the repository at this point in the history
  • Loading branch information
CodyReichert committed Feb 28, 2024
1 parent 3f549e1 commit 3e0ce66
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 14 deletions.
6 changes: 5 additions & 1 deletion src/assets/js/simply-rets-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,7 @@ function SimplyRETSMap() {

var vendor = document.getElementById('sr-map-search').dataset.vendor
var limit = document.getElementById('sr-map-search').dataset.limit
var settings = document.getElementById("sr-map-search").dataset.defaultSettings

this.element = 'sr-map-search';
this.bounds = [];
Expand All @@ -428,6 +429,7 @@ function SimplyRETSMap() {
this.siteRoot = window.location.href
this.vendor = vendor;
this.limit = limit;
this.settings = JSON.parse(settings);

this.map = new google.maps.Map(
document.getElementById('sr-map-search'), this.options
Expand Down Expand Up @@ -737,7 +739,8 @@ SimplyRETSMap.prototype.sendRequest = function(points, params, paginate) {
}

var offset = this.offset;
var vendor = this.vendor
var vendor = this.vendor;
var settings = this.settings;

/** URL Encode them all */
var pointsQ = $_.param(points);
Expand All @@ -752,6 +755,7 @@ SimplyRETSMap.prototype.sendRequest = function(points, params, paginate) {
data: {
action: 'update_int_map_data', // server controller
parameters: query,
settings: settings,
vendor: vendor
},
});
Expand Down
10 changes: 5 additions & 5 deletions src/simply-rets-maps.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,13 +163,13 @@ public static function update_int_map_data() {

header("Content-Type: application/json");

$markup_opts = array(
"show_map" => "false",
"vendor" => $vendor
);

$settings_ = $_POST['settings'];
$def_settings = array("show_map" => "false", "vendor" => $vendor);
$settings = array_merge($settings_, $def_settings);

$req = SimplyRetsApiHelper::makeApiRequest($_POST['parameters']);
$con = SimplyRetsApiHelper::srResidentialResultsGenerator($req, $markup_opts);
$con = SimplyRetsApiHelper::srResidentialResultsGenerator($req, $settings);

$response = array(
"result" => $req,
Expand Down
22 changes: 14 additions & 8 deletions src/simply-rets-shortcode.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,19 @@ public static function sr_int_map_search($atts) {
$agent_on_thumbnails = get_option('sr_agent_on_thumbnails', false);
$force_image_https = get_option('sr_listing_force_image_https', false);

$markup_settings = array(
"list_view" => false,
"search_form" => false,
"grid_view" => false
);

// Delete attributes that aren't API parameters
$default_parameters = array_diff_key($atts, [
"list_view" => true,
"search_form" => true
]);
$api_parameters = array_diff_key($atts, $markup_settings);
$api_parameters_json = json_encode($api_parameters);

// JSON encode the default search parameters for the frontend.
$default_parameters_json = json_encode($default_parameters);
// Delete attributes that are API parameters
$markup_settings = array_diff_key($atts, $api_parameters);
$markup_settings_json = json_encode($markup_settings);

$map_markup = "<div id='sr-map-search'
data-api-key='{$gmaps_key}'
Expand All @@ -78,10 +83,11 @@ public static function sr_int_map_search($atts) {
data-agent-on-thumbnails='{$agent_on_thumbnails}'
data-force-image-https='{$force_image_https}'
data-limit='{$limit}'
data-default-parameters='{$default_parameters_json}'
data-default-settings='{$markup_settings_json}'
data-default-parameters='{$api_parameters_json}'
data-vendor='{$vendor}'></div>";

$list_markup = !empty($atts['list_view'])
$list_markup = isset($atts["list_view"]) || isset($atts["grid_view"])
? "<div class=\"sr-map-search-list-view\"></div>"
: "";

Expand Down

0 comments on commit 3e0ce66

Please sign in to comment.