Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add blacklight advances search, blacklight date ranges and order already #1993

Closed
wants to merge 16 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 36 additions & 4 deletions app/assets/javascripts/admin_font_select.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,38 @@
Blacklight.onLoad(function() {
if($("#admin_appearance_body_font").length > 0){
$("#admin_appearance_body_font").fontselect({lookahead: 20});
$("#admin_appearance_headline_font").fontselect({lookahead: 20});
Blacklight.onLoad(function () {
if ($("#admin_appearance_body_font").length > 0) {
$("#admin_appearance_body_font").fontselect({ lookahead: 20 });
$("#admin_appearance_headline_font").fontselect({ lookahead: 20 });
}
});

$("div.defaultable-fonts a.restore-default-font").click(function (e) {
e.preventDefault();
var defaultTarget = $(e.target).data("default-target");
var input = $("input[name='admin_appearance[" + defaultTarget + "]']");
var defaultValue = input.data("default-value").replace(";", "");
var inputDisplay = $("div[class$='" + defaultTarget + "']").find(
"div.font-select span"
);

input.val(defaultValue);
inputDisplay.css("font-family", defaultValue);
inputDisplay.text(defaultValue);
});

$(".panel-footer a.restore-all-default-fonts").click(function (e) {
e.preventDefault();

var allFontInputs = $("input[name*='font']");

allFontInputs.each(function () {
var thisTarget = $(this).attr("id").replace("admin_appearance_", "");
var defaultValue = $(this).data("default-value").replace(";", "");
var inputDisplay = $("div[class$='" + thisTarget + "']").find(
"div.font-select span"
);

$(this).val(defaultValue);
inputDisplay.css("font-family", defaultValue);
inputDisplay.text(defaultValue);
});
});
7 changes: 7 additions & 0 deletions app/controllers/saved_searches_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# frozen_string_literal: true

class SavedSearchesController < ApplicationController
include Blacklight::SavedSearches

helper BlacklightAdvancedSearch::RenderConstraintsOverride
end
125 changes: 125 additions & 0 deletions app/views/blacklight_range_limit/_range_limit_panel.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
<%- # requires solr_config local passed in
field_config = range_config(field_name)
label = facet_field_label(field_name)

input_label_range_begin = field_config[:input_label_range_begin] || t("blacklight.range_limit.range_begin", field_label: label)
input_label_range_end = field_config[:input_label_range_end] || t("blacklight.range_limit.range_end", field_label: label)
maxlength = field_config[:maxlength]
-%>


<%# NOTE(dewey4iv): leaving the styling here for now so that Christy can test out what she wants this to look like %>
<style>
.year-input {
font-size: 1em;
}

.limit_content.range_limit {
margin: .5em;
}
.limit_content.range_limit .range_input_wrapper {
margin: 5px 0;
}

.limit_content.range_limit .range_input_wrapper span {
display: block;
line-height: 1;
}

.limit_content.range_limit .range_input_wrapper:nth-child(2) {
margin-bottom: 25px;
}
</style>

<div class="limit_content range_limit">
<% if has_selected_range_limit?(field_name) %>
<ul class="current list-unstyled facet-values">
<li class="selected">
<span class="facet-label">
<span class="selected"><%= range_display(field_name) %></span>
<%= link_to remove_range_param(field_name), :class=>"remove", :title => t('blacklight.range_limit.remove_limit') do %>
<span class="glyphicon glyphicon-remove"></span>
<span class="sr-only">[<%= t('blacklight.range_limit.remove_limit') %>]</span>
<% end %>
</span>
<span class="selected facet-count"><%= number_with_delimiter(@response.total) %></span>
</li>
</ul>

<% end %>

<% unless selected_missing_for_range_limit?(field_name) %>
<%= form_tag search_action_path, :method => :get, class: [BlacklightRangeLimit.classes[:form], "range_#{field_name}"].join(' ') do %>
<%= render_hash_as_hidden_fields(search_state.params_for_search.except(:page)) %>

<!--
we need to include a dummy search_field parameter if none exists,
to trick blacklight into displaying actual search results instead
of home page. Not a great solution, but easiest for now.
-->
<% unless params.has_key?(:search_field) %>
<%= hidden_field_tag("search_field", "dummy_range") %>
<% end %>

<div class="range_input_wrapper">
<span class="year-input">Between year:</span>
<%= render_range_input(field_name, :begin, input_label_range_begin, maxlength) %>
</div>
<div class="range_input_wrapper">
<span class="year-input">and year:</span>
<%= render_range_input(field_name, :end, input_label_range_end, maxlength) %>
</div>
<%= submit_tag t('blacklight.range_limit.submit_limit'), class: "#{BlacklightRangeLimit.classes[:submit]} btn btn-default btn-block" %>
<% end %>
<% end %>

<!-- no results profile if missing is selected -->
<% unless selected_missing_for_range_limit?(field_name) %>
<!--
you can hide this if you want, but it has to be on page if you want
JS slider and calculated facets to show up, JS sniffs it.
-->
<div class="profile">
<% if stats_for_field?(field_name) %>
<!-- No stats information found for field in search response -->
<% end %>

<% if (min = range_results_endpoint(field_name, :min)) &&
(max = range_results_endpoint(field_name, :max)) %>
<p class="range subsection <%= "slider_js" unless field_config[:slider_js] == false %>">
<!-- Current results range from <span class="min"><%= range_results_endpoint(field_name, :min) %></span> to <span class="max"><%= range_results_endpoint(field_name, :max) %></span> -->
</p>

<% if field_config[:segments] != false %>
<div class="distribution subsection <%= 'chart_js' unless field_config[:chart_js] == false %>">
<!--
if we already fetched segments from solr, display them
here. Otherwise, display a link to fetch them, which JS
will AJAX fetch.
-->
<% if solr_range_queries_to_a(field_name).length > 0 %>

<%= render(:partial => "blacklight_range_limit/range_segments", :locals => {:solr_field => field_name}) %>

<% else %>
<%= link_to('View distribution', main_app.url_for(search_state.to_h.merge(action: 'range_limit', range_field: field_name, range_start: min, range_end: max)), :class => "load_distribution") %>
<% end %>
</div>
<% end %>
<% end %>

<% if (stats = stats_for_field(field_name)) %>
<ul class="missing list-unstyled facet-values subsection">
<li>
<span class="facet-label">
<%= link_to BlacklightRangeLimit.labels[:missing], add_range_missing(field_name) %>
</span>
<span class="facet-count">
<%= number_with_delimiter(stats["missing"]) %>
</span>
</li>
</ul>
<% end %>
</div>
<% end %>
</div>
Loading