Order tags to search by alphabetically

We were ordering one group of tags alphabetically and then adding
another group of tags which wasn't ordered alphabetically, which didn't
make much sense.
This commit is contained in:
Javi Martín
2019-10-31 21:45:57 +01:00
parent fb2b821c28
commit beae82aae8

View File

@@ -54,9 +54,10 @@ module BudgetsHelper
end end
def investment_tags_select_options(budget, context) def investment_tags_select_options(budget, context)
tags = budget.investments.tags_on(context).order(:name).pluck(:name) taggables = [budget] + budget.investments
tags = tags.concat budget.tag_list_on(context) Tag.joins(:taggings)
tags.uniq .merge(Tagging.where(taggable: taggables, context: context))
.distinct.order(:name).pluck(:name)
end end
def unfeasible_or_unselected_filter def unfeasible_or_unselected_filter