Create a new controller for new products page

Controller is constrained by FeatureToggle

- new_products_page
 - and available on '/new_products'

Add simple view for new products page and a product

Add new products page as a new entry in the menu
This commit is contained in:
Jean-Baptiste Bellet
2022-03-14 17:25:51 +01:00
parent 2aea5d4957
commit d7d29e3654
5 changed files with 40 additions and 0 deletions

View File

@@ -0,0 +1,7 @@
# frozen_string_literal: true
module Admin
class ProductsController < Spree::Admin::BaseController
def index; end
end
end

View File

@@ -0,0 +1,14 @@
%div.product
= if product.images[0]
%div.image
%img{src: product.images[0].attachment.url(:mini, false) }
%div.title
= product.name
%div.unit
= product.unit_value
= product.variant_unit
%div.price
= product.price
%pre
= product.to_json

View File

@@ -0,0 +1,13 @@
- content_for :page_title do
New Products Page
= render partial: 'spree/admin/shared/product_sub_menu'
%div
%input.search{type: 'text', placeholder: 'Search', id: 'search_query'}
%button.btn.btn-primary{type: 'submit'}
Filter results
#new_products
= render partial: "product", collection: @products

View File

@@ -4,3 +4,5 @@
= tab :properties
= tab :variant_overrides, url: main_app.admin_inventory_path, match_path: '/inventory'
= tab :import, url: main_app.admin_product_import_path, match_path: '/product_import'
- if feature?(:new_products_page, spree_current_user)
= tab :new_products, url: main_app.admin_new_products_path, match_path: '/new_products'

View File

@@ -67,6 +67,10 @@ Openfoodnetwork::Application.routes.draw do
post '/product_import/save_data', to: 'product_import#save_data', as: 'product_import_save_async'
post '/product_import/reset_absent', to: 'product_import#reset_absent_products', as: 'product_import_reset_async'
constraints FeatureToggleConstraint.new(:new_products_page) do
get '/new_products', to: 'products#index'
end
resources :variant_overrides do
post :bulk_update, on: :collection
post :bulk_reset, on: :collection