Skip to content
Snippets Groups Projects
Commit 12a6a117 authored by Valentin Groues's avatar Valentin Groues :eyes:
Browse files

subjects list sorted by nd number and filtered by worker's location - fixes #104

parent 4b3709d8
No related branches found
No related tags found
No related merge requests found
Pipeline #
......@@ -88,6 +88,7 @@
<script src="{% static 'AdminLTE/plugins/datatables/dataTables.bootstrap.min.js' %}"></script>
<script>
var table;
$('#table tfoot div[name="string_filter"]').each(function () {
var title = $(this).text();
$(this).html('<input type="text" style="width:80px" placeholder="' + title + '" />');
......@@ -100,17 +101,21 @@
$('#table tfoot div[name="location_filter"]').each(function () {
var obj = $(this)
obj.html('<select style="width:80px"><option value selected="selected">---</option></select>');
var select = $('select', obj);
$.get("{% url 'web.api.locations' %}", function (data) {
$.each(data.locations, function (index, location) {
$('select', obj).append('<option value="' + location.id + '">' + location.name + '</option>');
select.append('<option value="' + location.id + '">' + location.name + '</option>');
});
{% if worker.locations.all.count == 1 %}
select.val({{ worker.locations.first.id}});
{% endif %}
});
});
$(function () {
var table = $('#table').DataTable({
table = $('#table').DataTable({
pageLength: 25,
stateSave: true,
serverSide: true,
processing: true,
responsive: true,
......@@ -131,8 +136,12 @@
"targets": 9,
"data": "id",
"defaultContent": '<a href="#" type="button" class="btn btn-block btn-default">Edit</a>'
}]
}],
order: [[0, 'desc']]
});
{% if worker.locations.all.count == 1 %}
table.columns(4).search({{ worker.locations.first.id}}).draw();
{% endif %}
$('#table tbody').on('click', 'a', function () {
var data = table.row($(this).parents('tr')).data();
......
......@@ -4,7 +4,7 @@ from django.shortcuts import redirect, get_object_or_404
from . import wrap_response
from ..forms import SubjectAddForm, SubjectEditForm, VisitDetailForm
from ..models import Subject, MailTemplate
from ..models import Subject, MailTemplate, Worker
SUBJECT_LIST_GENERIC = "GENERIC"
SUBJECT_LIST_NO_VISIT = "NO_VISIT"
......@@ -14,6 +14,7 @@ SUBJECT_LIST_REQUIRE_CONTACT = "REQUIRE_CONTACT"
def subjects(request):
context = {
'list_type': SUBJECT_LIST_GENERIC,
'worker': Worker.get_by_user(request.user)
}
return wrap_response(request, 'subjects/index.html', context)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment