Show list of hubs to select for managing variant overrides

This commit is contained in:
Rohan Mitchell
2014-11-20 09:33:26 +11:00
parent d810388248
commit 2c74a94e31
9 changed files with 56 additions and 0 deletions

View File

@@ -0,0 +1,2 @@
angular.module("ofn.admin").controller "AdminOverrideVariantsCtrl", ($scope, Enterprises) ->
$scope.Enterprises = Enterprises

View File

@@ -2,6 +2,7 @@ require 'open_food_network/spree_api_key_loader'
Spree::Admin::ProductsController.class_eval do
include OpenFoodNetwork::SpreeApiKeyLoader
include OrderCyclesHelper
before_filter :load_form_data, :only => [:bulk_edit, :new, :create, :edit, :update]
before_filter :load_spree_api_key, :only => :bulk_edit
@@ -48,6 +49,12 @@ Spree::Admin::ProductsController.class_eval do
end
end
def override_variants
@all_enterprises = []
@my_enterprises = order_cycle_permitted_enterprises.by_name
end
protected
def location_after_save
if URI(request.referer).path == '/admin/products/bulk_edit'

View File

@@ -0,0 +1,3 @@
/ insert_bottom "[data-hook='admin_product_sub_tabs']"
= tab :override_details, url: override_variants_admin_products_path, match_path: '/products/override_variants'

View File

@@ -0,0 +1,5 @@
= render 'spree/admin/products/override_variants/header'
= render 'spree/admin/products/override_variants/data'
%div{ ng: { app: 'ofn.admin', controller: 'AdminOverrideVariantsCtrl', init: 'initialise()' } }
= render 'spree/admin/products/override_variants/hub_choice'

View File

@@ -0,0 +1 @@
= admin_inject_enterprises

View File

@@ -0,0 +1,4 @@
- content_for :page_title do
Override Product Details
= render :partial => 'spree/admin/shared/product_sub_menu'

View File

@@ -0,0 +1,7 @@
.row
.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' }
.ten.columns.omega
%input{ type: 'button', value: 'Go', 'ng-click' => 'selectHub()' }

View File

@@ -118,6 +118,7 @@ Spree::Core::Engine.routes.prepend do
match '/admin/reports/orders_and_fulfillment' => 'admin/reports#orders_and_fulfillment', :as => "orders_and_fulfillment_admin_reports", :via => [:get, :post]
match '/admin/reports/users_and_enterprises' => 'admin/reports#users_and_enterprises', :as => "users_and_enterprises_admin_reports", :via => [:get, :post]
match '/admin/products/bulk_edit' => 'admin/products#bulk_edit', :as => "bulk_edit_admin_products"
match '/admin/products/override_variants' => 'admin/products#override_variants', :as => "override_variants_admin_products"
match '/admin/orders/bulk_management' => 'admin/orders#bulk_management', :as => "admin_bulk_order_management"
match '/admin/reports/products_and_inventory' => 'admin/reports#products_and_inventory', :as => "products_and_inventory_admin_reports", :via => [:get, :post]
match '/admin/reports/customers' => 'admin/reports#customers', :as => "customers_admin_reports", :via => [:get, :post]

View File

@@ -0,0 +1,26 @@
require 'spec_helper'
feature %q{
As an Administrator
With products I can add to order cycles
I want to override the stock level and price of those products
Without affecting other hubs that share the same products
}, js: true do
include AuthenticationWorkflow
include WebHelper
before do
login_to_admin_section
end
use_short_wait
describe "selecting a hub" do
let!(:hub) { create(:distributor_enterprise) }
it "displays a list of hub choices" do
visit '/admin/products/override_variants'
page.should have_select2 'hub_id', with_options: [hub.name]
end
end
end