Add methods and fees to sidebar on enterprise edit page

This commit is contained in:
Rob H
2014-05-15 14:52:19 +10:00
parent 31334be615
commit 7cdfb4bab2
10 changed files with 194 additions and 27 deletions

View File

@@ -0,0 +1,63 @@
div.sidebar_item
margin-bottom: 30px
.centered
text-align: center
div.header
font-size: 105%
color: #fff
padding: 10px 0px
position: relative
&.blue
background-color: #5498da
&.red
background-color: #DA5354
.list
//max-height: 150px
overflow-y: auto
.list-item
border: solid #5498da
border-width: 0px 1px 0px 1px
span.alpha
font-weight: bold
margin-left: -3px
padding: 10px 2px 10px 5%
overflow: hidden
max-width: 160px
text-overflow: ellipsis
span.omega
padding: 8px 13px 8px 0px
margin-right: -3px
text-align: right
.icon-remove-sign
color: #DA5354
font-size: 18px
&.red
color: #DA5354
border: solid #DA5354
border-width: 0px 3px 0px 3px
&.even
background-color: #fff
&.odd
background-color: #eff5fc
&.even, &.odd
&:hover
color: #ffffff
background-color: #9fc820
a.button
color: #fff
padding: 15px 15px
font-weight: bold
text-align: center
border-radius: 0px
&.blue
background-color: #5498da
&.red
background-color: #DA5354
&:hover
background-color: #9fc820

View File

@@ -2,6 +2,7 @@ module Admin
class EnterprisesController < ResourceController
before_filter :load_enterprise_set, :only => :index
before_filter :load_countries, :except => :index
before_filter :load_methods_and_fees, :only => [:new, :edit]
create.after :grant_management
helper 'spree/products'
@@ -41,5 +42,11 @@ module Admin
def collection_actions
[:index, :bulk_update]
end
def load_methods_and_fees
@payment_methods = Spree::PaymentMethod.managed_by(spree_current_user).sort_by!{ |pm| [(@enterprise.payment_methods.include? pm) ? 0 : 1, pm.name] }
@shipping_methods = Spree::ShippingMethod.managed_by(spree_current_user).sort_by!{ |sm| [(@enterprise.shipping_methods.include? sm) ? 0 : 1, sm.name] }
@enterprise_fees = EnterpriseFee.managed_by(spree_current_user).for_enterprise(@enterprise).order(:fee_type, :name).all
end
end
end

View File

@@ -21,6 +21,7 @@
%th Calculator values
%th.actions
%tbody
- binding.pry
= enterprise_fee_set_form.ng_fields_for :collection do |f|
%tr{'ng-repeat' => 'enterprise_fee in enterprise_fees | filter:query'}
%td

View File

@@ -1,9 +1,6 @@
- content_for :head do
= render 'shared/cms_elrte_head'
- content_for :page_title do
New Enterprise
- content_for :page_actions do
%li= button_link_to "Back to enterprises list", main_app.admin_enterprises_path, icon: 'icon-arrow-left'
@@ -39,7 +36,7 @@
= f.label :visible, 'Visible in search?'
= f.fields_for :address do |af|
%fieldset.no-border-bottom
%fieldset.twelve.columns.alpha.no-border-bottom
%legend Address
.row
.alpha.six.columns
@@ -64,13 +61,16 @@
.omega.four.columns
= af.text_field :zipcode
.row
.alpha.two.columns &nbsp;
.omega.three.columns
= af.collection_select(:state_id, af.object.country.states, :id, :name)
.row
.alpha.two.columns &nbsp;
.omega.three.columns
= af.collection_select(:country_id, available_countries, :id, :name)
.six.columns.alpha
.alpha.two.columns
= af.label :state_id, 'State'
.omega.four.columns
= af.collection_select :state_id, af.object.country.states, :id, :name, {}, :class => "select2 fullwidth"
.six.columns.omega
.alpha.two.columns
= af.label :countryid, 'Country'
.four.columns.omega
= af.collection_select :country_id, available_countries, :id, :name, {}, :class => "select2 fullwidth"
.row
.alpha.six.columns
%fieldset.no-border-bottom
@@ -119,7 +119,7 @@
= f.label :twitter
.omega.four.columns
= f.text_field :twitter
%fieldset.no-border-bottom
%fieldset.twelve.columns.alpha.no-border-bottom
%legend About Us
.row
.alpha.two.columns
@@ -131,7 +131,7 @@
= f.label :long_description, 'About Us'
%br
Tell us about yourself. This information appears on your public profile (under "About Us")
.omega.eight.columns
.omega.ten.columns
= f.text_area :long_description, class: 'rich_text', placeholder: 'Tell us about yourself. This information appears on your public profile (under "About Us")'
.row
.alpha.two.columns
@@ -140,7 +140,7 @@
%em (Hub only)
%br
Explain your distribution offer/s - this information appears on your public profile (under "How does it work?")
.omega.eight.columns
.omega.ten.columns
= f.text_area :distributor_info, class: 'rich_text', placeholder: 'Hub only: Explain your distribution offer/s - this is more detailed information that the user can access by clicking on "How does it work?"'
/ TODO: editor breaks scrolling with arrow keys
.row

