diff --git a/app/assets/stylesheets/admin/dashboard_item.css.sass b/app/assets/stylesheets/admin/dashboard_item.css.sass new file mode 100644 index 0000000000..79ae376ed1 --- /dev/null +++ b/app/assets/stylesheets/admin/dashboard_item.css.sass @@ -0,0 +1,113 @@ +div.dashboard_item + margin-bottom: 30px + + .centered + text-align: center + + div.header + border: solid + border-color: #5498da + border-width: 1px + border-radius: 6px 6px 0px 0px + position: relative + + a.with-tip + position: absolute + right: 5px + bottom: 5px + + &.red + border-color: #DA5354 + border-width: 3px + h3 + color: #DA5354 + + &.orange + border-color: #DA7F52 + border-width: 3px + h3 + color: #DA7F52 + + h3 + padding: 5px 5px 5px 3% + + .list-title + border: solid #5498da + border-width: 0px 1px 0px 1px + span + font-size: 105% + padding: 10px 0px + font-weight: bold + span.alpha + padding: 10px 2px 10px 5% + + .list-item + border: solid + border-width: 0px 1px 0px 1px + span.alpha + font-weight: bold + margin-left: -3px + padding: 10px 2px 10px 5% + span.omega + padding-right: 13px + margin-right: -3px + text-align: right + .icon-arrow-right + padding-top: 6px + font-size: 20px + .icon-warning-sign + color: #DA7F52 + font-size: 30px + .icon-remove-sign + color: #DA5354 + font-size: 30px + .icon-ok-sign + color: #9fc820 + font-size: 30px + &.orange + color: #DA7F52 + border: solid #DA7F52 + &.red + color: #DA5354 + border: solid #DA5354 + &.orange, &.red + border-width: 0px 3px 0px 3px + &.even + background-color: #fff + &.odd + background-color: #eff5fc + &.even, &.odd + &:hover + color: #ffffff + background-color: #9fc820 + .icon-arrow-right + color: #fff + .icon-remove-sign + color: #fff + .icon-warning-sign + color: #fff + .icon-ok-sign + color: #fff + + a.button + color: #fff + padding: 15px 15px + font-size: 110% + font-weight: bold + text-align: center + &.orange + background-color: #DA7F52 + &.blue + background-color: #5498da + &.red + background-color: #DA5354 + &:hover + background-color: #9fc820 + &.top + border-radius: 6px 6px 0px 0px + &.bottom + border-radius: 0px 0px 6px 6px + &.top-right + border-radius: 0px 6px 0px 0px + &.top-left + border-radius: 6px 0px 0px 0px \ No newline at end of file diff --git a/app/controllers/spree/admin/overview_controller_decorator.rb b/app/controllers/spree/admin/overview_controller_decorator.rb index e6555eb291..5ffdff288e 100644 --- a/app/controllers/spree/admin/overview_controller_decorator.rb +++ b/app/controllers/spree/admin/overview_controller_decorator.rb @@ -2,11 +2,9 @@ module Spree module Admin class OverviewController < Spree::Admin::BaseController def index - if current_spree_user.admin? || current_spree_user.enterprises.any?{ |e| e.is_distributor? } - redirect_to admin_orders_path - elsif current_spree_user.enterprises.any?{ |e| e.is_primary_producer? } - redirect_to bulk_edit_admin_products_path - end + @enterprises = Enterprise.managed_by(spree_current_user).order('is_distributor DESC, is_primary_producer ASC, name').limit(4) + @product_count = Spree::Product.active.managed_by(spree_current_user).count + @order_cycle_count = OrderCycle.active.managed_by(spree_current_user).count end end end diff --git a/app/views/spree/admin/overview/_enterprises.html.haml b/app/views/spree/admin/overview/_enterprises.html.haml new file mode 100644 index 0000000000..02030c272f --- /dev/null +++ b/app/views/spree/admin/overview/_enterprises.html.haml @@ -0,0 +1,43 @@ +%div.dashboard_item.sixteen.columns.alpha + %div.header.sixteen.columns.alpha{ :class => "#{@enterprises.count > 0 ? "" : "red"}"} + %h3.five.columns.alpha My Enterprises + %a.with-tip{ title: "Enterprises are Producers and/or Hubs and are the basic unit of organisation within the Open Food Network." } What's this? + %div.sixteen.columns.alpha.list + - if @enterprises.empty? + %div.sixteen.columns.alpha.list-item.red + %span.text.fifteen.columns.alpha You have no enterprises. + %span.one.columns.omega + %span.icon-remove-sign + %a.sixteen.columns.alpha.button.bottom.red{ href: "#{main_app.new_admin_enterprise_path}" } + CREATE NEW ENTERPRISE + %span.icon-arrow-right + - else + %div.sixteen.columns.alpha.list-title + %span.five.columns.alpha Name + %span.centered.three.columns Payment Methods + %span.centered.three.columns Shipping Methods + %span.centered.three.columns Enterprise Fees + - @enterprises.each do |enterprise| + %a.sixteen.columns.alpha.list-item{ class: "#{cycle('odd','even')}", href: "#{main_app.edit_admin_enterprise_path(enterprise)}" } + %span.five.columns.alpha + = enterprise.name + %span.symbol.three.columns.centered + - if enterprise.payment_methods.count > 0 + %span.icon-ok-sign + - else + %span.icon-remove-sign + %span.symbol.three.columns.centered + - if enterprise.shipping_methods.count > 0 + %span.icon-ok-sign + - else + %span.icon-remove-sign + %span.symbol.three.columns.centered + - if enterprise.enterprise_fees.count > 0 + %span.icon-ok-sign + - else + %span.icon-warning-sign + %span.two.columns.omega.right + %span.icon-arrow-right + %a.sixteen.columns.alpha.button.bottom.blue{ href: "#{main_app.admin_enterprises_path}" } + MANAGE MY ENTERPRISES + %span.icon-arrow-right \ No newline at end of file diff --git a/app/views/spree/admin/overview/_order_cycles.html.haml b/app/views/spree/admin/overview/_order_cycles.html.haml new file mode 100644 index 0000000000..4b53db7003 --- /dev/null +++ b/app/views/spree/admin/overview/_order_cycles.html.haml @@ -0,0 +1,22 @@ +%div.dashboard_item.seven.columns.omega + %div.header.seven.columns.alpha{ :class => "#{@order_cycle_count > 0 ? "" : "orange"}"} + %h3.five.columns.alpha Order Cycles + %a.with-tip{ title: "Order cycles determine when and where your products are available to customers." } What's this? + %div.seven.columns.alpha.list + - if @order_cycle_count > 0 + %div.seven.columns.alpha.list-item + %span.six.columns.alpha + = "You have #{@order_cycle_count} active order cycle#{@order_cycle_count > 1 ? "s" : ""}." + %span.one.column.omega + %span.icon-ok-sign + %a.seven.columns.alpha.button.bottom.blue{ href: "#{main_app.admin_order_cycles_path}" } + MANAGE ORDER CYCLES + %span.icon-arrow-right + - else + %div.seven.columns.alpha.list-item.orange + %span.six.columns.alpha You don't have any active order cycles. + %span.one.column.omega + %span.icon-warning-sign + %a.seven.columns.alpha.button.bottom.orange{ href: "#{main_app.admin_order_cycles_path}" } + MANAGE ORDER CYCLES + %span.icon-arrow-right \ No newline at end of file diff --git a/app/views/spree/admin/overview/_products.html.haml b/app/views/spree/admin/overview/_products.html.haml new file mode 100644 index 0000000000..e412c0d891 --- /dev/null +++ b/app/views/spree/admin/overview/_products.html.haml @@ -0,0 +1,25 @@ +%div.dashboard_item.seven.columns.alpha + %div.header.seven.columns.alpha{ :class => "#{@product_count > 0 ? "" : "red"}"} + %h3.four.columns.alpha Products + -# %a.three.columns.omega.button.top-right.blue{ href: "#{new_admin_product_path}" } + -# ADD NEW + -# %span.icon-plus + %a.with-tip{ title: "The products that you sell through the Open Food Network." } What's this? + %div.seven.columns.alpha.list + - if @product_count > 0 + %div.seven.columns.alpha.list-item + %span.six.columns.alpha + = "You have #{@product_count} active product#{@product_count > 1 ? "s" : ""}." + %span.one.column.omega + %span.icon-ok-sign + %a.seven.columns.alpha.button.bottom.blue{ href: "#{bulk_edit_admin_products_path}" } + MANAGE PRODUCTS + %span.icon-arrow-right + - else + %div.seven.columns.alpha.list-item.red + %span.six.columns.alpha You don't have any products yet. + %span.one.column.omega + %span.icon-remove-sign + %a.seven.columns.alpha.button.bottom.red{ href: "#{new_admin_product_path}" } + CREATE A NEW PRODUCT + %span.icon-arrow-right \ No newline at end of file diff --git a/app/views/spree/admin/overview/index.html.erb b/app/views/spree/admin/overview/index.html.erb deleted file mode 100644 index 328d1aa98d..0000000000 --- a/app/views/spree/admin/overview/index.html.erb +++ /dev/null @@ -1,39 +0,0 @@ -<% content_for :head do %> - <% if Rails.env.production? %> - <%= stylesheet_link_tag 'https://api.jirafe.com/dashboard/css/spree_ui.css', :media => 'all' %> - <%= javascript_include_tag 'https://jirafe.com/dashboard/js/spree_namespaced_ui.js' %> - <% end %> -<% end %> - -<% if Rails.env.production? %> - <% if Spree::Dash::Config.configured? %> -