-
Notifications
You must be signed in to change notification settings - Fork 263
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: New Knowledge Base for Customer Portal
- Loading branch information
1 parent
3c5b83c
commit c847199
Showing
8 changed files
with
187 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
desk/src/components/knowledge-base-v2/KnowledgeBaseCategoryHandler.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<template> | ||
<div class="flex flex-col p-5 px-10"> | ||
<h3 class="text-xl font-semibold text-gray-800"> | ||
{{ categoryName }} | ||
</h3> | ||
</div> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { createListResource, createResource } from "frappe-ui"; | ||
import { ref } from "vue"; | ||
import { watch } from "vue"; | ||
const props = defineProps<{ | ||
categoryId: string; | ||
}>(); | ||
const categoryName = ref(""); | ||
const categoryResource = createResource({ | ||
url: "helpdesk.api.kbase.get_category", | ||
name: props.categoryId, | ||
cache: ["category", props.categoryId], | ||
params: { | ||
category: props.categoryId, | ||
}, | ||
onSuccess: (data) => { | ||
categoryName.value = data.category_name ?? data.name; | ||
}, | ||
auto: true, | ||
}); | ||
const subCategories = createListResource({ | ||
doctype: "HD Article Category", | ||
name: props.categoryId, | ||
cache: ["category", props.categoryId], | ||
fields: ["name", "category_name", "icon", "parent_category"], | ||
filters: { | ||
parent_category: props.categoryId, | ||
}, | ||
auto: true, | ||
}); | ||
watch( | ||
() => props.categoryId, | ||
() => { | ||
categoryResource.update({ | ||
params: { | ||
category: props.categoryId, | ||
}, | ||
}); | ||
subCategories.update({ | ||
params: { name: props.categoryId }, | ||
}); | ||
categoryResource.reload(); | ||
subCategories.reload(); | ||
} | ||
); | ||
</script> | ||
|
||
<style scoped></style> |
60 changes: 60 additions & 0 deletions
60
desk/src/components/knowledge-base-v2/KnowledgeBaseSidebar.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<template> | ||
<div | ||
class="h-full space-y-2 border-r px-3.5 py-2.5" | ||
:style="{ | ||
'min-width': '242px', | ||
'max-width': '242px', | ||
}" | ||
> | ||
<div class="flex flex-col gap-1"> | ||
<div class="text-sm font-medium text-gray-600">Categories</div> | ||
<div v-if="!categories.isLoading" class="flex flex-col gap-1"> | ||
<!-- all categories here --> | ||
<SidebarLink | ||
v-for="category in categories.data" | ||
:key="category.label" | ||
:icon="getIcon(category.icon, true)" | ||
:is-active="activeCategory === category.name" | ||
:is-expanded="true" | ||
:label="category.category_name" | ||
:bg-color="'bg-gray-100'" | ||
@click="handleClick(category.name)" | ||
/> | ||
</div> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { ref } from "vue"; | ||
import SidebarLink from "../SidebarLink.vue"; | ||
import { createListResource } from "frappe-ui"; | ||
import { getIcon } from "@/pages/knowledge-base/util"; | ||
const emit = defineEmits(["category-change"]); | ||
const activeCategory = defineModel(); | ||
const categories = createListResource({ | ||
doctype: "HD Article Category", | ||
auto: true, | ||
fields: ["name", "category_name", "icon", "parent_category"], | ||
filters: { | ||
parent_category: "", | ||
}, | ||
transform: (data) => { | ||
const firstCategory = { | ||
name: "Explore All Articles", | ||
category_name: "Explore All Articles", | ||
icon: "search", | ||
}; | ||
return [firstCategory, ...data]; | ||
}, | ||
}); | ||
function handleClick(name: string) { | ||
if (activeCategory.value === name) return; | ||
activeCategory.value = name; | ||
} | ||
</script> | ||
|
||
<style scoped></style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<template> | ||
<div class="flex flex-col"> | ||
<LayoutHeader> | ||
<template #left-header> | ||
<div class="text-lg font-medium text-gray-900">Knowledge base</div> | ||
</template> | ||
</LayoutHeader> | ||
<div class="flex grow"> | ||
<KnowledgeBaseSidebar v-model="currentCategory" /> | ||
<KnowledgeBaseCategoryHandler | ||
v-if="currentCategory !== 'Explore All Articles'" | ||
:category-id="currentCategory" | ||
/> | ||
<div v-else>All</div> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { ref } from "vue"; | ||
import { LayoutHeader } from "@/components"; | ||
import KnowledgeBaseSidebar from "@/components/knowledge-base-v2/KnowledgeBaseSidebar.vue"; | ||
import KnowledgeBaseCategoryHandler from "@/components/knowledge-base-v2/KnowledgeBaseCategoryHandler.vue"; | ||
const currentCategory = ref("Explore All Articles"); | ||
</script> | ||
|
||
<style scoped></style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import frappe | ||
|
||
|
||
@frappe.whitelist() | ||
def get_category(category): | ||
category_doc = frappe.get_doc("HD Article Category", category) | ||
return category_doc |