mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-28 01:53:25 +00:00
Colour order cycle rows based on their status
This commit is contained in:
@@ -98,6 +98,20 @@ form.order_cycle {
|
||||
*/
|
||||
}
|
||||
|
||||
table#listing_order_cycles {
|
||||
tr.open td {
|
||||
background-color: #d9fccb;
|
||||
}
|
||||
|
||||
tr.upcoming td {
|
||||
background-color: #fbfccb;
|
||||
}
|
||||
|
||||
tr.closed td {
|
||||
background-color: #eee;
|
||||
}
|
||||
}
|
||||
|
||||
table#listing_payment_methods {
|
||||
table-layout: fixed;
|
||||
|
||||
|
||||
@@ -70,7 +70,11 @@ module Admin
|
||||
|
||||
protected
|
||||
def collection
|
||||
OrderCycle.managed_by(spree_current_user)
|
||||
ocs = OrderCycle.managed_by(spree_current_user)
|
||||
|
||||
ocs.soonest_closing +
|
||||
ocs.soonest_opening +
|
||||
ocs.most_recently_closed
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
@@ -17,6 +17,17 @@ module OrderCyclesHelper
|
||||
end
|
||||
end
|
||||
|
||||
def order_cycle_status_class(order_cycle)
|
||||
if order_cycle.upcoming?
|
||||
'upcoming'
|
||||
elsif order_cycle.open?
|
||||
'open'
|
||||
elsif order_cycle.closed?
|
||||
'closed'
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def distributor_options(distributors, current_distributor, order_cycle)
|
||||
options = distributors.map { |d| [d.name, d.id, {:class => order_cycle_local_remote_class(d, order_cycle).strip}] }
|
||||
options_for_select(options, current_distributor)
|
||||
|
||||
@@ -30,7 +30,8 @@
|
||||
%tbody
|
||||
= f.fields_for :collection do |order_cycle_form|
|
||||
- order_cycle = order_cycle_form.object
|
||||
%tr
|
||||
- klass = "order-cycle-#{order_cycle.id} #{order_cycle_status_class order_cycle}"
|
||||
%tr{class: klass}
|
||||
%td= link_to order_cycle.name, main_app.edit_admin_order_cycle_path(order_cycle)
|
||||
%td= order_cycle_form.text_field :orders_open_at, :class => 'datetimepicker', :value => order_cycle.orders_open_at
|
||||
%td= order_cycle_form.text_field :orders_close_at, :class => 'datetimepicker', :value => order_cycle.orders_close_at
|
||||
|
||||
@@ -18,26 +18,50 @@ feature %q{
|
||||
|
||||
|
||||
scenario "listing order cycles" do
|
||||
# Given an order cycle
|
||||
oc = create(:order_cycle)
|
||||
# Given some order cycles (created in an arbitrary order)
|
||||
oc4 = create(:simple_order_cycle, name: '4',
|
||||
orders_open_at: 2.day.from_now, orders_close_at: 1.month.from_now)
|
||||
oc2 = create(:simple_order_cycle, name: '2', orders_close_at: 1.month.from_now)
|
||||
oc6 = create(:simple_order_cycle, name: '6',
|
||||
orders_open_at: 1.month.ago, orders_close_at: 3.weeks.ago)
|
||||
oc3 = create(:simple_order_cycle, name: '3',
|
||||
orders_open_at: 1.day.from_now, orders_close_at: 1.month.from_now)
|
||||
oc5 = create(:simple_order_cycle, name: '5',
|
||||
orders_open_at: 1.month.ago, orders_close_at: 2.weeks.ago)
|
||||
oc1 = create(:order_cycle, name: '1')
|
||||
|
||||
# When I go to the admin order cycles page
|
||||
login_to_admin_section
|
||||
click_link 'Order Cycles'
|
||||
|
||||
# Then I should see the basic fields
|
||||
page.should have_selector 'a', text: oc.name
|
||||
# Then the order cycles should be ordered correctly
|
||||
page.all('#listing_order_cycles tr td:first-child').map(&:text).should ==
|
||||
['1', '2', '3', '4', '5', '6']
|
||||
|
||||
page.should have_selector "input[value='#{oc.orders_open_at}']"
|
||||
page.should have_selector "input[value='#{oc.orders_close_at}']"
|
||||
page.should have_content oc.coordinator.name
|
||||
# And the rows should have the correct classes
|
||||
page.should have_selector "#listing_order_cycles tr.order-cycle-#{oc1.id}.open"
|
||||
page.should have_selector "#listing_order_cycles tr.order-cycle-#{oc2.id}.open"
|
||||
page.should have_selector "#listing_order_cycles tr.order-cycle-#{oc3.id}.upcoming"
|
||||
page.should have_selector "#listing_order_cycles tr.order-cycle-#{oc4.id}.upcoming"
|
||||
page.should have_selector "#listing_order_cycles tr.order-cycle-#{oc5.id}.closed"
|
||||
page.should have_selector "#listing_order_cycles tr.order-cycle-#{oc6.id}.closed"
|
||||
|
||||
# And I should see the suppliers and distributors
|
||||
oc.suppliers.each { |s| page.should have_content s.name }
|
||||
oc.distributors.each { |d| page.should have_content d.name }
|
||||
# And I should see all the details for an order cycle
|
||||
within('table#listing_order_cycles tbody tr:first-child') do
|
||||
# Then I should see the basic fields
|
||||
page.should have_selector 'a', text: oc1.name
|
||||
|
||||
# And I should see the number of variants
|
||||
page.should have_selector 'td.products', text: '2 variants'
|
||||
page.should have_selector "input[value='#{oc1.orders_open_at}']"
|
||||
page.should have_selector "input[value='#{oc1.orders_close_at}']"
|
||||
page.should have_content oc1.coordinator.name
|
||||
|
||||
# And I should see the suppliers and distributors
|
||||
oc1.suppliers.each { |s| page.should have_content s.name }
|
||||
oc1.distributors.each { |d| page.should have_content d.name }
|
||||
|
||||
# And I should see the number of variants
|
||||
page.should have_selector 'td.products', text: '2 variants'
|
||||
end
|
||||
end
|
||||
|
||||
scenario "creating an order cycle", js: true do
|
||||
|
||||
Reference in New Issue
Block a user