diff --git a/app/assets/stylesheets/admin/components/states_decorator.scss b/app/assets/stylesheets/admin/components/states_decorator.scss new file mode 100644 index 0000000000..e64a192c09 --- /dev/null +++ b/app/assets/stylesheets/admin/components/states_decorator.scss @@ -0,0 +1,28 @@ +.state { + @extend .state; + + &.active { + background-color: #9fc820; + &, a { color: #ffffff; } + } + + &.paused { + background-color: #ff9300; + &, a { color: #ffffff; } + } + + &.canceled { + background-color: #c60f13; + &, a { color: #ffffff; } + } + + &.ended { + background-color: #7a7a7a; + &, a { color: #ffffff; } + } + + &.pending { + background-color: #7a7a7a; + &, a { color: #ffffff; } + } +} diff --git a/app/serializers/api/admin/standing_order_serializer.rb b/app/serializers/api/admin/standing_order_serializer.rb index 75dcec43b2..c554f6aaa0 100644 --- a/app/serializers/api/admin/standing_order_serializer.rb +++ b/app/serializers/api/admin/standing_order_serializer.rb @@ -1,6 +1,6 @@ class Api::Admin::StandingOrderSerializer < ActiveModel::Serializer attributes :id, :shop_id, :customer_id, :schedule_id, :payment_method_id, :shipping_method_id, :begins_at, :ends_at - attributes :customer_email, :schedule_name, :edit_path, :canceled_at, :paused_at + attributes :customer_email, :schedule_name, :edit_path, :canceled_at, :paused_at, :state has_many :standing_line_items, serializer: Api::Admin::StandingLineItemSerializer has_many :closed_standing_order_orders, serializer: Api::Admin::StandingOrderOrderSerializer diff --git a/app/views/admin/standing_orders/_orders_panel.html.haml b/app/views/admin/standing_orders/_orders_panel.html.haml index 6c2d603da9..cd9ec9a196 100644 --- a/app/views/admin/standing_orders/_orders_panel.html.haml +++ b/app/views/admin/standing_orders/_orders_panel.html.haml @@ -11,7 +11,7 @@ %thead %th= t('admin.standing_orders.orders.number') %th= t('admin.order_cycle') - %th= t('admin.standing_orders.orders.state') + %th= t('admin.status_state') %th= t('total') %th.actions %tbody diff --git a/app/views/admin/standing_orders/_table.html.haml b/app/views/admin/standing_orders/_table.html.haml index 4a97fb9cc4..f6b10f2c80 100644 --- a/app/views/admin/standing_orders/_table.html.haml +++ b/app/views/admin/standing_orders/_table.html.haml @@ -3,14 +3,15 @@ %table.index#standing_orders %col.customer{ width: "20%", 'ng-show' => 'columns.customer.visible' } - %col.schedule{ width: "15%", 'ng-show' => 'columns.schedule.visible' } + %col.schedule{ width: "20%", 'ng-show' => 'columns.schedule.visible' } %col.items{ width: "10%", 'ng-show' => 'columns.items.visible' } %col.orders{ width: "10%", 'ng-show' => 'columns.orders.visible' } + %col.status{ width: "15%", 'ng-show' => 'columns.state.visible' } %col.begins_on{ width: "10%", 'ng-show' => 'columns.begins_on.visible' } %col.ends_on{ width: "10%", 'ng-show' => 'columns.ends_on.visible' } %col.payment_method{ width: "20%", 'ng-show' => 'columns.payment_method.visible' } %col.shipping_method{ width: "20%", 'ng-show' => 'columns.shipping_method.visible' } - %col.actions{ width: "10%" } + %col.actions{ width: "15%" } %thead %tr -# %th.bulk @@ -23,6 +24,8 @@ = t('admin.items') %th.orders{ ng: { show: 'columns.orders.visible', } } = t('orders') + %th.status{ ng: { show: 'columns.state.visible', } } + = t('admin.status_state') %th.begins_on{ ng: { show: 'columns.begins_on.visible', } } = t('admin.begins_on') %th.ends_on{ ng: { show: 'columns.ends_on.visible', } } @@ -41,6 +44,8 @@ %h5{ ng: { bind: 'itemCount(standingOrder)' } } %td.orders.panel-toggle.text-center{ name: 'orders', ng: { show: 'columns.orders.visible' } } %h5{ ng: { bind: 'standingOrder.not_closed_standing_order_orders.length + standingOrder.closed_standing_order_orders.length' } } + %td.status.text-center{ ng: { show: 'columns.state.visible' } } + %span.state{ ng: { class: "standingOrder.state", bind: "'spree.standing_order_state.' + standingOrder.state | t" } } %td.begins_on.text-center{ ng: { show: 'columns.begins_on.visible', bind: '::standingOrder.begins_at' } } %td.ends_on.text-center{ ng: { show: 'columns.ends_on.visible', bind: '::standingOrder.ends_at' } } %td.payment_method{ ng: { show: 'columns.payment_method.visible', bind: '::paymentMethodsByID[standingOrder.payment_method_id].name' } } diff --git a/config/locales/en.yml b/config/locales/en.yml index 3df677c212..cf578d6e11 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -213,6 +213,7 @@ en: shipping_method: Shipping Method shop: Shop sku: SKU + status_state: State tags: Tags variant: Variant weight: Weight @@ -811,7 +812,6 @@ en: product_already_in_order: This product has already been added to the order. Please edit the quantity directly. orders: number: Number - status: Status confirm_cancel_msg: Are you sure you want to cancel this standing order? This action cannot be undone. cancel_failure_msg: 'Sorry, cancellation failed!'
 confirm_pause_msg: Are you sure you want to pause this standing order? @@ -2381,6 +2381,12 @@ See the %{link} to find out more about %{sitename}'s features and to start using resumed: resumed returned: returned skrill: skrill + standing_order_state: + active: active + pending: pending + ended: ended + paused: paused + canceled: cancelled payment_states: balance_due: balance due completed: completed diff --git a/lib/open_food_network/column_preference_defaults.rb b/lib/open_food_network/column_preference_defaults.rb index 7586e9e15b..887c9c1ab2 100644 --- a/lib/open_food_network/column_preference_defaults.rb +++ b/lib/open_food_network/column_preference_defaults.rb @@ -104,8 +104,9 @@ module OpenFoodNetwork schedule: { name: I18n.t("admin.schedule"), visible: true }, items: { name: I18n.t("items"), visible: true }, orders: { name: I18n.t("orders"), visible: true }, - begins_on: { name: I18n.t("admin.begins_on"), visible: true }, - ends_on: { name: I18n.t("admin.ends_on"), visible: true }, + state: { name: I18n.t("admin.status_state"), visible: true }, + begins_on: { name: I18n.t("admin.begins_on"), visible: false }, + ends_on: { name: I18n.t("admin.ends_on"), visible: false }, payment_method: { name: I18n.t("admin.payment_method"), visible: false }, shipping_method: { name: I18n.t("admin.shipping_method"), visible: false } } diff --git a/spec/features/admin/standing_orders_spec.rb b/spec/features/admin/standing_orders_spec.rb index e737a9443a..23b0bdd77d 100644 --- a/spec/features/admin/standing_orders_spec.rb +++ b/spec/features/admin/standing_orders_spec.rb @@ -98,6 +98,26 @@ feature 'Standing Orders' do end end + # Pausing a standing order + within "tr#so_#{standing_order.id}" do + find("a.pause-standing-order").click + end + click_button "Yes, I'm sure" + within "tr#so_#{standing_order.id}" do + expect(page).to have_selector ".state.paused", text: "PAUSED" + expect(standing_order.reload.paused_at).to be_within(5.seconds).of Time.zone.now + end + + # Unpausing a standing order + within "tr#so_#{standing_order.id}" do + find("a.unpause-standing-order").click + end + click_button "Yes, I'm sure" + within "tr#so_#{standing_order.id}" do + expect(page).to have_selector ".state.active", text: "ACTIVE" + expect(standing_order.reload.paused_at).to be nil + end + # Cancelling a standing order within "tr#so_#{standing_order.id}" do find("a.cancel-standing-order").click