mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Split dashboard into single and multiple enterprise views
This commit is contained in:
@@ -4,6 +4,13 @@ Spree::Admin::OverviewController.class_eval do
|
||||
@enterprises = Enterprise.managed_by(spree_current_user).order('is_primary_producer ASC, name')
|
||||
@product_count = Spree::Product.active.managed_by(spree_current_user).count
|
||||
@order_cycle_count = OrderCycle.active.managed_by(spree_current_user).count
|
||||
|
||||
if spree_current_user.manages_one_enterprise?
|
||||
@enterprise = @enterprises.first
|
||||
render partial: "single_enterprise_dashboard"
|
||||
else
|
||||
render partial: "multi_enterprise_dashboard"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -19,6 +19,10 @@ Spree.user_class.class_eval do
|
||||
end
|
||||
end
|
||||
|
||||
def manages_one_enterprise?
|
||||
enterprises.length == 1
|
||||
end
|
||||
|
||||
def send_signup_confirmation
|
||||
Spree::UserMailer.signup_confirmation(self).deliver
|
||||
end
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
%h1{ :style => 'margin-bottom: 30px'} Dashboard
|
||||
|
||||
- if @enterprises.unconfirmed.any?
|
||||
|
||||
= render partial: "unconfirmed"
|
||||
|
||||
%hr
|
||||
|
||||
- if @enterprises.empty?
|
||||
|
||||
= render partial: "enterprises"
|
||||
|
||||
- else
|
||||
|
||||
- if can? :admin, Spree::Product
|
||||
= render partial: "products"
|
||||
|
||||
%div.two.columns
|
||||
|
||||
|
||||
- if can? :admin, OrderCycle
|
||||
= render partial: "order_cycles"
|
||||
|
||||
= render partial: "enterprises"
|
||||
@@ -0,0 +1,17 @@
|
||||
-# - if @enterprise.sells == "unconfirmed"
|
||||
-# %h1 Welcome to the Open Food Network
|
||||
|
||||
|
||||
- if @enterprise.is_primary_producer
|
||||
// Basic Producer
|
||||
|
||||
// Producer with Shopfront
|
||||
|
||||
// Coming soon - Full Hub
|
||||
// Email us if you want this option
|
||||
|
||||
- else
|
||||
// Shop Profile
|
||||
|
||||
// Coming soon - Full Hub
|
||||
// Email us if you want this option
|
||||
@@ -1,24 +0,0 @@
|
||||
%h1{ :style => 'margin-bottom: 30px'} Dashboard
|
||||
|
||||
- if @enterprises.unconfirmed.any?
|
||||
|
||||
= render partial: "spree/admin/overview/unconfirmed"
|
||||
|
||||
%hr
|
||||
|
||||
- if @enterprises.empty?
|
||||
|
||||
= render partial: "spree/admin/overview/enterprises"
|
||||
|
||||
- else
|
||||
|
||||
- if can? :admin, Spree::Product
|
||||
= render partial: "spree/admin/overview/products"
|
||||
|
||||
%div.two.columns
|
||||
|
||||
|
||||
- if can? :admin, OrderCycle
|
||||
= render partial: "spree/admin/overview/order_cycles"
|
||||
|
||||
= render partial: "spree/admin/overview/enterprises"
|
||||
31
spec/controllers/spree/admin/overview_controller_spec.rb
Normal file
31
spec/controllers/spree/admin/overview_controller_spec.rb
Normal file
@@ -0,0 +1,31 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe Spree::Admin::OverviewController do
|
||||
include AuthenticationWorkflow
|
||||
context "loading overview" do
|
||||
let(:user) { create_enterprise_user(enterprise_limit: 2) }
|
||||
|
||||
before do
|
||||
controller.stub spree_current_user: user
|
||||
end
|
||||
|
||||
context "when user own only one enterprise" do
|
||||
let!(:enterprise) { create(:distributor_enterprise, owner: user) }
|
||||
|
||||
it "renders the single enterprise dashboard" do
|
||||
spree_get :index
|
||||
response.should render_template partial: "_single_enterprise_dashboard"
|
||||
end
|
||||
end
|
||||
|
||||
context "when user owns multiple enterprises" do
|
||||
let!(:enterprise1) { create(:distributor_enterprise, owner: user) }
|
||||
let!(:enterprise2) { create(:distributor_enterprise, owner: user) }
|
||||
|
||||
it "renders the multi enterprise dashboard" do
|
||||
spree_get :index
|
||||
response.should render_template partial: "_multi_enterprise_dashboard"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user