#112 CompensationAction Tree
* implements generic HTML based and Django compatible TreeView * enhances listing of CompensationActions on DetailView
This commit is contained in:
@@ -1,29 +0,0 @@
|
||||
|
||||
<div id="jstree"></div>
|
||||
<input id="jstree-input" name="{{ widget.name }}" hidden="hidden"/>
|
||||
|
||||
<script>
|
||||
$(function () {
|
||||
$('#jstree').jstree({
|
||||
'plugins': [
|
||||
'checkbox',
|
||||
'wholerow',
|
||||
],
|
||||
'core' : {
|
||||
'data' : {
|
||||
'url' : '{{ widget.attrs.url }}',
|
||||
'data' : function (node) {
|
||||
return { 'id' : node.id };
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
$('#jstree')
|
||||
.on('deselect_node.jstree', function (e, data) {
|
||||
$('#jstree-input').val(data.selected);
|
||||
})
|
||||
.on('select_node.jstree', function (e, data) {
|
||||
$('#jstree-input').val(data.selected);
|
||||
})
|
||||
});
|
||||
</script>
|
||||
@@ -1,9 +0,0 @@
|
||||
{% load l10n %}
|
||||
|
||||
<ul>
|
||||
{% for code in codes %}
|
||||
<li id="{{code.pk|unlocalize}}" class="{% if code.is_leaf%}jstree-leaf{% else %}jstree-closed{% endif %}">
|
||||
{{code.long_name}}
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
23
konova/templates/konova/widgets/checkbox-tree-select.html
Normal file
23
konova/templates/konova/widgets/checkbox-tree-select.html
Normal file
@@ -0,0 +1,23 @@
|
||||
{% load l10n fontawesome_5 %}
|
||||
|
||||
<div>
|
||||
{% for code in codes %}
|
||||
<div class="ml-4">
|
||||
<label role="{% if not code.is_leaf%}button{% endif %}" for="input_{{code.pk|unlocalize}}" id="{{code.pk|unlocalize}}" data-toggle="collapse" data-target="#children_{{code.pk|unlocalize}}" aria-expanded="true" aria-controls="children_{{code.pk|unlocalize}}">
|
||||
{% if code.is_leaf%}
|
||||
<input id="input_{{code.pk|unlocalize}}" name="{{ widget.name }}" type="checkbox" value="{{code.pk|unlocalize}}" {% if code.pk|unlocalize in widget.value %}checked{% endif %}/>
|
||||
{% else %}
|
||||
{% fa5_icon 'angle-right' %}
|
||||
{% endif %}
|
||||
{{code.long_name}}
|
||||
</label>
|
||||
{% if not code.is_leaf %}
|
||||
<div id="children_{{code.pk|unlocalize}}" data-toggle="collapse" class="collapse">
|
||||
{% with code.children as codes %}
|
||||
{% include 'konova/widgets/checkbox-tree-select.html' %}
|
||||
{% endwith %}
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
@@ -23,7 +23,7 @@ from konova.autocompletes import EcoAccountAutocomplete, \
|
||||
ShareUserAutocomplete, BiotopeExtraCodeAutocomplete, CompensationActionDetailCodeAutocomplete
|
||||
from konova.settings import SSO_SERVER, SSO_PUBLIC_KEY, SSO_PRIVATE_KEY, DEBUG
|
||||
from konova.sso.sso import KonovaSSOClient
|
||||
from konova.views import logout_view, home_view, get_konova_code_action_children
|
||||
from konova.views import logout_view, home_view
|
||||
|
||||
sso_client = KonovaSSOClient(SSO_SERVER, SSO_PUBLIC_KEY, SSO_PRIVATE_KEY)
|
||||
urlpatterns = [
|
||||
@@ -40,8 +40,6 @@ urlpatterns = [
|
||||
path('analysis/', include("analysis.urls")),
|
||||
path('api/', include("api.urls")),
|
||||
|
||||
path("codes/comp/action/children", get_konova_code_action_children, name="codes-action-children"),
|
||||
|
||||
# Autocomplete paths for all apps
|
||||
path("atcmplt/eco-accounts", EcoAccountAutocomplete.as_view(), name="accounts-autocomplete"),
|
||||
path("atcmplt/interventions", InterventionAutocomplete.as_view(), name="interventions-autocomplete"),
|
||||
|
||||
@@ -127,24 +127,3 @@ def get_500_view(request: HttpRequest):
|
||||
"""
|
||||
context = BaseContext.context
|
||||
return render(request, "500.html", context, status=500)
|
||||
|
||||
|
||||
@login_required
|
||||
def get_konova_code_action_children(request: HttpRequest):
|
||||
template = "konova/widgets/checkbox-tree-select-content.html"
|
||||
_id = request.GET.get("id", None)
|
||||
if _id == "#":
|
||||
# Return all!
|
||||
codes = KonovaCode.objects.filter(
|
||||
code_lists__in=[CODELIST_COMPENSATION_ACTION_ID],
|
||||
parent=None,
|
||||
)
|
||||
else:
|
||||
codes = KonovaCode.objects.filter(
|
||||
code_lists__in=[CODELIST_COMPENSATION_ACTION_ID],
|
||||
parent__id=_id,
|
||||
)
|
||||
context = {
|
||||
"codes": codes
|
||||
}
|
||||
return render(request, template, context)
|
||||
Reference in New Issue
Block a user