Skip to content

Commit

Permalink
wip form for case search; #43
Browse files Browse the repository at this point in the history
some js-magic was needed to align select forms initially hidden in collapsed accordion
  • Loading branch information
csae8092 committed Apr 22, 2024
1 parent e933a65 commit fd0a87a
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 13 deletions.
30 changes: 18 additions & 12 deletions archiv/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,25 +116,31 @@ def __init__(self, *args, **kwargs):
BS5Accordion(
AccordionGroup(
"Basic Search",
"id",
"ft_search",
"partial_legal_system",
"court",
"year_book_title",
"decission_date__year",
"file_number",
"party",
"location",
"short_description",
"situation",
"motto",
"commentary",
"additional_information",
# "location",
# "short_description",
# "situation",
# "motto",
# "commentary",
# "additional_information",
"keyword",
"tag",
css_id="basic",
),
AccordionGroup(
"Extended search fields",
"party",
"file_number",
"id",
"ecli",
"year_book_title",
"author",
css_id="more",
)
css_id="extended",
),
always_open=True
)
)

Expand Down
19 changes: 18 additions & 1 deletion archiv/templates/archiv/case_listview.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ <h1 class="text-center">{{table.paginator.count }} {{ verbose_name_plural }}</h1
</div>
<div class="col-md-8" id="results">


<div class="card-body table-responsive">
{% block table %}
{% include 'browsing/partials/table.html' %}
Expand All @@ -67,4 +67,21 @@ <h1 class="text-center">{{table.paginator.count }} {{ verbose_name_plural }}</h1
{% block scripts2 %}
<script src="{% static 'browsing/js/set-form-attributes.js' %}"></script>
<script src="{% static 'browsing/js/filter-for-blank-fields.js' %}"></script>
<script>

document.addEventListener('DOMContentLoaded', function () {
var accordion = document.getElementsByClassName('accordion')[0];
accordion.addEventListener('shown.bs.collapse', function (event) {
var shownElement = event.target;
var allSelect2Spans = document.getElementsByClassName("select2");
var firstSpan = allSelect2Spans[0];
var widthToset = allSelect2Spans[0].style["width"];
for (var i = 0; i < allSelect2Spans.length; i++) {
allSelect2Spans[i].style.width = widthToset;
}
});
});


</script>
{% endblock scripts2 %}

0 comments on commit fd0a87a

Please sign in to comment.