Skip to content

Commit 0bfafc3

Browse files
committed
Adjust search fields
1 parent b5b1d9d commit 0bfafc3

File tree

3 files changed

+82
-21
lines changed

3 files changed

+82
-21
lines changed

web/nuremberg/core/static/style/search.less

-4
Original file line numberDiff line numberDiff line change
@@ -217,10 +217,6 @@ section.results {
217217
.advanced-search-help {
218218
.transition(~"max-height 0.5s");
219219

220-
overflow: hidden;
221-
max-height: 1000px;
222-
223-
224220
&.hide {
225221
max-height: 0px;
226222
display: block;

web/nuremberg/search/forms.py

+46-7
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,8 @@ def apply_field_query(self, sqs, field_query):
333333
else:
334334
field_query.append('ignored')
335335

336+
print("SQS")
337+
print(sqs.query)
336338
return sqs
337339

338340

@@ -516,6 +518,11 @@ class AdvancedDocumentSearchForm(forms.Form):
516518
],
517519
list,
518520
)
521+
AND_OR_OR_CHOICES = (
522+
('and', 'all'),
523+
('or', 'any'),
524+
)
525+
519526
m = forms.CheckboxSelectMultiple()
520527
keywords = forms.CharField(
521528
required=False, widget=forms.TextInput(attrs={"class": "large"})
@@ -535,17 +542,27 @@ class AdvancedDocumentSearchForm(forms.Form):
535542
choices=AUTHOR_CHOICES,
536543
help_text="Personal author: the author's name, with a title or other identifying information if available. This information is usually drawn from the document itself, but often other documents provide additional information. Group author: provided if the document was produced by an agency or group or another collective source (e.g., laws published in the official state gazette).",
537544
)
538-
defendant = forms.MultipleChoiceField(
545+
author_and_or_or = forms.MultipleChoiceField(
539546
required=False,
540-
choices=DEFENDANT_CHOICES,
541-
help_text="Applies to case files only; indicates which defendants are involved or relevant to the subjects covered by the document.",
547+
choices=AND_OR_OR_CHOICES,
548+
help_text="Whether to AND or OR these selections",
542549
)
543550
issue = forms.MultipleChoiceField(
544551
label=_('Trial Issues'),
545552
required=False,
546553
choices=ISSUE_CHOICES,
547554
help_text="Subjects of trial documents; applies to case files only; indicates the subject areas of the document that are relevant for the trial. Other subjects are not indicated.",
548555
)
556+
issue_and_or_or = forms.MultipleChoiceField(
557+
required=False,
558+
choices=AND_OR_OR_CHOICES,
559+
help_text="Whether to AND or OR these selections",
560+
)
561+
defendant = forms.MultipleChoiceField(
562+
required=False,
563+
choices=DEFENDANT_CHOICES,
564+
help_text="Applies to case files only; indicates which defendants are involved or relevant to the subjects covered by the document.",
565+
)
549566
trial = forms.MultipleChoiceField(required=False, choices=TRIAL_CHOICES)
550567
language = forms.MultipleChoiceField(
551568
required=False,
@@ -617,9 +634,9 @@ def clean(self):
617634
)
618635
elif evidence:
619636
suffix = cleaned_data.get('evidence_suffix', '')
620-
cleaned_data[
621-
'evidence_code'
622-
] = f'{evidence}-{evidence_num}{suffix}'
637+
cleaned_data['evidence_code'] = (
638+
f'{evidence}-{evidence_num}{suffix}'
639+
)
623640

624641
exhibit = cleaned_data.get('exhibit')
625642
exhibit_num = cleaned_data.get('exhibit_num')
@@ -674,8 +691,30 @@ def as_search_qs(self, data=None):
674691
# choice field entries
675692
for term in (
676693
'author',
677-
'defendant',
678694
'issue',
695+
):
696+
values = _getlist(data, term)
697+
if values:
698+
# Determine if the user wants an AND or OR search here from
699+
# the select boxes next to these fields which are named after
700+
# the field
701+
option_name = f"{term}_and_or_or"
702+
print(f"OPTION NAME: {option_name}")
703+
print(f"OPTION VALUE: {data.get(option_name)}")
704+
if data.get(option_name) == 'and':
705+
terms.extend(
706+
f'{term}:"{value}"' for value in values if value
707+
)
708+
else:
709+
items = [value for value in values if value]
710+
new_values = "|".join(items)
711+
terms.append(f'{term}:"{new_values}"')
712+
print("TERMS")
713+
print(terms)
714+
715+
# single choice field entries
716+
for term in (
717+
'defendant',
679718
'trial',
680719
'language',
681720
'source',

web/nuremberg/search/templates/search/new-advanced-search.html

+36-10
Original file line numberDiff line numberDiff line change
@@ -1205,24 +1205,28 @@
12051205
placeholder: 'Choose one or more...',
12061206
});
12071207

1208-
$('#id_defendant').select2({
1208+
$('#id_issue').select2({
12091209
placeholder: 'Choose one or more...',
12101210
});
12111211

1212-
$('#id_issue').select2({
1213-
placeholder: 'Choose one or more...',
1212+
$('#id_defendant').select2({
1213+
placeholder: 'Choose one...',
1214+
multiple: false,
12141215
});
12151216

12161217
$('#id_trial').select2({
1217-
placeholder: 'Choose one or more...',
1218+
placeholder: 'Choose one...',
1219+
multiple: false,
12181220
});
12191221

12201222
$('#id_language').select2({
1221-
placeholder: 'Choose one or more...',
1223+
placeholder: 'Choose one...',
1224+
multiple: false,
12221225
});
12231226

12241227
$('#id_source').select2({
1225-
placeholder: 'Choose one or more...',
1228+
placeholder: 'Choose one...',
1229+
multiple: false,
12261230
});
12271231

12281232
// clear the selection when button pressed
@@ -1252,7 +1256,7 @@
12521256

12531257
<section id="search" role="search" aria-label="Search the archive" class="theme-beige thin">
12541258
<h1 class="h4">Search the archive &mdash; Advanced</h1>
1255-
<div class="full-width">
1259+
<div class="full-width" style="height: 100%">
12561260
<div class="advanced-search-help">
12571261

12581262
{% for message in messages %}
@@ -1264,6 +1268,7 @@ <h1 class="h4">Search the archive &mdash; Advanced</h1>
12641268
{% endfor %}
12651269

12661270
<form class="advanced-search" role="search" aria-label="advanced search" action="{% url 'search:advanced' %}" method="POST">
1271+
<h3>Main Search Criteria</h3>
12671272
<p>{% trans 'Match all entered search terms below' %}</p>
12681273
<p style="margin-top: 10px; margin-bottom: 10px">
12691274
<label style="margin-right: 50px;">Search Type:</label>
@@ -1285,16 +1290,35 @@ <h1 class="h4">Search the archive &mdash; Advanced</h1>
12851290
</label>
12861291
</p>
12871292
{% for field in form %}
1293+
{% if field.name == "author" %}
1294+
<h3>The options below here are AND or ORed</h3>
1295+
{% endif %}
1296+
{% if field.name == "defendant" %}
1297+
<h3>The options below here are ORed</h3>
1298+
{% endif %}
12881299
{% if field.name != 'evidence' and field.name != 'exhibit' and field.name != 'book' and field.name != 'm' and '_' not in field.name %}
12891300
<div class="{% if field.errors %}has-error{% endif %}">
1290-
<p>
1301+
<p style="display: inline-flex">
12911302
<label for="id_{{ field.name }}" {% if field.help_text %}class="help-label" data-content_id="adv-help-{{ field.name }}"{% endif %}>
12921303
{{ field.label }}
12931304
{% if field.help_text %}
12941305
<svg class="label"><use href="#i-icon" /></svg>
12951306
{% endif %}
12961307
</label>
12971308

1309+
{% if field.name == "author" %}
1310+
<select name="author_and_or_or" id="author_and_or_or">
1311+
<option value="and" checked>Match all</option>
1312+
<option value="or">Match any</option>
1313+
</select>
1314+
{% endif %}
1315+
1316+
{% if field.name == "issue" %}
1317+
<select name="issue_and_or_or" id="issue_and_or_or">
1318+
<option value="and" checked>Match all</option>
1319+
<option value="or">Match any</option>
1320+
</select>
1321+
{% endif %}
12981322
{{ field }}
12991323

13001324
{% if field.help_text %}
@@ -1311,6 +1335,9 @@ <h1 class="h4">Search the archive &mdash; Advanced</h1>
13111335
{% endif %}
13121336
{% endfor %}
13131337

1338+
<div style="margin-top: 50px">
1339+
<h3>Additional Options</h3>
1340+
</div>
13141341
<div class="{% if form.evidence.errors %}has-error{% endif %}">
13151342
<p>
13161343
<label for="id_{{ form.evidence.name }}" class="help-label" data-content_id="adv-help-{{ form.evidence.name }}">
@@ -1375,11 +1402,10 @@ <h1 class="h4">Search the archive &mdash; Advanced</h1>
13751402
<p><small class="has-error">{{ error }}</small></p>
13761403
{% endfor %}
13771404

1378-
<div class="advanced-search-button-group">
1405+
<div style="float: right">
13791406
<button class="button search-button" type="submit">Advanced Search</button>
13801407
<button class="button search-button" type="reset" id="clear-button">Clear</button>
13811408
</div>
1382-
13831409
</form>
13841410

13851411
</div>

0 commit comments

Comments
 (0)