-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* added range slider widget * added "party" to fulltext index #43 * adding info modal to fulltext search #43 * included search info modal also in case-listview * wip form for case search; #43 some js-magic was needed to align select forms initially hidden in collapsed accordion * more case-form (styling) things #43
- Loading branch information
Showing
23 changed files
with
284 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
[flake8] | ||
ignore = D203 W504 | ||
ignore = D203 W504 W503 | ||
max-line-length = 120 | ||
exclude = | ||
*/migrations, | ||
|
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# from django.contrib import admin | ||
|
||
# Register your models here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
from django.apps import AppConfig | ||
|
||
|
||
class AcdhDjangoWidgetsConfig(AppConfig): | ||
default_auto_field = "django.db.models.BigAutoField" | ||
name = "acdh_django_widgets" |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# from django.db import models | ||
|
||
# Create your models here. |
58 changes: 58 additions & 0 deletions
58
acdh_django_widgets/templates/acdh_django_widgets/range_slider_widget.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<div id="{{ name }}_slider" class="slider"></div> | ||
<div class="pt-2 container d-flex justify-content-center {% if attrs.hide_input_fileds %} d-none {% endif %}"> | ||
<div class="row"> | ||
<div class="col-5"> | ||
<input id="id_{{ name }}_0" name="{{ name }}_min" type="text" value="{{ value.0 }}" | ||
class="textinput form-control"> | ||
</div> | ||
<div class="col-auto align-self-center"> | ||
<span class="fs-4">—</span> | ||
</div> | ||
<div class="col-5"> | ||
<input id="id_{{ name }}_1" name="{{ name }}_max" type="text" value="{{ value.1 }}" | ||
class="textinput form-control"> | ||
</div> | ||
</div> | ||
</div> | ||
<script> | ||
var minValue = {{ attrs.min }}; | ||
var maxValue = {{ attrs.max }}; | ||
var sliderId = "{{ name }}_slider"; | ||
var minValForm = document.getElementById("id_{{ name }}_0"); | ||
var maxValForm = document.getElementById("id_{{ name }}_1"); | ||
var startValue = minValForm.value; | ||
var endValue = maxValForm.value; | ||
var slider = document.getElementById(sliderId); | ||
|
||
noUiSlider.create(slider, { | ||
start: [startValue, endValue], | ||
step: 1, | ||
connect: true, | ||
tooltips: true, | ||
format: wNumb({ | ||
decimals: 0 | ||
}), | ||
range: { | ||
"min": minValue, | ||
"max": maxValue | ||
} | ||
}); | ||
|
||
slider.noUiSlider.on('update', function (values, handle) { | ||
|
||
var value = values[handle]; | ||
if (handle) { | ||
maxValForm.value = value; | ||
} else { | ||
minValForm.value = value; | ||
} | ||
}); | ||
|
||
minValForm.addEventListener('change', function () { | ||
slider.noUiSlider.set([this.value, null]); | ||
}); | ||
|
||
maxValForm.addEventListener('change', function () { | ||
slider.noUiSlider.set([null, this.value]); | ||
}); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# from django.test import TestCase | ||
|
||
# Create your tests here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# from django.shortcuts import render | ||
|
||
# Create your views here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import django_filters | ||
from django.template.loader import render_to_string | ||
from django.utils.safestring import mark_safe | ||
|
||
|
||
class RangeSliderWidget(django_filters.widgets.RangeWidget): | ||
template_name = "acdh_django_widgets/range_slider_widget.html" | ||
|
||
class Media: | ||
css = { | ||
"all": ( | ||
"https://cdnjs.cloudflare.com/ajax/libs/noUiSlider/15.7.1/nouislider.css", | ||
) | ||
} | ||
js = ( | ||
"https://cdnjs.cloudflare.com/ajax/libs/noUiSlider/15.7.1/nouislider.min.js", | ||
"https://cdnjs.cloudflare.com/ajax/libs/wnumb/1.2.0/wNumb.min.js", | ||
) | ||
|
||
def render(self, name, value, attrs=None, renderer=None): | ||
if value[0] is None: | ||
value = [self.attrs.get("min", 0), self.attrs.get("max", 100)] | ||
context = {"name": name, "value": value, "attrs": self.attrs} | ||
rendered = render_to_string(self.template_name, context) | ||
return mark_safe(rendered) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
{% extends "webpage/base.html" %} | ||
{% load static %} | ||
{% load django_tables2 %} | ||
{% load browsing_extras %} | ||
{% load crispy_forms_field %} | ||
{% load crispy_forms_tags %} | ||
{% block title %} Browse {{ class_name }} {% endblock %} | ||
{% block scriptHeader %} | ||
|
||
{% endblock %} | ||
{% block content %} | ||
{% include 'archiv/partials/listview_breadcrumb.html' %} | ||
<div class="container-fluid"> | ||
<div class="card-header text-center"> | ||
|
||
<h1 class="text-center">{{table.paginator.count }} {{ verbose_name_plural }}</h1> | ||
{% if user.is_authenticated %} | ||
{% if create_view_link %} | ||
<div class="d-grid gap-2"> | ||
<a class="btn btn-primary float-center ms-5 me-5" href="{{ create_view_link }}">Create new {{ class_name | ||
}}</a> | ||
</div> | ||
{% endif %} | ||
{% endif %} | ||
</div> | ||
<div> | ||
<div class="row"> | ||
<div class="col-md-4"> | ||
|
||
<div> | ||
{% block create_button %}{% endblock %} | ||
<!--Search mask--> | ||
{% load django_tables2 crispy_forms_tags %} | ||
<form action="." class="uniForm" method="get"> | ||
{% crispy filter.form filter.form.helper %} | ||
{% include 'browsing/partials/column_selector.html' %} | ||
<a class="btn btn-primary" href=".">Reset</a> | ||
<button type="submit" class="btn btn-primary">Search</button> | ||
</form> | ||
{% include 'browsing/partials/chart_form.html' %} | ||
</div> | ||
</div> | ||
<div class="col-md-8" id="results"> | ||
|
||
|
||
<div class="card-body table-responsive"> | ||
{% block table %} | ||
{% include 'browsing/partials/table.html' %} | ||
{% endblock table %} | ||
{% block pagination.allpages %} | ||
{% include 'browsing/partials/pagination.html' %} | ||
{% endblock pagination.allpages %} | ||
<div class="float-end"> | ||
{% include "browsing/partials/download_menu.html" %} | ||
</div> | ||
</div> | ||
|
||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
{% include 'archiv/partials/info_modal.html' %} | ||
|
||
|
||
|
||
{% endblock %} | ||
{% 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 %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<div class="modal" id="searchInfoModal" tabindex="-1" aria-labelledby="searchInfoModalLabel" aria-hidden="true"> | ||
<div class="modal-dialog"> | ||
<div class="modal-content"> | ||
<div class="modal-header"> | ||
<h5 class="modal-title">Search information</h5> | ||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button> | ||
</div> | ||
<div class="modal-body"> | ||
<p>With this search, the fields "Short Description", "Facts", "Decision", "Commentary", "Additional Information" and "Parties" of a decision can be searched together. In order to keep the search efficient, the corresponding fields have been indexed. For this index, the individual texts are normalised back to their original forms. This also applies to the search term entered. Such a search index also allows more complex search queries such as: | ||
<ul> | ||
<li><strong>Phrase search</strong>: Terms in inverted commas are searched for together: "medical records".</li> | ||
<li><strong>medical records</strong> finds all documents in which either <em>medical</em> or <em>recods</em> appears</li> | ||
<li>A <strong>*</strong> at the end of a search term serves as a wildcard. <em>share*</em> also finds entries with <em>shareholder</em>, for example.</li> | ||
</ul> | ||
</p> | ||
<p>For information: Displaying many hits as so called <em>Keywords in context (KWIC)</em> like e.g. <span class="text-nowrap bg-warning border-warning rounded border-5">example</span> can take some time. It is therefore advisable to narrow down the search results using additional filter options. </p> | ||
</div> | ||
<div class="modal-footer"> | ||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button> | ||
</div> | ||
</div> | ||
</div> | ||
</div> |
Oops, something went wrong.