[UPDT] HELPDESK: Dynamic creation in ticket form

This commit is contained in:
Horilla
2024-01-31 16:25:07 +05:30
parent a34aa73d50
commit 8697b61c01
11 changed files with 387 additions and 241 deletions

View File

@@ -20,8 +20,10 @@ class YourForm(forms.Form):
# Custom validation logic goes here
pass
"""
from typing import Any
from base.forms import ModelForm
from base.models import Department, JobPosition
from employee.forms import MultipleFileField
from employee.models import Employee
from helpdesk.models import Attachment, DepartmentManager, TicketType, FAQ,Ticket, FAQCategory, Comment
from django import forms
@@ -73,27 +75,15 @@ class TicketForm(ModelForm):
context = {"form": self}
table_html = render_to_string("attendance_form.html", context)
return table_html
# def get_updated_choices(assigning_type):
# new_choices =[
# ('', '---------'),
# ]
# if assigning_type:
# if assigning_type == 'department':
# # Retrieve data from the Department model and format it as a list of dictionaries
# departments = Department.objects.values('id', 'department')
# raised_on = [{'id': dept['id'], 'name': dept['department']} for dept in departments]
# elif assigning_type == 'job_position':
# jobpositions = JobPosition.objects.values('id','job_position')
# raised_on = [{'id': job['id'], 'name': job['job_position']} for job in jobpositions]
# elif assigning_type == 'individual':
# employees = Employee.objects.values('id','employee_first_name','employee_last_name')
# raised_on = [{'id': employee['id'], 'name': f"{employee['employee_first_name']} {employee['employee_last_name']}"} for employee in employees]
# new_choices = [
# (choice['id'], choice['name']) for choice in raised_on
# ]
# return new_choices
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.fields["attachment"] = MultipleFileField(
label="Attachements", required=False
)
self.fields["tags"].choices = list(self.fields["tags"].choices)
self.fields["tags"].choices.append(("create_new_tag", "Create new tag"))
self.fields["ticket_type"].choices = list(self.fields["ticket_type"].choices)
self.fields["ticket_type"].choices.append(("create_new_ticket_type", "Create new ticket type"))
class TicketTagForm(ModelForm):
class Meta:

View File

@@ -1,9 +1,10 @@
import datetime
from datetime import datetime
import os
from django import apps
from django.db import models
from django.forms import ValidationError
from base.models import Department, JobPosition, Tags
from django.utils.translation import gettext_lazy as _
from employee.models import Employee
from base.models import Company
from base.horilla_company_manager import HorillaCompanyManager
@@ -93,7 +94,7 @@ class Ticket(models.Model):
created_date = models.DateField(auto_now_add=True)
resolved_date = models.DateField(blank=True, null=True)
assigning_type = models.CharField(choices = MANAGER_TYPES, max_length=100)
raised_on = models.CharField(max_length=100)
raised_on = models.CharField(max_length=100,verbose_name="Forward To")
assigned_to = models.ManyToManyField(Employee,blank=True,related_name="ticket_assigned_to")
deadline = models.DateField(null=True,blank=True)
tags = models.ManyToManyField(Tags,blank=True,related_name="ticket_tags")
@@ -108,7 +109,12 @@ class Ticket(models.Model):
objects = HorillaCompanyManager(
related_company_field="employee_id__employee__work_info__company_id"
)
def clean(self, *args, **kwargs):
super().clean(*args, **kwargs)
deadline = self.deadline
today = datetime.today().date()
if deadline < today:
raise ValidationError(_("Deadline should be greater than today"))
def get_raised_on(self):
obj_id = self.raised_on
if self.assigning_type == 'department':

View File

@@ -212,27 +212,10 @@
</div>
{% else %}
<!-- start of empty page-->
<div
style="
height: 70vh;
display: flex;
align-items: center;
justify-content: center;
"
class=""
>
<div style="" class="oh-404">
<img
style="display: block; width: 150px; height: 150px; margin: 10px auto top:70% !importent"
src="{% static 'images/ui/ticket.png' %}"
class="mb-4"
alt=""
/>
<h3 style="font-size: 20px" class="oh-404__subtitle">
{% trans "There are no tickets at the moment." %}
</h3>
</div>
</div>
<div style="display: flex; flex-direction: column; justify-content: center; align-items: center; height: 100%;">
<img style="display: block; width: 15%; margin: 20px auto; filter: opacity(0.5);" src="{% static 'images/ui/ticket.png' %}" class="" alt="Page not found. 404." />
<h5 class="oh-404__subtitle">{% trans "There are no tickets at the moment." %}</h5>
</div>
<!-- end of empty page-->
{% endif %}
@@ -466,27 +449,10 @@
</div>
{% else %}
<!-- start of empty page-->
<div
style="
height: 70vh;
display: flex;
align-items: center;
justify-content: center;
"
class=""
>
<div style="" class="oh-404">
<img
style="display: block; width: 150px; height: 150px; margin: 10px auto top:70% !importent"
src="{% static 'images/ui/ticket.png' %}"
class="mb-4"
alt=""
/>
<h3 style="font-size: 20px" class="oh-404__subtitle">
{% trans "There are no tickets at the moment." %}
</h3>
</div>
</div>
<div style="display: flex; flex-direction: column; justify-content: center; align-items: center; height: 100%;">
<img style="display: block; width: 15%; margin: 20px auto; filter: opacity(0.5);" src="{% static 'images/ui/ticket.png' %}" class="" alt="Page not found. 404." />
<h5 class="oh-404__subtitle">{% trans "There are no tickets at the moment." %}</h5>
</div>
<!-- end of empty page-->
{% endif %}
</div>
@@ -703,27 +669,10 @@
</div>
{% else %}
<!-- start of empty page-->
<div
style="
height: 70vh;
display: flex;
align-items: center;
justify-content: center;
"
class=""
>
<div style="" class="oh-404">
<img
style="display: block; width: 150px; height: 150px; margin: 10px auto top:70% !importent"
src="{% static 'images/ui/ticket.png' %}"
class="mb-4"
alt=""
/>
<h3 style="font-size: 20px" class="oh-404__subtitle">
{% trans "There are no tickets at the moment." %}
</h3>
</div>
</div>
<div style="display: flex; flex-direction: column; justify-content: center; align-items: center; height: 100%;">
<img style="display: block; width: 15%; margin: 20px auto; filter: opacity(0.5);" src="{% static 'images/ui/ticket.png' %}" class="" alt="Page not found. 404." />
<h5 class="oh-404__subtitle">{% trans "There are no tickets at the moment." %}</h5>
</div>
<!-- end of empty page-->
{% endif %}
</div>

View File

@@ -29,7 +29,13 @@
<p class="oh-helpdesk__header-title">{{ticket.title}}</p>
<span class="helpdesk__card-value me-3">
<select name="status_update" class="oh-select w-100" onchange="updateStatus()">
<select name="status_update" title='{% trans "Status" %}' class="oh-select" onchange="updateStatus()"
style="
width:190px;
align-items: center;
border: 1px solid #aaa;
border-radius: 2px;
">
{% for status in ticket_status %}
<option value="{{status.0}}" {% if status.0 == ticket.status %} selected {% endif %}>
<span class="oh-dot oh-dot--small oh-dot--warning">{{status.1}}</span></option>
@@ -273,11 +279,17 @@
<span class="helpdesk__card-label">{% trans "Priority" %}</span>
<span class="helpdesk__card-value" name="priority">
{% if ticket.priority == 'high' %}
<ion-icon name="star-sharp"></ion-icon> <ion-icon name="star-sharp"></ion-icon> <ion-icon name="star-sharp"></ion-icon>
<img style="width:4%;" src="{% static 'images/ui/orange_star.png' %}"/>
<img style="width:4%;" src="{% static 'images/ui/orange_star.png' %}"/>
<img style="width:4%;" src="{% static 'images/ui/orange_star.png' %}"/>
{% elif ticket.priority == 'medium' %}
<ion-icon name="star-sharp"></ion-icon> <ion-icon name="star-sharp"></ion-icon>
<img style="width:4%;" src="{% static 'images/ui/orange_star.png' %}"/>
<img style="width:4%;" src="{% static 'images/ui/orange_star.png' %}"/>
<img style="width:4%;" src="{% static 'images/ui/star.png' %}"/>
{% elif ticket.priority == 'low' %}
<ion-icon name="star-sharp"></ion-icon>
<img style="width:4%;" src="{% static 'images/ui/orange_star.png' %}"/>
<img style="width:4%;" src="{% static 'images/ui/star.png' %}"/>
<img style="width:4%;" src="{% static 'images/ui/star.png' %}"/>
{% endif %}
</span>
</li>
@@ -311,7 +323,7 @@
<div class="oh-helpdesk__card-body">
<div class="oh-helpdesk__subcard">
<div class="oh-helpdesk__subcard-header">
<span class="oh-helpdesk__subcard-title">{% trans "Raised on" %}</span>
<span class="oh-helpdesk__subcard-title">{% trans "Forward to" %}</span>
{% if perms.helpdesk.changeticket or request.user.employee_get == ticket.employee_id %}
<a
hx-get="{% url 'ticket-change-raised-on' ticket.id %}"
@@ -411,6 +423,8 @@
</div>
</div>
<!-- start of create tag modal. -->
<div id="addTagModal">
<div id="addTagTarget">
</div>
@@ -447,9 +461,9 @@
</div>
</div>
</div>
<!-- end of create tag modal. -->
<script>
function showTag(){
var title=$('#id_title').val()
var color = $("#id_color").val()

View File

@@ -18,11 +18,119 @@
{{form.as_p}}
</form>
<!-- start of create tag modal. -->
<div id="addTagModal">
<div id="addTagTarget">
</div>
</div>
<div
class="oh-modal"
id="createTagModal"
role="dialog"
aria-labelledby="editDialogModal"
aria-hidden="true"
>
<div class="oh-modal__dialog">
<div class="oh-modal__dialog-header">
<h2 class="oh-modal__dialog-title" id="editTitle">
{% trans "Create Tag" %}
</h2>
<button style="order: none;
background: none;
font-size: 1.5rem;
opacity: 0.7;
position: absolute;
top: 25px;
right: 15px;
cursor: pointer;
-webkit-transition: all 0.3s ease-in-out;
transition: all 0.3s ease-in-out;"
aria-label="Close"
onclick="event.stopPropagation(); $('#createTagModal').removeClass('oh-modal--show'); $('#id_tags option[value=\'create_new_tag\']').prop('selected', false);"
>
<ion-icon name="close-outline"></ion-icon>
</button>
</div>
<div class="oh-modal__dialog-body" id="editTarget">
<form
onsubmit="saveTag();event.preventDefault();"
>
{% csrf_token %}
<label class="oh-label">{% trans "Title" %}</label>
<input type="text" name="title" maxlength="30" class="oh-input w-100" placeholder="Title" required="" id="id_tag_title">
<label class="oh-label">{% trans "Color" %}</label>
<input type="color" name="color" style="height:50px" maxlength="30" class="oh-input w-100" placeholder="Color" required="" id="id_tag_color">
<input type="checkbox" name="is_active" class="oh-switch__checkbox" id="id_tag_is_active" checked style="display: none;">
<button
type="submit"
class="oh-btn oh-btn--secondary mt-2 mr-0 oh-btn--w-100-resp"
>
{% trans "Save" %}
</button>
</form>
</div>
</div>
</div>
<!-- end of create tag modal. -->
<!-- start of create ticket type modal. -->
<div id="addTicketTypeModal">
<div id="addTicketTypeTarget">
</div>
</div>
<div
class="oh-modal"
id="createTicketTypeModal"
role="dialog"
aria-labelledby="editDialogModal"
aria-hidden="true"
>
<div class="oh-modal__dialog">
<div class="oh-modal__dialog-header">
<h2 class="oh-modal__dialog-title" id="editTitle">
{% trans "Create Ticket Type" %}
</h2>
<button class="oh-modal__close" aria-label="Close">
<ion-icon name="close-outline"></ion-icon>
</button>
</div>
<div class="oh-modal__dialog-body" id="editTarget">
<form
onsubmit="saveTicketType();event.preventDefault();"
>
{% csrf_token %}
<label class="oh-label">{% trans "Title" %}</label>
<input type="text" name="title" maxlength="30" class="oh-input w-100" placeholder="Title" required="" id="id_ticket_type_title">
<label class="oh-label">{% trans "Type" %}</label>
{{ t_type_form.type }}
<label class="oh-label">{% trans "Prefix" %}</label>
{{ t_type_form.prefix }}
<input type="checkbox" name="is_active" class="oh-switch__checkbox" id="id_ticket_type_is_active" checked style="display: none;">
<button
type="submit"
class="oh-btn oh-btn--secondary mt-2 mr-0 oh-btn--w-100-resp"
>
{% trans "Save" %}
</button>
</form>
</div>
</div>
</div>
<!-- end of create ticket type modal. -->
<script>
$(document).ready( function(){
var assigning_type = $('#id_assigning_type').val();
if (assigning_type) {
$.ajax({
type: "GET",
@@ -75,5 +183,22 @@
},
});
})
$('#id_tags').change(function(){
var selectedValues = $("#id_tags option:selected").map(function(){
return $(this).val();
}).get();
// Check if 'create_new_tag' exists in the list
if (selectedValues.includes('create_new_tag')) {
$("#createTagModal").addClass("oh-modal--show");
}
})
$('#id_ticket_type').change(function(){
var selectedValues = $("#id_ticket_type").val()
// Check if 'create_new_ticket_type' is selected
if (selectedValues == 'create_new_ticket_type') {
$("#createTicketTypeModal").addClass("oh-modal--show");
}
})
})
</script>

View File

@@ -43,16 +43,17 @@
<div class="oh-sticky-table__th">{% trans "Title" %}</div>
<div class="oh-sticky-table__th">{% trans "Owner" %}</div>
<div class="oh-sticky-table__th">{% trans "Type" %}</div>
<div class="oh-sticky-table__th">{% trans "Raised on" %}</div>
<div class="oh-sticky-table__th">{% trans "Forward to" %}</div>
<div class="oh-sticky-table__th">{% trans "Assigned to" %}</div>
<div class="oh-sticky-table__th">{% trans "Status" %}</div>
<div class="oh-sticky-table__th">{% trans "Priority" %}</div>
<div class="oh-sticky-table__th">{% trans "Tags" %}</div>
<div class="oh-sticky-table__th">{% trans "Actions" %}</div>
</div>
</div>
<div class="oh-sticky-table__tbody">
{% for ticket in my_ticket_list.list %}
<div class="oh-sticky-table__tr" >
<div class="oh-sticky-table__tr" onclick="window.location.href = `{% url 'ticket-detail' ticket.id %}`">
<div class="oh-sticky-table__sd {% if ticket.priority == 'high' %}row-status--red
{% elif ticket.priority == 'medium' %}row-status--orange
{% elif ticket.priority == 'low' %}row-status--blue{% endif %}"
@@ -85,6 +86,21 @@
<div class="oh-sticky-table__td">{{ticket.get_raised_on}}</div>
<div class="oh-sticky-table__td">{{ticket.assigned_to.all|join:" , "}}</div>
<div class="oh-sticky-table__td">{{ticket.get_status_display}}</div>
<div class="oh-sticky-table__td">
{% if ticket.priority == 'high' %}
<img style="width:15%;" src="{% static 'images/ui/orange_star.png' %}"/>
<img style="width:15%;" src="{% static 'images/ui/orange_star.png' %}"/>
<img style="width:15%;" src="{% static 'images/ui/orange_star.png' %}"/>
{% elif ticket.priority == 'medium' %}
<img style="width:15%;" src="{% static 'images/ui/orange_star.png' %}"/>
<img style="width:15%;" src="{% static 'images/ui/orange_star.png' %}"/>
<img style="width:15%;" src="{% static 'images/ui/star.png' %}"/>
{% elif ticket.priority == 'low' %}
<img style="width:15%;" src="{% static 'images/ui/orange_star.png' %}"/>
<img style="width:15%;" src="{% static 'images/ui/star.png' %}"/>
<img style="width:15%;" src="{% static 'images/ui/star.png' %}"/>
{% endif %}
</div>
<div class="oh-sticky-table__td">{{ticket.tags.all|join:" , "}}</div>
<div class="oh-sticky-table__td" onclick="event.stopPropagation()">
<div class="oh-btn-group">
@@ -201,27 +217,10 @@
</div>
{% else %}
<!-- start of empty page-->
<div
style="
height: 70vh;
display: flex;
align-items: center;
justify-content: center;
"
class=""
>
<div style="" class="oh-404">
<img
style="display: block; width: 150px; height: 150px; margin: 10px auto"
src="{% static 'images/ui/ticket.png' %}"
class="mb-4"
alt=""
/>
<h3 style="font-size: 20px" class="oh-404__subtitle">
{% trans "There are no tickets at the moment." %}
</h3>
</div>
</div>
<div style="display: flex; flex-direction: column; justify-content: center; align-items: center; height: 100%;">
<img style="display: block; width: 15%; margin: 20px auto; filter: opacity(0.5);" src="{% static 'images/ui/ticket.png' %}" class="" alt="Page not found. 404." />
<h5 class="oh-404__subtitle">{% trans "There are no tickets at the moment." %}</h5>
</div>
<!-- end of empty page-->
{% endif %}
</div>
@@ -264,16 +263,17 @@
<div class="oh-sticky-table__th">{% trans "Title" %}</div>
<div class="oh-sticky-table__th">{% trans "Owner" %}</div>
<div class="oh-sticky-table__th">{% trans "Type" %}</div>
<div class="oh-sticky-table__th">{% trans "Raised on" %}</div>
<div class="oh-sticky-table__th">{% trans "Forward to" %}</div>
<div class="oh-sticky-table__th">{% trans "Assigned to" %}</div>
<div class="oh-sticky-table__th">{% trans "Status" %}</div>
<div class="oh-sticky-table__th">{% trans "Priority" %}</div>
<div class="oh-sticky-table__th">{% trans "Tags" %}</div>
<div class="oh-sticky-table__th">{% trans "Actions" %}</div>
</div>
</div>
<div class="oh-sticky-table__tbody">
{% for ticket in allocated_tickets_list.list %}
<div class="oh-sticky-table__tr" >
<div class="oh-sticky-table__tr" onclick="window.location.href = `{% url 'ticket-detail' ticket.id %}`">
<div class="oh-sticky-table__sd {% if ticket.priority == 'high' %}row-status--red
{% elif ticket.priority == 'medium' %}row-status--orange
{% elif ticket.priority == 'low' %}row-status--blue{% endif %}"
@@ -306,6 +306,21 @@
<div class="oh-sticky-table__td">{{ticket.get_raised_on}}</div>
<div class="oh-sticky-table__td">{{ticket.assigned_to.all|join:" , "}}</div>
<div class="oh-sticky-table__td">{{ticket.get_status_display}}</div>
<div class="oh-sticky-table__td">
{% if ticket.priority == 'high' %}
<img style="width:15%;" src="{% static 'images/ui/orange_star.png' %}"/>
<img style="width:15%;" src="{% static 'images/ui/orange_star.png' %}"/>
<img style="width:15%;" src="{% static 'images/ui/orange_star.png' %}"/>
{% elif ticket.priority == 'medium' %}
<img style="width:15%;" src="{% static 'images/ui/orange_star.png' %}"/>
<img style="width:15%;" src="{% static 'images/ui/orange_star.png' %}"/>
<img style="width:15%;" src="{% static 'images/ui/star.png' %}"/>
{% elif ticket.priority == 'low' %}
<img style="width:15%;" src="{% static 'images/ui/orange_star.png' %}"/>
<img style="width:15%;" src="{% static 'images/ui/star.png' %}"/>
<img style="width:15%;" src="{% static 'images/ui/star.png' %}"/>
{% endif %}
</div>
<div class="oh-sticky-table__td">{{ticket.tags.all|join:" , "}}</div>
<div class="oh-sticky-table__td" onclick="event.stopPropagation()">
<div class="oh-btn-group">
@@ -422,27 +437,10 @@
</div>
{% else %}
<!-- start of empty page-->
<div
style="
height: 70vh;
display: flex;
align-items: center;
justify-content: center;
"
class=""
>
<div style="" class="oh-404">
<img
style="display: block; width: 150px; height: 150px; margin: 10px auto"
src="{% static 'images/ui/ticket.png' %}"
class="mb-4"
alt=""
/>
<h3 style="font-size: 20px" class="oh-404__subtitle">
{% trans "There are no tickets at the moment." %}
</h3>
</div>
</div>
<div style="display: flex; flex-direction: column; justify-content: center; align-items: center; height: 100%;">
<img style="display: block; width: 15%; margin: 20px auto; filter: opacity(0.5);" src="{% static 'images/ui/ticket.png' %}" class="" alt="Page not found. 404." />
<h5 class="oh-404__subtitle">{% trans "There are no tickets at the moment." %}</h5>
</div>
<!-- end of empty page-->
{% endif %}
</div>
@@ -484,16 +482,17 @@
<div class="oh-sticky-table__th">{% trans "Title" %}</div>
<div class="oh-sticky-table__th">{% trans "Owner" %}</div>
<div class="oh-sticky-table__th">{% trans "Type" %}</div>
<div class="oh-sticky-table__th">{% trans "Raised on" %}</div>
<div class="oh-sticky-table__th">{% trans "Forward to" %}</div>
<div class="oh-sticky-table__th">{% trans "Assigned to" %}</div>
<div class="oh-sticky-table__th">{% trans "Status" %}</div>
<div class="oh-sticky-table__th">{% trans "Priority" %}</div>
<div class="oh-sticky-table__th">{% trans "Tags" %}</div>
<div class="oh-sticky-table__th">{% trans "Actions" %}</div>
</div>
</div>
<div class="oh-sticky-table__tbody">
{% for ticket in all_tickets_list.list %}
<div class="oh-sticky-table__tr" >
<div class="oh-sticky-table__tr" onclick="window.location.href = `{% url 'ticket-detail' ticket.id %}`" >
<div class="oh-sticky-table__sd {% if ticket.priority == 'high' %}row-status--red
{% elif ticket.priority == 'medium' %}row-status--orange
{% elif ticket.priority == 'low' %}row-status--blue{% endif %}"
@@ -526,6 +525,21 @@
<div class="oh-sticky-table__td">{{ticket.get_raised_on}}</div>
<div class="oh-sticky-table__td">{{ticket.assigned_to.all|join:" , "}}</div>
<div class="oh-sticky-table__td">{{ticket.get_status_display}}</div>
<div class="oh-sticky-table__td">
{% if ticket.priority == 'high' %}
<img style="width:15%;" src="{% static 'images/ui/orange_star.png' %}"/>
<img style="width:15%;" src="{% static 'images/ui/orange_star.png' %}"/>
<img style="width:15%;" src="{% static 'images/ui/orange_star.png' %}"/>
{% elif ticket.priority == 'medium' %}
<img style="width:15%;" src="{% static 'images/ui/orange_star.png' %}"/>
<img style="width:15%;" src="{% static 'images/ui/orange_star.png' %}"/>
<img style="width:15%;" src="{% static 'images/ui/star.png' %}"/>
{% elif ticket.priority == 'low' %}
<img style="width:15%;" src="{% static 'images/ui/orange_star.png' %}"/>
<img style="width:15%;" src="{% static 'images/ui/star.png' %}"/>
<img style="width:15%;" src="{% static 'images/ui/star.png' %}"/>
{% endif %}
</div>
<div class="oh-sticky-table__td">{{ticket.tags.all|join:" , "}}</div>
<div class="oh-sticky-table__td" onclick="event.stopPropagation()">
<div class="oh-btn-group">
@@ -642,27 +656,10 @@
</div>
{% else %}
<!-- start of empty page-->
<div
style="
height: 70vh;
display: flex;
align-items: center;
justify-content: center;
"
class=""
>
<div style="" class="oh-404">
<img
style="display: block; width: 150px; height: 150px; margin: 10px auto"
src="{% static 'images/ui/ticket.png' %}"
class="mb-4"
alt=""
/>
<h3 style="font-size: 20px" class="oh-404__subtitle">
{% trans "There are no tickets at the moment." %}
</h3>
</div>
</div>
<div style="display: flex; flex-direction: column; justify-content: center; align-items: center; height: 100%;">
<img style="display: block; width: 15%; margin: 20px auto; filter: opacity(0.5);" src="{% static 'images/ui/ticket.png' %}" class="" alt="Page not found. 404." />
<h5 class="oh-404__subtitle">{% trans "There are no tickets at the moment." %}</h5>
</div>
<!-- end of empty page-->
{% endif %}
</div>

View File

@@ -20,21 +20,23 @@
<div class="oh-sticky-table__th">{% trans "Title" %}</div>
<div class="oh-sticky-table__th">{% trans "Owner" %}</div>
<div class="oh-sticky-table__th">{% trans "Type" %}</div>
<div class="oh-sticky-table__th">{% trans "Raised on" %}</div>
<div class="oh-sticky-table__th">{% trans "Forward to" %}</div>
<div class="oh-sticky-table__th">{% trans "Assigned to" %}</div>
<div class="oh-sticky-table__th">{% trans "Status" %}</div>
<div class="oh-sticky-table__th">{% trans "Priority" %}</div>
<div class="oh-sticky-table__th">{% trans "Tags" %}</div>
<div class="oh-sticky-table__th">{% trans "Actions" %}</div>
</div>
</div>
<div class="oh-sticky-table__tbody">
{% for ticket in my_tickets %}
<div class="oh-sticky-table__tr" >
<div class="oh-sticky-table__tr" onclick="window.location.href = `{% url 'ticket-detail' ticket.id %}`" >
<div class="oh-sticky-table__sd {% if ticket.status == 'new' %}row-status--blue
{% elif ticket.status == 'in_progress' %}row-status--orange
{% elif ticket.status == 'resolved' %}row-status--yellowgreen
{% elif ticket.status == 'on_hold' %}row-status--red
{% elif ticket.status == 'canceled' %}row-status--grey{% endif %}"
onclick="event.stopPropagation()"
>
<div class="centered-div">
<input
@@ -64,6 +66,22 @@
<div class="oh-sticky-table__td">{{ticket.get_raised_on}}</div>
<div class="oh-sticky-table__td">{{ticket.assigned_to.all|join:" , "}}</div>
<div class="oh-sticky-table__td">{{ticket.get_status_display}}</div>
<div class="oh-sticky-table__td">
{% if ticket.priority == 'high' %}
<img style="width:15%;" src="{% static 'images/ui/orange_star.png' %}"/>
<img style="width:15%;" src="{% static 'images/ui/orange_star.png' %}"/>
<img style="width:15%;" src="{% static 'images/ui/orange_star.png' %}"/>
{% elif ticket.priority == 'medium' %}
<img style="width:15%;" src="{% static 'images/ui/orange_star.png' %}"/>
<img style="width:15%;" src="{% static 'images/ui/orange_star.png' %}"/>
<img style="width:15%;" src="{% static 'images/ui/star.png' %}"/>
{% elif ticket.priority == 'low' %}
<img style="width:15%;" src="{% static 'images/ui/orange_star.png' %}"/>
<img style="width:15%;" src="{% static 'images/ui/star.png' %}"/>
<img style="width:15%;" src="{% static 'images/ui/star.png' %}"/>
{% endif %}
</div>
<div class="oh-sticky-table__td">{{ticket.tags.all|join:" , "}}</div>
<div class="oh-sticky-table__td" onclick="event.stopPropagation()">
<div class="oh-btn-group">
@@ -172,27 +190,10 @@
</div>
{% else %}
<!-- start of empty page-->
<div
style="
height: 70vh;
display: flex;
align-items: center;
justify-content: center;
"
class=""
>
<div style="" class="oh-404">
<img
style="display: block; width: 150px; height: 150px; margin: 10px auto top:70% !importent"
src="{% static 'images/ui/ticket.png' %}"
class="mb-4"
alt=""
/>
<h3 style="font-size: 20px" class="oh-404__subtitle">
{% trans "There are no tickets at the moment." %}
</h3>
</div>
</div>
<div style="display: flex; flex-direction: column; justify-content: center; align-items: center; height: 100%;">
<img style="display: block; width: 15%; margin: 20px auto; filter: opacity(0.5);" src="{% static 'images/ui/ticket.png' %}" class="" alt="Page not found. 404." />
<h5 class="oh-404__subtitle">{% trans "There are no tickets at the moment." %}</h5>
</div>
<!-- end of empty page-->
{% endif %}
</div>
@@ -215,9 +216,10 @@
<div class="oh-sticky-table__th">{% trans "Title" %}</div>
<div class="oh-sticky-table__th">{% trans "Owner" %}</div>
<div class="oh-sticky-table__th">{% trans "Type" %}</div>
<div class="oh-sticky-table__th">{% trans "Raised on" %}</div>
<div class="oh-sticky-table__th">{% trans "Forward to" %}</div>
<div class="oh-sticky-table__th">{% trans "Assigned to" %}</div>
<div class="oh-sticky-table__th">{% trans "Status" %}</div>
<div class="oh-sticky-table__th">{% trans "Priority" %}</div>
<div class="oh-sticky-table__th">{% trans "Tags" %}</div>
<div class="oh-sticky-table__th">{% trans "Actions" %}</div>
<div class="oh-sticky-table__th"></div>
@@ -225,12 +227,13 @@
</div>
<div class="oh-sticky-table__tbody">
{% for ticket in allocated_tickets %}
<div class="oh-sticky-table__tr" >
<div class="oh-sticky-table__tr" onclick="window.location.href = `{% url 'ticket-detail' ticket.id %}`" >
<div class="oh-sticky-table__sd {% if ticket.status == 'new' %}row-status--blue
{% elif ticket.status == 'in_progress' %}row-status--orange
{% elif ticket.status == 'resolved' %}row-status--yellowgreen
{% elif ticket.status == 'on_hold' %}row-status--red
{% elif ticket.status == 'canceled' %}row-status--grey{% endif %}"
onclick="event.stopPropagation()"
>
<div class="centered-div">
<input
@@ -260,6 +263,21 @@
<div class="oh-sticky-table__td">{{ticket.get_raised_on}}</div>
<div class="oh-sticky-table__td">{{ticket.assigned_to.all|join:" , "}}</div>
<div class="oh-sticky-table__td">{{ticket.get_status_display}}</div>
<div class="oh-sticky-table__td">
{% if ticket.priority == 'high' %}
<img style="width:15%;" src="{% static 'images/ui/orange_star.png' %}"/>
<img style="width:15%;" src="{% static 'images/ui/orange_star.png' %}"/>
<img style="width:15%;" src="{% static 'images/ui/orange_star.png' %}"/>
{% elif ticket.priority == 'medium' %}
<img style="width:15%;" src="{% static 'images/ui/orange_star.png' %}"/>
<img style="width:15%;" src="{% static 'images/ui/orange_star.png' %}"/>
<img style="width:15%;" src="{% static 'images/ui/star.png' %}"/>
{% elif ticket.priority == 'low' %}
<img style="width:15%;" src="{% static 'images/ui/orange_star.png' %}"/>
<img style="width:15%;" src="{% static 'images/ui/star.png' %}"/>
<img style="width:15%;" src="{% static 'images/ui/star.png' %}"/>
{% endif %}
</div>
<div class="oh-sticky-table__td">{{ticket.tags.all|join:" , "}}</div>
<div class="oh-sticky-table__td" onclick="event.stopPropagation()">
<div class="oh-btn-group" style="border:none">
@@ -390,27 +408,10 @@
</div>
{% else %}
<!-- start of empty page-->
<div
style="
height: 70vh;
display: flex;
align-items: center;
justify-content: center;
"
class=""
>
<div style="" class="oh-404">
<img
style="display: block; width: 150px; height: 150px; margin: 10px auto"
src="{% static 'images/ui/ticket.png' %}"
class="mb-4"
alt=""
/>
<h3 style="font-size: 20px" class="oh-404__subtitle">
{% trans "There are no tickets at the moment." %}
</h3>
</div>
</div>
<div style="display: flex; flex-direction: column; justify-content: center; align-items: center; height: 100%;">
<img style="display: block; width: 15%; margin: 20px auto; filter: opacity(0.5);" src="{% static 'images/ui/ticket.png' %}" class="" alt="Page not found. 404." />
<h5 class="oh-404__subtitle">{% trans "There are no tickets at the moment." %}</h5>
</div>
<!-- end of empty page-->
{% endif %}
</div>
@@ -433,21 +434,23 @@
<div class="oh-sticky-table__th">{% trans "Title" %}</div>
<div class="oh-sticky-table__th">{% trans "Owner" %}</div>
<div class="oh-sticky-table__th">{% trans "Type" %}</div>
<div class="oh-sticky-table__th">{% trans "Raised on" %}</div>
<div class="oh-sticky-table__th">{% trans "Forward to" %}</div>
<div class="oh-sticky-table__th">{% trans "Assigned to" %}</div>
<div class="oh-sticky-table__th">{% trans "Status" %}</div>
<div class="oh-sticky-table__th">{% trans "Priority" %}</div>
<div class="oh-sticky-table__th">{% trans "Tags" %}</div>
<div class="oh-sticky-table__th">{% trans "Actions" %}</div>
</div>
</div>
<div class="oh-sticky-table__tbody">
{% for ticket in all_tickets %}
<div class="oh-sticky-table__tr" >
<div class="oh-sticky-table__tr" onclick="window.location.href = `{% url 'ticket-detail' ticket.id %}`">
<div class="oh-sticky-table__sd {% if ticket.status == 'new' %}row-status--blue
{% elif ticket.status == 'in_progress' %}row-status--orange
{% elif ticket.status == 'resolved' %}row-status--yellowgreen
{% elif ticket.status == 'on_hold' %}row-status--red
{% elif ticket.status == 'canceled' %}row-status--grey{% endif %}"
onclick="event.stopPropagation()"
>
<div class="centered-div">
<input
@@ -477,6 +480,21 @@
<div class="oh-sticky-table__td">{{ticket.get_raised_on}}</div>
<div class="oh-sticky-table__td">{{ticket.assigned_to.all|join:" , "}}</div>
<div class="oh-sticky-table__td">{{ticket.get_status_display}}</div>
<div class="oh-sticky-table__td">
{% if ticket.priority == 'high' %}
<img style="width:15%;" src="{% static 'images/ui/orange_star.png' %}"/>
<img style="width:15%;" src="{% static 'images/ui/orange_star.png' %}"/>
<img style="width:15%;" src="{% static 'images/ui/orange_star.png' %}"/>
{% elif ticket.priority == 'medium' %}
<img style="width:15%;" src="{% static 'images/ui/orange_star.png' %}"/>
<img style="width:15%;" src="{% static 'images/ui/orange_star.png' %}"/>
<img style="width:15%;" src="{% static 'images/ui/star.png' %}"/>
{% elif ticket.priority == 'low' %}
<img style="width:15%;" src="{% static 'images/ui/orange_star.png' %}"/>
<img style="width:15%;" src="{% static 'images/ui/star.png' %}"/>
<img style="width:15%;" src="{% static 'images/ui/star.png' %}"/>
{% endif %}
</div>
<div class="oh-sticky-table__td">{{ticket.tags.all|join:" , "}}</div>
<div class="oh-sticky-table__td" onclick="event.stopPropagation()">
<div class="oh-btn-group">
@@ -584,27 +602,10 @@
</div>
{% else %}
<!-- start of empty page-->
<div
style="
height: 70vh;
display: flex;
align-items: center;
justify-content: center;
"
class=""
>
<div style="" class="oh-404">
<img
style="display: block; width: 150px; height: 150px; margin: 10px auto"
src="{% static 'images/ui/ticket.png' %}"
class="mb-4"
alt=""
/>
<h3 style="font-size: 20px" class="oh-404__subtitle">
{% trans "There are no tickets at the moment." %}
</h3>
</div>
</div>
<div style="display: flex; flex-direction: column; justify-content: center; align-items: center; height: 100%;">
<img style="display: block; width: 15%; margin: 20px auto; filter: opacity(0.5);" src="{% static 'images/ui/ticket.png' %}" class="" alt="Page not found. 404." />
<h5 class="oh-404__subtitle">{% trans "There are no tickets at the moment." %}</h5>
</div>
<!-- end of empty page-->
{% endif %}
</div>

View File

@@ -131,7 +131,7 @@
{% trans "My Tickets" %}
</li>
<li class="oh-tabs__tab" data-target="#tab_2">
{% trans "Allocated Tickets" %}
{% trans "Suggested Tickets" %}
</li>
{% if request.user|is_reportingmanager %}
<li class="oh-tabs__tab" data-target="#tab_3">
@@ -232,6 +232,57 @@
$(".ticket-view-type").attr("hx-vals", hxVals);
});
});
function saveTag(){
var title=$('#id_tag_title').val()
var color = $("#id_tag_color").val()
var is_active = $("#id_tag_is_active").val()
$.ajax({
type: "post",
url: `/helpdesk/ticket-create-tag`,
data: {
csrfmiddlewaretoken: getCookie("csrftoken"),
"title": title,
"color":color,
"is_active":is_active,
},
success: function (response) {
if (response.errors === "no_error") {
var newOption = $('<option selected></option>').val(response.tag_id).text(response.title)
$("#createTagModal").removeClass("oh-modal--show");
$("#id_tags option[value='create_new_tag']").before(newOption);
$("#id_tags option[value='create_new_tag']").prop('selected',false)
{% comment %} updateTag() {% endcomment %}
}
}
});
}
function saveTicketType(){
var title=$('#id_ticket_type_title').val()
var type = $("#id_type").val()
var prefix = $("#id_prefix").val()
var is_active = $("#id_ticket_type_is_active").val()
$.ajax({
type: "post",
url: "{% url 'ticket-type-create' %}?ajax=True",
data: {
csrfmiddlewaretoken: getCookie("csrftoken"),
"title": title,
"type":type,
'prefix':prefix,
"is_active":is_active,
},
success: function (response) {
if (response.errors === "no_error") {
var newOption = $('<option selected></option>').val(response.ticket_id).text(response.title)
$("#createTicketTypeModal").removeClass("oh-modal--show");
$("#id_ticket_type option[value='create_new_ticket_type']").before(newOption);
$("#id_ticket_type option[value='create_new_ticket_type']").prop('selected',false)
{% comment %} updateTag() {% endcomment %}
}
}
});
}
</script>
{% endblock %}

View File

@@ -9,7 +9,7 @@ from base.methods import filtersubordinates, get_key_instances, get_pagination
from base.models import Department, JobPosition, Tags
from employee.models import Employee
from helpdesk.filter import FAQCategoryFilter, FAQFilter,TicketFilter, TicketReGroup
from helpdesk.forms import AttachmentForm, CommentForm, DepartmentManagerCreateForm, FAQCategoryForm, FAQForm,TicketForm, TicketRaisedOnForm, TicketTagForm ,TicketAssigneesForm
from helpdesk.forms import AttachmentForm, CommentForm, DepartmentManagerCreateForm, FAQCategoryForm, FAQForm,TicketForm, TicketRaisedOnForm, TicketTagForm ,TicketAssigneesForm, TicketTypeForm
from django.utils.translation import gettext as _
from django.contrib import messages
from django.db.models import ProtectedError
@@ -402,9 +402,13 @@ def ticket_create(request):
status = request.GET.get('status')
form = TicketForm(initial={'status':status})
if request.method == "POST":
form = TicketForm(request.POST)
if form.is_valid():
form = TicketForm(request.POST,request.FILES)
if form.is_valid():
ticket = form.save()
attachments = form.files.getlist('attachment')
for attachment in attachments:
attachment_instance= Attachment(file=attachment,ticket=ticket)
attachment_instance.save()
mail_thread = TicketSendThread(request, ticket, type="create")
mail_thread.start()
messages.success(
@@ -431,6 +435,7 @@ def ticket_create(request):
return HttpResponse("<script>window.location.reload()</script>")
context = {
'form': form,
't_type_form':TicketTypeForm(),
}
return render(request, "helpdesk/ticket/ticket_form.html", context)
@@ -452,9 +457,13 @@ def ticket_update(request,ticket_id):
ticket = Ticket.objects.get(id=ticket_id)
form = TicketForm(instance=ticket)
if request.method == "POST":
form = TicketForm(request.POST,instance=ticket)
form = TicketForm(request.POST,request.FILES,instance=ticket)
if form.is_valid():
form.save()
ticket = form.save()
attachments = form.files.getlist('attachment')
for attachment in attachments:
attachment_instance= Attachment(file=attachment,ticket=ticket)
attachment_instance.save()
messages.success(
request, _('The Ticket updated successfully.')
)
@@ -729,8 +738,11 @@ def ticket_detail(request,ticket_id,**kwargs):
context=context
)
@login_required
@owner_can_enter("perms.helpdesk.helpdesk_changeticket", Ticket)
# @owner_can_enter("perms.helpdesk.helpdesk_changeticket", Ticket)
def ticket_update_tag(request):
"""
method to update the tags of ticket
"""
data = request.GET
ticket = Ticket.objects.get(id=data['ticketId'])
tagids = data.getlist('selectedValues[]')
@@ -807,6 +819,7 @@ def create_tag(request):
"""
This is an ajax method to return json response to create tag in the change tag form.
"""
if request.method == "POST":
form = TagsForm(request.POST)

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

BIN
static/images/ui/star.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB