mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
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:
7
app/controllers/admin/products_controller.rb
Normal file
7
app/controllers/admin/products_controller.rb
Normal file
@@ -0,0 +1,7 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Admin
|
||||
class ProductsController < Spree::Admin::BaseController
|
||||
def index; end
|
||||
end
|
||||
end
|
||||
14
app/views/admin/products/_product.html.haml
Normal file
14
app/views/admin/products/_product.html.haml
Normal 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
|
||||
13
app/views/admin/products/index.html.haml
Normal file
13
app/views/admin/products/index.html.haml
Normal 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
|
||||
@@ -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'
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user