diff --git a/app/views/admin/enterprises/_form.html.haml b/app/views/admin/enterprises/_form.html.haml index dcaae1a149..87aeaa2d29 100644 --- a/app/views/admin/enterprises/_form.html.haml +++ b/app/views/admin/enterprises/_form.html.haml @@ -9,6 +9,12 @@ %fieldset.alpha.no-border-bottom{ id: "#{item[:name]}_panel", data: { "tabs-and-panels-target": "panel" }} %legend= t(".#{ item[:name] }.legend") + - when 'vouchers' + - if feature?(:vouchers, spree_current_user) + %fieldset.alpha.no-border-bottom{ id: "#{item[:name]}_panel", data: { "tabs-and-panels-target": "panel" }} + %legend= t(".#{ item[:form_name] || item[:name] }.legend") + = render "admin/enterprises/form/#{ item[:form_name] || item[:name] }", f: f + - else %fieldset.alpha.no-border-bottom{ id: "#{item[:name]}_panel", data: { "tabs-and-panels-target": "panel" }} %legend= t(".#{ item[:form_name] || item[:name] }.legend") diff --git a/app/views/admin/shared/_side_menu.html.haml b/app/views/admin/shared/_side_menu.html.haml index 18c9e4a04b..f9f38610bd 100644 --- a/app/views/admin/shared/_side_menu.html.haml +++ b/app/views/admin/shared/_side_menu.html.haml @@ -1,7 +1,7 @@ .side_menu#side_menu - if @enterprise - enterprise_side_menu_items(@enterprise).each do |item| - - next unless item[:show] + - next if !item[:show] || (item[:name] == 'vouchers' && !feature?(:vouchers, spree_current_user)) %a.menu_item{ href: item[:href] || "##{item[:name]}_panel", id: item[:name], data: { action: "tabs-and-panels#changeActivePanel tabs-and-panels#changeActiveTab", "tabs-and-panels-target": "tab" }, class: item[:selected] } %i{ class: item[:icon_class] } %span= t(".enterprise.#{item[:name] }") diff --git a/config/routes/admin.rb b/config/routes/admin.rb index 852c7a3436..69e2186cd0 100644 --- a/config/routes/admin.rb +++ b/config/routes/admin.rb @@ -41,8 +41,9 @@ Openfoodnetwork::Application.routes.draw do resources :tag_rules, only: [:destroy] - # TODO do we need to remove more routes - resources :vouchers, only: [:new, :create] + constraints FeatureToggleConstraint.new(:vouchers) do + resources :vouchers, only: [:new, :create] + end end resources :enterprise_relationships