From ba0fc3552d093a9e9e71728c9bbb1271b80e13ee Mon Sep 17 00:00:00 2001 From: iamsivin Date: Fri, 2 Sep 2022 17:43:57 +0530 Subject: [PATCH] feat: Adds the ability to edit/delete category --- .../dashboard/api/helpCenter/categories.js | 7 +- .../dashboard/i18n/locale/en/helpCenter.json | 51 +++++ .../components/HelpCenterLayout.vue | 17 +- .../dashboard/helpcenter/helpcenter.routes.js | 8 +- .../categories}/AddCategory.vue | 0 .../pages/categories/CategoryListItem.vue | 108 ++++++++++ .../pages/categories/EditCategory.vue | 197 ++++++++++++++++- .../pages/categories/ListAllCategories.vue | 200 +++++++++++++++++- .../helpcenter/pages/portals/EditPortal.vue | 21 +- .../modules/helpCenterCategories/actions.js | 15 +- .../modules/helpCenterCategories/getters.js | 7 + .../specs/actions.spec.js | 48 +++-- .../specs/getters.spec.js | 4 + 13 files changed, 646 insertions(+), 37 deletions(-) rename app/javascript/dashboard/routes/dashboard/helpcenter/{components => pages/categories}/AddCategory.vue (100%) create mode 100644 app/javascript/dashboard/routes/dashboard/helpcenter/pages/categories/CategoryListItem.vue diff --git a/app/javascript/dashboard/api/helpCenter/categories.js b/app/javascript/dashboard/api/helpCenter/categories.js index c5cb40cd4..b6eae3f32 100644 --- a/app/javascript/dashboard/api/helpCenter/categories.js +++ b/app/javascript/dashboard/api/helpCenter/categories.js @@ -15,8 +15,11 @@ class CategoriesAPI extends PortalsAPI { return axios.post(`${this.url}/${portalSlug}/categories`, categoryObj); } - update({ portalSlug, categoryObj }) { - return axios.patch(`${this.url}/${portalSlug}/categories`, categoryObj); + update({ portalSlug, categoryId, categoryObj }) { + return axios.patch( + `${this.url}/${portalSlug}/categories/${categoryId}`, + categoryObj + ); } delete({ portalSlug, categoryId }) { diff --git a/app/javascript/dashboard/i18n/locale/en/helpCenter.json b/app/javascript/dashboard/i18n/locale/en/helpCenter.json index d5ab8c8eb..cdee6bbe2 100644 --- a/app/javascript/dashboard/i18n/locale/en/helpCenter.json +++ b/app/javascript/dashboard/i18n/locale/en/helpCenter.json @@ -139,6 +139,20 @@ "TITLE": "Locales" } }, + "CATEGORIES": { + "TITLE": "Categories in", + "NEW_CATEGORY": "New category", + "TABLE": { + "NAME": "Name", + "DESCRIPTION": "Description", + "LOCALE": "Locale", + "ARTICLE_COUNT": "No. of articles", + "ACTION_BUTTON": { + "EDIT": "Edit category", + "DELETE": "Delete category" + } + } + }, "EDIT_BASIC_INFO": { "BUTTON_TEXT": "Update basic settings" } @@ -353,6 +367,43 @@ "SUCCESS_MESSAGE": "Category created successfully", "ERROR_MESSAGE": "Unable to create category" } + }, + "EDIT": { + "TITLE": "Edit a category", + "SUB_TITLE": "Editing a category will update the category in the public facing portal.", + "PORTAL": "Portal", + "LOCALE": "Locale", + "NAME": { + "LABEL": "Name", + "PLACEHOLDER": "Category name", + "HELP_TEXT": "The category name will be used in the public facing portal to categorize articles.", + "ERROR": "Name is required" + }, + "SLUG": { + "LABEL": "Slug", + "PLACEHOLDER": "Category slug for urls", + "HELP_TEXT": "app.chatwoot.com/portal/my-portal/en-US/categories/my-slug", + "ERROR": "Slug is required" + }, + "DESCRIPTION": { + "LABEL": "Description", + "PLACEHOLDER": "Give a short description about the category.", + "ERROR": "Description is required" + }, + "BUTTONS": { + "CREATE": "Update category", + "CANCEL": "Cancel" + }, + "API": { + "SUCCESS_MESSAGE": "Category updated successfully", + "ERROR_MESSAGE": "Unable to update category" + } + }, + "DELETE": { + "API": { + "SUCCESS_MESSAGE": "Category deleted successfully", + "ERROR_MESSAGE": "Unable to delete category" + } } } } diff --git a/app/javascript/dashboard/routes/dashboard/helpcenter/components/HelpCenterLayout.vue b/app/javascript/dashboard/routes/dashboard/helpcenter/components/HelpCenterLayout.vue index 4f9b30d97..4d60d108b 100644 --- a/app/javascript/dashboard/routes/dashboard/helpcenter/components/HelpCenterLayout.vue +++ b/app/javascript/dashboard/routes/dashboard/helpcenter/components/HelpCenterLayout.vue @@ -37,6 +37,7 @@ /> + + + + + + + + + + + + + + + + + + + + +
+ {{ $t('HELP_CENTER.PORTAL.EDIT.CATEGORIES.TABLE.NAME') }} + + {{ $t('HELP_CENTER.PORTAL.EDIT.CATEGORIES.TABLE.DESCRIPTION') }} + + {{ $t('HELP_CENTER.PORTAL.EDIT.CATEGORIES.TABLE.LOCALE') }} + + {{ $t('HELP_CENTER.PORTAL.EDIT.CATEGORIES.TABLE.ARTICLE_COUNT') }} + +
+
+ {{ category.name }} + + {{ category.description }} + + {{ category.locale }} + + {{ category.meta.articles_count }} + + + +
+ + + + + diff --git a/app/javascript/dashboard/routes/dashboard/helpcenter/pages/categories/EditCategory.vue b/app/javascript/dashboard/routes/dashboard/helpcenter/pages/categories/EditCategory.vue index ecd03c1b6..ea3bb4aff 100644 --- a/app/javascript/dashboard/routes/dashboard/helpcenter/pages/categories/EditCategory.vue +++ b/app/javascript/dashboard/routes/dashboard/helpcenter/pages/categories/EditCategory.vue @@ -1,3 +1,198 @@