Closed ansonphong closed 8 years ago
It's worth noting, that the author_name
field works and populates the URL - the bug is that the URL isn't populating the form or query.
how is the auto-complete directive capturing the author name as input?
it's using an AJAX function which is querying the users, using AngularUI Boostrap "Typeahead" directive on the front-end.
i guess it needs special handling on loading of the form, because the field name is called username, and the url has author_name, i need to do some mapping here, i will check now.
Oh now I recall - this is the reason - there is an isolated scope within the autocomplete controller, and there is an emit action which happens when it's set. That emit action sets it in the query model.
So what I'd suggest we do is a broadcast which tells the isolated scope to update the username. This makes it very clean and modular, so we don't need to include the autocomplete module scope within the parent controller.
Do you agree with this approach?
Sounds good, i just need to fit it within the liveFeed cycle, which loads the feed settings first then query string, then populates the search panel. i am working on that now.
Phong, after working on that, it turns out that autocomplete - the way it is implemented - will not allow me to do just that. The problem is that we need to set the initial username variable of autocomplete before it gets into the loop of emit/broadcast.
Broadcast/emit events do not work on autocomplete controller until it is created. and because it is created after the filterfeed directive, it does not catch the setting of the username to the url query string. any broadcasts sent before its creation are not caught.
The better solution for this is to convert autocomplete into a directive and pass the username [feedQuery.author_name] as an attribute to it from the filterfeed. That would be the ideal solution.
If we do this, we will need to do some rewrite to that controller and the places that are using it. There is however a simple/unclean hack that sets the default username using $scope.$parent, only for this search page. I tried it already and it works.
i can do it both ways, but i need your advice first.
Here is an example where when searching for an author from query vars, the value is not making it into the query or the form