mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
add product filter parameters on the group buy options and search pages, so that the bulk import product page filters can be preserved
This commit is contained in:
@@ -100,6 +100,14 @@ module Spree
|
||||
redirect_to edit_admin_product_url(@new)
|
||||
end
|
||||
|
||||
def group_buy_options
|
||||
@url_filters = ::ProductFilters.new.extract(request.query_parameters)
|
||||
end
|
||||
|
||||
def seo
|
||||
@url_filters = ::ProductFilters.new.extract(request.query_parameters)
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def find_resource
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
= render partial: 'spree/admin/shared/product_sub_menu'
|
||||
= render :partial => 'spree/admin/shared/product_tabs', :locals => { :current => 'Group Buy Options' }
|
||||
= render :partial => 'spree/shared/error_messages', :locals => { :target => @product }
|
||||
= render partial: 'spree/admin/shared/product_tabs', locals: { :current => 'Group Buy Options' }
|
||||
= render partial: 'spree/shared/error_messages', locals: { :target => @product }
|
||||
|
||||
= form_for [:admin, @product], :method => :put, :html => { :multipart => true } do |f|
|
||||
= form_for [:admin, @product], url: admin_product_url(@product, @url_filters), method: :put, html: { :multipart => true } do |f|
|
||||
%fieldset.no-border-top
|
||||
= render :partial => 'group_buy_form', :locals => { :f => f }
|
||||
= render :partial => 'spree/admin/shared/edit_resource_links'
|
||||
= render partial: 'group_buy_form', locals: { f: f }
|
||||
.form-buttons.filter-actions.actions
|
||||
= button t('spree.actions.update'), 'icon-refresh'
|
||||
%span.or= t('spree.or')
|
||||
= link_to t('spree.actions.cancel'), edit_admin_product_url(@product, @url_filters), id: 'cancel_link', class: 'button icon-remove'
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
= render partial: 'spree/admin/shared/product_sub_menu'
|
||||
= render :partial => 'spree/admin/shared/product_tabs', :locals => { :current => t(:search) }
|
||||
= render :partial => 'spree/shared/error_messages', :locals => { :target => @product }
|
||||
= render partial: 'spree/admin/shared/product_tabs', locals: { current: t(:search) }
|
||||
= render partial: 'spree/shared/error_messages', locals: { target: @product }
|
||||
|
||||
%div{ 'ng-app' => 'ofn.admin' }
|
||||
= form_for [:admin, @product], :method => :put, :html => { :multipart => true } do |f|
|
||||
= form_for [:admin, @product], url: admin_product_url(@product, @url_filters), method: :put, html: { :multipart => true } do |f|
|
||||
%fieldset.no-border-top
|
||||
= render :partial => 'seo_form', :locals => { :f => f }
|
||||
= render :partial => 'spree/admin/shared/edit_resource_links'
|
||||
.form-buttons.filter-actions.actions
|
||||
= button t('spree.actions.update'), 'icon-refresh'
|
||||
%span.or= t('spree.or')
|
||||
= link_to t('spree.actions.cancel'), edit_admin_product_url(@product, @url_filters), id: 'cancel_link', class: 'button icon-remove'
|
||||
|
||||
@@ -204,8 +204,30 @@ feature '
|
||||
expect(product.group_buy_unit_size).to eq(10.0)
|
||||
end
|
||||
|
||||
scenario "editing product Search" do
|
||||
scenario "loading editing product group buy options with url filters" do
|
||||
product = product = create(:simple_product, supplier: @supplier2)
|
||||
|
||||
visit spree.group_buy_options_admin_product_path(product, filter)
|
||||
|
||||
expected_cancel_link = Regexp.new(Regexp.escape(spree.edit_admin_product_path(product, filter)))
|
||||
expect(page).to have_link(I18n.t(:cancel), href: expected_cancel_link)
|
||||
end
|
||||
|
||||
scenario "editing product group buy options with url filter" do
|
||||
product = product = create(:simple_product, supplier: @supplier2)
|
||||
|
||||
visit spree.group_buy_options_admin_product_path(product, filter)
|
||||
choose('product_group_buy_1')
|
||||
fill_in 'Bulk unit size', with: '10'
|
||||
|
||||
click_button 'Update'
|
||||
|
||||
uri = URI.parse(current_url)
|
||||
expect("#{uri.path}?#{uri.query}").to eq spree.edit_admin_product_path(product, filter)
|
||||
end
|
||||
|
||||
scenario "editing product Search" do
|
||||
product = create(:simple_product, supplier: @supplier2)
|
||||
visit spree.edit_admin_product_path product
|
||||
within('#sidebar') { click_link 'Search' }
|
||||
fill_in 'Product Search Keywords', with: 'Product Search Keywords'
|
||||
@@ -217,6 +239,29 @@ feature '
|
||||
expect(product.meta_keywords).to eq('Product Search Keywords')
|
||||
end
|
||||
|
||||
scenario "loading editing product Search with url filters" do
|
||||
product = create(:simple_product, supplier: @supplier2)
|
||||
|
||||
visit spree.seo_admin_product_path(product, filter)
|
||||
|
||||
expected_cancel_link = Regexp.new(Regexp.escape(spree.edit_admin_product_path(product, filter)))
|
||||
expect(page).to have_link(I18n.t(:cancel), href: expected_cancel_link)
|
||||
end
|
||||
|
||||
scenario "editing product Search with url filter" do
|
||||
product = create(:simple_product, supplier: @supplier2)
|
||||
|
||||
visit spree.seo_admin_product_path(product, filter)
|
||||
|
||||
fill_in 'Product Search Keywords', with: 'Product Search Keywords'
|
||||
fill_in 'Notes', with: 'Just testing Notes'
|
||||
|
||||
click_button 'Update'
|
||||
|
||||
uri = URI.parse(current_url)
|
||||
expect("#{uri.path}?#{uri.query}").to eq spree.edit_admin_product_path(product, filter)
|
||||
end
|
||||
|
||||
scenario "loading product properties page including url filters", js: true do
|
||||
product = create(:simple_product, supplier: @supplier2)
|
||||
visit spree.admin_product_product_properties_path(product, filter)
|
||||
|
||||
Reference in New Issue
Block a user