Skip to content

Commit

Permalink
Merge pull request #1893 from sul-dlss/revert-1865
Browse files Browse the repository at this point in the history
Revert #1865
  • Loading branch information
jcoyne authored Oct 4, 2023
2 parents 24d6ea7 + ecc4dca commit 9d91269
Show file tree
Hide file tree
Showing 7 changed files with 95 additions and 17 deletions.
2 changes: 1 addition & 1 deletion app/models/folio/library.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class Library
attr_reader :id, :code, :name

def self.from_dynamic(dyn)
new(id: dyn.fetch('id'), code: dyn.fetch('code'), name: dyn.fetch('name'))
new(id: dyn.fetch('id'), code: dyn.fetch('code'), name: dyn['name'] || dyn['code'])
end

def initialize(id:, code:, name: nil)
Expand Down
8 changes: 3 additions & 5 deletions app/models/library_location.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,18 @@ def folio_location_code
end

class << self
# Most library codes used in requests will be FOLIO codes
# Settings will be used for the RWC code which has a service point but no FOLIO library associated
def library_name_by_code(code)
Folio::Types.libraries.find_by(code:)&.name || Settings.libraries[code]&.label
all_libraries[code]&.label
end

# This is a super-clunky way to convert data from RailsConfig to something
# Enumerable, so we can use e.g. #select
def all_settings_libraries
def all_libraries
Settings.libraries.map.to_h.with_indifferent_access
end

def pageable_libraries
all_settings_libraries.select { |_, v| v.pageable }
all_libraries.select { |_, v| v.pageable }
end
end
end
4 changes: 2 additions & 2 deletions app/views/aeon_pages/_info_modal.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div id="aeon-info-overlay" class="aeon-overlay">
<div class="modal-body">
<h1 class="dialog-title" id='dialogTitle'><%= t('.header', library: LibraryLocation.library_name_by_code(i18n_library_title_key) ) %></h1>
<h1 class="dialog-title" id='dialogTitle'><%= t('.header', library: Settings.libraries[i18n_library_title_key].label) %></h1>
<p><%= t('.reading_room_info') %></p>
<h2 class="dialog-how-to"><%= t('.how_to.header') %></h2>
<p><%= t('.how_to.body') %></p>
Expand All @@ -15,7 +15,7 @@
<% end %>
</ol>
<p class="dialog-more-info">
<%= t('.more_details_html', library: LibraryLocation.library_name_by_code(current_request.origin), reading_room_url: Settings.libraries[current_request.origin].reading_room_url) %>
<%= t('.more_details_html', library: Settings.libraries[current_request.origin].label, reading_room_url: Settings.libraries[current_request.origin].reading_room_url) %>
</p>
<div class="dialog-buttons">
<% if current_request.finding_aid? %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/messages/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<% LibraryLocation.pageable_libraries.each do |library_code, config| %>
<div class="library-page-<%= library_code %>">
<%= render partial: 'messages_for_library', locals: { library_name: LibraryLocation.library_name_by_code(library_code), library_code: library_code, request_type: 'page'} %>
<%= render partial: 'messages_for_library', locals: { library_name: config.label, library_code: library_code, request_type: 'page'} %>
</div>
<% end %>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<%= render 'pickup_confirmation' %>

<p>
The following item(s) will be delivered to <%= LibraryLocation.library_name_by_code(@request.destination) || @request.destination %>:<br/>
The following item(s) will be delivered to <%= Settings.libraries[@request.destination]&.label || @request.destination %>:<br/>
Title: <%= @request.item_title %>
</p>

