From 2ac543bea0ed2fa5f2d43a4ab91a3ad5e4c44eb1 Mon Sep 17 00:00:00 2001 From: Horilla Date: Thu, 22 Feb 2024 11:24:18 +0530 Subject: [PATCH] [ADD] HELPDESK: Column sorting in helpdesk --- .../helpdesk/ticket/ticket_list.html | 1230 +++++++++-------- helpdesk/views.py | 8 +- 2 files changed, 676 insertions(+), 562 deletions(-) diff --git a/helpdesk/templates/helpdesk/ticket/ticket_list.html b/helpdesk/templates/helpdesk/ticket/ticket_list.html index 343421d35..334e5c425 100644 --- a/helpdesk/templates/helpdesk/ticket/ticket_list.html +++ b/helpdesk/templates/helpdesk/ticket/ticket_list.html @@ -2,611 +2,687 @@
{% if my_tickets %} -
-
-
-
-
-
- +
+
+
+ +
+
    +
+
+
+
+
+ +
+
+
+
+
+
+ +
+
+
{% trans "Ticket Id" %}
+
{% trans "Title" %}
+
{% trans "Owner" %}
+
{% trans "Type" %}
+
{% trans "Forward to" %}
+
{% trans "Assigned to" %}
+
{% trans "Status" %}
+
{% trans "Priority" %}
+
{% trans "Tags" %}
+
{% trans "Actions" %}
-
{% trans "Ticket Id" %}
-
{% trans "Title" %}
-
{% trans "Owner" %}
-
{% trans "Type" %}
-
{% trans "Forward to" %}
-
{% trans "Assigned to" %}
-
{% trans "Status" %}
-
{% trans "Priority" %}
-
{% trans "Tags" %}
-
{% trans "Actions" %}
+
+ {% for ticket in my_tickets %} +
+
+
+ +
+
+
+ + {{ticket.ticket_type.prefix}}{{ ticket.id|stringformat:"03d" }} + + + + + +
+
{{ticket.title}}
+
{{ticket.employee_id}}
+
{{ticket.ticket_type}}
+
{{ticket.get_raised_on}}
+
{{ticket.assigned_to.all|join:" , "}}
+
{{ticket.get_status_display}}
+
+ {% if ticket.priority == 'high' %} + + + + {% elif ticket.priority == 'medium' %} + + + + {% elif ticket.priority == 'low' %} + + + + {% endif %} +
+ +
{{ticket.tags.all|join:" , "}}
+
+
+ + + + +
+ {% csrf_token %} + +
+
+
+
+ {% endfor %} +
-
- {% for ticket in my_tickets %} -
-
-
- -
-
-
- - {{ticket.ticket_type.prefix}}{{ ticket.id|stringformat:"03d" }} - - - - - -
-
{{ticket.title}}
-
{{ticket.employee_id}}
-
{{ticket.ticket_type}}
-
{{ticket.get_raised_on}}
-
{{ticket.assigned_to.all|join:" , "}}
-
{{ticket.get_status_display}}
-
- {% if ticket.priority == 'high' %} - - - - {% elif ticket.priority == 'medium' %} - - - - {% elif ticket.priority == 'low' %} - - - - {% endif %} -
+ -
{{ticket.tags.all|join:" , "}}
-
-
- - - - -
- {% csrf_token %} - -
-
-
-
- {% endfor %} + +
+ + {% trans "Page" %} {{ my_tickets.number }} {% trans "of" %} {{ my_tickets.paginator.num_pages }}. + +
+
- -
- - {% trans "Page" %} {{ my_tickets.number }} {% trans "of" %} {{ my_tickets.paginator.num_pages }}. - - -
{% else %} - -
- Page not found. 404. -
{% trans "There are no tickets at the moment." %}
-
- + +
+ +
+ {% trans "No search result found!" %} +
+
+ {% endif %}
{% if allocated_tickets %} -
-
-
-
-
-
- +
+
+
+ +
+
    +
