Skip to content

Commit

Permalink
Merge pull request #1220 from sul-dlss/1135-availability-display
Browse files Browse the repository at this point in the history
Update availability display on record view to match the search…
  • Loading branch information
Jessie Keck committed Feb 29, 2016
2 parents 1111eaa + 87aec6f commit 9e57ca3
Show file tree
Hide file tree
Showing 8 changed files with 130 additions and 102 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@
margin-left: -12px;
}
}
.reserve-note {
color: #990000;
}
}
}
}
Expand Down
36 changes: 28 additions & 8 deletions app/assets/stylesheets/modules/availability.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,32 @@
.note-highlight {
padding: 2px 5px;
background-color: $public-note-yellow;
&.bound-with-note {
margin-left: 10px;
}
}

.availability {
width: 100%;

&.record-view {
margin-top: 4px;
margin-bottom: 15px;
}

tr td:first-child {
width: 60%;
}

td {
padding: 2px 5px 5px 0;
vertical-align: top;
}

.availability-icon-wrapper {
white-space: nowrap;
}

.availability-icon {
width: 1.2em;
}
Expand All @@ -9,13 +37,5 @@
}
.current-location {
color: $sul-availability-current-location-color;
margin-right: 0.5em;
}
.note-highlight {
padding: 2px 5px;
background-color: $public-note-yellow;
&.bound-with-note {
margin-left: 10px;
}
}
}
2 changes: 1 addition & 1 deletion app/views/catalog/_index_location.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
<% end %>
</span>
<% if item.on_reserve? %>
On Reserve <%= item.loan_period %>
<%= item.loan_period %>
<% end %>
<span class="request-link">
<% if item.must_request? %>
Expand Down
125 changes: 67 additions & 58 deletions app/views/catalog/access_panels/_location.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
<% if document.access_panels.library_locations? %>
<div data-live-lookup-id="<%= document[:id] %>" data-live-lookup-url="<%= availability_index_path %>">
<% document.access_panels.library_locations.libraries.each do |library| %>
<div class="panel panel-default access-panel panel-library-location availability" <%= "data-hours-route='#{hour_path(library.code)}'".html_safe if library.holding_library? %>>
<div class="panel panel-default access-panel panel-library-location" <%= "data-hours-route='#{hour_path(library.code)}'".html_safe if library.holding_library? %>>
<%= link_to_library_header(library) %>
<div class="panel-body">
<div class="panel-body location">
<% if document.index_links.finding_aid.present? %>
<div class='access-panel-subsection'>
<h4>Finding aid</h4>
Expand All @@ -17,64 +17,73 @@
<p><%= library.library_instructions[:text] %></p>
</div>
<% end %>
<ul class="list-unstyled location">
<% library.locations.select(&:present?).each do |location| %>
<li>
<%= render partial: "catalog/stackmap_link", locals: { document: document, location: location, location_name_class: "location-name" } %>
<% if location.items.present? %>
<% if location.bound_with? && document.bound_with? %>
<p class="bound-with-note note-highlight">
<%= render document.bound_with_note %>
</p>
<% else %>
<% if location_level_request_link?(library, location) %>
<%= link_to_request_link(document: document, callnumber: location.items.first, class: 'btn btn-default btn-xs request-button pull-right') %>
<% end %>
<% end %>
<% library.locations.select(&:present?).each do |location| %>
<%= render partial: "catalog/stackmap_link", locals: { document: document, location: location, location_name_class: "location-name" } %>
<% if location.bound_with? && document.bound_with? %>
<p class="bound-with-note note-highlight">
<%= render document.bound_with_note %>
</p>
<% else %>
<% if location_level_request_link?(library, location) %>
<%= link_to_request_link(document: document, callnumber: location.items.first, class: 'btn btn-default btn-xs request-button pull-right') %>
<% end %>
<% end %>
<% if location.mhld.present? %>
<% location.mhld.each do |mhld| %>
<% if mhld.public_note.present? %>
<div class='mhld'><%= mhld.public_note %></div>
<% end %>
<% if mhld.latest_received.present? %>
<div class='mhld note-highlight'>Latest: <%= mhld.latest_received %></div>
<% end %>
<ul class="list-unstyled items" data-long-list data-list-type="location">
<% if location.mhld.present? %>
<% location.mhld.each do |mhld| %>
<% if mhld.public_note.present? %>
<li class='mhld'><%= mhld.public_note %></li>
<% end %>
<% if mhld.latest_received.present? %>
<li class='mhld note-highlight'>Latest: <%= mhld.latest_received %></li>
<% end %>
<% if mhld.library_has.present? %>
<li class='mhld'>Library has: <%= mhld.library_has %></li>
<% end %>
<% end %>
<% end %>
<% location.items.each do |item| %>
<li data-status-target=".availability-icon" data-barcode="<%= item.barcode if item.live_status? %>" <%= "data-request-url='#{request_link(document, item, item.barcode)}'".html_safe if item.requestable? && !item.must_request? && !location_level_request_link?(library, location) %>>
<i title="<%= item.status.status_text %>" class="availability-icon <%= item.status.availability_class %>"></i>
<span data-available-text="<%= Constants::TRANSLATE_STATUS['available'] %>" data-unavailable-text="<%= Constants::TRANSLATE_STATUS['unavailable'] %>" class='status-text sr-only'>
<%= item.status.status_text %>
</span>
<%= item.callnumber %>
<div class="request-link pull-right">
<% if item.must_request? %>
<%= link_to_request_link(document: document, callnumber: item, barcode: item.barcode, class: 'btn btn-info btn-xs') %>
<% end %>
</div>
<div class="current-location">
<% unless item.treat_current_location_as_home_location? %>
<%= item.current_location.name %>
<% end %>
</div>
<% if item.on_reserve? %>
<div class="reserve-note">On Reserve <%= item.loan_period %></div>
<% end %>
<% unless item.public_note.blank? %>
<div class='public-note note-highlight'>Note: <%= item.public_note %></div>
<% end %>
</li>
<% end %>
</ul>
</li>
<% if mhld.library_has.present? %>
<div class='mhld'>Library has: <%= mhld.library_has %></div>
<% end %>
<% end %>
<% end %>
</ul>
<table class='availability record-view'>
<caption class="sr-only">Items in <%= location.name %></caption>
<thead>
<tr class="sr-only">
<th scope="col">Call number</th>
<th scope="col">Status</th>
</tr>
</thead>
<tbody data-long-list data-list-type="location">
<% location.items.each do |item| %>
<tr>
<td>
<%= item.callnumber %>
<% if item.public_note.present? %>
<div class='public-note note-highlight'>Note: <%= item.public_note %></div>
<% end %>
</td>
<td data-live-lookup-id="<%= document[:id] %>" data-status-target=".availability-icon" data-barcode="<%= item.barcode if item.live_status? %>" <%= "data-request-url='#{request_link(document, item, item.barcode)}'".html_safe if item.requestable? && !item.must_request? && !location_level_request_link?(library, location) %>>
<span class="availability-icon-wrapper">
<i class="availability-icon <%= item.status.availability_class %>"></i>
<span data-available-text="<%= Constants::TRANSLATE_STATUS['available'] %>" data-unavailable-text="<%= Constants::TRANSLATE_STATUS['unavailable'] %>" class='status-text'>
<%= item.status.status_text unless item.current_location && item.current_location.name.present? %>
</span>
</span>
<span class="current-location">
<% unless item.treat_current_location_as_home_location? %>
<%= item.current_location.name %>
<% end %>
</span>
<% if item.on_reserve? %>
<%= item.loan_period %>
<% end %>
<span class="request-link">
<% if item.must_request? %>
<%= link_to_request_link(document: document, callnumber: item, barcode: item.barcode, class: 'btn btn-info btn-xs') %>
<% end %>
</span>
</td>
</tr>
<% end %>
</tbody>
</table>
<% end %>
</div>
</div>
<% end %>
Expand Down
4 changes: 2 additions & 2 deletions spec/features/access_panels/library_location_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
feature 'long lists should be truncated', js: true do
scenario 'items with more than 5 callnumbers should be truncated with a more link' do
visit catalog_path '10'
expect(page).to_not have_css('li', text: 'GHI', visible: true)
expect(page).not_to have_css('td', text: 'IHG', visible: true)
click_button 'show all'
expect(page).to have_css('li', text: 'GHI', visible: true)
expect(page).to have_css('td', text: 'IHG', visible: true)
end
end
end
12 changes: 6 additions & 6 deletions spec/features/mhld_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@