View File

@@ -0,0 +1,59 @@
.sidebar_item.four.columns.alpha#payment_methods
.four.columns.alpha.header{ class: "#{@payment_methods.count > 0 ? "blue" : "red"}" }
%span.four.columns.alpha.centered Payment Methods
- if @payment_methods.count > 0
.four.columns.alpha.list
- @payment_methods.each do |payment_method|
%a.four.columns.alpha.list-item{ class: "#{cycle('odd','even')}", href: "#{edit_admin_payment_method_path(payment_method)}" }
%span.three.columns.alpha
= payment_method.name
%span.one.column.omega
= f.check_box :payment_method_ids, { :multiple => true }, payment_method.id, nil
- else
.four.columns.alpha.list-item.red
%span.three.columns.alpha None Available
%span.one.column.omega
%span.icon-remove-sign
%a.four.columns.alpha.button{ href: "#{new_admin_payment_method_path}", class: "#{@payment_methods.count > 0 ? "blue" : "red"}" }
CREATE NEW
%span.icon-arrow-right
.sidebar_item.four.columns.alpha#shipping_methods
.four.columns.alpha.header{ class: "#{@shipping_methods.count > 0 ? "blue" : "red"}" }
%span.four.columns.alpha.centered Shipping Methods
- if @shipping_methods.count > 0
.four.columns.alpha.list
- @shipping_methods.each do |shipping_method|
%a.four.columns.alpha.list-item{ class: "#{cycle('odd','even')}", href: "#{edit_admin_shipping_method_path(shipping_method)}" }
%span.three.columns.alpha
= shipping_method.name
%span.one.column.omega
= f.check_box :shipping_method_ids, { :multiple => true }, shipping_method.id, nil
- else
.four.columns.alpha.list-item.red
%span.three.columns.alpha None Available
%span.one.column.omega
%span.icon-remove-sign
%a.four.columns.alpha.button{ href: "#{new_admin_shipping_method_path}", class: "#{@payment_methods.count > 0 ? "blue" : "red"}" }
CREATE NEW
%span.icon-arrow-right
.sidebar_item.four.columns.alpha#enterprise_fees
.four.columns.alpha.header{ class: "#{@enterprise_fees.count > 0 ? "blue" : "red"}" }
%span.four.columns.alpha.centered Enterprise Fees
- if @enterprise_fees.count > 0
.four.columns.alpha.list
- @enterprise_fees.each do |enterprise_fee|
%a.four.columns.alpha.list-item{ class: "#{cycle('odd','even')}", href: "#{main_app.admin_enterprise_fees_path}" }
%span.three.columns.alpha
= enterprise_fee.name
%span.one.column.omega
&nbsp;
- else
.four.columns.alpha.list-item.red
%span.three.columns.alpha None Available
%span.one.column.omega
%span.icon-remove-sign
%a.four.columns.alpha.button{ href: "#{main_app.admin_enterprise_fees_path}", class: "#{@enterprise_fees.count > 0 ? "blue" : "red"}" }
CREATE NEW
%span.icon-arrow-right

View File

@@ -1,6 +0,0 @@
<%= render :partial => 'spree/shared/error_messages', :locals => { :target => @enterprise } %>
<%= form_for [main_app, :admin, @enterprise] do |f| %>
<%= render :partial => 'form', :locals => { :f => f } %>
<%= render :partial => 'spree/admin/shared/edit_resource_links' %>
<% end %>

