Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

configurable point search #808

Merged
merged 2 commits into from
Dec 14, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/js/configurations/geography_sa.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ export class Config {
return false;
}

get pointSearchEnabled(){
if(this.config["point_search_enabled"] != undefined)
return this.config["point_search_enabled"];
return true;
}

get siteWideFiltersEnabled() {
if (this.config["site_wide_filters_enabled"] != undefined)
return this.config["site_wide_filters_enabled"];
Expand Down
27 changes: 16 additions & 11 deletions src/js/elements/header/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,14 @@ export class Search extends Component {
* constructor of the class
* sets the default values, calls init function(this.setSearchInput)
* */
constructor(parent, api, profileId, minChars) {
constructor(parent, api, profileId, minChars, config) {
super(parent);

minLength = minChars;
this.api = api;
this.profileId = profileId;
this.plate = null;
this.config = config;

this.prepareDomElements();
this.setSearchInput();
Expand All @@ -60,9 +61,11 @@ export class Search extends Component {

this.updateGeoSearchHeader(titleRow);
this.updateGeoSearch();
this.appendSearchSeparator();
this.appendPointsTitle(titleRow);
this.appendPointsNoData();
if (this.config.pointSearchEnabled) {
this.appendSearchSeparator();
this.appendPointsTitle(titleRow);
this.appendPointsNoData();
}
}

updateGeoSearchHeader(titleRow) {
Expand Down Expand Up @@ -282,13 +285,15 @@ export class Search extends Component {
response(data);
})

const mapCenter = self.getMapCenter();
self.api.searchPointsByDistance(self.profileId, searchTerm, mapCenter.lat, mapCenter.lng).then(data => {
self.removePointsNoData();
self.appendPointsHeaderRow();
self.appendPointsTable(searchTerm, data);
self.updatePointsHeaderSummary(data);
})
if (self.config.pointSearchEnabled) {
const mapCenter = self.getMapCenter();
self.api.searchPointsByDistance(self.profileId, searchTerm, mapCenter.lat, mapCenter.lng).then(data => {
self.removePointsNoData();
self.appendPointsHeaderRow();
self.appendPointsTable(searchTerm, data);
self.updatePointsHeaderSummary(data);
})
}
}, 0)
}
})
Expand Down
2 changes: 1 addition & 1 deletion src/js/load.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class Application extends Component {
const pointData = new PointData(this, api, mapcontrol.map, profileId, config);
const pointDataTray = new PointDataTray(this, api, profileId, config.watermarkEnabled, config.ccLicenseEnabled);
const mapchip = new MapChip(this, config.choropleth, config.siteWideFiltersEnabled, config.restrictValues, config.defaultFilters);
const search = new Search(this, api, profileId, 2);
const search = new Search(this, api, profileId, 2, config);
const profileLoader = new ProfileLoader(this, formattingConfig, api, profileId, config.config, config.watermarkEnabled, config.siteWideFiltersEnabled, config.restrictValues, config.defaultFilters, config.chartColorRange);
const locationInfoBox = new LocationInfoBox(this, formattingConfig);
const zoomToggle = new ZoomToggle(this);
Expand Down
Loading