appirits/comable

View on GitHub
backend/app/views/comable/admin/orders/show.slim

Summary

Maintainability
Test Coverage
.comable-page
  .comable-page-heading
    ul.pull-right.list-inline
      - if !@order.shipped?
        li
          = link_to comable.ship_admin_order_path(@order), class: 'btn btn-primary', method: :post, disabled: !@order.can_ship? do
            i.fa.fa-truck>
            = Comable.t('admin.ship')
      - if @order.can_cancel?
        li
          = link_to comable.cancel_admin_order_path(@order), class: 'btn btn-default', method: :post do
            = @order.class.human_state_event_name(:cancel)
      - if @order.can_resume?
        li
          = button_to comable.resume_admin_order_path(@order), class: 'btn btn-default', method: :post do
            = @order.class.human_state_event_name(:resume)

    ul.pull-right.list-inline
      li
        = link_to comable.edit_admin_order_path(@order), class: 'btn btn-default' do
          span.fa.fa-edit>
          = Comable.t('admin.actions.edit')

      li.btn-group
        / TODO: Comment out after implemented.
        / = link_to Comable.t('admin.nav.orders.cart'), '#', class: 'btn btn-default'
        / = link_to Comable.t('admin.nav.orders.shipment'), '#', class: 'btn btn-default'
        / = link_to Comable.t('admin.nav.orders.payment'), '#', class: 'btn btn-default'

    h1.page-header
      ol.breadcrumb
        li>
          = link_to Comable.t('admin.nav.order'), comable.admin_orders_path
        li.active
          = @order.code
          small< data-toggle="tooltip" data-placement="right" title="#{l @order.completed_at}"
            = time_ago_in_words @order.completed_at

  .comable-page-body
    - if @order.payment
      = render 'payment_state', payment: @order.payment
    - @order.shipments.each do |shipment|
      = render 'shipment_state', shipment: shipment

    section.row
      .col-lg-8
        .panel.panel-default
          table.table
            thead
              tr
                th colspan="2"
                  = @order.order_items.klass.human_attribute_name(:product)
                th
                  = @order.order_items.klass.human_attribute_name(:price)
                th
                  = @order.order_items.klass.human_attribute_name(:quantity)
                th
                  = @order.order_items.klass.human_attribute_name(:subtotal_price)
            tbody
              - @order.order_items.each do |order_item|
                tr
                  td width="180"
                    = image_tag order_item.image_url, width: '100%'
                  td
                    = order_item.name_with_sku
                    .text-muted
                      small = order_item.sku
                  td
                    = number_to_currency order_item.price
                  td
                    = number_with_delimiter order_item.quantity
                  td
                    = number_to_currency order_item.subtotal_price
              tr
                th.text-right colspan="4"
                  = @order.class.human_attribute_name(:item_total_price)
                td
                  = number_to_currency @order.item_total_price
              tr
                th.text-right colspan="4"
                  = @order.class.human_attribute_name(:payment_fee)
                td
                  = number_to_currency @order.payment_fee
              tr
                th.text-right colspan="4"
                  = @order.class.human_attribute_name(:shipment_fee)
                td
                  = number_to_currency @order.shipment_fee
              tr
                th.text-right colspan="4"
                  = @order.class.human_attribute_name(:total_price)
                td
                  = number_to_currency @order.total_price

      nav.col-lg-4
        .panel.panel-default.visible-lg-block
          .panel-body
            h3.text-center
              small>
                = @order.class.human_attribute_name(:total_price)
              = number_to_currency @order.total_price

        .panel.panel-default
          .panel-heading
            .panel-title
              = Comable.t('admin.bill')
          .panel-body
            .pull-right
              .comable-avatar
                = gravatar_tag @order.email, class: 'thumbnail'

            dl.dl-horizontal.comable-address-with-icon
              dt
                i.fa.fa-map-marker.fa-lg data-toggle="tooltip" data-placement="left" title="#{@order.class.human_attribute_name(:bill_address)}"
              dd
                ul.list-unstyled
                  li = @order.bill_address.zip_code
                  li = @order.bill_address.state_name
                  li = @order.bill_address.city
                  li = @order.bill_address.detail

              - if @order.bill_address.phone_number.present?
                dt
                  i.fa.fa-phone.fa-lg data-toggle="tooltip" data-placement="left" title="#{@order.bill_address.class.human_attribute_name(:phone_number)}"
                dd
                  = @order.bill_address.phone_number

              dt
                i.fa.fa-user.fa-lg data-toggle="tooltip" data-placement="left" title="#{@order.class.human_attribute_name(:user)}"
              dd
                = link_to_if @order.user, @order.bill_address.full_name, [comable, :admin, @order.user]

              dt
                i.fa.fa-envelope.fa-lg data-toggle="tooltip" data-placement="left" title="#{@order.class.human_attribute_name(:email)}"
              dd
                = mail_to @order.email

        .panel.panel-default
          .panel-heading
            .panel-title
              = Comable.t('admin.ship')
          .panel-body
            dl.dl-horizontal.comable-address-with-icon
              dt
                i.fa.fa-map-marker.fa-lg data-toggle="tooltip" data-placement="left" title="#{@order.class.human_attribute_name(:ship_address)}"
              dd
                ul.list-unstyled
                  li = @order.ship_address.zip_code
                  li = @order.ship_address.state_name
                  li = @order.ship_address.city
                  li = @order.ship_address.detail

              - if @order.ship_address.phone_number.present?
                dt
                  i.fa.fa-phone.fa-lg data-toggle="tooltip" data-placement="left" title="#{@order.ship_address.class.human_attribute_name(:phone_number)}"
                dd
                  = @order.ship_address.phone_number

              dt
                i.fa.fa-user.fa-lg data-toggle="tooltip" data-placement="left" title="#{@order.class.human_attribute_name(:user)}"
              dd
                = @order.bill_address.full_name

              - if @order.shipment
                dt
                  i.fa.fa-truck.fa-lg data-toggle="tooltip" data-placement="left" title="#{@order.class.human_attribute_name(:shipment_method)}"
                dd
                  = @order.shipment.name

              - if @order.payment
                dt
                  i.fa.fa-money.fa-lg data-toggle="tooltip" data-placement="left" title="#{@order.class.human_attribute_name(:payment_method)}"
                dd
                  = @order.payment.name

          .panel-footer
            = render 'google_map', id: 'comable-google-map-for-ship-address', address: @order.ship_address