Skip to content

Commit

Permalink
feat: ticket tags
Browse files Browse the repository at this point in the history
  • Loading branch information
ssiyad committed Oct 19, 2023
1 parent d1bcc1c commit b5df665
Show file tree
Hide file tree
Showing 4 changed files with 137 additions and 14 deletions.
11 changes: 9 additions & 2 deletions desk/src/pages/ticket/TicketAgentSidebar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,14 @@ import TicketActions from "./TicketActions.vue";
import TicketContact from "./TicketContact.vue";
import TicketDetails from "./TicketDetails.vue";
import TicketHistory from "./TicketHistory.vue";
import TicketTags from "./TicketTags.vue";
import TicketViews from "./TicketViews.vue";
import LucideInfo from "~icons/lucide/info";
import LucideContact2 from "~icons/lucide/contact-2";
import LucideHistory from "~icons/lucide/history";
import LucideView from "~icons/lucide/view";
import LucideInfo from "~icons/lucide/info";
import LucidePointer from "~icons/lucide/pointer";
import LucideTags from "~icons/lucide/tags";
import LucideView from "~icons/lucide/view";
const isExpanded = ref(true);
const items = [
Expand All @@ -64,6 +66,11 @@ const items = [
component: TicketDetails,
icon: LucideInfo,
},
{
name: "Tags",
component: TicketTags,
icon: LucideTags,
},
{
name: "Actions",
component: TicketActions,
Expand Down
68 changes: 68 additions & 0 deletions desk/src/pages/ticket/TicketTags.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<template>
<div class="flex flex-col border-l">
<TicketSidebarHeader title="Tags" />
<div class="flex flex-wrap gap-2 overflow-auto p-5">
<Button
v-for="tag in ticket.data.tags"
:key="tag.name"
:label="tag"
theme="gray"
variant="outline"
>
<template #suffix>
<LucideX class="h-4 w-4" @click="rmTag.submit({ tag })" />
</template>
</Button>
<FormControl
v-if="showInput"
type="text"
placeholder="Tag"
@keydown.enter="addTag.submit({ tag: $event.target.value })"
/>
<Button
v-else
theme="gray"
variant="outline"
@click="() => (showInput = !showInput)"
>
<template #icon>
<LucidePlus class="h-4 w-4" />
</template>
</Button>
</div>
</div>
</template>

<script setup lang="ts">
import { inject, ref } from "vue";
import { FormControl, createResource } from "frappe-ui";
import TicketSidebarHeader from "./TicketSidebarHeader.vue";
import { ITicket } from "./symbols";
import LucidePlus from "~icons/lucide/plus";
import LucideX from "~icons/lucide/x";
const showInput = ref(false);
const ticket = inject(ITicket);
const addTag = createResource({
url: "frappe.desk.doctype.tag.tag.add_tag",
debounce: 300,
makeParams: (params) => ({
tag: params.tag,
dt: "HD Ticket",
dn: ticket.data.name,
}),
onSuccess: () => {
ticket.reload().then(() => (showInput.value = false));
},
});
const rmTag = createResource({
url: "frappe.desk.doctype.tag.tag.remove_tag",
debounce: 300,
makeParams: (params) => ({
tag: params.tag,
dt: "HD Ticket",
dn: ticket.data.name,
}),
onSuccess: () => ticket.reload(),
});
</script>
19 changes: 18 additions & 1 deletion helpdesk/helpdesk/doctype/hd_ticket/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,11 @@ def get_one(name):
return {
**ticket,
"assignee": get_assignee(ticket._assign),
"communications": get_communications(name),
"comments": get_comments(name),
"communications": get_communications(name),
"contact": contact,
"history": get_history(name),
"tags": get_tags(name),
"template": get_template(ticket.template or DEFAULT_TICKET_TEMPLATE),
"views": get_views(name),
}
Expand Down Expand Up @@ -171,6 +172,22 @@ def get_views(ticket: str):
return views


def get_tags(ticket: str):
QBTag = frappe.qb.DocType("Tag Link")
rows = (
frappe.qb.from_(QBTag)
.select(QBTag.tag)
.where(QBTag.document_type == "HD Ticket")
.where(QBTag.document_name == ticket)
.orderby(QBTag.creation, order=Order.asc)
.run(as_dict=True)
)
res = []
for tag in rows:
res.append(tag.tag)
return res


@redis_cache()
def get_attachments(doctype, name):
QBFile = frappe.qb.DocType("File")
Expand Down
53 changes: 42 additions & 11 deletions helpdesk/helpdesk/doctype/hd_ticket/hd_ticket.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"sb_details",
"description",
"template",
"sla_tab",
"service_level_section",
"sla",
"response_by",
Expand All @@ -29,11 +30,13 @@
"service_level_agreement_creation",
"on_hold_since",
"total_hold_time",
"response_tab",
"response",
"first_response_time",
"first_responded_on",
"column_break_26",
"avg_response_time",
"resolution_tab",
"section_break_19",
"resolution_details",
"column_break1",
Expand All @@ -42,6 +45,7 @@
"resolution_date",
"resolution_time",
"user_resolution_time",
"reference_tab",
"additional_info",
"contact",
"customer",
Expand All @@ -50,11 +54,13 @@
"via_customer_portal",
"attachment",
"content_type",
"feedback_tab",
"customer_feedback_section",
"feedback_rating",
"feedback_text",
"feedback",
"feedback_extra"
"feedback_extra",
"meta_tab"
],
"fields": [
{
Expand Down Expand Up @@ -152,8 +158,7 @@
{
"collapsible": 1,
"fieldname": "service_level_section",
"fieldtype": "Section Break",
"label": "SLA Details"
"fieldtype": "Section Break"
},
{
"fieldname": "sla",
Expand Down Expand Up @@ -212,8 +217,7 @@
{
"collapsible": 1,
"fieldname": "response",
"fieldtype": "Section Break",
"label": "Response Details"
"fieldtype": "Section Break"
},
{
"bold": 1,
Expand Down Expand Up @@ -241,8 +245,7 @@
{
"collapsible": 1,
"fieldname": "section_break_19",
"fieldtype": "Section Break",
"label": "Resolution Details"
"fieldtype": "Section Break"
},
{
"depends_on": "eval:!doc.__islocal",
Expand Down Expand Up @@ -305,7 +308,6 @@
"collapsible": 1,
"fieldname": "additional_info",
"fieldtype": "Section Break",
"label": "Reference",
"options": "fa fa-pushpin",
"read_only": 1
},
Expand Down Expand Up @@ -351,8 +353,7 @@
},
{
"fieldname": "customer_feedback_section",
"fieldtype": "Section Break",
"label": "Customer Feedback"
"fieldtype": "Section Break"
},
{
"fieldname": "feedback_extra",
Expand All @@ -374,12 +375,42 @@
"fieldname": "feedback_text",
"fieldtype": "Data",
"label": "Feedback (Text)"
},
{
"fieldname": "sla_tab",
"fieldtype": "Tab Break",
"label": "SLA"
},
{
"fieldname": "response_tab",
"fieldtype": "Tab Break",
"label": "Response"
},
{
"fieldname": "resolution_tab",
"fieldtype": "Tab Break",
"label": "Resolution"
},
{
"fieldname": "reference_tab",
"fieldtype": "Tab Break",
"label": "Reference"
},
{
"fieldname": "feedback_tab",
"fieldtype": "Tab Break",
"label": "Feedback"
},
{
"fieldname": "meta_tab",
"fieldtype": "Tab Break",
"label": "Meta"
}
],
"icon": "fa fa-issue",
"idx": 61,
"links": [],
"modified": "2023-10-17 16:20:41.301974",
"modified": "2023-10-19 19:23:07.571029",
"modified_by": "Administrator",
"module": "Helpdesk",
"name": "HD Ticket",
Expand Down

0 comments on commit b5df665

Please sign in to comment.