View File

@@ -0,0 +1,13 @@
= render :partial => 'spree/shared/error_messages', :locals => { :target => @enterprise }
- content_for :page_title do
Editing:
= @enterprise.name
= form_for [main_app, :admin, @enterprise] do |f|
.twelve.columns.alpha
= render :partial => 'form', :locals => { :f => f }
.four.columns.omega
= render :partial => 'sidebar', :locals => { :f => f }
.twelve.columns.alpha
= render :partial => 'spree/admin/shared/edit_resource_links'

View File

@@ -1,7 +0,0 @@
<%= render :partial => 'spree/shared/error_messages', :locals => { :target => @enterprise } %>
<%= form_for [main_app, :admin, @enterprise] do |f| %>
<%= render :partial => 'form', :locals => { :f => f } %>
<!-- Save, Save & Close and Cancel button -->
<%= render :partial => 'spree/admin/shared/new_resource_links' %>
<% end %>

View File

@@ -0,0 +1,13 @@
= render :partial => 'spree/shared/error_messages', :locals => { :target => @enterprise }
- content_for :page_title do
New Enterprise
= form_for [main_app, :admin, @enterprise] do |f|
.twelve.columns.alpha
= render :partial => 'form', :locals => { :f => f }
.four.columns.omega
= render :partial => 'sidebar', :locals => { :f => f }
.twelve.columns.alpha
-# Save, Save & Close and Cancel button
= render :partial => 'spree/admin/shared/new_resource_links'

View File

@@ -46,6 +46,9 @@ feature %q{
scenario "creating a new enterprise" do
eg1 = create(:enterprise_group, name: 'eg1')
eg2 = create(:enterprise_group, name: 'eg2')
payment_method = create(:payment_method)
shipping_method = create(:shipping_method)
enterprise_fee = create(:enterprise_fee)
login_to_admin_section
@@ -62,6 +65,12 @@ feature %q{
select eg1.name, from: 'enterprise_group_ids'
page.should_not have_checked_field "enterprise_payment_method_ids_#{payment_method.id}"
page.should_not have_checked_field "enterprise_shipping_method_ids_#{shipping_method.id}"
check "enterprise_payment_method_ids_#{payment_method.id}"
check "enterprise_shipping_method_ids_#{shipping_method.id}"
fill_in 'enterprise_contact', :with => 'Kirsten or Ren'
fill_in 'enterprise_phone', :with => '0413 897 321'
fill_in 'enterprise_email', :with => 'info@eaterprises.com.au'
@@ -84,6 +93,9 @@ feature %q{
@enterprise = create(:enterprise)
eg1 = create(:enterprise_group, name: 'eg1')
eg2 = create(:enterprise_group, name: 'eg2')
payment_method = create(:payment_method, distributors: [])
shipping_method = create(:shipping_method, distributors: [])
enterprise_fee = create(:enterprise_fee, enterprise: @enterprise )
login_to_admin_section
@@ -99,6 +111,12 @@ feature %q{
select eg1.name, from: 'enterprise_group_ids'
page.should_not have_checked_field "enterprise_payment_method_ids_#{payment_method.id}"
page.should_not have_checked_field "enterprise_shipping_method_ids_#{shipping_method.id}"
check "enterprise_payment_method_ids_#{payment_method.id}"
check "enterprise_shipping_method_ids_#{shipping_method.id}"
fill_in 'enterprise_contact', :with => 'Kirsten or Ren'
fill_in 'enterprise_phone', :with => '0413 897 321'
fill_in 'enterprise_email', :with => 'info@eaterprises.com.au'
@@ -117,6 +135,12 @@ feature %q{
flash_message.should == 'Enterprise "Eaterprises" has been successfully updated!'
page.should have_selector '#listing_enterprises a', text: 'Eaterprises'
click_link 'Edit Profile'
page.should have_checked_field "enterprise_payment_method_ids_#{payment_method.id}"
page.should have_checked_field "enterprise_shipping_method_ids_#{shipping_method.id}"
page.should have_selector "a.list-item", text: enterprise_fee.name
end
context 'as an Enterprise user' do