diff --git a/desk/src/components/ListViewBuilder.vue b/desk/src/components/ListViewBuilder.vue index a08c9a581..9c291e3ce 100644 --- a/desk/src/components/ListViewBuilder.vue +++ b/desk/src/components/ListViewBuilder.vue @@ -29,7 +29,7 @@ :rows="rows" row-key="name" :options="{ - selectable: true, + selectable: props.options.selectable ?? true , showTooltip: true, resizeColumn: false, onRowClick: (row: Object) => emit('rowClick', row['name']), @@ -61,6 +61,9 @@
{{ dayjs.tz(item).fromNow() }}
+
+ +
{{ item }}
@@ -109,13 +112,16 @@ import { ListRow, ListHeader, ListHeaderItem, + Badge, } from "frappe-ui"; + import { Filter, SortBy, QuickFilters } from "@/components/view-controls"; import { dayjs } from "@/dayjs"; import FadedScrollableDiv from "./FadedScrollableDiv.vue"; import Reload from "./view-controls/Reload.vue"; import { useScreenSize } from "@/composables/screen"; import EmptyState from "./EmptyState.vue"; +import { BadgeStatus } from "@/types"; interface P { options: { @@ -126,6 +132,9 @@ interface P { icon?: HTMLElement | string; title: string; }; + hideViewControls?: boolean; + selectable?: boolean; + statusMap?: Record; }; } @@ -134,7 +143,15 @@ interface E { (event: "rowClick", row: any): void; } -const props = defineProps

