Skip to content

armgit / spree

Public Imported from GitHub
0

Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.

Search properties in Admin by filterable status (#11258)

Virginia Nguyenc48e1ac00991
diff --git a/backend/app/views/spree/admin/properties/index.html.erb b/backend/app/views/spree/admin/properties/index.html.erb
index b0b628dec2..9d810f4e23 100644
--- a/backend/app/views/spree/admin/properties/index.html.erb
+++ b/backend/app/views/spree/admin/properties/index.html.erb
@@ -28,6 +28,16 @@
</div>
</div>
+ <div class="row">
+ <div class="col-12 col-lg-6">
+ <div class="form-group">
+ <%= label_tag :q_filterable_eq, Spree.t(:filterable_status) %>
+ <%= f.select :filterable_eq, options_for_select([[Spree.t(:filterable), true], [Spree.t(:non_filterable), false]]), { include_blank: true }, class: 'select2-clear js-filterable' %>
+ </div>
+ </div>
+ </div>
+ </div>
+
<div class="form-actions" data-hook="admin_pproperties_index_search_buttons">
<%= button Spree.t(:search), 'search.svg' %>
</div>
diff --git a/backend/spec/features/admin/products/properties_spec.rb b/backend/spec/features/admin/products/properties_spec.rb
index c3983a2f9e..3bc61dc579 100644
--- a/backend/spec/features/admin/products/properties_spec.rb
+++ b/backend/spec/features/admin/products/properties_spec.rb
@@ -9,8 +9,8 @@ describe 'Properties', type: :feature, js: true do
context 'Property index' do
before do
- create(:property, name: 'shirt size', presentation: 'size')
- create(:property, name: 'shirt fit', presentation: 'fit')
+ create(:property, name: 'shirt size', presentation: 'size', filterable: true)
+ create(:property, name: 'shirt fit', presentation: 'fit', filterable: false)
visit spree.admin_properties_path
end
@@ -38,6 +38,16 @@ describe 'Properties', type: :feature, js: true do
expect(page).not_to have_content('shirt fit')
end
+ it 'search by filterable status' do
+ click_on 'Filter'
+ select 'Filterable', from: 'Filterable Status'
+
+ click_on 'Search'
+
+ expect(page).to have_content('shirt size')
+ expect(page).not_to have_content('shirt fit')
+ end
+
it 'renders selected filters' do
click_on 'Filter'
diff --git a/core/app/models/spree/property.rb b/core/app/models/spree/property.rb
index 44ff82aa14..e66101bd30 100644
--- a/core/app/models/spree/property.rb
+++ b/core/app/models/spree/property.rb
@@ -18,7 +18,7 @@ module Spree
after_touch :touch_all_products
after_save :ensure_product_properties_have_filter_params
- self.whitelisted_ransackable_attributes = ['presentation']
+ self.whitelisted_ransackable_attributes = ['presentation', 'filterable']
def uniq_values(product_properties_scope: nil)
with_uniq_values_cache_key(product_properties_scope) do