Skip to content

Commit

Permalink
Merge pull request #320 from data-mermaid/M775
Browse files Browse the repository at this point in the history
[M775] Fix dashboard org filtering bug
  • Loading branch information
saanobhaai authored May 13, 2024
2 parents 09dc625 + 821436d commit effa47d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
7 changes: 5 additions & 2 deletions src/components/LeafletMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,11 @@ class LeafletMap extends Component {
if (markersData.length === 0) {
this.map.setView(mapProperty.center, mapProperty.zoom)
} else {
const mapBounds = markersCluster.getBounds().pad(0.1)
const markerBounds = markersCluster.getBounds()

this.map.fitBounds(markerBounds)

const mapBounds = this.map.getBounds()
const mapBoundingBox = this.createBoundingBox(mapBounds)
const mapBoundingBoxCorner = mapBounds.getSouth()

Expand All @@ -613,7 +617,6 @@ class LeafletMap extends Component {
mapBounds,
})

this.map.fitBounds(mapBounds)
getMapBounds(mapBoundingBox)
}

Expand Down
18 changes: 9 additions & 9 deletions src/components/MermaidDash.js
Original file line number Diff line number Diff line change
Expand Up @@ -546,10 +546,9 @@ class MermaidDash extends Component {

return sites.reduce((newSites, site) => {
const { longitude, latitude } = site[1][0]
const point = [longitude, latitude]

for (const { x, y } of bboxList) {
if (point[0] >= x[0] && point[0] <= x[1] && point[1] >= y[0] && point[1] <= y[1]) {
if (longitude >= x[0] && longitude <= x[1] && latitude >= y[0] && latitude <= y[1]) {
newSites.push(site)
}
}
Expand All @@ -570,7 +569,8 @@ class MermaidDash extends Component {
})
}

filterUpdate = (queryStrings = []) => {
filterUpdate = () => {
const queryStrings = new URLSearchParams()
const { filterParams } = this.state
const countryProperty = Object.entries(filterParams)[0]
const projectIdProperty = Object.entries(filterParams)[1]
Expand All @@ -579,28 +579,28 @@ class MermaidDash extends Component {
const sampleDateBeforeProperty = Object.entries(filterParams)[4]

if (countryProperty[1].length > 0) {
queryStrings.push([countryProperty[0], countryProperty[1].join(',')].join('='))
queryStrings.append(`${countryProperty[0]}`, `${countryProperty[1].join(',')}`)
}

if (projectIdProperty[1].length > 0) {
queryStrings.push([projectIdProperty[0], projectIdProperty[1].join(',')].join('='))
queryStrings.append(`${projectIdProperty[0]}`, `${projectIdProperty[1].join(',')}`)
}

if (organizationIdProperty[1].length > 0) {
queryStrings.push([organizationIdProperty[0], organizationIdProperty[1].join(',')].join('='))
queryStrings.append(`${organizationIdProperty[0]}`, `${organizationIdProperty[1].join(',')}`)
}

if (sampleDateAfterProperty[1].length > 0) {
queryStrings.push([sampleDateAfterProperty[0], sampleDateAfterProperty[1]].join('='))
queryStrings.append(`${sampleDateAfterProperty[0]}`, `${sampleDateAfterProperty[1]}`)
}
if (sampleDateBeforeProperty[1].length > 0) {
queryStrings.push([sampleDateBeforeProperty[0], sampleDateBeforeProperty[1]].join('='))
queryStrings.append(`${sampleDateBeforeProperty[0]}`, `${sampleDateBeforeProperty[1]}`)
}

// eslint-disable-next-line
this.props.history.push({
pathname: '/',
search: `?${queryStrings.join('&')}`,
search: `?${queryStrings.toString()}`,
})

window.location.reload()
Expand Down

0 comments on commit effa47d

Please sign in to comment.