app/views/imports/_cases.html.erb
<div class="mb-3">
<h4>
1.
<%= link_to "/casa_cases.csv", format: :csv, download: "casa_cases.csv" do %>
Download and reference example Case CSV file
<i class="lni lni-download"></i>
<% end %>
</h4>
</div>
<div class="mb-3">
<h4>
2. Upload your CSV file
<i class="lni lni-upload" aria-hidden="true"></i>
</h4>
<%= form_with(url: imports_path, local: :true) do |f| %>
<%= f.hidden_field :import_type, value: "casa_case" %>
<ul style="list-style-type: disc;" class="mx-4">
<li>Click the choose file button and navigate to the saved file and select it.</li>
<li><strong>Do not</strong> change any of the values in the first line of the example csv file.</li>
<li>Then click the "Import Cases CSV" button to import your cases.</li>
</ul>
<%= f.file_field :file,
id: 'case-file',
accept: 'text/csv',
class: 'form-control mt-4',
type: 'file',
style: "margin: auto;" %>
</div>
<%= button_tag id: "case-import-button", class: "main-btn primary-btn btn-hover pull-right",
disabled: true, data: {disable_with: "<i class='fa fa-spinner fa-spin'></i> Importing File"} do %>
<i class="lni lni-upload"></i> Import Cases CSV
<% end %>
<script type="text/javascript">
document.getElementById('case-file').addEventListener('change', function (event) {
document.getElementById('case-import-button').disabled = (event.target.value == '')
})
</script>
<% end %>