From b9340efa607074ed960b4d458103bff7c575d514 Mon Sep 17 00:00:00 2001 From: Sumit Bhanushali Date: Thu, 16 May 2024 01:59:21 +0530 Subject: [PATCH] fix(KB): form cleanup, removed dead code, idx counter back to working --- .../src/components/desk/kb/ArticleDetails.vue | 155 ------------ .../desk/kb/ArticleTitleAndContent.vue | 148 ------------ .../components/desk/kb/CategorySelector.vue | 198 ---------------- desk/src/pages/desk/kb/Articles.vue | 221 ------------------ desk/src/pages/desk/kb/KnowledgeBase.vue | 11 - .../knowledge-base/KnowledgeBaseArticle.vue | 2 - .../KnowledgeBaseArticleTopView.vue | 52 ----- .../KnowledgeBasePublicSearch.vue | 1 - .../KnowledgeBaseSubcategory.vue | 5 - .../helpdesk/doctype/hd_article/hd_article.js | 40 +--- .../doctype/hd_article/hd_article.json | 44 +--- .../helpdesk/doctype/hd_article/hd_article.py | 24 +- 12 files changed, 18 insertions(+), 883 deletions(-) delete mode 100644 desk/src/components/desk/kb/ArticleDetails.vue delete mode 100644 desk/src/components/desk/kb/ArticleTitleAndContent.vue delete mode 100644 desk/src/components/desk/kb/CategorySelector.vue delete mode 100644 desk/src/pages/desk/kb/Articles.vue delete mode 100644 desk/src/pages/desk/kb/KnowledgeBase.vue diff --git a/desk/src/components/desk/kb/ArticleDetails.vue b/desk/src/components/desk/kb/ArticleDetails.vue deleted file mode 100644 index cd5b8f05f..000000000 --- a/desk/src/components/desk/kb/ArticleDetails.vue +++ /dev/null @@ -1,155 +0,0 @@ - - - diff --git a/desk/src/components/desk/kb/ArticleTitleAndContent.vue b/desk/src/components/desk/kb/ArticleTitleAndContent.vue deleted file mode 100644 index 8ee982800..000000000 --- a/desk/src/components/desk/kb/ArticleTitleAndContent.vue +++ /dev/null @@ -1,148 +0,0 @@ - - - diff --git a/desk/src/components/desk/kb/CategorySelector.vue b/desk/src/components/desk/kb/CategorySelector.vue deleted file mode 100644 index 2b09280c2..000000000 --- a/desk/src/components/desk/kb/CategorySelector.vue +++ /dev/null @@ -1,198 +0,0 @@ - - - diff --git a/desk/src/pages/desk/kb/Articles.vue b/desk/src/pages/desk/kb/Articles.vue deleted file mode 100644 index 10abdbed7..000000000 --- a/desk/src/pages/desk/kb/Articles.vue +++ /dev/null @@ -1,221 +0,0 @@ - - - diff --git a/desk/src/pages/desk/kb/KnowledgeBase.vue b/desk/src/pages/desk/kb/KnowledgeBase.vue deleted file mode 100644 index c3df8a5e0..000000000 --- a/desk/src/pages/desk/kb/KnowledgeBase.vue +++ /dev/null @@ -1,11 +0,0 @@ - - - diff --git a/desk/src/pages/knowledge-base/KnowledgeBaseArticle.vue b/desk/src/pages/knowledge-base/KnowledgeBaseArticle.vue index e527a6e7b..18b19324d 100644 --- a/desk/src/pages/knowledge-base/KnowledgeBaseArticle.vue +++ b/desk/src/pages/knowledge-base/KnowledgeBaseArticle.vue @@ -182,8 +182,6 @@ const options__ = computed(() => ({ categoryName: article.data?.category.category_name || category?.doc?.category_name, creation: article.data?.creation, - dislikes: article.data?.not_helpful, - likes: article.data?.helpful, modified: article.data?.modified, status: article.data?.status, subCategoryId: subCategoryId.value, diff --git a/desk/src/pages/knowledge-base/KnowledgeBaseArticleTopView.vue b/desk/src/pages/knowledge-base/KnowledgeBaseArticleTopView.vue index 02c7b0f49..1bca1eae5 100644 --- a/desk/src/pages/knowledge-base/KnowledgeBaseArticleTopView.vue +++ b/desk/src/pages/knowledge-base/KnowledgeBaseArticleTopView.vue @@ -19,17 +19,6 @@ {{ status }} -
- -
- {{ likes }} -
-
|
- -
- {{ dislikes }} -
-
@@ -39,18 +28,9 @@ diff --git a/desk/src/pages/knowledge-base/KnowledgeBasePublicSearch.vue b/desk/src/pages/knowledge-base/KnowledgeBasePublicSearch.vue index dbedd9c63..8e56fcee9 100644 --- a/desk/src/pages/knowledge-base/KnowledgeBasePublicSearch.vue +++ b/desk/src/pages/knowledge-base/KnowledgeBasePublicSearch.vue @@ -87,7 +87,6 @@ const articles = createListResource({ filters: { status: "Published", }, - orderBy: "views desc", pageLength: 99999, debounce: 500, auto: false, diff --git a/desk/src/pages/knowledge-base/KnowledgeBaseSubcategory.vue b/desk/src/pages/knowledge-base/KnowledgeBaseSubcategory.vue index a4f1eed18..dce4cca52 100644 --- a/desk/src/pages/knowledge-base/KnowledgeBaseSubcategory.vue +++ b/desk/src/pages/knowledge-base/KnowledgeBaseSubcategory.vue @@ -155,11 +155,6 @@ const columns = [ key: "title", width: "w-96", }, - { - label: "Views", - key: "views", - width: "w-12", - }, { label: "Status", key: "status", diff --git a/helpdesk/helpdesk/doctype/hd_article/hd_article.js b/helpdesk/helpdesk/doctype/hd_article/hd_article.js index ee85744da..4af52d2b3 100644 --- a/helpdesk/helpdesk/doctype/hd_article/hd_article.js +++ b/helpdesk/helpdesk/doctype/hd_article/hd_article.js @@ -1,38 +1,8 @@ -// Copyright (c) 2021, Frappe Technologies and contributors +// Copyright (c) 2023, Frappe Technologies and contributors // For license information, please see license.txt -frappe.ui.form.on("HD Article", { - refresh: function (frm) { - show_content_wrt_type(frm) +// frappe.ui.form.on("HD Article", { +// refresh(frm) { - frm.dashboard.clear_headline() - frm.dashboard.set_headline_alert(` -
-
- - Views: ${frm.doc.views || 0} - -
-
- - Helpful: ${frm.doc.helpful || 0} - -
-
- - Not Helpful: ${frm.doc.not_helpful || 0} - -
-
- `) - }, - - content_type: function (frm) { - show_content_wrt_type(frm) - }, -}) - -function show_content_wrt_type(frm) { - frm.toggle_display("content_md", frm.doc.content_type === "Markdown") - frm.toggle_display("content", frm.doc.content_type === "Rich Text") -} +// }, +// }); diff --git a/helpdesk/helpdesk/doctype/hd_article/hd_article.json b/helpdesk/helpdesk/doctype/hd_article/hd_article.json index c2cf8ad13..d9b9907de 100644 --- a/helpdesk/helpdesk/doctype/hd_article/hd_article.json +++ b/helpdesk/helpdesk/doctype/hd_article/hd_article.json @@ -7,18 +7,15 @@ "engine": "InnoDB", "field_order": [ "title", - "title_slug", "category", - "idx", "status", - "column_break_7", "published_on", + "title_slug", + "column_break_7", "author", + "idx", "content_section", - "content", - "views", - "helpful", - "not_helpful" + "content" ], "fields": [ { @@ -39,27 +36,6 @@ "label": "Category", "options": "HD Article Category" }, - { - "default": "0", - "fieldname": "views", - "fieldtype": "Int", - "hidden": 1, - "label": "Views" - }, - { - "default": "0", - "fieldname": "helpful", - "fieldtype": "Int", - "hidden": 1, - "label": "Helpful" - }, - { - "default": "0", - "fieldname": "not_helpful", - "fieldtype": "Int", - "hidden": 1, - "label": "Not Helpful" - }, { "allow_in_quick_entry": 1, "fieldname": "content_section", @@ -69,7 +45,7 @@ { "allow_in_quick_entry": 1, "fieldname": "content", - "fieldtype": "Text", + "fieldtype": "Text Editor", "label": "Content" }, { @@ -81,10 +57,11 @@ "read_only": 1 }, { - "depends_on": "eval:doc.published", + "depends_on": "eval:doc.status === \"Published\"", "fieldname": "published_on", "fieldtype": "Datetime", - "label": "Published On" + "label": "Published On", + "read_only": 1 }, { "fieldname": "column_break_7", @@ -92,8 +69,9 @@ }, { "default": "-1", + "description": "Position of article in ascending order", "fieldname": "idx", - "fieldtype": "Data", + "fieldtype": "Int", "label": "Index" }, { @@ -111,7 +89,7 @@ } ], "links": [], - "modified": "2023-08-13 14:43:24.002737", + "modified": "2024-05-16 01:43:17.042347", "modified_by": "Administrator", "module": "Helpdesk", "name": "HD Article", diff --git a/helpdesk/helpdesk/doctype/hd_article/hd_article.py b/helpdesk/helpdesk/doctype/hd_article/hd_article.py index 6836077c2..94af66f7e 100644 --- a/helpdesk/helpdesk/doctype/hd_article/hd_article.py +++ b/helpdesk/helpdesk/doctype/hd_article/hd_article.py @@ -21,7 +21,6 @@ def get_list_filters(query): .select( QBArticle.title, QBArticle.status, - QBArticle.views, QBArticle.author, QBArticle.modified, ) @@ -48,7 +47,7 @@ def before_save(self): if self.status == "Published" and self.idx == -1: self.idx = cint( frappe.db.count( - "HD Article", {"category": self.category}, {"status": "Published"} + "HD Article", {"category": self.category, "status": "Published"}, ) ) @@ -75,23 +74,4 @@ def get_breadcrumbs(self): breadcrumbs.append( {"name": current_category.name, "label": current_category.category_name} ) - return breadcrumbs[::-1] - - -@frappe.whitelist(allow_guest=True) -def add_feedback(hd_article, helpful): - # TODO: use a base 5 or 10 rating system instead of a boolean - field = "helpful" if helpful else "not_helpful" - - value = cint(frappe.db.get_value("HD Article", hd_article, field)) - frappe.db.set_value( - "HD Article", hd_article, field, value + 1, update_modified=False - ) - - -@frappe.whitelist(allow_guest=True) -def increment_view(hd_article): - value = cint(frappe.db.get_value("HD Article", hd_article, "views")) - frappe.db.set_value( - "HD Article", hd_article, "views", value + 1, update_modified=False - ) + return breadcrumbs[::-1] \ No newline at end of file