within('[data-hours-route="/hours/CHEMCHMENG"]') do
expect(page).to have_css('.location-name', text: 'Current periodicals')
expect(page).to have_css('li.mhld', text: 'public note2')
expect(page).to have_css('li.mhld.note-highlight', text: 'Latest: latest received2')
expect(page).to have_css('li.mhld', text: 'Library has: library has2')
expect(page).to have_css('.mhld', text: 'public note2')
expect(page).to have_css('.mhld.note-highlight', text: 'Latest: latest received2')
expect(page).to have_css('.mhld', text: 'Library has: library has2')
end
within('[data-hours-route="/hours/GREEN"]') do
expect(page).to have_css('.location-name', text: 'Stacks')
expect(page).to have_css('li.mhld', text: 'public note3')
expect(page).to have_css('li.mhld.note-highlight', text: 'Latest: latest received3')
expect(page).to have_css('li.mhld', text: 'Library has: library has3')
expect(page).to have_css('.mhld', text: 'public note3')
expect(page).to have_css('.mhld.note-highlight', text: 'Latest: latest received3')
expect(page).to have_css('.mhld', text: 'Library has: library has3')
end
end
end
Expand Down
3 changes: 3 additions & 0 deletions spec/fixtures/solr_documents/10.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
- "123 -|- CHEMCHMENG -|- STACKS -|- -|- -|- -|- -|- -|- ABC -|-"
- "456 -|- CHEMCHMENG -|- STACKS -|- -|- -|- -|- -|- -|- DEF -|-"
- "123 -|- CHEMCHMENG -|- STACKS -|- -|- -|- -|- -|- -|- GHI -|-"
- "321 -|- CHEMCHMENG -|- STACKS -|- -|- -|- -|- -|- -|- CBA -|-"
- "654 -|- CHEMCHMENG -|- STACKS -|- -|- -|- -|- -|- -|- FED -|-"
- "876 -|- CHEMCHMENG -|- STACKS -|- -|- -|- -|- -|- -|- IHG -|-"
- "678 -|- EARTH-SCI -|- STACKS -|- -|- -|- -|- -|- -|- JKL -|-"
- "123 -|- CHEMCHMENG -|- STACKS -|- -|- -|- -|- -|- -|- MNO -|-"
- "543 -|- BIOLOGY -|- STACKS -|- -|- -|- -|- -|- -|- PQR -|-"
Expand Down
47 changes: 23 additions & 24 deletions spec/views/catalog/access_panels/_location.html.erb_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@
]
))
render
expect(rendered).to have_css('ul.location li', text: /University Archives\s*Request/)
expect(rendered).to have_css('ul.location li a', text: "Request")
expect(rendered).to have_css('.location a', text: "Request")
end

