* wip * feat: ✨ Use MultiSelectAutocomplete for Tags * feat: ✨ Add additional tags for listings * refactor: ♻️ Use preact/hooks and refactor propTypes * fix: 🐛 Fix addiional tags support depending on the selected category - Add slug to returned array in select_options_for_categories helper - Differentiate the fields categoryId and categorySlug * fix: 🐛 Adjust propTypes * test: 🚨 Change test for select_options_for_categories helper * refactor: ♻️ Apply requested changes * refactor: ♻️ Remove border prop - default is true * test: 🚨 Add test suite for ListingTagsField component * refactor: ♻️ Apply requested changes * refactor: ♻️ Remove unnecessary forEach + Improve code legibility * docs: 📚 Remove topTags from hook documentation * refactor: ♻️ Use the alias for crayons folder + Use loclaCompare in sort * test: 🚨 Clean up mock response * fix: 🐛 Reorder styles * style: 🎨 Add comment to TagAutocompleteOption/Selection components
19 lines
560 B
Ruby
19 lines
560 B
Ruby
module ListingHelper
|
|
def select_options_for_categories
|
|
ListingCategory.select(:id, :slug, :name, :cost).map do |cl|
|
|
[I18n.t("helpers.listing_helper.option", cl_name: cl.name, count: cl.cost), cl.slug, cl.id]
|
|
end
|
|
end
|
|
|
|
def categories_for_display
|
|
ListingCategory.pluck(:slug, :name).map do |slug, name|
|
|
{ slug: slug, name: name }
|
|
end
|
|
end
|
|
|
|
def categories_available
|
|
ListingCategory.all.each_with_object({}) do |cat, h|
|
|
h[cat.slug] = cat.attributes.slice("cost", "name", "rules")
|
|
end.deep_symbolize_keys
|
|
end
|
|
end
|