diff --git a/app/helpers/filters_helper.rb b/app/helpers/filters_helper.rb index 0b37484be..f281c1007 100644 --- a/app/helpers/filters_helper.rb +++ b/app/helpers/filters_helper.rb @@ -10,4 +10,8 @@ module FiltersHelper name = params[key].is_a?(Array) ? "#{key}[]" : key hidden_field_tag name, value, id: nil end + + def filter_selected_collections_title(user_filtering) + user_filtering.selected_collection_titles.collect { tag.strong it }.to_sentence.html_safe + end end diff --git a/app/models/user/filtering.rb b/app/models/user/filtering.rb index fdc5fa415..74c436801 100644 --- a/app/models/user/filtering.rb +++ b/app/models/user/filtering.rb @@ -13,16 +13,18 @@ class User::Filtering @collections ||= user.collections.ordered_by_recently_accessed end - def collections_title + def selected_collection_titles if filter.collections.none? - collections.one? ? collections.first.name : "All collections" - elsif filter.collections.one? - filter.collections.first.name + [ collections.one? ? collections.first.name : "All collections" ] else - filter.collections.map(&:name).to_sentence + filter.collections.map(&:name) end end + def selected_collections_label + selected_collection_titles.to_sentence + end + def tags @tags ||= Tag.all.alphabetically end diff --git a/app/views/cards/index.html.erb b/app/views/cards/index.html.erb index 946370aef..7a3cf9d29 100644 --- a/app/views/cards/index.html.erb +++ b/app/views/cards/index.html.erb @@ -1,4 +1,4 @@ -<% @page_title = @user_filtering.collections_title %> +<% @page_title = @user_filtering.selected_collections_label %> <%= render "filters/broadcasts", filter: @filter %> @@ -16,7 +16,7 @@ <%= render "filters/menu/add_card_button", user_filtering: @user_filtering %>