-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce categories into navbar tags/search dropdown #11307
Comments
Actually i believe that this line shows that it doesn't sort the results at all -- it only shows a category header if the previous item is not of the same category type as the current one: That may mean that we can introduce the "search" option from the Ruby side, whether or not we use categories -- JavaScript really isn't re-ordering the returned results! |
So the steps would be:
render json: items
I may have missed some steps but that sounds like a good start! Does it make sense? |
@KarishmaVanwari let me know what you think about this! |
Hi @jywarren! |
Yes we can def. discuss Tuesday! It is a bit complex. I would break it into parts:
We could make a PR here and merge it if you want since it's all working OK at this point!
Now we could do another PR and merge
[
{id: "typeahead-search", name: "Search for 'water'", category: "search"},
{id: "typeahead-water-quality", name: "water-quality", category: "tags"},
{id: "typeahead-water-pollution", name: "water-pollution", category: "tags"}
] This will probably mean editing the outgoing Ruby Hash, doing something like this: https://stackoverflow.com/a/16573500 OK, this is a lot... let me know if it makes any sense, but the big message is, do it in small pieces and ask for clarifications along the way! You don't have to understand the whole thing at once, and you're learning a lot of moving pieces at the same time, so it's OK to solve one piece at a time. 🎉 |
Good day my name is jesutobi, i am an outreachy applicant, i would like to contribute on this issue |
Hey, can I work on this issue? |
plots2/app/controllers/tag_controller.rb
Lines 398 to 405 in 77188ba
So when typing
water
this endpoint returns:My guess from this code: https://github.com/bassjobsen/Bootstrap-3-Typeahead/blob/fc2d5dce4a5406d9b924224e395d5647918707c7/bootstrap3-typeahead.js#L335-L352
...is that if an item has an attribute "category" then they will be sorted by that category.
But above they are just strings. We should switch to the JSON type shown here: https://github.com/bassjobsen/Bootstrap-3-Typeahead#using-json-objects-instead-of-simple-strings
So we will need to modify
def suggested
above - and will have to be careful that doesn't break anything else (some other systems may depend on it returning a string -- https://github.com/publiclab/plots2/search?q=suggested shows a few!)So as not to break anything else, maybe we should use a params flag like
params[:json]
and the request should be like:https://publiclab.org/tag/suggested/water?json=true
?The text was updated successfully, but these errors were encountered: