-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
72 additions
and
0 deletions.
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
app/assets/javascripts/spotlight/blocks/solr_documents_osd_block.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
//= require spotlight/blocks/solr_documents_block | ||
|
||
SirTrevor.Blocks.SolrDocumentsOsd = (function(){ | ||
|
||
return SirTrevor.Blocks.SolrDocuments.extend({ | ||
type: "solr_documents_Osd", | ||
title: function() { return "Item OSD"; }, | ||
|
||
icon_name: "item_osd", | ||
blockGroup: 'Exhibit item widgets', | ||
description: "This widget displays items in an OpenSeaDragon environment", | ||
|
||
item_options: function() { return "" } | ||
}); | ||
|
||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
app/models/sir_trevor_rails/blocks/solr_documents_osd_block.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module SirTrevorRails::Blocks | ||
class SolrDocumentsOsdBlock < SirTrevorRails::Blocks::SolrDocumentsBlock | ||
end | ||
end |
22 changes: 22 additions & 0 deletions
22
app/views/spotlight/sir_trevor/blocks/_solr_documents_osd_block.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<% solr_documents_osd_block.with_solr_helper(self) %> | ||
|
||
<div class="content-block items-block row"> | ||
|
||
<% if solr_documents_osd_block.text? %> | ||
<div class="text-col col-md-6 pull-<%= solr_documents_osd_block.text_align %>"> | ||
<h3><%= solr_documents_osd_block.title %></h3> | ||
<%= sir_trevor_markdown solr_documents_osd_block.text %> | ||
</div> | ||
<% end %> | ||
<% if solr_documents_osd_block.documents? %> | ||
|
||
<div class="content-block spotlight-flexbox <%= solr_documents_osd_block.text? ? "col-md-6" : "col-md-12" %> "> | ||
<% solr_documents_osd_block.documents.each do |document| %> | ||
<div class="box" data-id="<%= document.id %>"> | ||
<%= render_document_partial document, 'openseadragon', osd_container_class: "" %> | ||
</div> | ||
<% end %> | ||
</div> | ||
<% end %> | ||
</div> |
29 changes: 29 additions & 0 deletions
29
spec/views/spotlight/sir_trevor/blocks/_solr_documents_osd_block.html.erb_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
require 'spec_helper' | ||
|
||
describe 'spotlight/sir_trevor/blocks/_solr_documents_osd_block.html.erb', type: :view do | ||
|
||
let(:p) { "spotlight/sir_trevor/blocks/solr_documents_osd_block.html.erb" } | ||
let(:page) { double("Page") } | ||
let(:block) do | ||
SirTrevorRails::Blocks::SolrDocumentsGridBlock.new({type: "block", data: { title: "Some title", text: "Some text", "text-align" => "right" }}, page) | ||
end | ||
let(:doc) { ::SolrDocument.new(id: 1) } | ||
|
||
before do | ||
allow(block).to receive(:documents).and_return([doc]) | ||
allow(block).to receive(:document_options).and_return({}) | ||
end | ||
|
||
before do | ||
allow(view).to receive_messages(has_thumbnail?: true, render_thumbnail_tag: 'thumb') | ||
end | ||
|
||
it "should have a slideshow block" do | ||
expect(view).to receive(:render_document_partial).with(doc, "openseadragon", hash_including()).and_return("OSD") | ||
render partial: p, locals: { solr_documents_osd_block: block} | ||
expect(rendered).to have_selector 'h3', text: 'Some title' | ||
expect(rendered).to have_content "Some text" | ||
expect(rendered).to have_selector '.box', text: 'OSD' | ||
expect(rendered).to have_selector '.text-col.pull-right' | ||
end | ||
end |