Skip to content

Commit

Permalink
Merge pull request #1244 from sul-dlss/non-collection-online-items
Browse files Browse the repository at this point in the history
Move online label into model method and change algorithm to return…
  • Loading branch information
Jessie Keck committed Mar 3, 2016
2 parents 0198084 + f3c0801 commit c2dc853
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 16 deletions.
6 changes: 6 additions & 0 deletions app/models/concerns/collection_member.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ def index_parent_collections
@index_parent_collections
end

def online_label
return if is_a_collection?
return if druid.blank?
"<span class='online-label'>Online</span>".html_safe
end

private
def parent_collection_params
self["collection"].map do |collection_id|
Expand Down
4 changes: 1 addition & 3 deletions app/views/browse/_index_header_default.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
<%= render_resource_icon document[document.format_key] %>
<%= link_to_document document, get_main_title(document) %>
<span class="main-title-date"><%= get_main_title_date(document) %></span>
<% if document.is_a_collection_member? %>
<span class="online-label">Online</span>
<% end %>
<%= document.online_label %>
</h3>
<% # bookmark functions for items/docs -%>
<%= render_index_doc_actions document, :wrapping_class => "index-document-functions col-sm-3 col-lg-2" %>
Expand Down
4 changes: 1 addition & 3 deletions app/views/catalog/_index_brief.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@
</span>
<%= link_to_document document, get_main_title(document), :counter => (counter + @response.params[:start].to_i) %>
<span class="main-title-date"><%= get_main_title_date(document) %></span>
<% if document.is_a_collection_member? %>
<span class="online-label">Online</span>
<% end %>
<%= document.online_label %>
</h3>
<% if document[:vern_title_display].present? %>
<ul class="document-metadata"><li><%= document[:vern_title_display].html_safe %></li></ul>
Expand Down
4 changes: 1 addition & 3 deletions app/views/catalog/_index_header_default.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@
</span>
<%= link_to_document document, get_main_title(document), :counter => counter %>
<span class="main-title-date"><%= get_main_title_date(document) %></span>
<% if document.is_a_collection_member? %>
<span class="online-label">Online</span>
<% end %>
<%= document.online_label %>
</h3>
<% # bookmark functions for items/docs -%>
Expand Down
4 changes: 1 addition & 3 deletions app/views/catalog/_index_header_gallery.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
<%= render_resource_icon document[document.format_key] %>
<%= link_to_document document, get_main_title(document), counter: counter %>
<span class="main-title-date"><%= get_main_title_date(document) %></span>
<% if document.is_a_collection_member? %>
<span class="online-label">Online</span>
<% end %>
<%= document.online_label %>
</h3>
</div>
4 changes: 1 addition & 3 deletions app/views/preview/_show_header_default.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,5 @@
<%= render_resource_icon document[document.format_key] %>
<%= link_to_document document, get_main_title(document) %>
<span class="main-title-date"><%= get_main_title_date(document) %></span>
<% if document.is_a_collection_member? %>
<span class="online-label">Online</span>
<% end %>
<%= document.online_label %>
</h3>
28 changes: 27 additions & 1 deletion spec/models/concerns/collection_member_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,30 @@
expect(document_without_parent.index_parent_collections).to be_nil
end
end
end

describe '#online_label' do
context 'for collections' do
subject { SolrDocument.new(collection_type: ['Digital Collection'], druid: ['12345']) }

it 'is nil' do
expect(subject.online_label).to be_nil
end
end

context 'for items w/o druids' do
subject { SolrDocument.new }

it 'is nil' do
expect(subject.online_label).to be_nil
end
end

context 'for items with a druid' do
subject { SolrDocument.new(druid: ['12345']) }

it 'is the online-label markup' do
expect(Capybara.string(subject.online_label)).to have_css('span.online-label', text: 'Online')
end
end
end
end

0 comments on commit c2dc853

Please sign in to comment.