Skip to content

Commit 78cb988

Browse files
committed
Reorganize advanced search form for GDT
Why these changes are being introduced: Stakeholders have requested that 'citation', 'funding information', and 'identifiers' be removed from the advanced search form, and that 'contributors' be renamed to 'authors'. UXWS has also requested that we hide the 'source' field in GDT, as we now only have two sources and have effectively turned that filter into a toggle. Relevant ticket(s): * [GDT-219](https://mitlibraries.atlassian.net/browse/GDT-219) How this addresses that need: This renders the unwanted fields only if the `:gdt` feature is not enabled, and similarly changes the label of 'contributors' to 'authors' when `:gdt` is enabled. It also moves 'title' to the top of the form (and citation lower) for both GDT and non-GDT contexts, as this seems like a useful change for any TIMDEX UI application. Side effects of this change: Some of the markup has been reformatted to match our line width limits.
1 parent 90bb957 commit 78cb988

File tree

2 files changed

+65
-29
lines changed

2 files changed

+65
-29
lines changed

app/views/search/_form.html.erb

Lines changed: 44 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -157,54 +157,69 @@ end
157157
<% end %>
158158

159159
<details id="advanced-search-panel" <%= "open" if params[:advanced] == "true" %>>
160-
<summary class="btn button-secondary" id="advanced-summary"><span id="advanced-search-label" class="<%= advanced_label_class %>"><%= advanced_label %></span></summary>
160+
<summary class="btn button-secondary" id="advanced-summary">
161+
<span id="advanced-search-label"class="<%= advanced_label_class %>"><%= advanced_label %></span>
162+
</summary>
161163
<input id="advanced-search-field" type="hidden" name="advanced" value="<%= params[:advanced] %>">
162164
<div class="field-container">
163165
<div class="field-wrap">
164-
<label for="advanced-citation" class="field-label">Citation</label>
165-
<input type="text" class="field field-text wide" id="advanced-citation" name="citation" placeholder="Citation" value="<%= params[:citation] %>">
166+
<label for="advanced-title" class="field-label">Title</label>
167+
<input type="text" class="field field-text wide" id="advanced-title" name="title"
168+
value="<%= params[:title] %>">
166169
</div>
167170

168171
<div class="field-wrap">
169-
<label for="advanced-contributors" class="field-label">Contributors</label>
170-
<input type="text" class="field field-text wide" id="advanced-contributors" name="contributors" placeholder="Contributors" value="<%= params[:contributors] %>">
172+
<label for="advanced-contributors" class="field-label">
173+
<%= Flipflop.enabled?(:gdt) ? "Authors" : "Contributors" %>
174+
</label>
175+
<input type="text" class="field field-text wide" id="advanced-contributors" name="contributors"
176+
value="<%= params[:contributors] %>">
171177
</div>
172178

173-
<div class="field-wrap">
174-
<label for="advanced-fundingInformation" class="field-label">Funding information</label>
175-
<input type="text" class="field field-text wide" id="advanced-fundingInformation" name="fundingInformation" placeholder="Funding information" value="<%= params[:fundingInformation] %>">
176-
</div>
179+
<% unless Flipflop.enabled?(:gdt) %>
180+
<div class="field-wrap">
181+
<label for="advanced-citation" class="field-label">Citation</label>
182+
<input type="text" class="field field-text wide" id="advanced-citation" name="citation"
183+
value="<%= params[:citation] %>">
184+
</div>
177185

178-
<div class="field-wrap">
179-
<label for="advanced-identifiers" class="field-label">Identifiers</label>
180-
<input type="text" class="field field-text wide" id="advanced-identifiers" name="identifiers" placeholder="Identifiers" value="<%= params[:identifiers] %>">
181-
</div>
186+
<div class="field-wrap">
187+
<label for="advanced-fundingInformation" class="field-label">Funding information</label>
188+
<input type="text" class="field field-text wide" id="advanced-fundingInformation" name="fundingInformation"
189+
value="<%= params[:fundingInformation] %>">
190+
</div>
182191

183-
<div class="field-wrap">
184-
<label for="advanced-locations" class="field-label">Locations</label>
185-
<input type="text" class="field field-text wide" id="advanced-locations" name="locations" placeholder="Locations" value="<%= params[:locations] %>">
186-
</div>
192+
<div class="field-wrap">
193+
<label for="advanced-identifiers" class="field-label">Identifiers</label>
194+
<input type="text" class="field field-text wide" id="advanced-identifiers" name="identifiers"
195+
value="<%= params[:identifiers] %>">
196+
</div>
197+
<% end %>
187198

188199
<div class="field-wrap">
189200
<label for="advanced-subjects" class="field-label">Subjects</label>
190-
<input type="text" class="field field-text wide" id="advanced-subjects" name="subjects" placeholder="Subjects" value="<%= params[:subjects] %>">
201+
<input type="text" class="field field-text wide" id="advanced-subjects" name="subjects"
202+
value="<%= params[:subjects] %>">
191203
</div>
192204

193205
<div class="field-wrap">
194-
<label for="advanced-title" class="field-label">Title</label>
195-
<input type="text" class="field field-text wide" id="advanced-title" name="title" placeholder="Title" value="<%= params[:title] %>">
206+
<label for="advanced-locations" class="field-label">Locations</label>
207+
<input type="text" class="field field-text wide" id="advanced-locations" name="locations"
208+
value="<%= params[:locations] %>">
196209
</div>
197210

198-
<div class="field-wrap list-checkboxes">
199-
<%# https://www.w3.org/WAI/tutorials/forms/grouping/ %>
200-
<fieldset>
201-
<legend>Limit search to checked sources.</legend>
211+
<% unless Flipflop.enabled?(:gdt) %>
212+
<div class="field-wrap list-checkboxes">
213+
<%# https://www.w3.org/WAI/tutorials/forms/grouping/ %>
214+
<fieldset>
215+
<legend>Limit search to checked sources.</legend>
202216

203-
<% timdex_sources.each do |source| %>
204-
<%= source_checkbox(source, params) %>
205-
<% end %>
206-
</fieldset>
207-
</div>
217+
<% timdex_sources.each do |source| %>
218+
<%= source_checkbox(source, params) %>
219+
<% end %>
220+
</fieldset>
221+
</div>
222+
<% end %>
208223
</div>
209224
</details>
210225
</div>

test/controllers/search_controller_geo_test.rb

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,27 @@ def setup
77
@test_strategy.switch!(:gdt, true)
88
end
99

10+
test 'GDT has specific advanced search fields' do
11+
get '/'
12+
13+
# Please note that this test confirms fields in the DOM - but not whether
14+
# they are visible. Fields in a hidden details panel are still in the DOM,
15+
# but not visible or reachable via keyboard interaction.
16+
assert_select 'input#advanced-title', count: 1
17+
assert_select 'input#advanced-contributors', count: 1
18+
assert_select 'input#advanced-locations', count: 1
19+
assert_select 'input#advanced-subjects', count: 1
20+
assert_select 'input.source', count: 0
21+
assert_select 'input#advanced-citation', count: 0
22+
assert_select 'input#advanced-fundingInformation', count: 0
23+
assert_select 'input#advanced-identifiers', count: 0
24+
end
25+
26+
test 'contributors label is renamed to authors in GDT' do
27+
get '/'
28+
assert_select 'label', text: "Authors"
29+
end
30+
1031
test 'index shows geobox form, closed by default' do
1132
get '/'
1233
assert_response :success

0 commit comments

Comments
 (0)