anthonymidili/EasyKeep

View on GitHub
app/views/invoices/_table.html.haml

Summary

Maintainability
Test Coverage
.scroll_overflow-x
  %table
    %thead
      %tr
        %th Invoice#
        %th Date
        %th Total
        %th Balance Due
        - if current_user.is_admin?
          %th Edit
          %th Destroy

    %tbody
      - @invoices.each do |invoice|
        %tr{id: "tableRow#{invoice.id}"}
          %td.center_cell
            = link_to invoice_path(invoice) do
              %i.fas.fa-file
              %b= invoice.pre_post_number
          %td= invoice.established_at.strftime('%Y-%b-%d')
          %td= number_to_currency(invoice.total_cost)
          %td{class: "no_action_required_#{invoice.paid_in_full?}"}
            = pif_or_balance_due(invoice)
          - if current_user.is_admin?
            %td.center_cell
              = link_to edit_invoice_path(invoice), class: invoice.disable_link_if_archived? do
                %i.fas.fa-edit
            %td.center_cell
              = link_to invoice, class: "#{invoice.disable_link_if_archived?} red_link", method: :delete,
              data: { confirm: t(:confirm_delete_invoice) } do
                %i.fas.fa-trash