fix: Update article count in portal admin dashboard (#5647)

Co-authored-by: Pranav Raj S <pranav@chatwoot.com>
This commit is contained in:
Tejaswini Chile
2022-10-22 02:13:15 +05:30
committed by GitHub
parent 95cc55d043
commit 782165478b
29 changed files with 157 additions and 94 deletions

View File

@@ -16,7 +16,7 @@
:accessible-menu-items="accessibleMenuItems"
:additional-secondary-menu-items="additionalSecondaryMenuItems"
@open-popover="openPortalPopover"
@open-modal="onClickOpenAddCatogoryModal"
@open-modal="onClickOpenAddCategoryModal"
/>
<section class="app-content columns" :class="contentClassName">
<router-view />
@@ -134,14 +134,14 @@ export default {
},
accessibleMenuItems() {
if (!this.selectedPortal) return [];
const {
meta: {
all_articles_count: allArticlesCount,
mine_articles_count: mineArticlesCount,
draft_articles_count: draftArticlesCount,
archived_articles_count: archivedArticlesCount,
} = {},
} = this.selectedPortal;
allArticlesCount,
mineArticlesCount,
draftArticlesCount,
archivedArticlesCount,
} = this.meta;
return [
{
icon: 'book',
@@ -216,6 +216,13 @@ export default {
return this.selectedPortal ? this.selectedPortal.name : '';
},
},
watch: {
selectedPortal() {
this.fetchPortalsAndItsCategories();
},
},
mounted() {
window.addEventListener('resize', this.handleResize);
this.handleResize();
@@ -251,12 +258,15 @@ export default {
toggleSidebar() {
this.isSidebarOpen = !this.isSidebarOpen;
},
fetchPortalsAndItsCategories() {
this.$store.dispatch('portals/index').then(() => {
this.$store.dispatch('categories/index', {
portalSlug: this.selectedPortalSlug,
});
});
async fetchPortalsAndItsCategories() {
await this.$store.dispatch('portals/index');
const selectedPortalParam = {
portalSlug: this.selectedPortalSlug,
locale: this.selectedLocaleInPortal,
};
this.$store.dispatch('portals/show', selectedPortalParam);
this.$store.dispatch('categories/index', selectedPortalParam);
this.$store.dispatch('agents/get');
},
toggleKeyShortcutModal() {
@@ -277,7 +287,7 @@ export default {
closePortalPopover() {
this.showPortalPopover = false;
},
onClickOpenAddCatogoryModal() {
onClickOpenAddCategoryModal() {
this.showAddCategoryModal = true;
},
onClickCloseAddCategoryModal() {

View File

@@ -112,16 +112,8 @@ export default {
this.selectedLocale = this.locale || this.portal?.meta?.default_locale;
},
methods: {
fetchPortalsAndItsCategories() {
this.$store.dispatch('portals/index').then(() => {
this.$store.dispatch('categories/index', {
portalSlug: this.portal.slug,
});
});
},
onClick(event, code, portal) {
event.preventDefault();
this.fetchPortalsAndItsCategories();
this.$router.push({
name: 'list_all_locale_articles',
params: {

View File

@@ -104,9 +104,6 @@ export default {
}
return null;
},
articleCount() {
return this.articles ? this.articles.length : 0;
},
headerTitleInCategoryView() {
return this.categories && this.categories.length
? this.selectedCategory.name