it 'should not have the location level request link for -RESV locations' do
Expand All @@ -74,11 +73,11 @@
))
render
end
it "should have screen-reader-only unknown status text for items we'll be looking up" do
expect(rendered).to have_css('.status-text.sr-only', text: 'Unknown')
it "should have unknown status text for items we'll be looking up" do
expect(rendered).to have_css('.status-text', text: 'Unknown')
end
it "should have explicit screen-reader-only status text for items that we know the status" do
expect(rendered).to have_css('.status-text.sr-only', text: 'In-library use')
it "should have explicit status text for items that we know the status" do
expect(rendered).to have_css('.status-text', text: 'In-library use')
end
end
describe "current locations" do
Expand Down Expand Up @@ -130,11 +129,11 @@
it "should include the matched MHLD" do
expect(rendered).to have_css('.panel-library-location a', count: 3)
expect(rendered).to have_css('h3', text: "Green Library", count: 1)
expect(rendered).to have_css('li .location-name a', text: "Stacks", count: 1)
expect(rendered).to have_css('ul.items li.mhld', text: "public note")
expect(rendered).to have_css('ul.items li.mhld.note-highlight', text: "Latest: latest received")
expect(rendered).to have_css('ul.items li.mhld', text: "Library has: library has")
expect(rendered).to have_css('ul.items li', text: "ABC 123")
expect(rendered).to have_css('.location-name a', text: "Stacks", count: 1)
expect(rendered).to have_css('.panel-library-location .mhld', text: "public note")
expect(rendered).to have_css('.panel-library-location .mhld.note-highlight', text: "Latest: latest received")
expect(rendered).to have_css('.panel-library-location .mhld', text: "Library has: library has")
expect(rendered).to have_css('.panel-library-location td', text: "ABC 123")
end
end
describe "that has no matching library/location" do
Expand All @@ -148,10 +147,10 @@
it "should invoke a library block w/ the appropriate mhld data" do
expect(rendered).to have_css('.panel-library-location a', count: 1)
expect(rendered).to have_css('h3', text: "Green Library")
expect(rendered).to have_css('li .location-name', text: "Stacks")
expect(rendered).to have_css('ul.items li.mhld', text: "public note")
expect(rendered).to have_css('ul.items li.mhld.note-highlight', text: "Latest: latest received")
expect(rendered).to have_css('ul.items li.mhld', text: "Library has: library has")
expect(rendered).to have_css('.location-name', text: "Stacks")
expect(rendered).to have_css('.panel-library-location .mhld', text: "public note")
expect(rendered).to have_css('.panel-library-location .mhld.note-highlight', text: "Latest: latest received")
expect(rendered).to have_css('.panel-library-location .mhld', text: "Library has: library has")
end
end
end
Expand All @@ -165,10 +164,10 @@
render
end
it "should be present" do
expect(rendered).to have_css('ul.location li a', text: 'Request')
expect(rendered).to have_css('.location a', text: 'Request')
end
it "should not have any requestable items" do
expect(rendered).to_not have_css('ul.items li[data-request-url]')
expect(rendered).to_not have_css('td[data-request-url]')
end
end
describe "item level request links" do
Expand All @@ -180,10 +179,10 @@
render
end
it "should not have a request url stored in the data attribute" do
expect(rendered).to_not have_css('ul.items li[data-request-url]')
expect(rendered).to_not have_css('td[data-request-url]')
end
it "should not have a request link in the item" do
expect(rendered).to have_css('ul.items li a', text: 'Request')
expect(rendered).to have_css('tbody a', text: 'Request')
end
end
describe "requestable vs. non-requestable items" do
Expand All @@ -198,10 +197,10 @@
render
end
it "should have an item that has a request url" do
expect(rendered).to have_css('ul.items li[data-request-url]', text: 'ABC 456')
expect(rendered).to have_css('.availability td[data-barcode="456"][data-request-url]')
end
it "should have an item that does not have a request url" do
expect(rendered).to_not have_css('ul.items li[data-request-url]', text: 'ABC 123')
expect(rendered).to_not have_css('.availability td[data-barcode="123"][data-request-url]')
end
end
end
Expand All @@ -221,13 +220,13 @@
expect(rendered).to have_css('.panel-library-location a', count: 1)
end
it "should render SUL items in the zombie library" do
expect(rendered).to have_css('.panel-library-location li', text: 'ABC')
expect(rendered).to have_css('.panel-library-location td', text: 'ABC')
end
it "should render PHYSICS items in the zombie library" do
expect(rendered).to have_css('.panel-library-location li', text: 'DEF')
expect(rendered).to have_css('.panel-library-location td', text: 'DEF')
end
it "should render blank (i.e. on order) items in the zombie library" do
expect(rendered).to have_css('.panel-library-location li', text: 'GHI')
expect(rendered).to have_css('.panel-library-location td', text: 'GHI')
end
end
describe 'public note' do
Expand Down

0 comments on commit 9e57ca3

Please sign in to comment.