appirits/comable

View on GitHub
backend/app/views/comable/admin/products/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 @products, '<', class: 'btn btn-default' do
            .btn.btn-default disabled="disabled"
              | <
          = link_to_next_page @products, '>', class: 'btn btn-default' do
            .btn.btn-default disabled="disabled"
              | >
      li
        = link_to Comable.t('admin.actions.new'), comable.new_admin_product_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_products_path(format: :csv, q: params[:q])
          li
            = link_to Comable.t('admin.export_to_excel'), comable.export_admin_products_path(format: :xlsx, q: params[:q])
          li.divider
          li
            a.btn-file
              span>
                = Comable.t('admin.import')
              = form_tag comable.import_admin_products_path, multipart: true do
                = file_field_tag :file

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

  .comable-page-body
    .comable-search
      = search_form_for @q, url: comable.admin_products_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_products_path
          = f.text_field :name_or_variants_sku_cont_any_splitted, class: 'form-control'
          span.input-group-btn
            = f.submit Comable.t('admin.search'), class: 'btn btn-default'

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

    section
      - if @products.empty?
        = Comable.t('admin.not_found')
      - else
        table.table.table-striped
          thead
            th
            th
              = sort_link [:comable, @q], :name
            th
              = sort_link [:comable, @q], :price
            th
              = Comable.t('admin.stocks')
          tbody
            - @products.each do |product|
              tr
                td.comable-image
                  = link_to comable.admin_product_path(product), class: 'thumbnail' do
                    = image_tag product.image_url, width: '100%'
                td
                  = link_to product.name, comable.admin_product_path(product)
                  - unless product.published?
                    span.fa.fa-eye-slash.text-muted<
                td
                  = number_to_currency product.price
                td
                  ul.list-unstyled
                    - product.variants.each do |variant|
                      li
                        - quantity = variant.quantity
                        strong class="#{(quantity <= 0) ? 'text-danger' : (quantity <= 10) ? 'text-warning' : 'text-success'}"
                          = number_with_delimiter quantity
                        - if !product.master?
                          span<
                            | (
                            - variant.options.each do |option|
                              span.comable-variant-name
                                = option.value
                            | )

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