mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-26 01:33:22 +00:00
Add tag search
First minimal implementation with a basic filter UI. Only support search by any of the selected tags
This commit is contained in:
@@ -112,6 +112,7 @@ module Admin
|
||||
@search_term = params[:search_term] || params[:_search_term]
|
||||
@producer_id = params[:producer_id] || params[:_producer_id]
|
||||
@category_id = params[:category_id] || params[:_category_id]
|
||||
@tags = params[:tags_name_in] || params[:_tags_name_in]
|
||||
end
|
||||
|
||||
def init_pagination_params
|
||||
@@ -160,6 +161,7 @@ module Admin
|
||||
query.merge!(Spree::Variant::SEARCH_KEY => @search_term)
|
||||
end
|
||||
query.merge!(variants_primary_taxon_id_in: @category_id) if @category_id.present?
|
||||
query.merge!(variants_tags_name_in: @tags) if @tags.present?
|
||||
query.merge!(@q) if @q
|
||||
|
||||
query
|
||||
@@ -176,6 +178,7 @@ module Admin
|
||||
:stock_items,
|
||||
:tax_category,
|
||||
:supplier,
|
||||
:taggings,
|
||||
] },
|
||||
]
|
||||
end
|
||||
|
||||
@@ -17,6 +17,9 @@
|
||||
= select_tag :category_id, options_for_select(category_options, category_id),
|
||||
include_blank: t('.all_categories'), class: "fullwidth",
|
||||
data: { "controller": "tom-select", 'tom-select-placeholder-value': t('.search_for_categories')}
|
||||
.tags
|
||||
= label_tag :tags_name_in, t('.tags.label')
|
||||
= select_tag :tags_name_in, options_for_select(ActsAsTaggableOn::Tag.for_context("variant_tag").distinct.order(:name).pluck(:name), @tags), { class: "fullwidth", multiple: true }
|
||||
.submit
|
||||
.search-button
|
||||
= button_tag t(".search"), class: "secondary icon-search relaxed", name: nil
|
||||
|
||||
@@ -973,6 +973,8 @@ en:
|
||||
label: Producers
|
||||
categories:
|
||||
label: Categories
|
||||
tags:
|
||||
label: Tags
|
||||
search: Search
|
||||
sort:
|
||||
pagination:
|
||||
|
||||
Reference in New Issue
Block a user