Skip to content

Commit

Permalink
Add a toggle to view the files table
Browse files Browse the repository at this point in the history
This adds a button for each files table that
will show/hide the table.

Connected to https://github.com/curationexperts/in-house/issues/427
  • Loading branch information
little9 committed Nov 8, 2019
1 parent 6c8926f commit fa91c7b
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 23 deletions.
49 changes: 27 additions & 22 deletions app/views/zizia/csv_import_details/_pre_ingest_files_table.html.erb
Original file line number Diff line number Diff line change
@@ -1,24 +1,29 @@
<table id="files-table" class="dataTable display responsive nowrap table table-striped works-list" style="width:100%">
<tr>
<th>Filename</th>
<th>Size</th>
<th>Row Number</th>
<th>Date Created</th>
</tr>
<% pre_ingest_work.pre_ingest_files.each do |pre_ingest_file| %>
<div class="pre-ingest-file-table">
<a class="btn btn-primary" data-toggle="collapse" href="#files-table-<%= pre_ingest_work.id %>" role="button" aria-expanded="false" aria-controls="files-table-<%= pre_ingest_work.id %>">
View Files
</a>
<table id="files-table-<%= pre_ingest_work.id %>" class="responsive collapse nowrap table table-striped works-list">
<tr>
<td>
<%= pre_ingest_file.basename %>
</td>
<td>
<%= number_to_human_size(pre_ingest_file.size) %>
</td>
<td>
<%= pre_ingest_file.row_number %>
</td>
<td>
<%= pre_ingest_file.created_at.strftime("%B %-d, %Y %H:%M") %>
</td>
<th>Filename</th>
<th>Size</th>
<th>Row Number</th>
<th>Date Created</th>
</tr>
<% end %>
</table>
<% pre_ingest_work.pre_ingest_files.each do |pre_ingest_file| %>
<tr>
<td>
<%= pre_ingest_file.basename %>
</td>
<td>
<%= number_to_human_size(pre_ingest_file.size) %>
</td>
<td>
<%= pre_ingest_file.row_number %>
</td>
<td>
<%= pre_ingest_file.created_at.strftime("%B %-d, %Y %H:%M") %>
</td>
</tr>
<% end %>
</table>
</div>
13 changes: 12 additions & 1 deletion spec/dummy/spec/system/csv_import_details_page_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require 'rails_helper'
include Warden::Test::Helpers

RSpec.describe 'viewing the csv import detail page' do
RSpec.describe 'viewing the csv import detail page', js: true do
let(:user) { FactoryBot.create(:admin, email: 'systems@curationexperts.com')}
let(:second_user) { FactoryBot.create(:user, email: 'user@curationexperts.com') }
let(:csv_import) { FactoryBot.create(:csv_import) }
Expand All @@ -10,6 +10,7 @@
let(:csv_import_detail_second) { FactoryBot.create(:csv_import_detail, created_at: Time.parse('Thur, 31 Oct 2019 14:20:02 UTC +00:00').utc, status: 'zippy', update_actor_stack: 'ZiziaTesting', depositor_id: user.id) }
let(:csv_import_detail_third) { FactoryBot.create(:csv_import_detail, created_at: Time.parse('Wed, 30 Oct 2019 14:20:02 UTC +00:00').utc, depositor_id: second_user.id, csv_import_id: 2) }
let(:csv_pre_ingest_works) { FactoryBot.create_list(:pre_ingest_work, 12, csv_import_detail_id: 4) }
let(:csv_pre_ingest_work_second) { FactoryBot.create(:pre_ingest_work, csv_import_detail_id: 5, created_at: Time.parse('Thur, 31 Oct 2019 14:20:02 UTC +00:00').utc) }

before do
user.save
Expand All @@ -25,6 +26,7 @@
csv_import_detail_second.save
csv_import_detail_third.save
csv_pre_ingest_works.each(&:save)
csv_pre_ingest_work_second.save
login_as user
end

Expand Down Expand Up @@ -123,4 +125,13 @@
click_on 'Next'
expect(page).to have_content 'Previous'
end

it 'can hide/show a PreIngestFiles table' do
visit('/csv_import_details/index')
click_on '5'
expect(page).to have_content 'View Files'
expect(page).not_to have_content 'Row Number'
click_on 'View Files'
expect(page).to have_content 'Row Number'
end
end
1 change: 1 addition & 0 deletions spec/dummy/spec/system/import_from_csv_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@
visit "/csv_import_details/index"
expect(page).to have_content('Total Size')
click_on '4'
click_on 'View Files'
expect(page).to have_content('dog.jpg')
expect(page).to have_content('cat.jpg')
expect(page).to have_content('5.74 MB')
Expand Down

0 comments on commit fa91c7b

Please sign in to comment.