From 6fadeacf0eeddc53520127a41e57f6d16fe12578 Mon Sep 17 00:00:00 2001 From: Rob Harrington Date: Fri, 7 Oct 2016 17:51:14 +1100 Subject: [PATCH] SO Index: Adding begins_on and ends_on columns --- .../api/admin/index_standing_order_serializer.rb | 10 +++++----- app/views/admin/standing_orders/_table.html.haml | 12 +++++++++++- config/locales/en.yml | 3 +++ lib/open_food_network/column_preference_defaults.rb | 2 ++ 4 files changed, 21 insertions(+), 6 deletions(-) diff --git a/app/serializers/api/admin/index_standing_order_serializer.rb b/app/serializers/api/admin/index_standing_order_serializer.rb index 8f07c9578b..d2ddabf7ce 100644 --- a/app/serializers/api/admin/index_standing_order_serializer.rb +++ b/app/serializers/api/admin/index_standing_order_serializer.rb @@ -1,5 +1,5 @@ class Api::Admin::IndexStandingOrderSerializer < ActiveModel::Serializer - attributes :id, :begins_at, :ends_at + attributes :id, :begins_on, :ends_on has_one :shop, serializer: Api::Admin::IdNameSerializer has_one :customer, serializer: Api::Admin::IdEmailSerializer # Remove IdEmailSerializer if no longer user here @@ -7,11 +7,11 @@ class Api::Admin::IndexStandingOrderSerializer < ActiveModel::Serializer has_one :payment_method, serializer: Api::Admin::IdNameSerializer has_one :shipping_method, serializer: Api::Admin::IdNameSerializer - def begins_at - object.begins_at.andand.strftime('%F') + def begins_on + object.begins_at.strftime('%b %d, %Y') end - def ends_at - object.ends_at.andand.strftime('%F') + def ends_on + object.ends_at.andand.strftime('%b %d, %Y') || I18n.t(:ongoing) end end diff --git a/app/views/admin/standing_orders/_table.html.haml b/app/views/admin/standing_orders/_table.html.haml index ea4b6c99a0..cc658a6392 100644 --- a/app/views/admin/standing_orders/_table.html.haml +++ b/app/views/admin/standing_orders/_table.html.haml @@ -1,6 +1,10 @@ %table.index#standing_orders %col.customer{ width: "20%", 'ng-show' => 'columns.customer.visible' } - %col.schedule{ width: "20%", 'ng-show' => 'columns.name.visible' } + %col.schedule{ width: "15%", 'ng-show' => 'columns.schedule.visible' } + %col.begins_on{ width: "15%", 'ng-show' => 'columns.begins_on.visible' } + %col.ends_on{ width: "15%", '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 %thead %tr @@ -10,6 +14,10 @@ = t('admin.customer') %th.schedule{ ng: { show: 'columns.schedule.visible', } } = t('admin.schedule') + %th.begins_on{ ng: { show: 'columns.begins_on.visible', } } + = t('admin.begins_on') + %th.ends_on{ ng: { show: 'columns.ends_on.visible', } } + = t('admin.ends_on') %th.payment_method{ ng: { show: 'columns.payment_method.visible', } } = t('admin.payment_method') %th.shipping_method{ ng: { show: 'columns.shipping_method.visible', } } @@ -19,6 +27,8 @@ %tr.standing_order{ :id => "so_{{standingOrder.id}}", ng: { repeat: "standingOrder in standingOrders | filter:query", class: { even: "'even'", odd: "'odd'" } } } %td.customer{ ng: { show: 'columns.customer.visible', bind: '::standingOrder.customer.email' } } %td.schedule{ ng: { show: 'columns.schedule.visible', bind: '::standingOrder.schedule.name' } } + %td.begins_on{ ng: { show: 'columns.begins_on.visible', bind: '::standingOrder.begins_on' } } + %td.ends_on{ ng: { show: 'columns.ends_on.visible', bind: '::standingOrder.ends_on' } } %td.payment_method{ ng: { show: 'columns.payment_method.visible', bind: '::standingOrder.payment_method.name' } } %td.shipping_method{ ng: { show: 'columns.shipping_method.visible', bind: '::standingOrder.shipping_method.name' } } -# %td.actions diff --git a/config/locales/en.yml b/config/locales/en.yml index 92b9336875..cace4f8b46 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -128,6 +128,7 @@ en: say_no: "No" say_yes: "Yes" then: then + ongoing: Ongoing sort_order_cycles_on_shopfront_by: "Sort Order Cycles On Shopfront By" required_fields: Required fields are denoted with an asterisk select_continue: Select and Continue @@ -189,10 +190,12 @@ en: admin: # Common properties / models begins_at: Begins At + begins_on: Begins On customer: Customer date: Date email: Email ends_at: Ends At + ends_on: Ends On name: Name on_hand: On Hand on_demand: On Demand diff --git a/lib/open_food_network/column_preference_defaults.rb b/lib/open_food_network/column_preference_defaults.rb index c7baa90d42..b941c80491 100644 --- a/lib/open_food_network/column_preference_defaults.rb +++ b/lib/open_food_network/column_preference_defaults.rb @@ -102,6 +102,8 @@ module OpenFoodNetwork { customer: { name: I18n.t("admin.customer"), visible: true }, schedule: { name: I18n.t("admin.schedule"), visible: true }, + begins_on: { name: I18n.t("admin.begins_on"), visible: true }, + ends_on: { name: I18n.t("admin.ends_on"), visible: true }, payment_method: { name: I18n.t("admin.payment_method"), visible: false }, shipping_method: { name: I18n.t("admin.shipping_method"), visible: false } }