From 52ac8db808b7cf6db9e03b5a0abd887483a26e11 Mon Sep 17 00:00:00 2001 From: RitvikSardana Date: Mon, 23 Dec 2024 13:19:06 +0530 Subject: [PATCH] refactor: remove custom list view from knowledge base --- desk/src/components/ListViewBuilder.vue | 29 ++++- .../KnowledgeBaseSubcategory.vue | 110 +++++++++--------- desk/src/types.ts | 6 + desk/tsconfig.json | 2 +- .../helpdesk/doctype/hd_article/hd_article.py | 39 +++++++ 5 files changed, 125 insertions(+), 61 deletions(-) diff --git a/desk/src/components/ListViewBuilder.vue b/desk/src/components/ListViewBuilder.vue index a08c9a581..83582e412 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.listViewSelection ?? 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; + listViewSelection?: boolean; + statusMap?: Record; }; } @@ -190,6 +199,17 @@ 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], @@ -232,7 +252,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/pages/knowledge-base/KnowledgeBaseSubcategory.vue b/desk/src/pages/knowledge-base/KnowledgeBaseSubcategory.vue index 706403726..723c68850 100644 --- a/desk/src/pages/knowledge-base/KnowledgeBaseSubcategory.vue +++ b/desk/src/pages/knowledge-base/KnowledgeBaseSubcategory.vue @@ -29,27 +29,11 @@ - - - - - +