File tree 3 files changed +47
-10
lines changed
app/presenters/blacklight_range_limit
lib/blacklight_range_limit
3 files changed +47
-10
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,15 @@ def label
8
8
label_for_range || super
9
9
end
10
10
11
+ # Very hacky way to keep params used for ajax query for segments out
12
+ # of our generated facet links. Sorry this seems to be the best way!
13
+ #
14
+ # https://github.com/projectblacklight/blacklight_range_limit/issues/296
15
+ def href ( path_options = { } )
16
+ override_to_nil = BlacklightRangeLimit ::ControllerOverride ::RANGE_LIMIT_FIELDS . collect { |f | [ f , nil ] } . to_h
17
+ super ( path_options . merge ( override_to_nil ) )
18
+ end
19
+
11
20
private
12
21
13
22
def label_for_range
Original file line number Diff line number Diff line change @@ -8,21 +8,18 @@ module ControllerOverride
8
8
9
9
RANGE_LIMIT_FIELDS = [ :range_end , :range_field , :range_start ] . freeze
10
10
11
- included do
12
- before_action do
13
- # Blacklight 7.25+: Allow range limit params if necessary
14
- if blacklight_config . search_state_fields
15
- missing_keys = RANGE_LIMIT_FIELDS - blacklight_config . search_state_fields
16
- blacklight_config . search_state_fields . concat ( missing_keys )
17
- end
18
- end
19
- end
20
-
21
11
# Action method of our own!
22
12
# Delivers a _partial_ that's a display of a single fields range facets.
23
13
# Used when we need a second Solr query to get range facets, after the
24
14
# first found min/max from result set.
25
15
def range_limit
16
+ # The builder in this action will need our special range_limit fields, so we
17
+ # must allow them.
18
+ if blacklight_config . search_state_fields
19
+ missing_keys = RANGE_LIMIT_FIELDS - blacklight_config . search_state_fields
20
+ blacklight_config . search_state_fields . concat ( missing_keys )
21
+ end
22
+
26
23
@facet = blacklight_config . facet_fields [ params [ :range_field ] ]
27
24
raise ActionController ::RoutingError , 'Not Found' unless @facet &.range
28
25
Original file line number Diff line number Diff line change 176
176
end
177
177
end
178
178
end
179
+
180
+ context "Range Limit text facets" do
181
+ # Make sure it works with strict permitted params
182
+ around do |example |
183
+ original = ActionController ::Parameters . action_on_unpermitted_parameters
184
+ ActionController ::Parameters . action_on_unpermitted_parameters = :raise
185
+
186
+ example . run
187
+
188
+ ActionController ::Parameters . action_on_unpermitted_parameters = original
189
+ end
190
+
191
+ it "work with strict permitted params" do
192
+ visit search_catalog_path
193
+
194
+ click_button 'Publication Date Sort'
195
+
196
+ from_val , to_val = nil , nil
197
+ within ".facet-limit.blacklight-pub_date_si" do
198
+ find ( "summary" , text : "Range List" ) . click
199
+
200
+ facet_link = first ( ".facet-values li a" )
201
+ from_val = facet_link . find ( "span[data-blrl-begin]" ) [ "data-blrl-begin" ]
202
+ to_val = facet_link . find ( "span[data-blrl-end]" ) [ "data-blrl-end" ]
203
+
204
+ facet_link . click
205
+ end
206
+
207
+ expect ( page ) . to have_css ( ".applied-filter" , text : /Publication Date Sort.*#{ from_val } to #{ to_val } / )
208
+ end
209
+ end
179
210
end
You can’t perform that action at this time.
0 commit comments