spielhoelle/zelos

View on GitHub
app/views/admin/customers/edit.html.haml

Summary

Maintainability
Test Coverage
- if ["new"].include?(action_name)
  - path = admin_customers_path
- elsif action_name == "edit"
  - path = admin_customer_path(@customer)
.section.container.row.full-width.no-max-width
  .row
    .col.s12
      .col.m6.s12
        = form_for(@customer, url: path) do |f|
          .row
            .col.s12.full-width
              .input-field
                = f.label :name, class: action_name == "edit" ? "active" : ""
                = f.text_field :name, class: "validate", required: true
              .input-field
                = f.label :company, class: action_name == "edit" ? "active" : ""
                = f.text_field :company, class: "validate", required: true
              .input-field
                = f.label :address, class: action_name == "edit" ? "active" : ""
                = f.text_area :address, class: "materialize-textarea validate", required: true
                
            .col.s12.full-width.text-right.pt-3
              .row
                = link_to admin_customers_path, class: "btn btn-floating" do
                  %i.material-icons view_list
                = f.button :submit, class: "btn btn-floating" do
                  %i.material-icons done


      .col.m6.s12
        %ul.collection.with-header
          %li.collection-header
            %h5
              ="Invoices"
              %strong.right= "#{money_helper(@total_last_year)} total"
          - if @customer.entries.any?
            .py-1
              = pie_chart @customer.entries.collect { |x| [x.title, get_items_total(x)] }, legend: false, donut: true


            - @customer.entries.each do |entry|
              %li.pl-1.pr-1.collection-item.justify-content-start.d-flex
                %i.material-icons.mr-1{class: entry.status == "paid" ? "green-text" : "red-text"}= entry.is_offer? ? "info_outline" : "done"
                = link_to edit_admin_entry_path(entry), class: "" do
                  = entry.title
                .ml-auto.no-wrap.pl-2
                  = money_helper(get_items_total(entry))
          - else
            %h2.grey-text.text-lighten-1.center-align.my-5
              %div
                %i.material-icons.large.grey-text.text-lighten-1 child_care
              Nothing here