Expand Down
90 changes: 87 additions & 3 deletions config/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -120,50 +120,72 @@ libraries:
email: [email protected]
label: Stanford Libraries
ARS:
label: Archive of Recorded Sound
contact_info:
phone: (650) 723-9312
email: [email protected]
folio_pickup_service_point_code: ARS
reading_room_url: https://library.stanford.edu/libraries/archive-recorded-sound
hold_pseudopatron: HOLD@AS
hours:
library_slug: ars
location_slug: archive-recorded-sound
ART:
label: Art & Architecture Library (Bowes)
contact_info:
phone: "(650) 723-3408"
email: [email protected]
folio_pickup_service_point_code: ART
hold_pseudopatron: HOLD@AR
hours:
library_slug: art
location_slug: library-circulation
BIOLOGY:
label: Biology Library (Falconer)
hours:
library_slug: falconer
location_slug: library-circulation
BUSINESS:
label: Business Library
contact_info:
phone: "(650) 725-2055"
email: [email protected]
folio_pickup_service_point_code: BUS-IDESK
hold_pseudopatron: HOLD@BU # NOTE, in FOLIO the name is HOLD@JA
hours:
library_slug: business
location_slug: library-i-desk
CHEMCHMENG:
label: Chemistry & ChemEng Library (Swain)
hours:
library_slug: swain
location_slug: library-circulation
CLASSICS:
label: Classics Library
hold_pseudopatron: HOLD@CL
hours:
library_slug: classics-library
location_slug: library-circulation
EARTH-SCI:
label: Earth Sciences Library (Branner)
folio_pickup_service_point_code: EARTH-SCI
hold_pseudopatron: HOLD@ES
hours:
library_slug: branner
location_slug: library-circulation
EAST-ASIA:
label: East Asia Library
contact_info:
phone: (650) 725-3435
email: [email protected]
reading_room_url: https://library.stanford.edu/libraries/east-asia-library
folio_pickup_service_point_code: EAST-ASIA
hold_pseudopatron: HOLD@EA
hours:
library_slug: eal
location_slug: library-circulation
EDUCATION:
label: Education Library (at SAL1&2)
instructions: The Education Library is closed for construction. Request items for pickup at another library.
contact_info:
phone: "(650) 723-2121"
Expand All @@ -174,57 +196,111 @@ libraries:
location_slug: operations
iplc_pickup_location_code: STA_GREEN
ENG:
label: Engineering Library (Terman)
folio_pickup_service_point_code: ENG
hold_pseudopatron: HOLD@EN
hours:
library_slug: englib
location_slug: library-circulation
GREEN:
label: Green Library
contact_info:
phone: "(650) 723-1493"
email: [email protected]
folio_pickup_service_point_code: GREEN-LOAN
hold_pseudopatron: HOLD@GR
hours:
library_slug: green
location_slug: library-circulation
HOPKINS:
label: Marine Biology Library (Miller)
contact_info:
phone: "(831) 655-6229"
email: [email protected]
folio_pickup_service_point_code: MARINE-BIO
hold_pseudopatron: HOLD@MA
hours:
library_slug: hopkins
location_slug: library-circulation
LANE:
hold_pseudopatron: HOLD@LN
hours:
library_slug: lane
location_slug: library-circulation
LANE-MED:
label: Medical Library (Lane)
hold_pseudopatron: HOLD@LN
hours:
library_slug: lane
location_slug: library-circulation
LATHROP:
label: Lathrop Library
hours:
library_slug: lathrop
location_slug: tech-lounge
LAW:
label: Law Library (Crown)
contact_info:
phone: "(650) 723-2477"
email: [email protected]
folio_pickup_service_point_code: LAW
hold_pseudopatron: HOLD@LW
hours:
library_slug: law
location_slug: library-circulation
MARINE-BIO:
contact_info:
phone: "(831) 655-6229"
email: [email protected]
hold_pseudopatron: HOLD@MA
hours:
library_slug: hopkins
location_slug: library-circulation
MATH-CS:
label: Math & Statistics Library
hours:
library_slug: mathstat
location_slug: library-circulation
MEDIA-MTXT:
label: Media Microtext
folio_pickup_service_point_code: MEDIA-CENTER
hold_pseudopatron: HOLD@MD
hours:
library_slug: green
location_slug: media-microtext-center
MEDIA-CENTER:
label: Media Microtext
folio_pickup_service_point_code: MEDIA-CENTER
hold_pseudopatron: HOLD@MD
hours:
library_slug: green
location_slug: media-microtext-center
MUSIC:
label: Music Library
contact_info:
phone: (650) 723-1211
email: [email protected]
folio_pickup_service_point_code: MUSIC
hold_pseudopatron: HOLD@MU
hours:
library_slug: music
location_slug: library-circulation
RUMSEYMAP:
label: David Rumsey Map Center
instructions: Researchers can request to view these materials in the David Rumsey Map Center.
contact_info:
phone: (650) 498-8698
email: [email protected]
folio_pickup_service_point_code: RUMSEY-MAP
reading_room_url: https://library.stanford.edu/rumsey/about-center/visitor-policies
hold_pseudopatron: HOLD@RM
hours:
library_slug: Rumsey
location_slug: visitor-access
RUMSEY-MAP:
label: David Rumsey Map Center
instructions: Researchers can request to view these materials in the David Rumsey Map Center.
contact_info:
phone: (650) 498-8698
email: [email protected]
folio_pickup_service_point_code: RUMSEY-MAP
reading_room_url: https://library.stanford.edu/rumsey/about-center/visitor-policies
hold_pseudopatron: HOLD@RM
hours:
Expand All @@ -238,17 +314,20 @@ libraries:
library_slug: srwc
location_slug: lobby-desk
SAL:
label: SAL1&2 (on-campus shelving)
hold_pseudopatron: HOLD@SL
hours:
library_slug: sal12
location_slug: operations
pageable: true
SAL3:
label: SAL3 (off-campus storage)
hours:
library_slug: sal3
location_slug: operations
pageable: true
SAL-NEWARK:
label: SAL Newark (off-campus storage)
hours:
library_slug: newark
location_slug: operations
Expand All @@ -258,24 +337,29 @@ libraries:
phone: '(650) 723-3278'
email: '[email protected]'
SCIENCE:
label: Science Library (Li and Ma)
contact_info:
phone: "(650) 723-1528"
email: [email protected]
folio_pickup_service_point_code: SCIENCE
hold_pseudopatron: HOLD@CS
hours:
library_slug: science
location_slug: library-circulation
SPEC-COLL:
label: Special Collections
instructions: Researchers can request to view these materials in the Special Collections Reading Room. Request materials at least 2 business days in advance. Maximum 5 items per day.
contact_info:
phone: "(650) 725-1022"
email: [email protected]
folio_pickup_service_point_code: SPEC
reading_room_url: https://library.stanford.edu/spc/using-our-collections
hold_pseudopatron: HOLD@SP
hours:
library_slug: spc
location_slug: field-reading-room
TANNER:
label: Philosophy Library (Tanner)
hold_pseudopatron: HOLD@TA
hours:
library_slug: philosophy
Expand Down
4 changes: 0 additions & 4 deletions spec/models/library_location_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@
expect(described_class.library_name_by_code('SAL3')).to eq 'SAL3 (off-campus storage)'
end

it 'returns the label from Settings for a library like RWC without a FOLIO library code' do
expect(described_class.library_name_by_code('RWC')).to eq 'Academy Hall (SRWC)'
end

it 'returns nil when there is no configured library' do
expect(described_class.library_name_by_code('NOT-A-LIBRARY')).to be_nil
end
Expand Down

0 comments on commit 9d91269

Please sign in to comment.