Skip to content

Commit

Permalink
Use ordinary facet and show fields for exhibit-specific tags
Browse files Browse the repository at this point in the history
  • Loading branch information
cbeer committed Mar 18, 2015
1 parent cca55a0 commit 76786d9
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 22 deletions.
11 changes: 11 additions & 0 deletions app/assets/stylesheets/spotlight/_catalog.scss
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,14 @@ form.edit_solr_document {
float:left;
margin-right: $padding-xs-horizontal;
}

#document {
.blacklight-exhibit_tags {
color: $body-bg;
}

.blacklight-exhibit_tags a {
@extend .label;
@extend .label-default;
}
}
1 change: 0 additions & 1 deletion app/controllers/spotlight/catalog_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ def update
def edit
@response, @document = fetch params[:id]
blacklight_config.view.edit.partials = blacklight_config.view_config(:show).partials.dup
blacklight_config.view.edit.partials.delete "spotlight/catalog/tags"
blacklight_config.view.edit.partials.insert(2, :edit)
end

Expand Down
5 changes: 2 additions & 3 deletions app/models/spotlight/blacklight_configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,6 @@ def blacklight_config

config.default_solr_params = config.default_solr_params.merge(default_solr_params)

config.show.partials.insert(2, "spotlight/catalog/tags")

config.view.embed.partials ||= ['openseadragon']
config.view.embed.if = false
config.view.embed.locals ||= { osd_container_class: "" }
Expand Down Expand Up @@ -189,7 +187,8 @@ def default_blacklight_config

protected
def add_exhibit_specific_fields config
config.add_facet_field Spotlight::SolrDocument.solr_field_for_tagger(exhibit), label: :'blacklight.search.fields.facet.exhibit_tag', show: false unless config.facet_fields.include? :exhibit_tag
config.add_show_field :exhibit_tags, field: Spotlight::SolrDocument.solr_field_for_tagger(exhibit), link_to_search: true unless config.show_fields.include? :exhibit_tags
config.add_facet_field :exhibit_tags, field: Spotlight::SolrDocument.solr_field_for_tagger(exhibit) unless config.facet_fields.include? :exhibit_tags

exhibit.uploaded_resource_fields.each do |f|
key = Array(f.solr_field || f.field_name).first.to_s
Expand Down
5 changes: 0 additions & 5 deletions app/views/spotlight/catalog/_tags_default.html.erb

This file was deleted.

2 changes: 1 addition & 1 deletion blacklight-spotlight.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Gem::Specification.new do |s|
s.test_files = Dir["spec/**/*"]

s.add_dependency "rails", "~> 4.0", ">= 4.2.0"
s.add_dependency "blacklight", "~> 5.11"
s.add_dependency "blacklight", "~> 5.11", ">= 5.11.1"
s.add_dependency "autoprefixer-rails"
s.add_dependency "cancancan"
s.add_dependency "sir_trevor_rails", ">= 0.5.0a"
Expand Down
1 change: 1 addition & 0 deletions lib/generators/spotlight/templates/catalog_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class CatalogController < ApplicationController
config.index.title_field = 'full_title_tesim'

config.add_sort_field 'relevance', sort: 'score desc', label: 'Relevance'

end

end
8 changes: 4 additions & 4 deletions spec/features/exhibits/add_tags_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@

visit spotlight.exhibit_catalog_path(exhibit, "dq287tq6352")

within("ul.tags") do
expect(page).to have_selector "li", text: "One"
expect(page).to have_selector "li", text: "Two and a half"
expect(page).to have_selector "li", text: "Three"
within("dd.blacklight-exhibit_tags") do
expect(page).to have_selector "a", text: "One"
expect(page).to have_selector "a", text: "Two and a half"
expect(page).to have_selector "a", text: "Three"
end

click_on "Two and a half"
Expand Down
16 changes: 8 additions & 8 deletions spec/models/spotlight/blacklight_configuration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
config.add_sort_field 'source', sort: 'sort_source_ssi asc', :label => 'Source'
config.add_sort_field 'identifier', sort: 'id asc', :label => 'Identifier'
end
allow(subject).to receive_messages default_blacklight_config: blacklight_config
allow(Spotlight::Engine).to receive_messages blacklight_config: blacklight_config
subject.exhibit = FactoryGirl.create(:exhibit)
end

Expand Down Expand Up @@ -64,7 +64,7 @@

expect(subject.blacklight_config.facet_fields.keys).to eq ['c', 'a', 'b']
end

context "custom fields" do
it "should include any custom fields" do
allow(subject).to receive_messages(custom_facet_fields: { 'a' => double(if: nil, :if= => true, merge!: true, validate!: true, normalize!: true) })
Expand All @@ -77,7 +77,12 @@
expect(subject.blacklight_config.facet_fields['a'].show).to be_falsey
end
end


context "exhibit fields" do
it "should inject a tags facet" do
expect(subject.blacklight_config.facet_fields).to include "exhibit_tags"
end
end
end

describe "index fields" do
Expand Down Expand Up @@ -385,11 +390,6 @@
subject.show[:title_field] = 'abc'
expect(subject.blacklight_config.show.title_field).to eq 'abc'
end

it "should inject partials" do
partials = subject.blacklight_config.show.partials
expect(partials).to include "spotlight/catalog/tags"
end
end

describe "index" do
Expand Down

0 comments on commit 76786d9

Please sign in to comment.