Add name of the customers into subscriptions table

- Thus, we can filter subscriptions by customer email
This commit is contained in:
Jean-Baptiste Bellet
2021-04-20 16:09:48 +02:00
parent a3b90f3a63
commit ddb63dff8a
2 changed files with 9 additions and 2 deletions

View File

@@ -5,7 +5,7 @@ module Api
class SubscriptionSerializer < ActiveModel::Serializer
attributes :id, :shop_id, :customer_id, :schedule_id, :payment_method_id, :shipping_method_id,
:begins_at, :ends_at,
:customer_email, :schedule_name, :edit_path, :canceled_at, :paused_at, :state,
:customer_email, :customer_name, :schedule_name, :edit_path, :canceled_at, :paused_at, :state,
:shipping_fee_estimate, :payment_fee_estimate
has_many :subscription_line_items, serializer: Api::Admin::SubscriptionLineItemSerializer
@@ -34,6 +34,10 @@ module Api
object.customer.andand.email
end
def customer_name
object.customer.andand.name
end
def schedule_name
object.schedule.andand.name
end

View File

@@ -38,7 +38,10 @@
&nbsp;
%tbody.panel-ctrl{ object: 'subscription', ng: { repeat: "subscription in subscriptions | filter:query as filteredSubscriptions track by subscription.id" } }
%tr.subscription{ :id => "so_{{subscription.id}}", ng: { class: { even: "'even'", odd: "'odd'" } } }
%td.customer.text-center{ ng: { show: 'columns.customer.visible', bind: '::subscription.customer_email' } }
%td.customer.text-center{ ng: { show: 'columns.customer.visible'}}
%span{ "ng-bind": '::subscription.customer_email' }
%br
%span{ "ng-bind": '::subscription.customer_name' }
%td.schedule.text-center{ ng: { show: 'columns.schedule.visible', bind: '::subscription.schedule_name' } }
%td.items.panel-toggle.text-center{ name: 'products', ng: { show: 'columns.items.visible' } }
%h5{ ng: { bind: 'itemCount(subscription)' } }