armandofox/audience1st

View on GitHub
app/views/ticket_sales_imports/index.html.haml

Summary

Maintainability
Test Coverage
%h1 Import External Vendor Ticket Sales

= form_tag ticket_sales_imports_path, :multipart => true, :class => 'form' do
  .form-row.px-2
    %label.col-2.text-right.col-form-label{:for => 'vendor'} Import from
    = select_tag 'vendor', options_for_select(@vendors), :class => 'form-control col-2'
    %label.col-2.mx-2.btn.btn-primary{:for => 'file'} Choose file...
    = file_field_tag 'file', :accept => '.csv,.json', :hidden => 'hidden', :onchange => %q{$('#filename').html($('#file')[0].files[0].name)}
    %label.col-3.col-form-label.a1-text-small#filename (No file chosen)
    = submit_tag 'Upload', :class => 'col-2 btn btn-success'

- if !(in_progress = @ticket_sales_imports.in_progress).empty?
  %h1 In Progress
  %table.table
    %thead
      %tr
        %th Started on
        %th Started by
        %th Vendor
        %th File name
        %th
    %tbody
      - in_progress.each do |imp|
        %tr
          %td= link_to imp.created_at.to_formatted_s(:foh)
          %td= imp.processed_by.first_name rescue ''
          %td= imp.vendor
          %td= imp.filename
          %td= button_to 'Cancel', ticket_sales_import_path(imp), {:method => :delete, :form_class => 'form-inline', :class => 'form-control btn btn-danger', 'data-confirm' => t('import.confirm_delete_import')}
  

- unless (completed = @ticket_sales_imports.completed).empty?
  %h1 Completed Imports
  %table#ticket_sales_imports.table
    %thead
      %tr
        %th Date of Import
        %th Imported by
        %th Vendor
        %th File name
        %th Tickets Sold
        %th New Customers Added
        %th Existing Customers Found
    %tbody
      - completed.each do |imp|
        %tr[imp]
          %td= link_to imp.updated_at.to_formatted_s(:foh), ticket_sales_import_path(imp)
          %td= imp.processed_by.first_name rescue ''
          %td= imp.vendor
          %td= imp.filename
          %td= imp.tickets_sold
          %td= imp.new_customers
          %td= imp.existing_customers