mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-02 21:57:17 +00:00
Merge pull request #11383 from jibees/11274-buu-as-a-single-producer-i-should-not-be-able-to-see-the-producer-dropdown
🚧 Products V3: Do not display "Producers" selector if only one is possible
This commit is contained in:
@@ -2,9 +2,10 @@
|
||||
.query
|
||||
.search-input
|
||||
= text_field_tag :search_term, search_term, placeholder: t('.search_products')
|
||||
.producers
|
||||
.label= t('.producers.label')
|
||||
= select_tag :producer_id, options_for_select(producer_options, producer_id), include_blank: t('.all_producers'), "data-controller": "tom-select", "data-tom-select-options-value": '{ "plugins": [] }', class: "fullwidth"
|
||||
- if producer_options.many?
|
||||
.producers
|
||||
.label= t('.producers.label')
|
||||
= select_tag :producer_id, options_for_select(producer_options, producer_id), include_blank: t('.all_producers'), "data-controller": "tom-select", "data-tom-select-options-value": '{ "plugins": [] }', class: "fullwidth"
|
||||
.categories
|
||||
.label= t('.categories.label')
|
||||
= select_tag :category_id, options_for_select(category_options, category_id), include_blank: t('.all_categories'), "data-controller": "tom-select", "data-tom-select-options-value": '{ "plugins": [] }', class: "fullwidth"
|
||||
|
||||
44
spec/views/admin/products_v3/_filters.html.haml_spec.rb
Normal file
44
spec/views/admin/products_v3/_filters.html.haml_spec.rb
Normal file
@@ -0,0 +1,44 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require "spec_helper"
|
||||
|
||||
describe "admin/products_v3/_filters.html.haml" do
|
||||
subject { render }
|
||||
|
||||
let(:locals) do
|
||||
{
|
||||
search_term: "",
|
||||
producer_options: [],
|
||||
producer_id: nil,
|
||||
category_options: [],
|
||||
category_id: nil,
|
||||
}
|
||||
end
|
||||
|
||||
it "shows the producer filter when there are options" do
|
||||
allow(view).to receive_messages locals.merge(
|
||||
producer_options: [
|
||||
["Ada's Apples", 1],
|
||||
["Ben's Bananas", 2],
|
||||
],
|
||||
)
|
||||
|
||||
is_expected.to have_content "Producers"
|
||||
is_expected.to have_select "producer_id", options: [
|
||||
"All producers",
|
||||
"Ada's Apples",
|
||||
"Ben's Bananas",
|
||||
], selected: nil
|
||||
end
|
||||
|
||||
it "doesn't show the producer filter when there's only one option" do
|
||||
allow(view).to receive_messages locals.merge(
|
||||
producer_options: [
|
||||
["Ada's Apples", 1],
|
||||
],
|
||||
)
|
||||
|
||||
is_expected.to have_no_content "Producers"
|
||||
is_expected.to have_no_select "producer_id"
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user