flightplan-tool / flightplan

Search for award inventory using Node.js and Headless Chrome!
Apache License 2.0
142 stars 41 forks source link

Filtering by flight number doesn't work #15

Open ferni7 opened 5 years ago

ferni7 commented 5 years ago

This used to work in the old version, but ticking/unticking the flight number checkboxes no longer seems to apply any filter that I can tell?

jd20 commented 5 years ago

Probably a regression, will need to investigate.

ferni7 commented 5 years ago

Have you had a chance to look at this one at all?

jd20 commented 5 years ago

Sorry, I have not, will try to take a look soon.

johneakin commented 5 years ago

When a flight is filtered I seen it runs: @action toggleFlight(flight) { const { selectedFlights: sel } = this const key = flightKey(flight) const val = sel.has(key) ? !sel.get(key) : false sel.set(key, val)

// Propagate to airlines
if (val) {
  this.selectedAirlines.set(flight.airline, true)
}

}

What actually causes the chart to update though and remove any matches for the flight that has just been unchecked?

jd20 commented 5 years ago

All the filtering logic is in searchStore.js (which uses mobx, so it "magically" recomputes the result set whenever dependent variables like selectedAirlines changes). The airline and flight filtering happens in get awards (which uses the output of get results).

johneakin commented 5 years ago

many thanks for your response I am VERY new with React and mobx and have been attempting to reuse this UI for a different dataset (A much simpler one). Its all working apart from the filters. Hoping its something simple but I'm stuck. Are you on Skype? Would be helpful if you can spare 10mins :)

jd20 commented 5 years ago

E-mail me your skype, I'll try and help you out.

johneakin commented 5 years ago

thanks, I have emailed you

zubairv85 commented 5 years ago

I created a pull request that fixes this. It's a bit clunky with multi-segment routes in that if you unselect a segment of a particular route, it wont auto unselect the corresponding segment (assuming they were mutually exclusive). Like wise, for a route to show up, all flight segments must be selected.