Skip to content

Commit

Permalink
configurable point search
Browse files Browse the repository at this point in the history
  • Loading branch information
emre2038 committed Dec 13, 2023
1 parent e4ef3c6 commit ba17621
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 12 deletions.
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

0 comments on commit ba17621

Please sign in to comment.