diff --git a/app/assets/javascripts/spotlight/appearance.js b/app/assets/javascripts/spotlight/appearance.js
new file mode 100644
index 000000000..a4c20a4dc
--- /dev/null
+++ b/app/assets/javascripts/spotlight/appearance.js
@@ -0,0 +1,26 @@
+Spotlight.onLoad(function(){
+ $('#nested-navigation').nestable({maxDepth: 1});
+ updateWeightsAndRelationships($('#nested-navigation'));
+ addRestoreDefaultBehavior();
+});
+
+function addRestoreDefaultBehavior(){
+ $("[data-behavior='restore-default']").each(function(){
+ var hidden = $("[data-default-value]", $(this));
+ var value = $($("[data-in-place-edit-target]", $(this)).data('in-place-edit-target'), $(this));
+ var button = $("[data-restore-default]", $(this));
+ hidden.on('blur', function(){
+ if( $(this).val() == $(this).data('default-value') ) {
+ button.addClass('hidden');
+ } else {
+ button.removeClass('hidden');
+ }
+ });
+ button.on('click', function(e){
+ e.preventDefault();
+ hidden.val(hidden.data('default-value'));
+ value.text(hidden.data('default-value'));
+ button.hide();
+ });
+ });
+}
\ No newline at end of file
diff --git a/app/controllers/spotlight/about_pages_controller.rb b/app/controllers/spotlight/about_pages_controller.rb
index 323a6ad96..f438f0d78 100644
--- a/app/controllers/spotlight/about_pages_controller.rb
+++ b/app/controllers/spotlight/about_pages_controller.rb
@@ -20,7 +20,7 @@ def attach_breadcrumbs
if action_name == 'edit'
add_breadcrumb t(:'spotlight.pages.index.about_pages.header'), exhibit_about_pages_path(@exhibit)
else
- add_breadcrumb t(:'spotlight.about_pages.nav_link'), [@exhibit, @exhibit.main_about_page]
+ add_breadcrumb (@exhibit.main_navigations.about.label_or_default), [@exhibit, @exhibit.main_about_page]
end
unless @page == @exhibit.main_about_page
diff --git a/app/controllers/spotlight/appearances_controller.rb b/app/controllers/spotlight/appearances_controller.rb
index 936599e79..4399631a7 100644
--- a/app/controllers/spotlight/appearances_controller.rb
+++ b/app/controllers/spotlight/appearances_controller.rb
@@ -27,7 +27,7 @@ def load_and_authorize_appearance
def appearance_params
params.require(:appearance).permit(:default_per_page, :thumbnail_size,
document_index_view_types: @appearance.view_type_options,
- sort_fields: @appearance.allowed_params)
+ sort_fields: @appearance.allowed_params,
+ main_navigations: [:id, :label, :weight])
end
-
end
diff --git a/app/controllers/spotlight/browse_controller.rb b/app/controllers/spotlight/browse_controller.rb
index 9a79f51f6..b8f2c7cc7 100644
--- a/app/controllers/spotlight/browse_controller.rb
+++ b/app/controllers/spotlight/browse_controller.rb
@@ -32,7 +32,7 @@ def history_session
def attach_breadcrumbs
add_breadcrumb t(:'spotlight.exhibits.breadcrumb', title: @exhibit.title), @exhibit
- add_breadcrumb t(:'spotlight.browse.nav_link'), exhibit_browse_index_path(@exhibit)
+ add_breadcrumb (@exhibit.main_navigations.browse.label_or_default), exhibit_browse_index_path(@exhibit)
end
def _prefixes
diff --git a/app/controllers/spotlight/catalog_controller.rb b/app/controllers/spotlight/catalog_controller.rb
index fc1981433..ee32d4afa 100644
--- a/app/controllers/spotlight/catalog_controller.rb
+++ b/app/controllers/spotlight/catalog_controller.rb
@@ -29,7 +29,7 @@ def show
end
if current_browse_category
- add_breadcrumb t(:'spotlight.browse.nav_link'), exhibit_browse_index_path(current_browse_category.exhibit)
+ add_breadcrumb current_browse_category.exhibit.main_navigations.browse.label_or_default, exhibit_browse_index_path(current_browse_category.exhibit)
add_breadcrumb current_browse_category.title, exhibit_browse_path(current_browse_category.exhibit, current_browse_category)
elsif current_page_context
add_breadcrumb current_page_context.title, [current_page_context.exhibit, current_page_context] if current_page_context.title.present? and !current_page_context.is_a?(Spotlight::HomePage)
diff --git a/app/forms/spotlight/appearance.rb b/app/forms/spotlight/appearance.rb
index b2d711bc8..49da6f0dd 100644
--- a/app/forms/spotlight/appearance.rb
+++ b/app/forms/spotlight/appearance.rb
@@ -2,7 +2,7 @@ module Spotlight
class Appearance
extend ActiveModel::Naming
include ActiveModel::Conversion
-
+
def initialize(configuration)
@configuration = configuration
end
@@ -11,6 +11,8 @@ def initialize(configuration)
delegate :persisted?, :exhibit, :exhibit_id, :default_per_page, :thumbnail_size,
:default_blacklight_config, to: :configuration
+ delegate :main_navigations, to: :exhibit
+
##
# This enables us to have a group of checkboxes that is backed by the array
# stored in Spotlight::BlacklightConfiguration#document_index_view_types
@@ -40,9 +42,8 @@ def allowed_params
end
def update(params)
- params[:document_index_view_types] = keep_selected_values(params[:document_index_view_types])
- params[:sort_fields] = enable_sort_fields(keep_selected_values(params[:sort_fields]))
- configuration.update(params)
+ configuration.exhibit.update(main_navigations_attributes: exhibit_params(params)) if exhibit_params(params)
+ configuration.update(configuration_params(params))
end
def view_type_options
@@ -73,6 +74,17 @@ def enable_sort_fields(checked_fields)
end
end
+ def configuration_params(params)
+ p = params.except(:main_navigations)
+ p[:document_index_view_types] = keep_selected_values(p[:document_index_view_types])
+ p[:sort_fields] = enable_sort_fields(keep_selected_values(p[:sort_fields]))
+ p
+ end
+
+ def exhibit_params(params)
+ params[:main_navigations].try(:values)
+ end
+
##
# A group of checkboxes on a form returns values like this:
# {"list"=>["0", "1"], "gallery"=>["0", "1"], "map"=>["0"]}
diff --git a/app/models/spotlight/exhibit.rb b/app/models/spotlight/exhibit.rb
index 67734de22..856578497 100644
--- a/app/models/spotlight/exhibit.rb
+++ b/app/models/spotlight/exhibit.rb
@@ -15,6 +15,7 @@ class Spotlight::Exhibit < ActiveRecord::Base
has_many :custom_fields, dependent: :delete_all
has_many :contacts, dependent: :delete_all # These are the contacts who appear in the sidebar
has_many :contact_emails, dependent: :delete_all # These are the contacts who get "Contact us" emails
+ has_many :main_navigations, dependent: :delete_all
has_many :solr_document_sidecars, dependent: :delete_all
has_many :roles, dependent: :delete_all
has_many :attachments, dependent: :destroy
@@ -29,6 +30,7 @@ class Spotlight::Exhibit < ActiveRecord::Base
accepts_nested_attributes_for :about_pages
accepts_nested_attributes_for :feature_pages
accepts_nested_attributes_for :home_page, update_only: true
+ accepts_nested_attributes_for :main_navigations
accepts_nested_attributes_for :contacts
accepts_nested_attributes_for :contact_emails, reject_if: proc {|attr| attr['email'].blank?}
accepts_nested_attributes_for :roles, allow_destroy: true, reject_if: proc {|attr| attr['user_key'].blank?}
@@ -42,6 +44,7 @@ class Spotlight::Exhibit < ActiveRecord::Base
before_create :build_home_page
after_create :initialize_config
after_create :initialize_browse
+ after_create :initialize_main_navigation
before_save :sanitize_description
validate :title, presence: true
@@ -91,7 +94,18 @@ def initialize_browse
long_description: "All items in this exhibit"
end
+ def initialize_main_navigation
+ self.default_main_navigations.each_with_index do |nav_type, weight|
+ self.main_navigations.create nav_type: nav_type, weight: weight
+ end
+ end
+
def sanitize_description
self.description = HTML::FullSanitizer.new.sanitize(description) if description_changed?
end
+
+ def default_main_navigations
+ [:curated_features, :browse, :about]
+ end
+
end
diff --git a/app/models/spotlight/main_navigation.rb b/app/models/spotlight/main_navigation.rb
new file mode 100644
index 000000000..5ba950e66
--- /dev/null
+++ b/app/models/spotlight/main_navigation.rb
@@ -0,0 +1,20 @@
+module Spotlight
+ class MainNavigation < ActiveRecord::Base
+ belongs_to :exhibit
+ default_scope -> { order("weight ASC") }
+ scope :browse, -> { where(nav_type: "browse").take }
+ scope :about, -> { where(nav_type: "about").take }
+
+ def label_or_default
+ if label.present?
+ label
+ else
+ default_label
+ end
+ end
+
+ def default_label
+ I18n.t(:"spotlight.main_navigation.#{nav_type}")
+ end
+ end
+end
diff --git a/app/views/shared/_about_navbar.html.erb b/app/views/shared/_about_navbar.html.erb
new file mode 100644
index 000000000..67a492d40
--- /dev/null
+++ b/app/views/shared/_about_navbar.html.erb
@@ -0,0 +1,3 @@
+<% if current_exhibit.main_about_page %>
+
"><%= link_to navigation.label_or_default, [spotlight, current_exhibit, current_exhibit.main_about_page] %>
+<% end %>
\ No newline at end of file
diff --git a/app/views/shared/_browse_navbar.html.erb b/app/views/shared/_browse_navbar.html.erb
new file mode 100644
index 000000000..46f40788b
--- /dev/null
+++ b/app/views/shared/_browse_navbar.html.erb
@@ -0,0 +1,3 @@
+<% if current_exhibit.has_browse_categories? %>
+ "><%= link_to navigation.label_or_default, spotlight.exhibit_browse_index_path(current_exhibit) %>
+<% end %>
\ No newline at end of file
diff --git a/app/views/shared/_curated_features_navbar.html.erb b/app/views/shared/_curated_features_navbar.html.erb
new file mode 100644
index 000000000..5c3db2638
--- /dev/null
+++ b/app/views/shared/_curated_features_navbar.html.erb
@@ -0,0 +1,15 @@
+<% published_top_level_feature_pages = current_exhibit.feature_pages.published.at_top_level -%>
+<% if published_top_level_feature_pages.present? %>
+ <% if published_top_level_feature_pages.many? %>
+
+ <%= navigation.label_or_default %>
+
+
+ <% else %>
+ "><%= link_to published_top_level_feature_pages.first.title, [spotlight, published_top_level_feature_pages.first.exhibit, published_top_level_feature_pages.first] %>
+ <% end %>
+<% end %>
\ No newline at end of file
diff --git a/app/views/shared/_exhibit_navbar.html.erb b/app/views/shared/_exhibit_navbar.html.erb
index 8f0e6892b..33e0204e1 100644
--- a/app/views/shared/_exhibit_navbar.html.erb
+++ b/app/views/shared/_exhibit_navbar.html.erb
@@ -2,31 +2,11 @@
<% if current_exhibit -%>
- - "><%= link_to t(:'spotlight.curation.nav.home'), current_exhibit %>
- <% published_top_level_feature_pages = current_exhibit.feature_pages.published.at_top_level -%>
- <% if published_top_level_feature_pages.present? %>
- <% if published_top_level_feature_pages.many? %>
- -
- <%= t(:'spotlight.feature_pages.nav_link') %>
-
-
- <% else %>
- - "><%= link_to published_top_level_feature_pages.first.title, [spotlight, published_top_level_feature_pages.first.exhibit, published_top_level_feature_pages.first] %>
+ - "><%= link_to t(:'spotlight.curation.nav.home'), current_exhibit %>
+ <% current_exhibit.main_navigations.each do |navigation| %>
+ <%= render partial: "shared/#{navigation.nav_type}_navbar", locals: {navigation: navigation} %>
<% end %>
<% end %>
- <% if current_exhibit.has_browse_categories? %>
- - "><%= link_to t(:'spotlight.browse.nav_link'), spotlight.exhibit_browse_index_path(current_exhibit) %>
- <% end %>
- <% if current_exhibit.main_about_page %>
- - "><%= link_to t(:'spotlight.about_pages.nav_link'), [spotlight, current_exhibit, current_exhibit.main_about_page] %>
- <% end %>
- <% end %>
diff --git a/app/views/spotlight/about_pages/_sidebar.html.erb b/app/views/spotlight/about_pages/_sidebar.html.erb
index 1e29708a2..fa12d4697 100644
--- a/app/views/spotlight/about_pages/_sidebar.html.erb
+++ b/app/views/spotlight/about_pages/_sidebar.html.erb
@@ -1,5 +1,5 @@