appirits/comable

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

Summary

Maintainability
Test Coverage
.comable-page
  .comable-page-heading
    ul.pull-right.list-inline
      li
        .btn-group role="group"
          = link_to_previous_page @orders, '<', class: 'btn btn-default' do
            .btn.btn-default disabled="disabled"
              | <
          = link_to_next_page @orders, '>', class: 'btn btn-default' do
            .btn.btn-default disabled="disabled"
              | >
      li
        = link_to Comable.t('admin.actions.new'), comable.new_admin_order_path, class: 'btn btn-default'
      li.dropdown
        = link_to '#', class: 'btn btn-default', 'data-toggle' => 'dropdown' do
          = Comable.t('admin.more')
          i.fa.fa-angle-down<
        ul.dropdown-menu.dropdown-menu-right
          li
            = link_to Comable.t('admin.export_to_csv'), comable.export_admin_orders_path(format: :csv, q: params[:q])
          li
            = link_to Comable.t('admin.export_to_excel'), comable.export_admin_orders_path(format: :xlsx, q: params[:q])

    h1.page-header
      = Comable.t('admin.nav.order')
      small<
        | #{@orders.total_count} #{Comable.t('admin.results')}

  .comable-page-body
    .comable-search
      = search_form_for @q, url: comable.admin_orders_path do |f|
        .input-group
          span.input-group-btn
            button.btn.btn-default.dropdown-toggle type="button" data-toggle="dropdown"
              i.fa.fa-search
              span.caret<
            ul.dropdown-menu role="menu"
              li
                = link_to Comable.t('admin.advanced_search'), 'javascript:void(0)', 'data-toggle' => 'collapse', 'data-target' => '#comable-advanced-search'
              li
                = link_to Comable.t('admin.clear_search_conditions'), comable.admin_orders_path
          = f.text_field :code_cont, class: 'form-control'
          span.input-group-btn
            = f.submit Comable.t('admin.search'), class: 'btn btn-default'
        .hidden
          = f.label :user_id
          = f.text_field :user_id_eq

        = render 'comable/admin/shared/advanced_search', f: f

    section
      - if @orders.empty?
        = Comable.t('admin.not_found')
      - else
        table.table.table-striped
          thead
            th
              = sort_link [:comable, @q], :code
            th
              = sort_link [:comable, @q], :state
            th
              = @orders.klass.human_attribute_name(:payment_state)
            th
              = @orders.klass.human_attribute_name(:shipment_state)
            th
              = @orders.klass.human_attribute_name(:bill_full_name)
            th
              = @orders.klass.human_attribute_name(:order_items)
            th
              = sort_link [:comable, @q], :total_price
            th
              = sort_link [:comable, @q], :completed_at
          tbody
            - @orders.each do |order|
              tr
                td
                  = link_to order.code, comable.admin_order_path(order)
                td
                  = order.human_state_name
                td
                  = order.payment_human_state_name
                td
                  = order.shipment_human_state_name
                td
                  = order.bill_full_name
                td
                  ul.list-unstyled
                    - order.order_items.each do |order_item|
                      li
                        | #{order_item.name_with_sku} x #{order_item.quantity}
                td
                  = number_to_currency order.total_price
                td
                  = l order.completed_at

        .text-center
          = paginate @orders, theme: :comable_backend