mirror of
https://github.com/django-helpdesk/django-helpdesk.git
synced 2024-12-13 10:21:05 +01:00
Remove "classic" code path and always use datatables for ticket lists
This commit is contained in:
parent
f127b2c224
commit
b862732512
@ -106,9 +106,6 @@ HELPDESK_REDIRECT_TO_LOGIN_BY_DEFAULT = False
|
|||||||
LOGIN_URL = '/login/'
|
LOGIN_URL = '/login/'
|
||||||
LOGIN_REDIRECT_URL = '/login/'
|
LOGIN_REDIRECT_URL = '/login/'
|
||||||
|
|
||||||
# Turn off server-side processing for this local demo
|
|
||||||
HELPDESK_USE_SERVERSIDE_PROCESSING = False
|
|
||||||
|
|
||||||
# Database
|
# Database
|
||||||
# - by default, we use SQLite3 for the demo, but you can also
|
# - by default, we use SQLite3 for the demo, but you can also
|
||||||
# configure MySQL or PostgreSQL, see the docs for more:
|
# configure MySQL or PostgreSQL, see the docs for more:
|
||||||
|
@ -90,11 +90,6 @@ These changes are visible throughout django-helpdesk
|
|||||||
|
|
||||||
**Default:** ``HELPDESK_ANON_ACCESS_RAISES_404 = False``
|
**Default:** ``HELPDESK_ANON_ACCESS_RAISES_404 = False``
|
||||||
|
|
||||||
- **HELPDESK_USE_SERVERSIDE_PROCESSING** If True, may improve performance by utilizing server-side processing of the full ticket list whenever performing queries on the ticket list. Set to False to restore the "classic" functionality using javascript.
|
|
||||||
|
|
||||||
**Default:** ``HELPDESK_USE_SERVERSIDE_PROCESSING = True``
|
|
||||||
|
|
||||||
|
|
||||||
Options shown on public pages
|
Options shown on public pages
|
||||||
-----------------------------
|
-----------------------------
|
||||||
|
|
||||||
|
@ -151,7 +151,3 @@ HELPDESK_ENABLE_PER_QUEUE_STAFF_PERMISSION = getattr(
|
|||||||
|
|
||||||
# use https in the email links
|
# use https in the email links
|
||||||
HELPDESK_USE_HTTPS_IN_EMAIL_LINK = getattr(settings, 'HELPDESK_USE_HTTPS_IN_EMAIL_LINK', False)
|
HELPDESK_USE_HTTPS_IN_EMAIL_LINK = getattr(settings, 'HELPDESK_USE_HTTPS_IN_EMAIL_LINK', False)
|
||||||
|
|
||||||
# Asynchronous Datatables - Optional
|
|
||||||
HELPDESK_USE_SERVERSIDE_PROCESSING = getattr(
|
|
||||||
settings, 'HELPDESK_USE_SERVERSIDE_PROCESSING', True)
|
|
||||||
|
@ -185,9 +185,6 @@
|
|||||||
<th>{% trans "Time Spent" %}</th>
|
<th>{% trans "Time Spent" %}</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
{% if not server_side %}
|
|
||||||
{% include 'helpdesk/ticket_list_table.html' %}
|
|
||||||
{% endif %}
|
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<p><label>{% trans "Select:" %} </label>
|
<p><label>{% trans "Select:" %} </label>
|
||||||
@ -229,135 +226,126 @@
|
|||||||
{% block helpdesk_js %}
|
{% block helpdesk_js %}
|
||||||
<script src='{% static "helpdesk/filter.js" %}'></script>
|
<script src='{% static "helpdesk/filter.js" %}'></script>
|
||||||
<script>
|
<script>
|
||||||
{% if not server_side %}
|
function get_url(row)
|
||||||
$('#ticketTable').DataTable({
|
{
|
||||||
"language": {
|
return "{% url 'helpdesk:view' 1234 %}".replace(/1234/, row.id.toString());
|
||||||
"emptyTable": "{% trans 'No Tickets Match Your Selection' %}"
|
}
|
||||||
},
|
$(document).ready(function()
|
||||||
"order": [],
|
{
|
||||||
responsive: true
|
//DataTables Initialization
|
||||||
});
|
let tasks_table = $('#ticketTable').DataTable({
|
||||||
{% else %}
|
"language": {
|
||||||
function get_url(row)
|
"emptyTable": "{% trans 'No Tickets Match Your Selection' %}"
|
||||||
{
|
},
|
||||||
return "{% url 'helpdesk:view' 1234 %}".replace(/1234/, row.id.toString());
|
"processing": true,
|
||||||
}
|
"serverSide": true,
|
||||||
$(document).ready(function()
|
"ajax": {
|
||||||
{
|
"url": "{% url 'helpdesk:datatables_ticket_list' %}",
|
||||||
//DataTables Initialization
|
"type": "GET",
|
||||||
let tasks_table = $('#ticketTable').DataTable({
|
},
|
||||||
"language": {
|
createdRow: function( row, data, dataIndex )
|
||||||
"emptyTable": "{% trans 'No Tickets Match Your Selection' %}"
|
{
|
||||||
},
|
$( row ).addClass(data.row_class);
|
||||||
"processing": true,
|
},
|
||||||
"serverSide": true,
|
|
||||||
"ajax": {
|
|
||||||
"url": "{% url 'helpdesk:datatables_ticket_list' %}",
|
|
||||||
"type": "GET",
|
|
||||||
},
|
|
||||||
createdRow: function( row, data, dataIndex )
|
|
||||||
{
|
|
||||||
$( row ).addClass(data.row_class);
|
|
||||||
},
|
|
||||||
|
|
||||||
"columns": [
|
"columns": [
|
||||||
{"data": "id",
|
{"data": "id",
|
||||||
"orderable": false,
|
"orderable": false,
|
||||||
"render": function(data, type, row, meta)
|
"render": function(data, type, row, meta)
|
||||||
{
|
{
|
||||||
var pk = data;
|
var pk = data;
|
||||||
if(type === 'display'){
|
if(type === 'display'){
|
||||||
data = "<input type='checkbox' name='ticket_id' value='"+pk+"'"+ "class='ticket_multi_select' />"
|
data = "<input type='checkbox' name='ticket_id' value='"+pk+"'"+ "class='ticket_multi_select' />"
|
||||||
}
|
}
|
||||||
return data
|
return data
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{"data": "ticket",
|
{"data": "ticket",
|
||||||
"render": function (data, type, row, meta)
|
"render": function (data, type, row, meta)
|
||||||
{
|
{
|
||||||
var id = data.split(" ")[0];
|
var id = data.split(" ")[0];
|
||||||
var name = data.split(" ")[1];
|
var name = data.split(" ")[1];
|
||||||
if (type === 'display')
|
if (type === 'display')
|
||||||
{
|
{
|
||||||
data = '<div class="tickettitle"><a href="' + get_url(row) + '" >' +
|
data = '<div class="tickettitle"><a href="' + get_url(row) + '" >' +
|
||||||
row.id + '. ' +
|
row.id + '. ' +
|
||||||
row.title + '</a></div>';
|
row.title + '</a></div>';
|
||||||
}
|
}
|
||||||
return data
|
return data
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{"data": "priority",
|
{"data": "priority",
|
||||||
"render": function (data, type, row, meta) {
|
"render": function (data, type, row, meta) {
|
||||||
var priority = "success";
|
var priority = "success";
|
||||||
if (data == 4 ) {
|
if (data == 4 ) {
|
||||||
priority = "warning";
|
priority = "warning";
|
||||||
} else if (data == 5) {
|
} else if (data == 5) {
|
||||||
priority = "danger";
|
priority = "danger";
|
||||||
}
|
}
|
||||||
return '<p class="text-'+priority+'">'+data+'</p>';
|
return '<p class="text-'+priority+'">'+data+'</p>';
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{"data": "queue",
|
{"data": "queue",
|
||||||
"render": function(data, type, row, meta) {
|
"render": function(data, type, row, meta) {
|
||||||
return data.title;
|
return data.title;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{"data": "status"},
|
{"data": "status"},
|
||||||
{"data": "created"},
|
{"data": "created"},
|
||||||
{"data": "due_date"},
|
{"data": "due_date"},
|
||||||
{"data": "assigned_to",
|
{"data": "assigned_to",
|
||||||
"render": function(data, type, row, meta) {
|
"render": function(data, type, row, meta) {
|
||||||
if (data != "None") {
|
if (data != "None") {
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{"data": "time_spent"},
|
{"data": "time_spent"},
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
{% endif %}
|
|
||||||
$(document).ready(function()
|
|
||||||
{
|
|
||||||
$("#select_all_btn").click(function() {
|
|
||||||
$(".ticket_multi_select").prop('checked', true);
|
|
||||||
});
|
|
||||||
$("#select_none_btn").click(function() {
|
|
||||||
$(".ticket_multi_select").prop('checked', false);
|
|
||||||
});
|
|
||||||
$("#select_inverse_btn").click(function() {
|
|
||||||
$(".ticket_multi_select").each(function() {
|
|
||||||
$(this).prop('checked', !$(this).prop('checked'));
|
|
||||||
});
|
|
||||||
});
|
|
||||||
})
|
|
||||||
|
|
||||||
/**
|
$(document).ready(function()
|
||||||
* Disable active filtering options in filter select menu
|
{
|
||||||
*/
|
$("#select_all_btn").click(function() {
|
||||||
$(document).ready(function() {
|
$(".ticket_multi_select").prop('checked', true);
|
||||||
{% if query_params.sorting %}
|
});
|
||||||
$("#filterBuilderSelect-Sort")[0].disabled = "disabled";
|
$("#select_none_btn").click(function() {
|
||||||
{% endif %}
|
$(".ticket_multi_select").prop('checked', false);
|
||||||
{% if query_params.filtering.assigned_to__id__in %}
|
});
|
||||||
$("#filterBuilderSelect-Owner")[0].disabled = "disabled";
|
$("#select_inverse_btn").click(function() {
|
||||||
{% endif %}
|
$(".ticket_multi_select").each(function() {
|
||||||
{% if query_params.filtering.queue__id__in %}
|
$(this).prop('checked', !$(this).prop('checked'));
|
||||||
$("#filterBuilderSelect-Queue")[0].disabled = "disabled";
|
});
|
||||||
{% endif %}
|
});
|
||||||
{% if query_params.filtering.status__in %}
|
})
|
||||||
$("#filterBuilderSelect-Status")[0].disabled = "disabled";
|
|
||||||
{% endif %}
|
/**
|
||||||
{% if query_params.filtering.created__gte or query_params.filtering.created__lte %}
|
* Disable active filtering options in filter select menu
|
||||||
$("#filterBuilderSelect-Dates")[0].disabled = "disabled";
|
*/
|
||||||
{% endif %}
|
$(document).ready(function() {
|
||||||
{% if query %}
|
{% if query_params.sorting %}
|
||||||
$("#filterBuilderSelect-Keywords")[0].disabled = "disabled";
|
$("#filterBuilderSelect-Sort")[0].disabled = "disabled";
|
||||||
{% endif %}
|
{% endif %}
|
||||||
});
|
{% if query_params.filtering.assigned_to__id__in %}
|
||||||
|
$("#filterBuilderSelect-Owner")[0].disabled = "disabled";
|
||||||
|
{% endif %}
|
||||||
|
{% if query_params.filtering.queue__id__in %}
|
||||||
|
$("#filterBuilderSelect-Queue")[0].disabled = "disabled";
|
||||||
|
{% endif %}
|
||||||
|
{% if query_params.filtering.status__in %}
|
||||||
|
$("#filterBuilderSelect-Status")[0].disabled = "disabled";
|
||||||
|
{% endif %}
|
||||||
|
{% if query_params.filtering.created__gte or query_params.filtering.created__lte %}
|
||||||
|
$("#filterBuilderSelect-Dates")[0].disabled = "disabled";
|
||||||
|
{% endif %}
|
||||||
|
{% if query %}
|
||||||
|
$("#filterBuilderSelect-Keywords")[0].disabled = "disabled";
|
||||||
|
{% endif %}
|
||||||
|
});
|
||||||
|
|
||||||
{% for f in query_params.filtering %}
|
{% for f in query_params.filtering %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
@ -24,7 +24,6 @@ from django.utils.html import escape
|
|||||||
from django import forms
|
from django import forms
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
from django.views.generic.edit import FormView, UpdateView
|
from django.views.generic.edit import FormView, UpdateView
|
||||||
# For datatables serverside
|
|
||||||
from django.core.cache import cache
|
from django.core.cache import cache
|
||||||
|
|
||||||
from helpdesk.lib import query_tickets_by_args
|
from helpdesk.lib import query_tickets_by_args
|
||||||
@ -972,13 +971,7 @@ def ticket_list(request):
|
|||||||
|
|
||||||
user_saved_queries = SavedSearch.objects.filter(Q(user=request.user) | Q(shared__exact=True))
|
user_saved_queries = SavedSearch.objects.filter(Q(user=request.user) | Q(shared__exact=True))
|
||||||
|
|
||||||
# Serverside processing on datatables is optional. Set
|
cache.set('ticket_qs', ticket_qs)
|
||||||
# HELPDESK_USE_SERVERSIDE_PROCESSING to False in settings.py to disable
|
|
||||||
if helpdesk_settings.HELPDESK_USE_SERVERSIDE_PROCESSING:
|
|
||||||
cache.set('ticket_qs', ticket_qs)
|
|
||||||
context['server_side'] = True
|
|
||||||
else:
|
|
||||||
context['server_side'] = False
|
|
||||||
|
|
||||||
return render(request, 'helpdesk/ticket_list.html', dict(
|
return render(request, 'helpdesk/ticket_list.html', dict(
|
||||||
context,
|
context,
|
||||||
|
Loading…
Reference in New Issue
Block a user