Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: setting to make feedback mandatory #2058

Merged
merged 2 commits into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions desk/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@
<RouterView class="antialiased" />
<Toasts />
<KeymapDialog />
<Dialogs />
</template>

<script setup lang="ts">
import { provide, ref, onMounted, onUnmounted } from "vue";
import { onMounted, onUnmounted } from "vue";
import { Toasts } from "frappe-ui";
import { createToast } from "@/utils";
import { useConfigStore } from "@/stores/config";
import KeymapDialog from "@/pages/KeymapDialog.vue";
import { stopSession } from "@/telemetry";
import { init as initTelemetry } from "@/telemetry";
import { init as initTelemetry, stopSession } from "@/telemetry";
import { Dialogs } from "frappe-ui";
useConfigStore();

onMounted(async () => {
Expand Down
35 changes: 21 additions & 14 deletions desk/src/pages/TicketCustomer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</template>
<template #right-header>
<Button
v-if="showResolveButton"
v-if="ticket.data.status !== 'Closed'"
label="Close"
theme="gray"
variant="solid"
Expand Down Expand Up @@ -70,6 +70,8 @@ import { createToast } from "@/utils";
import { LayoutHeader } from "@/components";
import TicketCustomerSidebar from "@/components/ticket/TicketCustomerSidebar.vue";
import { useScreenSize } from "@/composables/screen";
import { useConfigStore } from "@/stores/config";
import { confirmDialog } from "frappe-ui";
interface P {
ticketId: string;
}
Expand Down Expand Up @@ -126,10 +128,22 @@ function handleClose() {
if (showFeedback.value) {
showFeedbackDialog.value = true;
} else {
setValue.submit({ fieldname: "status", value: "Closed" });
showConfirmationDialog();
}
}

function showConfirmationDialog() {
confirmDialog({
title: "Close Ticket",
message: "Are you sure you want to close this ticket?",
onConfirm: ({ hideDialog }: { hideDialog: Function }) => {
ticket.data.status = "Closed";
setValue.submit({ fieldname: "status", value: "Closed" });
hideDialog();
},
});
}

const setValue = createResource({
url: "frappe.client.set_value",
debounce: 300,
Expand Down Expand Up @@ -157,21 +171,14 @@ const breadcrumbs = computed(() => {
return items;
});

const showReopenButton = computed(
() => ticket.data.status === "Resolved" && !ticket.data.feedback
);
const showResolveButton = computed(() =>
["Open", "Replied"].includes(ticket.data.status)
);

const showEditor = computed(() => ticket.data.status !== "Closed");

// this handles whether the ticket was raised and then was closed without any reply from the agent.
const { isFeedbackMandatory } = useConfigStore();
const showFeedback = computed(() => {
return ticket.data?.communications?.some((c) => {
if (c.sender !== ticket.data.raised_by) {
return true;
}
});
const hasAgentCommunication = ticket.data?.communications?.some(
(c) => c.sender !== ticket.data.raised_by
);
return hasAgentCommunication && isFeedbackMandatory;
});
</script>
4 changes: 4 additions & 0 deletions desk/src/stores/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ export const useConfigStore = defineStore("config", () => {
const preferKnowledgeBase = computed(
() => !!parseInt(config.value.prefer_knowledge_base)
);
const isFeedbackMandatory = computed(
() => !!parseInt(config.value.is_feedback_mandatory)
);

socket.on("helpdesk:settings-updated", () => configRes.reload());

Expand All @@ -29,5 +32,6 @@ export const useConfigStore = defineStore("config", () => {
preferKnowledgeBase,
isSetupComplete,
skipEmailWorkflow,
isFeedbackMandatory,
};
});
1 change: 1 addition & 0 deletions helpdesk/api/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ def get_config():
"prefer_knowledge_base",
"setup_complete",
"skip_email_workflow",
"is_feedback_mandatory",
]
res = frappe.get_value(doctype="HD Settings", fieldname=fields, as_dict=True)
return res
16 changes: 15 additions & 1 deletion helpdesk/helpdesk/doctype/hd_settings/hd_settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
"column_break_zxek",
"ticket_restrictions_section",
"allow_anyone_to_create_tickets",
"feedback_section",
"is_feedback_mandatory",
"section_break_duow",
"auto_update_status",
"workflow_tab",
Expand Down Expand Up @@ -307,11 +309,23 @@
"fieldname": "auto_update_status",
"fieldtype": "Check",
"label": "Auto Update Status"
},
{
"fieldname": "feedback_section",
"fieldtype": "Section Break",
"label": "Feedback"
},
{
"default": "0",
"description": "If enabled, the feedback dialog will be shown, when a user tries to close a ticket. \nNote: User can't close a ticket without giving a feedback.",
"fieldname": "is_feedback_mandatory",
"fieldtype": "Check",
"label": "Make Feedback Mandatory"
}
],
"issingle": 1,
"links": [],
"modified": "2024-11-22 16:50:02.831137",
"modified": "2024-11-22 17:25:40.112881",
"modified_by": "Administrator",
"module": "Helpdesk",
"name": "HD Settings",
Expand Down
Loading