marklogic-community / demo-cat

An application to help SEs find good demos and record bugs and RFEs on them. AngularJS talks to the MarkLogic database via the REST API.
Other
11 stars 17 forks source link

Hitting back button from detail page fails to re-run query #161

Closed dmcassel closed 9 years ago

dmcassel commented 9 years ago

On the search page, I click a facet. I click one of the results and go to the detail page. From the detail page, I click the browser's back button. I get back to the search page, but all results are showing instead of just those with the facet value I asked for.

joemfb commented 9 years ago

This bug is at the intersection of the search-ctrl and ml-search service, so I'll take a look

grtjn commented 9 years ago

Navigation to / usually causes recreation of ctrl. That often implies recreation of searchcontext. One way would be to save search state in request url, but more performant can be to put model in a factory to preserve them between instances of same ctrl..

grtjn commented 9 years ago

This issue also occurs in https://github.com/marklogic/slush-marklogic-node..

One issue is that re-entering the main page re-executes the instantiation of the SearchCtrl, and effectively flushes the model that was built in previous visit. That model is easy to preserve by putting it in a factory, and then get that injected as dependency of the Ctrl.

Second issue is that the ml-search tries to put facet selections into the browser url, and the current Ctrl code tries to read those when initializing the Ctrl. But often when you go back to home you don't add those params in the url, but merely link to /. What I did in the last demo is to bypass the fromParams call when model.search.results is defined.

These two changes together make the UI a bit faster as well, as it doesn't rerun search when you go back to home..

grtjn commented 9 years ago

@joemfb were you already working on this? From the looks of it I should be able to mimic the changed made in the other project here..

joemfb commented 9 years ago

I haven't started yet. I'd love to see what you did. PR?

grtjn commented 9 years ago

Okay, I'll do a PR tomorrow morning..

grtjn commented 9 years ago

Fixed in develop