(); +const props = withDefaults(defineProps

(), { + options: () => { + return { + doctype: "", + hideViewControls: false, + selectable: true, + }; + }, +}); const emit = defineEmits(); const { isMobileView } = useScreenSize(); @@ -190,10 +207,21 @@ function handleColumnConfig(column) { return column; } +const statusMap: Record = props.options + .statusMap as Record; +function handleStatusColor(status: "Published" | "Draft"): BadgeStatus { + if (!statusMap) + return { + label: status, + theme: "gray", + }; + return statusMap[status]; +} + const filterableFields = createResource({ url: "helpdesk.api.doc.get_filterable_fields", cache: ["DocField", props.options.doctype], - auto: true, + auto: !props.options.hideViewControls, params: { doctype: props.options.doctype, append_assign: true, @@ -212,7 +240,7 @@ const filterableFields = createResource({ const sortableFields = createResource({ url: "helpdesk.api.doc.sort_options", - auto: true, + auto: !props.options.hideViewControls, params: { doctype: props.options.doctype, }, @@ -220,7 +248,7 @@ const sortableFields = createResource({ const quickFilters = createResource({ url: "helpdesk.api.doc.get_quick_filters", - auto: true, + auto: !props.options.hideViewControls, params: { doctype: props.options.doctype, }, @@ -232,7 +260,12 @@ const quickFilters = createResource({ }); const showViewControls = computed(() => { - return filterableFields.data && sortableFields.data && quickFilters.data; + return ( + !props.options.hideViewControls && + filterableFields.data && + sortableFields.data && + quickFilters.data + ); }); const listViewData = reactive({ diff --git a/desk/src/components/desk/global/NewContactDialog.vue b/desk/src/components/desk/global/NewContactDialog.vue index cc6619524..5cdf1ffed 100644 --- a/desk/src/components/desk/global/NewContactDialog.vue +++ b/desk/src/components/desk/global/NewContactDialog.vue @@ -51,6 +51,7 @@ import { ErrorMessage, createResource, Autocomplete, + createListResource, } from "frappe-ui"; import zod from "zod"; @@ -141,20 +142,17 @@ const open = computed({ }, }); -const customerResource = createResource({ - url: "helpdesk.extends.client.get_list", - params: { - doctype: "HD Customer", - fields: ["name", "customer_name"], - }, +const customerResource = createListResource({ + doctype: "HD Customer", + fields: ["name"], + cache: "customers", transform: (data) => { - let allData = data.map((option) => { + return data.map((option) => { return { label: option.name, - value: option.customer_name, + value: option.name, }; }); - return allData; }, auto: true, }); diff --git a/desk/src/components/index.ts b/desk/src/components/index.ts index edc4b21a5..339ab9153 100644 --- a/desk/src/components/index.ts +++ b/desk/src/components/index.ts @@ -1,7 +1,6 @@ export { default as AttachmentItem } from "./AttachmentItem.vue"; export { default as CommandPalette } from "./command-palette/CP.vue"; export { default as HCard } from "./HCard.vue"; -export { default as ListView } from "./list-view/LV.vue"; export { default as NestedPopover } from "./NestedPopover.vue"; export { default as Notifications } from "./notifications/Notifications.vue"; export { default as PageTitle } from "./PageTitle.vue"; diff --git a/desk/src/components/list-view/LV.vue b/desk/src/components/list-view/LV.vue deleted file mode 100644 index fba5e59b2..000000000 --- a/desk/src/components/list-view/LV.vue +++ /dev/null @@ -1,108 +0,0 @@ - - - diff --git a/desk/src/components/list-view/LVEmpty.vue b/desk/src/components/list-view/LVEmpty.vue deleted file mode 100644 index 82ec350ed..000000000 --- a/desk/src/components/list-view/LVEmpty.vue +++ /dev/null @@ -1,17 +0,0 @@ - - - diff --git a/desk/src/components/list-view/LVHeader.vue b/desk/src/components/list-view/LVHeader.vue deleted file mode 100644 index 00ad57645..000000000 --- a/desk/src/components/list-view/LVHeader.vue +++ /dev/null @@ -1,40 +0,0 @@ - - - diff --git a/desk/src/components/list-view/LVLoading.vue b/desk/src/components/list-view/LVLoading.vue deleted file mode 100644 index eb8c23fea..000000000 --- a/desk/src/components/list-view/LVLoading.vue +++ /dev/null @@ -1,31 +0,0 @@ - - - diff --git a/desk/src/components/list-view/LVNavigation.vue b/desk/src/components/list-view/LVNavigation.vue deleted file mode 100644 index 9ef6ed398..000000000 --- a/desk/src/components/list-view/LVNavigation.vue +++ /dev/null @@ -1,36 +0,0 @@ - - - diff --git a/desk/src/components/list-view/LVRow.vue b/desk/src/components/list-view/LVRow.vue deleted file mode 100644 index d0217c44c..000000000 --- a/desk/src/components/list-view/LVRow.vue +++ /dev/null @@ -1,115 +0,0 @@ - - - diff --git a/desk/src/components/list-view/LVSelectionBar.vue b/desk/src/components/list-view/LVSelectionBar.vue deleted file mode 100644 index 6145c14c0..000000000 --- a/desk/src/components/list-view/LVSelectionBar.vue +++ /dev/null @@ -1,48 +0,0 @@ - - - diff --git a/desk/src/components/list-view/selection.ts b/desk/src/components/list-view/selection.ts deleted file mode 100644 index fc77c7e5c..000000000 --- a/desk/src/components/list-view/selection.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { reactive } from "vue"; -import { Action, Key } from "./types"; - -export const selection = reactive({ - storage: new Set(), - actions: new Set(), - toggle: (key: Key) => { - if (!selection.storage.delete(key)) { - selection.storage.add(key); - } - }, - reset: () => { - selection.storage.clear(); - selection.actions.clear(); - }, -}); diff --git a/desk/src/components/list-view/symbols.ts b/desk/src/components/list-view/symbols.ts deleted file mode 100644 index b3f6d269e..000000000 --- a/desk/src/components/list-view/symbols.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { InjectionKey, Ref } from "vue"; -import { Resource, Column } from "@/types"; - -type I = { - name: string; - [key: string]: unknown; -}; -type R = Resource>; -export const CheckboxKey: InjectionKey = Symbol("Checkbox"); -export const ColumnsKey: InjectionKey> = Symbol("Columns"); -export const DocTypeKey: InjectionKey = Symbol("DocType"); -export const FilterKey: InjectionKey = Symbol("Filter"); -export const IdKey: InjectionKey = Symbol("Id"); -export const PluralKey: InjectionKey> = Symbol("Plural"); -export const ResourceKey: InjectionKey = Symbol("Resource"); -export const SingluarKey: InjectionKey> = Symbol("Singular"); diff --git a/desk/src/components/list-view/types.ts b/desk/src/components/list-view/types.ts deleted file mode 100644 index 4f67ee37f..000000000 --- a/desk/src/components/list-view/types.ts +++ /dev/null @@ -1,6 +0,0 @@ -export type Selection = Set; -export type Key = string; -export type Action = { - label: string; - onClick: (key: Key[]) => void; -}; diff --git a/desk/src/components/notifications/Notifications.vue b/desk/src/components/notifications/Notifications.vue index 1b8fcf3b4..4356fdb33 100644 --- a/desk/src/components/notifications/Notifications.vue +++ b/desk/src/components/notifications/Notifications.vue @@ -48,13 +48,11 @@ } " > - +

- {{ - n.user_from.name - }} + {{ n.user_from }} mentioned you in ticket diff --git a/desk/src/composables/listManager.ts b/desk/src/composables/listManager.ts deleted file mode 100644 index c40ce2f1c..000000000 --- a/desk/src/composables/listManager.ts +++ /dev/null @@ -1,96 +0,0 @@ -import { ref, watch } from "vue"; -import { createListResource, createResource } from "frappe-ui"; - -const GET_LIST_METHOD = "helpdesk.extends.client.get_list"; -const GET_LIST_META_METHOD = "helpdesk.extends.client.get_list_meta"; - -type ListOptions = { - doctype: string; - fields?: Array; - filters?: object; - orderBy?: string; - pageLength?: number; - start?: number; - cache?: boolean | string | Array; - auto?: boolean; - transform?: any; -}; - -type MetaData = { - total_count: number; - total_pages: number; - current_page: number; - start_from: number; - end_at: number; - has_next_page: boolean; - has_previous_page: boolean; -}; - -export function createListManager(options: ListOptions) { - const doctype = options.doctype; - const fields = options.fields; - const filters = options.filters; - const orderBy = options.orderBy; - const pageLength = options.pageLength; - const start = options.start; - const cache = options.cache; - const auto = options.auto; - const transform = options.transform; - - const list = createListResource({ - type: "list", - url: GET_LIST_METHOD, - realtime: true, - doctype, - fields, - orderBy, - filters, - pageLength, - start, - cache, - auto, - transform, - onSuccess() { - meta.submit({ - doctype, - filters: list.filters, - limit: list.pageLength, - order_by: list.orderBy, - start: list.start, - }); - }, - }); - - Object.assign(list, { - totalCount: ref(0), - totalPages: ref(0), - currentPage: ref(0), - hasNextPage: ref(false), - hasPreviousPage: ref(false), - startFrom: ref(0), - endAt: ref(0), - }); - - const meta = createResource({ - url: GET_LIST_META_METHOD, - onSuccess: (data: MetaData) => { - list.totalCount = data.total_count; - list.totalPages = data.total_pages; - list.currentPage = data.current_page; - list.hasNextPage = data.has_next_page; - list.hasPreviousPage = data.has_previous_page; - list.startFrom = data.start_from; - list.endAt = data.end_at; - }, - }); - - watch( - () => list.list.loading, - () => { - list.hasPreviousPage = false; - list.hasNextPage = false; - } - ); - - return list; -} diff --git a/desk/src/pages/CLayout.vue b/desk/src/pages/CLayout.vue deleted file mode 100644 index 986e94309..000000000 --- a/desk/src/pages/CLayout.vue +++ /dev/null @@ -1,12 +0,0 @@ - - - diff --git a/desk/src/pages/KnowledgeBasePublic.vue b/desk/src/pages/KnowledgeBasePublic.vue deleted file mode 100644 index 01882415c..000000000 --- a/desk/src/pages/KnowledgeBasePublic.vue +++ /dev/null @@ -1,53 +0,0 @@ - - - diff --git a/desk/src/pages/KnowledgeBasePublicCategory.vue b/desk/src/pages/KnowledgeBasePublicCategory.vue deleted file mode 100644 index ea3cccb7c..000000000 --- a/desk/src/pages/KnowledgeBasePublicCategory.vue +++ /dev/null @@ -1,62 +0,0 @@ - - - diff --git a/desk/src/pages/KnowledgeBasePublicHome.vue b/desk/src/pages/KnowledgeBasePublicHome.vue deleted file mode 100644 index 30ca9958f..000000000 --- a/desk/src/pages/KnowledgeBasePublicHome.vue +++ /dev/null @@ -1,44 +0,0 @@ - - - diff --git a/desk/src/pages/MobileNotifications.vue b/desk/src/pages/MobileNotifications.vue index bc6d78b8c..e3680d6b8 100644 --- a/desk/src/pages/MobileNotifications.vue +++ b/desk/src/pages/MobileNotifications.vue @@ -32,13 +32,11 @@ } " > - +
- {{ - n.user_from.name - }} + {{ n.user_from }} mentioned you in ticket diff --git a/desk/src/pages/TicketsCustomer.vue b/desk/src/pages/TicketsCustomer.vue deleted file mode 100644 index c3c9b127d..000000000 --- a/desk/src/pages/TicketsCustomer.vue +++ /dev/null @@ -1,204 +0,0 @@ - - - diff --git a/desk/src/pages/c-layout/CLayoutNav.vue b/desk/src/pages/c-layout/CLayoutNav.vue deleted file mode 100644 index 68f5145f6..000000000 --- a/desk/src/pages/c-layout/CLayoutNav.vue +++ /dev/null @@ -1,60 +0,0 @@ - - - diff --git a/desk/src/pages/desk/escalation/EscalationRuleList.vue b/desk/src/pages/desk/escalation/EscalationRuleList.vue deleted file mode 100644 index f696339d3..000000000 --- a/desk/src/pages/desk/escalation/EscalationRuleList.vue +++ /dev/null @@ -1,96 +0,0 @@ - - diff --git a/desk/src/pages/desk/escalation/EscalationRules.vue b/desk/src/pages/desk/escalation/EscalationRules.vue new file mode 100644 index 000000000..bc4622975 --- /dev/null +++ b/desk/src/pages/desk/escalation/EscalationRules.vue @@ -0,0 +1,53 @@ + + diff --git a/desk/src/pages/knowledge-base/KnowledgeBaseCategory.vue b/desk/src/pages/knowledge-base/KnowledgeBaseCategory.vue index ae6401ccc..025a2140c 100644 --- a/desk/src/pages/knowledge-base/KnowledgeBaseCategory.vue +++ b/desk/src/pages/knowledge-base/KnowledgeBaseCategory.vue @@ -44,8 +44,7 @@ > @@ -131,7 +130,6 @@ import { import { isEmpty } from "lodash"; import { AGENT_PORTAL_KNOWLEDGE_BASE_SUB_CATEGORY } from "@/router"; import { createToast } from "@/utils"; -import { createListManager } from "@/composables/listManager"; import { useError } from "@/composables/error"; import { HCard } from "@/components"; import KnowledgeBaseCategoryHeader from "./KnowledgeBaseCategoryHeader.vue"; @@ -208,9 +206,9 @@ const newSubCategory = createResource({ onError: useError({ title: "Error creating sub category" }), }); -const subCategories = createListManager({ - doctype: "HD Article Category", - filters: { +const subCategories = createResource({ + url: "helpdesk.helpdesk.doctype.hd_article_category.api.get_subcategories", + params: { parent_category: categoryId.value, }, auto: true, diff --git a/desk/src/pages/knowledge-base/KnowledgeBasePublicSearch.vue b/desk/src/pages/knowledge-base/KnowledgeBasePublicSearch.vue deleted file mode 100644 index 8e56fcee9..000000000 --- a/desk/src/pages/knowledge-base/KnowledgeBasePublicSearch.vue +++ /dev/null @@ -1,121 +0,0 @@ - - - diff --git a/desk/src/pages/knowledge-base/KnowledgeBaseSubcategory.vue b/desk/src/pages/knowledge-base/KnowledgeBaseSubcategory.vue index 706403726..34f900972 100644 --- a/desk/src/pages/knowledge-base/KnowledgeBaseSubcategory.vue +++ b/desk/src/pages/knowledge-base/KnowledgeBaseSubcategory.vue @@ -29,27 +29,11 @@
- - - - - +