Skip to content

Commit

Permalink
fix(ux): allow empty sla
Browse files Browse the repository at this point in the history
  • Loading branch information
ssiyad committed Oct 17, 2023
1 parent c6a2f4f commit 273c98a
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 22 deletions.
43 changes: 25 additions & 18 deletions desk/src/pages/ticket/TicketDetails.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,33 @@
{{ data.customer }}
</span>
</div>
<div class="space-y-1.5">
<span class="block text-sm text-gray-700">First response</span>
<span class="mr-2 font-medium text-gray-900">
<div
v-if="data.first_responded_on || data.response_by"
class="space-y-1.5"
>
<div class="text-sm text-gray-700">First response</div>
<div class="mr-2 inline-block font-medium text-gray-900">
{{ dayjs(data.first_responded_on || data.response_by).short() }}
</div>
<span v-if="data.response_by">
<Badge
v-if="!data.first_responded_on"
label="Due"
theme="orange"
variant="outline"
/>
<Badge
v-else-if="
dayjs(data.first_responded_on).isBefore(
dayjs(data.response_by)
)
"
label="Fulfilled"
theme="green"
variant="outline"
/>
<Badge v-else label="Failed" theme="red" variant="outline" />
</span>
<Badge
v-if="!data.first_responded_on"
label="Due"
theme="orange"
variant="outline"
/>
<Badge
v-else-if="
dayjs(data.first_responded_on).isBefore(dayjs(data.response_by))
"
label="Fulfilled"
theme="green"
variant="outline"
/>
<Badge v-else label="Failed" theme="red" variant="outline" />
</div>
<div
v-if="data.resolution_date || data.resolution_by"
Expand Down
3 changes: 1 addition & 2 deletions helpdesk/helpdesk/doctype/hd_ticket/hd_ticket.json
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,6 @@
"read_only": 1
},
{
"default": "First Response Due",
"depends_on": "eval: doc.sla",
"fieldname": "agreement_status",
"fieldtype": "Select",
Expand Down Expand Up @@ -380,7 +379,7 @@
"icon": "fa fa-issue",
"idx": 61,
"links": [],
"modified": "2023-10-08 23:24:56.917977",
"modified": "2023-10-17 13:34:03.649901",
"modified_by": "Administrator",
"module": "Helpdesk",
"name": "HD Ticket",
Expand Down
12 changes: 10 additions & 2 deletions helpdesk/helpdesk/doctype/hd_ticket/hd_ticket.py
Original file line number Diff line number Diff line change
Expand Up @@ -713,12 +713,20 @@ def apply_escalation_rule(self):
self.assign_agent(escalation_rule.to_agent)

def set_sla(self):
"""
Find an SLA to apply to this ticket.
"""
if sla := get_sla(self):
self.sla = sla.name
self.sla = None

def apply_sla(self):
sla = frappe.get_doc("HD Service Level Agreement", self.sla)
sla.apply(self)
"""
Apply SLA if set. This won't check whether the SLA exists. Hence, will
fail/error if the SLA is deleted.
"""
if self.sla:
frappe.get_doc("HD Service Level Agreement", self.sla).apply(self)

# `on_communication_update` is a special method exposed from `Communication` doctype.
# It is called when a communication is updated. Beware of changes as this effectively
Expand Down

0 comments on commit 273c98a

Please sign in to comment.