mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Do not show producers in hubs list
This commit is contained in:
@@ -1,2 +1,2 @@
|
||||
angular.module("ofn.admin").controller "AdminOverrideVariantsCtrl", ($scope, Enterprises) ->
|
||||
$scope.Enterprises = Enterprises
|
||||
angular.module("ofn.admin").controller "AdminOverrideVariantsCtrl", ($scope, hubs) ->
|
||||
$scope.hubs = hubs
|
||||
|
||||
@@ -50,8 +50,7 @@ Spree::Admin::ProductsController.class_eval do
|
||||
end
|
||||
|
||||
def override_variants
|
||||
@all_enterprises = []
|
||||
@my_enterprises = order_cycle_permitted_enterprises.by_name
|
||||
@hubs = order_cycle_hub_enterprises(without_validation: true)
|
||||
end
|
||||
|
||||
|
||||
|
||||
@@ -25,6 +25,10 @@ module Admin
|
||||
admin_inject_json_ams_array "admin.shipping_methods", "shippingMethods", @shipping_methods, Api::Admin::IdNameSerializer
|
||||
end
|
||||
|
||||
def admin_inject_hubs
|
||||
admin_inject_json_ams_array "ofn.admin", "hubs", @hubs, Api::Admin::IdNameSerializer
|
||||
end
|
||||
|
||||
def admin_inject_producers
|
||||
admin_inject_json_ams_array "ofn.admin", "producers", @producers, Api::Admin::IdNameSerializer
|
||||
end
|
||||
|
||||
@@ -15,23 +15,27 @@ module OrderCyclesHelper
|
||||
order_cycle_permitted_enterprises.is_distributor.by_name
|
||||
end
|
||||
|
||||
def order_cycle_hub_enterprises
|
||||
def order_cycle_hub_enterprises(options={})
|
||||
enterprises = order_cycle_permitted_enterprises.is_distributor.by_name
|
||||
|
||||
enterprises.map do |e|
|
||||
disabled_message = nil
|
||||
if e.shipping_methods.empty? && e.payment_methods.available.empty?
|
||||
disabled_message = 'no shipping or payment methods'
|
||||
elsif e.shipping_methods.empty?
|
||||
disabled_message = 'no shipping methods'
|
||||
elsif e.payment_methods.available.empty?
|
||||
disabled_message = 'no payment methods'
|
||||
end
|
||||
if options[:without_validation]
|
||||
enterprises
|
||||
else
|
||||
enterprises.map do |e|
|
||||
disabled_message = nil
|
||||
if e.shipping_methods.empty? && e.payment_methods.available.empty?
|
||||
disabled_message = 'no shipping or payment methods'
|
||||
elsif e.shipping_methods.empty?
|
||||
disabled_message = 'no shipping methods'
|
||||
elsif e.payment_methods.available.empty?
|
||||
disabled_message = 'no payment methods'
|
||||
end
|
||||
|
||||
if disabled_message
|
||||
["#{e.name} (#{disabled_message})", e.id, {disabled: true}]
|
||||
else
|
||||
[e.name, e.id]
|
||||
if disabled_message
|
||||
["#{e.name} (#{disabled_message})", e.id, {disabled: true}]
|
||||
else
|
||||
[e.name, e.id]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
= admin_inject_enterprises
|
||||
= admin_inject_hubs
|
||||
|
||||
|
||||
@@ -2,6 +2,6 @@
|
||||
.two.columns.alpha
|
||||
Hub
|
||||
.four.columns
|
||||
%select.select2.fullwidth#hub_id{ 'ng-model' => 'hub_id', name: 'hub_id', 'ng-options' => 'hub.id as hub.name for hub in Enterprises.my_enterprises' }
|
||||
%select.select2.fullwidth#hub_id{ 'ng-model' => 'hub_id', name: 'hub_id', 'ng-options' => 'hub.id as hub.name for hub in hubs' }
|
||||
.ten.columns.omega
|
||||
%input{ type: 'button', value: 'Go', 'ng-click' => 'selectHub()' }
|
||||
|
||||
@@ -17,10 +17,11 @@ feature %q{
|
||||
|
||||
describe "selecting a hub" do
|
||||
let!(:hub) { create(:distributor_enterprise) }
|
||||
let!(:producer) { create(:supplier_enterprise) }
|
||||
|
||||
it "displays a list of hub choices" do
|
||||
visit '/admin/products/override_variants'
|
||||
page.should have_select2 'hub_id', with_options: [hub.name]
|
||||
page.should have_select2 'hub_id', options: ['', hub.name]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user