Skip to content

Commit

Permalink
Refactor csv modal template into partial
Browse files Browse the repository at this point in the history
  • Loading branch information
JEscalanteGT authored and Elizabeth Prescott committed Nov 3, 2018
1 parent ff41804 commit 3ae709f
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 55 deletions.
2 changes: 1 addition & 1 deletion app/views/diaper_drive_participants/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<div class="box-header with-border bg-gray">
<section id="filters">
<div class="pull-right">
<%= modal_button_to("#importDiaperDriveParticipantsModal", { text: "Import Diaper Drive Participants", size: "lg"}) if @diaper_drive_participants.empty? %>
<%= modal_button_to("#csvImportModal", { icon: "upload", text: "Import Diaper Drive Participants", size: "lg"}) if @diaper_drive_participants.empty? %>
<%= download_button_to(csv_path(format: :csv, type: "DiaperDriveParticipant"), { text: "Export Participants", size: "lg" }) if @diaper_drive_participants.any? %>
<%= new_button_to new_diaper_drive_participant_path(organization_id: current_organization), text: "New Diaper Drive Participant" %>
</div>
Expand Down
16 changes: 14 additions & 2 deletions app/views/donation_sites/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<!-- TBA; replicate HTML from other #index views -->
<div class="pull-right">
<!-- Button HTML (to Trigger Modal) -->
<%= modal_button_to("#importDonationSiteModal", { icon: "upload", text: "Import Donation Sites", size: "lg" }) if @donation_sites.empty? %>
<%= modal_button_to("#csvImportModal", { icon: "upload", text: "Import Donation Sites", size: "lg" }) if @donation_sites.empty? %>
<%= download_button_to(csv_path(format: :csv, type: "DonationSite"), { text: "Export Donation Sites", size: "lg" }) if @donation_sites.any? %>
<%= new_button_to new_donation_site_path(organization_id: current_organization), { text: "New Donation Site" } %>
</div>
Expand Down Expand Up @@ -56,6 +56,18 @@
</div><!-- /.box-body -->
</div><!-- /.box -->

<%= render partial: "import_donation_site_modal" %>
<%= render(
layout: "shared/csv_import_modal",
locals: {
title: 'Import Donation Sites',
csv_template_url: "/donation_sites.csv",
csv_import_url: import_csv_donation_sites_path
}
) do %>
<li>Open the csv file with excel or your favourite spreadsheet program.</li>
<li>Delete the sample data and enter your donation site names and addresses in the appropriate columns.</li>
<li>Save the file as a csv file.</li>
<% end %>

</section><!-- /.content -->

5 changes: 2 additions & 3 deletions app/views/partners/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,9 @@
<div class="box-header with-border bg-gray">
<section id="filters">
<div class="pull-right">
<%= modal_button_to("#importPartnerModal", { text: "Import Partners", icon: "upload", size: "lg" }) if @partners.empty? %>
<%= modal_button_to("#csvImportModal", { text: "Import Partners", icon: "upload", size: "lg" }) if @partners.empty? %>
<%= download_button_to(csv_path(format: :csv, type: "Partner"), { text: "Export Partner Agencies", size: "lg" }) if @partners.any? %>
<%= new_button_to new_partner_path(organization_id: current_organization), { text: "New Partner Agency" } %>

<%= new_button_to new_partner_path(organization_id: current_organization), { text: "New Partner Agency" } %>
</div>
</section><!-- /#filters -->
</div><!-- /.box-header -->
Expand Down
File renamed without changes.
61 changes: 13 additions & 48 deletions app/views/storage_locations/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -43,54 +43,19 @@
<% if @storage_locations.empty? %>
<div class="import-storage-locations">
<!-- Button HTML (to Trigger Modal) -->
<a href="#importStorageLocationModal" class="btn btn-lg btn-primary" data-toggle="modal">Import Storage Locations</a>

<!-- Modal HTML -->
<div id="importStorageLocationModal" class="modal fade">
<div class="modal-dialog onboarding_steps">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h2 class="modal-title">Import Storage Locations Instructions:</h2>
</div><!-- /.modal-header -->
<div class="modal-body">
<div class="row">
<div class="col-md-6 col-sm-12" style="padding-top: 30px;">
<i class="fa fa-download fa-4x" aria-hidden="true"></i>
<h3 class="text-info">1. Download example CSV file</h3>
<ul>
<li>Open the csv file with excel or your favourite spreadsheet program.</li>
<li>Delete the sample data and enter your storage location names and addresses in the appropriate columns.</li>
<li>Save the file as a csv file.</li>
<li><%= link_to "/storage_locations.csv", :format => :csv, :class => "btn btn-xs btn-info" do %><i class="fa fa-download"></i> Download example csv<% end %></li>
</ul>
</div>
<div class="col-md-6 col-sm-12" style="padding-top: 30px;">
<i class="fa fa-file-text-o fa-4x" aria-hidden="true"></i>
<h3 class="text-info">2. Upload your CSV file</h3>
<%= form_tag import_csv_storage_locations_path, multipart: true do %>
<ul>
<li>Click the choose file button and <br>navigate to the saved file and select it.</li>
<li>
<%= file_field_tag :file, :accept => 'text/csv', class: "form-control-file", style: "margin: auto;" %>
</li>
<li style="margin-bottom: 27px;">Then click the "Import CSV" button <br>to import your storage locations.</li>
<li>
<%= button_tag :class => "btn btn-md btn-info" do %>
<i class="fa fa-upload"></i> Import CSV
<% end #button %>
</li>
</ul>
<% end #form %>
</div>
</div><!-- / row -->
</div><!-- /.modal-body -->
<div class="modal-footer">
<small>Note: You're only able to run the import one time to prevent accidental imports or writing over existing locations!</small>
</div><!-- /.modal-footer -->
</div>
</div>
</div>
<a href="#csvImportModal" class="btn btn-lg btn-primary" data-toggle="modal">Import Storage Locations</a>
<%= render(
layout: "shared/csv_import_modal",
locals: {
title: 'Import Storage Locations Instructions:',
csv_template_url: "/storage_locations.csv",
csv_import_url: import_csv_storage_locations_path
}
) do %>
<li>Open the csv file with excel or your favourite spreadsheet program.</li>
<li>Delete the sample data and enter your storage location names and addresses in the appropriate columns.</li>
<li>Save the file as a csv file.</li>
<% end %>
</div>
<% end %>
<div class="row">
Expand Down
2 changes: 1 addition & 1 deletion app/views/storage_locations/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<div class="box">
<div class="box-header with-border bg-gray">
<div class="pull-right">
<%= modal_button_to("#importStorageLocationModal", { text: "Import Baseline Inventory", icon: "upload" }) if @storage_location.items.empty? %>
<%= modal_button_to("#csvImportModal", { text: "Import Baseline Inventory", icon: "upload" }) if @storage_location.items.empty? %>
</div>
</div>
<div class="box-body">
Expand Down

0 comments on commit 3ae709f

Please sign in to comment.