+
+
+
+
+
+
+
+
+
+
+ +
+
+
{% trans "Ticket Id" %}
+
{% trans "Title" %}
+
{% trans "Owner" %}
+
{% trans "Type" %}
+
{% trans "Forward to" %}
+
{% trans "Assigned to" %}
+
{% trans "Status" %}
+
{% trans "Priority" %}
+
{% trans "Tags" %}
+
{% trans "Actions" %}
-
{% trans "Ticket Id" %}
-
{% trans "Title" %}
-
{% trans "Owner" %}
-
{% trans "Type" %}
-
{% trans "Forward to" %}
-
{% trans "Assigned to" %}
-
{% trans "Status" %}
-
{% trans "Priority" %}
-
{% trans "Tags" %}
-
{% trans "Actions" %}
-
+
+ {% for ticket in allocated_tickets %} +
+
+
+ +
+
+
+ + {{ticket.ticket_type.prefix}}{{ ticket.id|stringformat:"03d" }} + + + + + +
+
{{ticket.title}}
+
{{ticket.employee_id}}
+
{{ticket.ticket_type}}
+
{{ticket.get_raised_on}}
+
{{ticket.assigned_to.all|join:" , "}}
+
{{ticket.get_status_display}}
+
+ {% if ticket.priority == 'high' %} + + + + {% elif ticket.priority == 'medium' %} + + + + {% elif ticket.priority == 'low' %} + + + + {% endif %} +
+
{{ticket.tags.all|join:" , "}}
+
+
+ {% if ticket.assigned_to.all or request.user.employee_get == ticket.employee_id %} + + {% trans "Claim" %} + + {% else %} + + + {% comment %} {% trans "Claim" %} {% endcomment %} + + {% endif %} + {% if ticket.employee_id == request.user.employee_get or perms.helpdesk.changeticket %} + + {% endif %} + {% if ticket.employee_id == request.user.employee_get or perms.helpdesk.deleteticket %} +
+ {% csrf_token %} + +
+ {% endif %} +
+
+
+ {% endfor %} +
-
- {% for ticket in allocated_tickets %} -
-
-
- -
-
-
- - {{ticket.ticket_type.prefix}}{{ ticket.id|stringformat:"03d" }} - - - - - -
-
{{ticket.title}}
-
{{ticket.employee_id}}
-
{{ticket.ticket_type}}
-
{{ticket.get_raised_on}}
-
{{ticket.assigned_to.all|join:" , "}}
-
{{ticket.get_status_display}}
-
- {% if ticket.priority == 'high' %} - - - - {% elif ticket.priority == 'medium' %} - - - - {% elif ticket.priority == 'low' %} - - - - {% endif %} -
-
{{ticket.tags.all|join:" , "}}
-
-
- - - - {% if ticket.employee_id == request.user.employee_get or perms.helpdesk.changeticket %} - - {% endif %} - {% if ticket.employee_id == request.user.employee_get or perms.helpdesk.deleteticket %} -
- {% csrf_token %} - -
- {% endif %} -
-
-
- {% if ticket.assigned_to.all or request.user.employee_get == ticket.employee_id %} - - {% trans "Claim" %} - - {% else %} - - {% trans "Claim" %} - - {% endif %} -
-
- {% endfor %} +
+ + {% trans "Page" %} {{ allocated_tickets.number }} {% trans "of" %} {{ allocated_tickets.paginator.num_pages }}. + +
-
- - {% trans "Page" %} {{ allocated_tickets.number }} {% trans "of" %} {{ allocated_tickets.paginator.num_pages }}. - - -
{% else %} - -
- Page not found. 404. -
{% trans "There are no tickets at the moment." %}
-
- + +
+ +
+ {% trans "No search result found!" %} +
+
+ {% endif %}
{% if all_tickets %} -
-
-
-
-
-
- -
-
-
{% trans "Ticket Id" %}
-
{% trans "Title" %}
-
{% trans "Owner" %}
-
{% trans "Type" %}
-
{% trans "Forward to" %}
-
{% trans "Assigned to" %}
-
{% trans "Status" %}
-
{% trans "Priority" %}
-
{% trans "Tags" %}
-
{% trans "Actions" %}
+
+
+
+ +
+
    +
