Skip to content

Commit

Permalink
feat(ui): ticket: move status up (frappe#1547)
Browse files Browse the repository at this point in the history
  • Loading branch information
ssiyad authored Sep 4, 2023
1 parent b870908 commit b8f740d
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 17 deletions.
40 changes: 40 additions & 0 deletions desk/src/pages/ticket/TicketAgentActions.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,25 @@
/>
</template>
</Autocomplete>
<Dropdown
:options="
ticketStatusStore.options.map((o) => ({
label: o,
value: o,
onClick: () => setValue.submit({ field: 'status', value: o }),
}))
"
>
<Button
:label="ticket.data.status"
:theme="ticketStatusStore.colorMap[ticket.data.status]"
variant="subtle"
>
<template #suffix>
<Icon icon="lucide:chevron-down" />
</template>
</Button>
</Dropdown>
<Button
v-for="a in actions.data?.slice(0, 1)"
:key="a.name"
Expand Down Expand Up @@ -75,12 +94,14 @@ import { Icon } from "@iconify/vue";
import { emitter } from "@/emitter";
import { createToast } from "@/utils";
import { useAgentStore } from "@/stores/agent";
import { useTicketStatusStore } from "@/stores/ticketStatus";
import { useUserStore } from "@/stores/user";
import { useError } from "@/composables/error";
import { ITicket } from "./symbols";
const ticket = inject(ITicket);
const agentStore = useAgentStore();
const ticketStatusStore = useTicketStatusStore();
const userStore = useUserStore();
const data = computed(() => ticket.data);
const assignedTo = computed(() => {
Expand Down Expand Up @@ -139,6 +160,25 @@ const actions = createListResource({
},
});
const setValue = createResource({
url: "frappe.client.set_value",
auto: false,
makeParams: (params) => ({
doctype: "HD Ticket",
name: data.value.name,
fieldname: params.field,
value: params.value,
}),
onSuccess: () => {
emitter.emit("update:ticket");
createToast({
title: "Ticket updated",
icon: "check",
iconClasses: "text-green-600",
});
},
});
/**
* Wrapper function for eval. Can be used with `.call()`. Helps in
* forcing context
Expand Down
18 changes: 3 additions & 15 deletions desk/src/pages/ticket/TicketDetails.vue
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,11 @@ import { computed, inject } from "vue";
import { createResource, Autocomplete, Tooltip } from "frappe-ui";
import { dayjs } from "@/dayjs";
import { emitter } from "@/emitter";
import { createToast } from "@/utils";
import { useTeamStore } from "@/stores/team";
import { useTicketPriorityStore } from "@/stores/ticketPriority";
import { useTicketStatusStore } from "@/stores/ticketStatus";
import { useTicketTypeStore } from "@/stores/ticketType";
import { createToast } from "@/utils";
import { useError } from "@/composables/error";
import { StarRating, UniInput } from "@/components";
import TicketSidebarHeader from "./TicketSidebarHeader.vue";
import { ITicket } from "./symbols";
Expand All @@ -134,11 +134,6 @@ const options = computed(() => [
label: "Ticket type",
store: useTicketTypeStore(),
},
{
field: "status",
label: "Status",
store: useTicketStatusStore(),
},
{
field: "priority",
label: "Priority",
Expand Down Expand Up @@ -169,14 +164,7 @@ function update(fieldname: string, value: string) {
iconClasses: "text-green-600",
});
},
onError: (err) => {
createToast({
title: "Error updating ticket",
text: err.messages?.[0],
icon: "x",
iconClasses: "text-red-600",
});
},
onError: useError(),
});
}
</script>
Expand Down
4 changes: 2 additions & 2 deletions desk/src/stores/ticketStatus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ export const useTicketStatusStore = defineStore("ticketStatus", () => {
);
const colorMap = {
Open: "red",
Replied: "orange",
Replied: "blue",
Resolved: "green",
Closed: "blue",
Closed: "gray",
};
const stateActive = ["Open", "Replied"];
const stateInactive = ["Resolved", "Closed"];
Expand Down

0 comments on commit b8f740d

Please sign in to comment.