From 6ce7d3ec4743850757fd4a7821e5e9d75be70c5b Mon Sep 17 00:00:00 2001 From: Jessie Keck Date: Wed, 17 Feb 2016 17:28:41 -0800 Subject: [PATCH 1/5] Make the Unavailable status take precedence over all others. --- lib/holdings/status.rb | 4 ++-- spec/lib/holdings/status_spec.rb | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/lib/holdings/status.rb b/lib/holdings/status.rb index f1d797ec8..405be7319 100644 --- a/lib/holdings/status.rb +++ b/lib/holdings/status.rb @@ -13,6 +13,8 @@ def initialize(callnumber) def availability_class case + when unavailable? + 'unavailable' when noncirc_page? 'noncirc_page' when noncirc? @@ -21,8 +23,6 @@ def availability_class 'page' when available? 'available' - when unavailable? - 'unavailable' when unknown? 'unknown' else diff --git a/spec/lib/holdings/status_spec.rb b/spec/lib/holdings/status_spec.rb index ad89707ae..167e21e2e 100644 --- a/spec/lib/holdings/status_spec.rb +++ b/spec/lib/holdings/status_spec.rb @@ -91,6 +91,27 @@ expect(status.availability_class).to eq 'unknown' end end + + describe 'precedence' do + subject { Holdings::Status.new(callnumber) } + + describe 'unavailable' do + let(:callnumber) do + double( + 'Call number', + library: 'SAL3', + home_location: 'STACKS', + current_location: double('Location', code: 'LOST-ASSUM'), + type: 'STACKS' + ) + end + + it 'takes precedence over things like page' do + expect(subject.availability_class).to eq 'unavailable' + end + end + end + describe '#as_json' do let(:as_json) { status.as_json } it 'should return a json hash with the availability class and status text' do From 82690daab56bc6b96240622acbf6921f551857be Mon Sep 17 00:00:00 2001 From: Jessie Keck Date: Wed, 17 Feb 2016 17:29:14 -0800 Subject: [PATCH 2/5] Make Noncirc include item type NH-INHOUSE. --- lib/holdings/noncirc.rb | 2 +- spec/lib/holdings/noncirc_spec.rb | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/holdings/noncirc.rb b/lib/holdings/noncirc.rb index 38ad7e3fe..d2ccaead2 100644 --- a/lib/holdings/noncirc.rb +++ b/lib/holdings/noncirc.rb @@ -37,7 +37,7 @@ def location_is_default_noncirc? end def type_is_default_noncirc? - ["REF", "NONCIRC", "LIBUSEONLY"].include?(@callnumber.type) + %w(LIBUSEONLY NH-INHOUSE NONCIRC REF).include?(@callnumber.type) end def sanitized_library diff --git a/spec/lib/holdings/noncirc_spec.rb b/spec/lib/holdings/noncirc_spec.rb index 5c83d55e9..07e71f98f 100644 --- a/spec/lib/holdings/noncirc_spec.rb +++ b/spec/lib/holdings/noncirc_spec.rb @@ -22,7 +22,8 @@ let(:noncirc_types) { [OpenStruct.new(type: 'REF'), OpenStruct.new(type: 'NONCIRC'), - OpenStruct.new(type: 'LIBUSEONLY') + OpenStruct.new(type: 'LIBUSEONLY'), + OpenStruct.new(type: 'NH-INHOUSE') ] } let(:circ_type) { OpenStruct.new(type: "SOMETHING") } From 0b31dc3603910e0d5f8c6c32923f92a8170eef0c Mon Sep 17 00:00:00 2001 From: Jessie Keck Date: Wed, 17 Feb 2016 17:38:55 -0800 Subject: [PATCH 3/5] Allow the live lookup to mark Page items as unavailable. --- app/assets/javascripts/jquery.live-lookup.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/jquery.live-lookup.js b/app/assets/javascripts/jquery.live-lookup.js index 3edcacca3..842c96256 100644 --- a/app/assets/javascripts/jquery.live-lookup.js +++ b/app/assets/javascripts/jquery.live-lookup.js @@ -27,8 +27,10 @@ if ( live_data.due_date ) { current_location.append(' Due ' + live_data.due_date); } - if ( live_data.due_date && target.hasClass('unknown') ) { + + if ( live_data.due_date && (target.hasClass('unknown') || target.hasClass('page')) ) { target.removeClass('unknown'); + target.removeClass('page'); target.addClass('unavailable'); status_text.text(''); // The due date/current location acts as the status text at this point if (target.attr('title')) { From 93c0858105da288b6d1e275f00320b59cf6918aa Mon Sep 17 00:00:00 2001 From: Jessie Keck Date: Thu, 18 Feb 2016 17:43:39 -0800 Subject: [PATCH 4/5] Change unavailable current location from SEE-LOAN to SPE-LOAN. --- lib/holdings/unavailable.rb | 2 +- spec/lib/holdings/unavailable_spec.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/holdings/unavailable.rb b/lib/holdings/unavailable.rb index e98a8b01e..8b095266b 100644 --- a/lib/holdings/unavailable.rb +++ b/lib/holdings/unavailable.rb @@ -30,7 +30,7 @@ def unavailable_current_location? def current_location_ends_with_loan? @callnumber.current_location.try(:code) && - @callnumber.current_location.code != "SEE-LOAN" && + @callnumber.current_location.code != 'SPE-LOAN' && @callnumber.current_location.code.ends_with?("-LOAN") end end diff --git a/spec/lib/holdings/unavailable_spec.rb b/spec/lib/holdings/unavailable_spec.rb index 491ee826f..d4c60be8e 100644 --- a/spec/lib/holdings/unavailable_spec.rb +++ b/spec/lib/holdings/unavailable_spec.rb @@ -27,8 +27,8 @@ it "should handle identify -LOAN properly as unavailable" do expect(Holdings::Status::Unavailable.new(OpenStruct.new(current_location: Holdings::Location.new("SOMETHING-LOAN")))).to be_unavailable end - it "should not identify SEE-LOAN as unavailable" do - expect(Holdings::Status::Unavailable.new(OpenStruct.new(current_location: Holdings::Location.new("SEE-LOAN")))).to_not be_unavailable + it "should not identify SPE-LOAN as unavailable" do + expect(Holdings::Status::Unavailable.new(OpenStruct.new(current_location: Holdings::Location.new("SPE-LOAN")))).to_not be_unavailable end end end From 85c8cf6544f95fbb80f6fc20c6dd8c1aad447625 Mon Sep 17 00:00:00 2001 From: Jessie Keck Date: Thu, 18 Feb 2016 17:43:58 -0800 Subject: [PATCH 5/5] Add some more current locations to the hide-due-date config. --- lib/constants.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/constants.rb b/lib/constants.rb index c71964b9a..56c3e8f97 100644 --- a/lib/constants.rb +++ b/lib/constants.rb @@ -896,6 +896,9 @@ module Constants HIDE_DUE_DATE_CURRENT_LOCS = [ 'ART-AT-ENG', 'IC-DISPLAY', + 'LOST-ASSUM', + 'LOST-CLAIM', + 'LOST-PAID', 'NEWBOOKS', 'SEE-LOAN' ]