-
-
- {% for ticket in all_tickets %} -
-
+
+
+
+
+
+
+
+
-
- {% trans "Ticket Id" %}
+
{% trans "Title" %}
+
{% trans "Owner" %}
+
{% trans "Type" %}
+
{% trans "Forward to" %}
+
{% trans "Assigned to" %}
+
{% trans "Status" %}
+
{% trans "Priority" %}
+
{% trans "Tags" %}
+
{% trans "Actions" %}
+
+
+
+ {% for ticket in all_tickets %} +
+
- {{ticket.ticket_type.prefix}}{{ ticket.id|stringformat:"03d" }} - - - - - -
-
{{ticket.title}}
-
{{ticket.employee_id}}
-
{{ticket.ticket_type}}
-
{{ticket.get_raised_on}}
-
{{ticket.assigned_to.all|join:" , "}}
-
{{ticket.get_status_display}}
-
- {% if ticket.priority == 'high' %} - - - - {% elif ticket.priority == 'medium' %} - - - - {% elif ticket.priority == 'low' %} - - - - {% endif %} -
-
{{ticket.tags.all|join:" , "}}
-
-
- - - -
+
+
+ - - -
- {% csrf_token %} + {{ticket.ticket_type.prefix}}{{ ticket.id|stringformat:"03d" }} + + + + + +
+
{{ticket.title}}
+
{{ticket.employee_id}}
+
{{ticket.ticket_type}}
+
{{ticket.get_raised_on}}
+
{{ticket.assigned_to.all|join:" , "}}
+
{{ticket.get_status_display}}
+
+ {% if ticket.priority == 'high' %} + + + + {% elif ticket.priority == 'medium' %} + + + + {% elif ticket.priority == 'low' %} + + + + {% endif %} +
+
{{ticket.tags.all|join:" , "}}
+
+
+ + + - +
+ {% csrf_token %} + +
+
-
- {% endfor %} + {% endfor %} +
-
-
- - {% trans "Page" %} {{ all_tickets.number }} {% trans "of" %} {{ all_tickets.paginator.num_pages }}. - -
+
{% else %} - -
- Page not found. 404. -
{% trans "There are no tickets at the moment." %}
+ +
+ +
+ {% trans "No search result found!" %} +
- + {% endif %}
@@ -678,6 +754,9 @@ $(document).ready(function () { tickTicketsCheckboxes(); $(".my-tickets-row").change(function () { + if ($('.myTicketsAll').is(":checked")) { + $('.myTicketsAll').prop("checked", false); + } addingTicketsIds(); }); $(".myTicketsAll").change(function () { @@ -685,13 +764,19 @@ }); $(".allocated-tickets-row").change(function () { + if ($('.allocatedTicketsAll').is(":checked")) { + $('.allocatedTicketsAll').prop("checked", false); + } addingTicketsIds(); }); $(".allocatedTicketsAll").change(function () { addingTicketsIds(); }); $(".all-tickets-row").change(function () { - addingTicketsIds(); + if ($('.allTicketsAll').is(":checked")) { + $('.allTicketsAll').prop("checked", false); + } + addingTicketsIds(); }); $(".allTicketsAll").change(function () { addingTicketsIds(); @@ -707,5 +792,28 @@ exportObjectives(); }); {% endcomment %} }); + // start of column toggle // + //my tickets// + toggleColumns("my-ticket-table","MyTicketsCells") + localStorageMyTicketsCells = localStorage.getItem("my_ticket_table") + if (!localStorageMyTicketsCells) { + $("#MyTicketsCells").find("[type=checkbox]").prop("checked",true) + } + + //suggested tickets// + toggleColumns("suggested-ticket-table","SuggestedTicketsCells") + localStorageSuggestedTicketsCells = localStorage.getItem("suggested_ticket_table") + if (!localStorageSuggestedTicketsCells) { + $("#SuggestedTicketsCells").find("[type=checkbox]").prop("checked",true) + } + + //all tickets// + toggleColumns("all-ticket-table","AllTicketsCells") + localStorageAllTicketsCells = localStorage.getItem("all_ticket_table") + if (!localStorageAllTicketsCells) { + $("#AllTicketsCells").find("[type=checkbox]").prop("checked",true) + } + $("[type=checkbox]").change() + // end of toggle columns // \ No newline at end of file diff --git a/helpdesk/views.py b/helpdesk/views.py index 09f7fb94d..436f63cd1 100644 --- a/helpdesk/views.py +++ b/helpdesk/views.py @@ -6,7 +6,7 @@ from django.http import HttpResponse, JsonResponse, HttpResponseRedirect from django.shortcuts import redirect, render from attendance.methods.group_by import group_by_queryset from base.forms import TagsForm -from base.methods import filtersubordinates, get_key_instances, get_pagination +from base.methods import filtersubordinates, get_key_instances, get_pagination, sortby from base.models import Department, JobPosition, Tags from employee.models import Employee from helpdesk.filter import FAQCategoryFilter, FAQFilter, TicketFilter, TicketReGroup @@ -726,6 +726,12 @@ def ticket_filter(request): allocated_tickets = ( list(tickets_items1) + list(tickets_items2) + list(tickets_items3) ) + if request.GET.get("sortby"): + all_tickets = sortby(request, all_tickets, "sortby") + my_tickets = sortby(request,my_tickets,"sortby") + allocated_tickets = tickets_items1 | tickets_items2 | tickets_items3 + allocated_tickets = sortby(request,allocated_tickets,"sortby") + field = request.GET.get("field") if field != "" and field is not None: my_tickets = group_by_queryset(