blacklight 6.11.0 → 6.11.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/app/assets/javascripts/blacklight/ajax_modal.js +53 -63
- data/app/controllers/concerns/blacklight/catalog.rb +5 -4
- data/app/helpers/blacklight/catalog_helper_behavior.rb +5 -1
- data/app/helpers/blacklight/component_helper_behavior.rb +11 -1
- data/app/helpers/blacklight/configuration_helper_behavior.rb +8 -1
- data/app/helpers/blacklight/url_helper_behavior.rb +2 -2
- data/app/models/concerns/blacklight/document.rb +6 -7
- data/app/models/concerns/blacklight/document/semantic_fields.rb +5 -3
- data/app/views/catalog/_show_tools.html.erb +26 -24
- data/app/views/catalog/_view_type_group.html.erb +1 -1
- data/lib/blacklight/utils.rb +1 -1
- data/spec/helpers/catalog_helper_spec.rb +1 -1
- data/spec/helpers/configuration_helper_spec.rb +12 -0
- data/spec/helpers/url_helper_spec.rb +3 -3
- data/spec/models/blacklight/solr/document_spec.rb +9 -3
- data/spec/views/catalog/_show_tools.html.erb_spec.rb +12 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8a72b5c9469391daec118e8cfef69fd9960cf687
|
4
|
+
data.tar.gz: 1a9a6c9147a770fa9ffaa107d789618b39b2c2fd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 286d8992abd602981c3603da27a5fe7aa9d7f5796b1b32c4ee63f1afdd66ca3ea50d7a5b15ebf2ea03102b3460a19e5f4ebf0a5a12f2b36772f6971a08cc7f3c
|
7
|
+
data.tar.gz: 9d8b1df273e758854c4e79407cd4817a8561e6b1879100855a1db2400d43fc54219e9ef4c41ba5c69074897915328dd54876f252ba702bc5b6734516c7e32f9e
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
6.11.
|
1
|
+
6.11.1
|
@@ -1,14 +1,14 @@
|
|
1
1
|
//= require blacklight/core
|
2
2
|
|
3
|
-
/*
|
3
|
+
/*
|
4
4
|
The ajax_modal plugin can display some interactions inside a Bootstrap
|
5
|
-
modal window, including some multi-page interactions.
|
5
|
+
modal window, including some multi-page interactions.
|
6
6
|
|
7
7
|
It supports unobtrusive Javascript, where a link or form that would have caused
|
8
8
|
a new page load is changed to display it's results inside a modal dialog,
|
9
9
|
by this plugin. The plugin assumes there is a Bootstrap modal div
|
10
10
|
on the page with id #ajax-modal to use as the modal -- the standard Blacklight
|
11
|
-
layout provides this.
|
11
|
+
layout provides this.
|
12
12
|
|
13
13
|
To make a link or form have their results display inside a modal, add
|
14
14
|
`data-ajax-modal="trigger"` to the link or form. (Note, form itself not submit input)
|
@@ -23,18 +23,18 @@
|
|
23
23
|
the layout when a JS AJAX request is detected, OR the response
|
24
24
|
can include a `<div data-ajax-modal="container">` -- only the contents
|
25
25
|
of the container will be placed inside the modal, the rest of the
|
26
|
-
page will be ignored.
|
26
|
+
page will be ignored.
|
27
27
|
|
28
28
|
If you'd like to have a link or button that closes the modal,
|
29
29
|
you can just add a `data-dismiss="modal"` to the link,
|
30
30
|
standard Bootstrap convention. But you can also have
|
31
31
|
an href on this link for non-JS contexts, we'll make sure
|
32
|
-
inside the modal it closes the modal and the link is NOT followed.
|
32
|
+
inside the modal it closes the modal and the link is NOT followed.
|
33
33
|
|
34
34
|
Link or forms inside the modal will ordinarily cause page loads
|
35
35
|
when they are triggered. However, if you'd like their results
|
36
36
|
to stay within the modal, just add `data-ajax-modal="preserve"`
|
37
|
-
to the link or form.
|
37
|
+
to the link or form.
|
38
38
|
|
39
39
|
Here's an example of what might be returned, demonstrating most of the devices available:
|
40
40
|
|
@@ -43,7 +43,7 @@
|
|
43
43
|
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
44
44
|
<h3 class="modal-title">Request Placed</h3>
|
45
45
|
</div>
|
46
|
-
|
46
|
+
|
47
47
|
<div class="modal-body">
|
48
48
|
<p>Some message</p>
|
49
49
|
<%= link_to "This result will still be within modal", some_link, :data => {:ajax_modal => "preserve"} %>
|
@@ -59,22 +59,22 @@
|
|
59
59
|
One additional feature. If the content returned from the AJAX modal load
|
60
60
|
has an element with `data-ajax-modal=close`, that will trigger the modal
|
61
61
|
to be closed. And if this element includes a node with class "flash_messages",
|
62
|
-
the flash-messages node will be added to the main page inside #main-flahses.
|
62
|
+
the flash-messages node will be added to the main page inside #main-flahses.
|
63
63
|
|
64
64
|
== Events
|
65
65
|
|
66
66
|
We'll send out an event 'loaded.blacklight.ajax-modal' with the #ajax-modal
|
67
67
|
dialog as the target, right after content is loaded into the modal but before
|
68
|
-
it is shown (if not already a shown modal). In an event handler, you can
|
68
|
+
it is shown (if not already a shown modal). In an event handler, you can
|
69
69
|
inspect loaded content by looking inside $(this). If you call event.preventDefault(),
|
70
70
|
we won't 'show' the dialog (although it may already have been shown, you may want to
|
71
|
-
$(this).modal("hide") if you want to ensure hidden/closed.
|
71
|
+
$(this).modal("hide") if you want to ensure hidden/closed.
|
72
72
|
|
73
|
-
The data-ajax-modal=close behavior is implemented with this event, see for example.
|
73
|
+
The data-ajax-modal=close behavior is implemented with this event, see for example.
|
74
74
|
*/
|
75
75
|
|
76
|
-
// We keep all our data in Blacklight.ajaxModal object.
|
77
|
-
// Create lazily if someone else created first.
|
76
|
+
// We keep all our data in Blacklight.ajaxModal object.
|
77
|
+
// Create lazily if someone else created first.
|
78
78
|
if (Blacklight.ajaxModal === undefined) {
|
79
79
|
Blacklight.ajaxModal = {};
|
80
80
|
}
|
@@ -104,67 +104,57 @@ Blacklight.ajaxModal.modalCloseSelector = "[data-ajax-modal~=close], span.ajax
|
|
104
104
|
|
105
105
|
// Called on fatal failure of ajax load, function returns content
|
106
106
|
// to show to user in modal. Right now called only for extreme
|
107
|
-
// network errors.
|
107
|
+
// network errors.
|
108
108
|
Blacklight.ajaxModal.onFailure = function(data) {
|
109
109
|
var contents = "<div class='modal-header'>" +
|
110
110
|
"<button type='button' class='close' data-dismiss='modal' aria-hidden='true'>×</button>" +
|
111
111
|
"Network Error</div>";
|
112
112
|
$(Blacklight.ajaxModal.modalSelector).find('.modal-content').html(contents);
|
113
|
-
$(Blacklight.ajaxModal.modalSelector).modal('show');
|
113
|
+
$(Blacklight.ajaxModal.modalSelector).modal('show');
|
114
114
|
}
|
115
115
|
|
116
|
-
Blacklight.ajaxModal.receiveAjax = function (
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
// send custom event with the modal dialog div as the target
|
136
|
-
var e = $.Event('loaded.blacklight.ajax-modal')
|
137
|
-
$(Blacklight.ajaxModal.modalSelector).trigger(e);
|
138
|
-
// if they did preventDefault, don't show the dialog
|
139
|
-
if (e.isDefaultPrevented()) return;
|
140
|
-
|
141
|
-
$(Blacklight.ajaxModal.modalSelector).modal('show');
|
142
|
-
}
|
116
|
+
Blacklight.ajaxModal.receiveAjax = function (contents) {
|
117
|
+
// does it have a data- selector for container?
|
118
|
+
// important we don't execute script tags, we shouldn't.
|
119
|
+
// code modelled off of JQuery ajax.load. https://github.com/jquery/jquery/blob/master/src/ajax/load.js?source=c#L62
|
120
|
+
var container = $("<div>").
|
121
|
+
append( jQuery.parseHTML(contents) ).find( Blacklight.ajaxModal.containerSelector ).first();
|
122
|
+
if (container.length !== 0) {
|
123
|
+
contents = container.html();
|
124
|
+
}
|
125
|
+
|
126
|
+
$(Blacklight.ajaxModal.modalSelector).find('.modal-content').html(contents);
|
127
|
+
|
128
|
+
// send custom event with the modal dialog div as the target
|
129
|
+
var e = $.Event('loaded.blacklight.blacklight-modal')
|
130
|
+
$(Blacklight.ajaxModal.modalSelector).trigger(e);
|
131
|
+
// if they did preventDefault, don't show the dialog
|
132
|
+
if (e.isDefaultPrevented()) return;
|
133
|
+
|
134
|
+
$(Blacklight.ajaxModal.modalSelector).modal('show');
|
143
135
|
};
|
144
136
|
|
145
137
|
|
146
138
|
Blacklight.ajaxModal.modalAjaxLinkClick = function(e) {
|
147
139
|
e.preventDefault();
|
148
140
|
|
149
|
-
|
150
|
-
url: $(this).attr('href')
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
jqxhr.always( Blacklight.ajaxModal.receiveAjax );
|
141
|
+
$.ajax({
|
142
|
+
url: $(this).attr('href')
|
143
|
+
})
|
144
|
+
.fail(Blacklight.ajaxModal.onFailure)
|
145
|
+
.done(Blacklight.ajaxModal.receiveAjax)
|
155
146
|
};
|
156
147
|
|
157
148
|
Blacklight.ajaxModal.modalAjaxFormSubmit = function(e) {
|
158
|
-
|
159
|
-
|
160
|
-
var jqxhr = $.ajax({
|
161
|
-
url: $(this).attr('action'),
|
162
|
-
data: $(this).serialize(),
|
163
|
-
type: $(this).attr('method'), //POST',
|
164
|
-
dataType: 'script'
|
165
|
-
});
|
149
|
+
e.preventDefault();
|
166
150
|
|
167
|
-
|
151
|
+
$.ajax({
|
152
|
+
url: $(this).attr('action'),
|
153
|
+
data: $(this).serialize(),
|
154
|
+
type: $(this).attr('method') // POST
|
155
|
+
})
|
156
|
+
.fail(Blacklight.ajaxModal.onFailure)
|
157
|
+
.done(Blacklight.ajaxModal.receiveAjax)
|
168
158
|
}
|
169
159
|
|
170
160
|
|
@@ -172,14 +162,14 @@ Blacklight.ajaxModal.modalAjaxFormSubmit = function(e) {
|
|
172
162
|
Blacklight.ajaxModal.setup_modal = function() {
|
173
163
|
// Event indicating blacklight is setting up a modal link,
|
174
164
|
// you can catch it and call e.preventDefault() to abort
|
175
|
-
// setup.
|
165
|
+
// setup.
|
176
166
|
var e = $.Event('setup.blacklight.ajax-modal');
|
177
167
|
$("body").trigger(e);
|
178
168
|
if (e.isDefaultPrevented()) return;
|
179
169
|
|
180
170
|
// Register both trigger and preserve selectors in ONE event handler, combining
|
181
171
|
// into one selector with a comma, so if something matches BOTH selectors, it
|
182
|
-
// still only gets the event handler called once.
|
172
|
+
// still only gets the event handler called once.
|
183
173
|
$("body").on("click", Blacklight.ajaxModal.triggerLinkSelector + ", " + Blacklight.ajaxModal.preserveLinkSelector,
|
184
174
|
Blacklight.ajaxModal.modalAjaxLinkClick);
|
185
175
|
$("body").on("submit", Blacklight.ajaxModal.triggerFormSelector + ", " + Blacklight.ajaxModal.preserveFormSelector,
|
@@ -190,7 +180,7 @@ Blacklight.ajaxModal.setup_modal = function() {
|
|
190
180
|
|
191
181
|
// we support doing data-dismiss=modal on a <a> with a href for non-ajax
|
192
182
|
// use, we need to suppress following the a's href that's there for
|
193
|
-
// non-JS contexts.
|
183
|
+
// non-JS contexts.
|
194
184
|
$("body ").on("click", Blacklight.ajaxModal.modalSelector + " a[data-dismiss~=modal]", function (e) {
|
195
185
|
e.preventDefault();
|
196
186
|
});
|
@@ -198,7 +188,7 @@ Blacklight.ajaxModal.setup_modal = function() {
|
|
198
188
|
|
199
189
|
// A function used as an event handler on loaded.blacklight.ajax-modal
|
200
190
|
// to catch contained data-ajax-modal=closed directions
|
201
|
-
Blacklight.ajaxModal.check_close_ajax_modal = function(event) {
|
191
|
+
Blacklight.ajaxModal.check_close_ajax_modal = function(event) {
|
202
192
|
if ($(event.target).find(Blacklight.ajaxModal.modalCloseSelector).length) {
|
203
193
|
modal_flashes = $(this).find('.flash_messages');
|
204
194
|
|
@@ -207,10 +197,10 @@ Blacklight.ajaxModal.check_close_ajax_modal = function(event) {
|
|
207
197
|
|
208
198
|
main_flashes = $('#main-flashes');
|
209
199
|
main_flashes.append(modal_flashes);
|
210
|
-
modal_flashes.fadeIn(500);
|
200
|
+
modal_flashes.fadeIn(500);
|
211
201
|
}
|
212
202
|
}
|
213
203
|
|
214
|
-
Blacklight.onLoad(function() {
|
204
|
+
Blacklight.onLoad(function() {
|
215
205
|
Blacklight.ajaxModal.setup_modal();
|
216
206
|
});
|
@@ -71,11 +71,12 @@ module Blacklight::Catalog
|
|
71
71
|
@display_facet = @response.aggregations[@facet.field]
|
72
72
|
@pagination = facet_paginator(@facet, @display_facet)
|
73
73
|
respond_to do |format|
|
74
|
-
|
75
|
-
|
74
|
+
format.html do
|
75
|
+
# Draw the partial for the "more" facet modal window:
|
76
|
+
return render layout: false if request.xhr?
|
77
|
+
# Otherwise draw the facet selector for users who have javascript disabled.
|
78
|
+
end
|
76
79
|
format.json
|
77
|
-
# Draw the partial for the "more" facet modal window:
|
78
|
-
format.js { render :layout => false }
|
79
80
|
end
|
80
81
|
end
|
81
82
|
|
@@ -214,7 +214,11 @@ module Blacklight::CatalogHelperBehavior
|
|
214
214
|
end
|
215
215
|
|
216
216
|
if value
|
217
|
-
if url_options == false
|
217
|
+
if url_options == false
|
218
|
+
Deprecation.warn(self, "passing false as the second argument to render_thumbnail_tag is deprecated. Use suppress_link: true instead. This behavior will be removed in Blacklight 7")
|
219
|
+
url_options = { suppress_link: true }
|
220
|
+
end
|
221
|
+
if url_options[:suppress_link]
|
218
222
|
value
|
219
223
|
else
|
220
224
|
link_to_document document, value, url_options
|
@@ -54,7 +54,7 @@ module Blacklight
|
|
54
54
|
|
55
55
|
def render_filtered_partials(partials, options={}, &block)
|
56
56
|
content = []
|
57
|
-
partials
|
57
|
+
filter_partials(partials, options).each do |key, config|
|
58
58
|
config.key ||= key
|
59
59
|
rendered = render(partial: config.partial || key.to_s, locals: { document_action_config: config }.merge(options))
|
60
60
|
if block_given?
|
@@ -78,5 +78,15 @@ module Blacklight
|
|
78
78
|
def render_show_doc_actions(document=@document, options={}, &block)
|
79
79
|
render_filtered_partials(blacklight_config.show.document_actions, { document: document }.merge(options), &block)
|
80
80
|
end
|
81
|
+
|
82
|
+
def show_doc_actions?(document = @document, options = {})
|
83
|
+
filter_partials(blacklight_config.show.document_actions, { document: document }.merge(options)).any?
|
84
|
+
end
|
85
|
+
|
86
|
+
private
|
87
|
+
|
88
|
+
def filter_partials(partials, options)
|
89
|
+
partials.select { |_, config| blacklight_configuration_context.evaluate_if_unless_configuration config, options }
|
90
|
+
end
|
81
91
|
end
|
82
92
|
end
|
@@ -130,7 +130,14 @@ module Blacklight::ConfigurationHelperBehavior
|
|
130
130
|
should_render_field? config
|
131
131
|
end
|
132
132
|
end
|
133
|
-
|
133
|
+
|
134
|
+
# filter #document_index_views to just views that should display in the view type control
|
135
|
+
def document_index_view_controls
|
136
|
+
document_index_views.select do |_k, config|
|
137
|
+
config.display_control.nil? || blacklight_configuration_context.evaluate_configuration_conditional(config.display_control)
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
134
141
|
##
|
135
142
|
# Get the default index view type
|
136
143
|
def default_document_index_view_type
|
@@ -76,9 +76,9 @@ module Blacklight::UrlHelperBehavior
|
|
76
76
|
return if document.nil?
|
77
77
|
|
78
78
|
if respond_to?(controller_tracking_method)
|
79
|
-
send(controller_tracking_method, params.merge(id: document
|
79
|
+
send(controller_tracking_method, params.merge(id: document))
|
80
80
|
else
|
81
|
-
blacklight.track_search_context_path(params.merge(id: document
|
81
|
+
blacklight.track_search_context_path(params.merge(id: document))
|
82
82
|
end
|
83
83
|
end
|
84
84
|
|
@@ -37,7 +37,7 @@ module Blacklight::Document
|
|
37
37
|
extend ActiveModel::Naming
|
38
38
|
include Blacklight::Document::Extensions
|
39
39
|
include GlobalID::Identification
|
40
|
-
end
|
40
|
+
end
|
41
41
|
|
42
42
|
attr_reader :response, :_source
|
43
43
|
alias_method :solr_response, :response
|
@@ -69,15 +69,14 @@ module Blacklight::Document
|
|
69
69
|
end
|
70
70
|
|
71
71
|
def respond_to_missing? m, *args
|
72
|
-
return super if
|
73
|
-
|
72
|
+
return super if %i(empty? to_hash).include?(m)
|
74
73
|
_source_responds_to?(m, *args) || super
|
75
74
|
end
|
76
75
|
|
77
76
|
# Helper method to check if value/multi-values exist for a given key.
|
78
77
|
# The value can be a string, or a RegExp
|
79
78
|
# Multiple "values" can be given; only one needs to match.
|
80
|
-
#
|
79
|
+
#
|
81
80
|
# Example:
|
82
81
|
# doc.has?(:location_facet)
|
83
82
|
# doc.has?(:location_facet, 'Clemons')
|
@@ -141,12 +140,12 @@ module Blacklight::Document
|
|
141
140
|
module ClassMethods
|
142
141
|
attr_writer :unique_key
|
143
142
|
def unique_key
|
144
|
-
@unique_key ||= 'id'
|
143
|
+
@unique_key ||= 'id'
|
145
144
|
end
|
146
145
|
end
|
147
|
-
|
146
|
+
|
148
147
|
private
|
149
|
-
|
148
|
+
|
150
149
|
def _source_responds_to? *args
|
151
150
|
_source && self != _source && _source.respond_to?(*args)
|
152
151
|
end
|
@@ -34,12 +34,14 @@ module Blacklight::Document
|
|
34
34
|
# but extensions should call super and modify hash returned, to avoid
|
35
35
|
# unintentionally erasing values provided by other extensions.
|
36
36
|
def to_semantic_values
|
37
|
-
@semantic_value_hash ||= self.class.field_semantics.each_with_object(Hash.new([])) do |(key,
|
38
|
-
|
37
|
+
@semantic_value_hash ||= self.class.field_semantics.each_with_object(Hash.new([])) do |(key, field_names), hash|
|
38
|
+
##
|
39
|
+
# Handles single string field_name or an array of field_names
|
40
|
+
value = Array.wrap(field_names).map { |field_name| self[field_name] }.flatten.compact
|
39
41
|
|
40
42
|
# Make single and multi-values all arrays, so clients
|
41
43
|
# don't have to know.
|
42
|
-
hash[key] =
|
44
|
+
hash[key] = value unless value.empty?
|
43
45
|
end
|
44
46
|
|
45
47
|
@semantic_value_hash ||= {}
|
@@ -1,24 +1,26 @@
|
|
1
|
-
<%-
|
2
|
-
# Compare with render_document_functions_partial helper, and
|
3
|
-
# _document_functions partial. BL actually has two groups
|
4
|
-
# of document-related tools. "document functions" by default
|
5
|
-
# contains Bookmark functionality shown on both results and
|
6
|
-
# item view. While "document tools" contains external export type
|
7
|
-
# functions by default only on detail.
|
8
|
-
|
9
|
-
-%>
|
10
|
-
|
11
|
-
<div class="panel-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
<
|
17
|
-
|
18
|
-
|
19
|
-
<%=
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
</div>
|
1
|
+
<%-
|
2
|
+
# Compare with render_document_functions_partial helper, and
|
3
|
+
# _document_functions partial. BL actually has two groups
|
4
|
+
# of document-related tools. "document functions" by default
|
5
|
+
# contains Bookmark functionality shown on both results and
|
6
|
+
# item view. While "document tools" contains external export type
|
7
|
+
# functions by default only on detail.
|
8
|
+
|
9
|
+
-%>
|
10
|
+
<% if show_doc_actions? %>
|
11
|
+
<div class="panel panel-default show-tools">
|
12
|
+
<div class="panel-heading">
|
13
|
+
<%= t('blacklight.tools.title') %>
|
14
|
+
</div>
|
15
|
+
|
16
|
+
<div class="panel-body">
|
17
|
+
<ul class="nav">
|
18
|
+
<%= render_show_doc_actions @document do |config, inner| %>
|
19
|
+
<li class="<%= config.key %>">
|
20
|
+
<%= inner %>
|
21
|
+
</li>
|
22
|
+
<% end %>
|
23
|
+
</ul>
|
24
|
+
</div>
|
25
|
+
</div>
|
26
|
+
<% end %>
|
@@ -2,7 +2,7 @@
|
|
2
2
|
<div class="view-type">
|
3
3
|
<span class="sr-only"><%= t('blacklight.search.view_title') %></span>
|
4
4
|
<div class="view-type-group btn-group">
|
5
|
-
<%
|
5
|
+
<% document_index_view_controls.each do |view, config| %>
|
6
6
|
<%= link_to url_for(search_state.to_h.merge(view: view)), title: view_label(view), class: "btn btn-default view-type-#{ view.to_s.parameterize } #{"active" if document_index_view_type == view}" do %>
|
7
7
|
<%= render_view_type_group_icon view %>
|
8
8
|
<span class="caption"><%= view_label(view) %></span>
|
data/lib/blacklight/utils.rb
CHANGED
@@ -14,7 +14,7 @@ module Blacklight
|
|
14
14
|
##
|
15
15
|
# An OpenStruct that responds to common Hash methods
|
16
16
|
class OpenStructWithHashAccess < OpenStruct
|
17
|
-
delegate :keys, :each, :map, :has_key?, :key?, :include?, :empty?, :length, :delete, :delete_if, :keep_if, :clear, :reject!, :select!, :replace, :fetch, :to_json, :as_json, to: :to_h
|
17
|
+
delegate :keys, :each, :map, :has_key?, :key?, :include?, :empty?, :length, :delete, :delete_if, :keep_if, :clear, :reject!, :select!, :replace, :fetch, :to_json, :as_json, :any?, to: :to_h
|
18
18
|
|
19
19
|
##
|
20
20
|
# Expose the internal hash
|
@@ -243,7 +243,7 @@ describe CatalogHelper do
|
|
243
243
|
it "does not link to the document if the url options are false" do
|
244
244
|
allow(helper).to receive_messages(:blacklight_config => Blacklight::Configuration.new(:index => Blacklight::OpenStructWithHashAccess.new(:thumbnail_method => :xyz) ))
|
245
245
|
allow(helper).to receive_messages(:xyz => "some-thumbnail")
|
246
|
-
|
246
|
+
expect(Deprecation).to receive(:warn)
|
247
247
|
result = helper.render_thumbnail_tag document, {}, false
|
248
248
|
expect(result).to eq "some-thumbnail"
|
249
249
|
end
|
@@ -65,6 +65,18 @@ describe BlacklightConfigurationHelper do
|
|
65
65
|
end
|
66
66
|
end
|
67
67
|
|
68
|
+
describe '#document_index_view_controls' do
|
69
|
+
before do
|
70
|
+
blacklight_config.view.a
|
71
|
+
blacklight_config.view.b.display_control = false
|
72
|
+
end
|
73
|
+
|
74
|
+
it "filters index views to those set to display controls" do
|
75
|
+
expect(helper.document_index_view_controls).to have_key :a
|
76
|
+
expect(helper.document_index_view_controls).not_to have_key :b
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
68
80
|
describe "#has_alternative_views?" do
|
69
81
|
subject { helper.has_alternative_views?}
|
70
82
|
describe "with a single view defined" do
|
@@ -245,7 +245,7 @@ describe BlacklightUrlHelper do
|
|
245
245
|
end
|
246
246
|
|
247
247
|
it "converts the counter parameter into a data- attribute" do
|
248
|
-
allow(helper).to receive(:track_test_path).with(hash_including(id: '123456', counter: 5)).and_return('tracking url')
|
248
|
+
allow(helper).to receive(:track_test_path).with(hash_including(id: have_attributes(id: '123456'), counter: 5)).and_return('tracking url')
|
249
249
|
|
250
250
|
expect(helper.link_to_document(document, :title_display, counter: 5)).to include 'data-context-href="tracking url"'
|
251
251
|
end
|
@@ -287,12 +287,12 @@ describe BlacklightUrlHelper do
|
|
287
287
|
describe "#session_tracking_path" do
|
288
288
|
let(:document) { SolrDocument.new(id: 1) }
|
289
289
|
it "determines the correct route for the document class" do
|
290
|
-
allow(helper).to receive(:track_test_path).with(id: 1).and_return('x')
|
290
|
+
allow(helper).to receive(:track_test_path).with(id: have_attributes(id: 1)).and_return('x')
|
291
291
|
expect(helper.session_tracking_path(document)).to eq 'x'
|
292
292
|
end
|
293
293
|
|
294
294
|
it "passes through tracking parameters" do
|
295
|
-
allow(helper).to receive(:track_test_path).with(id: 1, x: 1).and_return('x')
|
295
|
+
allow(helper).to receive(:track_test_path).with(id: have_attributes(id: 1), x: 1).and_return('x')
|
296
296
|
expect(helper.session_tracking_path(document, x: 1)).to eq 'x'
|
297
297
|
end
|
298
298
|
end
|
@@ -199,17 +199,23 @@ describe "Blacklight::Solr::Document" do
|
|
199
199
|
include Blacklight::Solr::Document
|
200
200
|
end
|
201
201
|
before do
|
202
|
-
MockDocument.field_semantics.merge!(
|
203
|
-
|
202
|
+
MockDocument.field_semantics.merge!(
|
203
|
+
title: ["title_field", "other_title"],
|
204
|
+
author: "author_field",
|
205
|
+
something: "something_field"
|
206
|
+
)
|
207
|
+
|
204
208
|
@doc1 = MockDocument.new(
|
205
209
|
"title_field" => "doc1 title",
|
210
|
+
"other_title" => "doc1 title other",
|
206
211
|
"something_field" => ["val1", "val2"],
|
207
212
|
"not_in_list_field" => "weird stuff"
|
208
213
|
)
|
209
214
|
end
|
210
215
|
|
211
216
|
it "should return complete dictionary based on config'd fields" do
|
212
|
-
expect(@doc1.to_semantic_values)
|
217
|
+
expect(@doc1.to_semantic_values)
|
218
|
+
.to eq title: ["doc1 title", "doc1 title other"], something: ["val1", "val2"]
|
213
219
|
end
|
214
220
|
it "should return empty array for a key without a value" do
|
215
221
|
expect(@doc1.to_semantic_values[:author]).to be_empty
|
@@ -69,5 +69,17 @@ describe "catalog/_show_tools.html.erb" do
|
|
69
69
|
render partial: 'catalog/show_tools'
|
70
70
|
expect(rendered).not_to have_selector '.some_action > a[data-ajax-modal="trigger"]', text: "Some action"
|
71
71
|
end
|
72
|
+
|
73
|
+
context 'without any document actions defined' do
|
74
|
+
before do
|
75
|
+
document_actions.clear
|
76
|
+
end
|
77
|
+
|
78
|
+
it 'does not display the tools' do
|
79
|
+
render partial: 'catalog/show_tools'
|
80
|
+
|
81
|
+
expect(rendered).to be_blank
|
82
|
+
end
|
83
|
+
end
|
72
84
|
end
|
73
85
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: blacklight
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 6.11.
|
4
|
+
version: 6.11.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonathan Rochkind
|
@@ -17,7 +17,7 @@ authors:
|
|
17
17
|
autorequire:
|
18
18
|
bindir: exe
|
19
19
|
cert_chain: []
|
20
|
-
date: 2017-08
|
20
|
+
date: 2017-09-08 00:00:00.000000000 Z
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|
23
23
|
name: rails
|