Skip to content

Introduce categories into navbar tags/search dropdown #11307

@jywarren

Description

@jywarren

def suggested
if !params[:id].empty? && params[:id].size > 2
@suggestions = SearchService.new.search_tags(params[:id])
render json: @suggestions.collect { |tag| tag.name }.uniq
else
render json: []
end
end

So when typing water this endpoint returns:

[
  "water",
  "water-samples",
  "waterkeepers",
  "water-sampling",
  "wateristic",
  "wateristics",
  "water-monitoring-network",
  "water-monitoring",
  "water-monitor",
  "water-sensing"
]

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions