Skip to content
Snippets Groups Projects
Commit 08bd5dae authored by Angelina Filippova's avatar Angelina Filippova
Browse files

Show reports count in Sidebar

parent 1899450d
No related branches found
No related tags found
1 merge request!143Show open reports count in Sidebar Menu
Pipeline #28556 passed
...@@ -3,6 +3,10 @@ export default { ...@@ -3,6 +3,10 @@ export default {
name: 'MenuItem', name: 'MenuItem',
functional: true, functional: true,
props: { props: {
count: {
type: String,
default: null
},
icon: { icon: {
type: String, type: String,
default: '' default: ''
...@@ -13,7 +17,7 @@ export default { ...@@ -13,7 +17,7 @@ export default {
} }
}, },
render(h, context) { render(h, context) {
const { icon, title } = context.props const { count, icon, title } = context.props
const vnodes = [] const vnodes = []
if (icon) { if (icon) {
...@@ -21,7 +25,11 @@ export default { ...@@ -21,7 +25,11 @@ export default {
} }
if (title) { if (title) {
vnodes.push(<span slot='title'>{(title)}</span>) vnodes.push(<span slot='title'>{(title)} </span>)
}
if (count) {
vnodes.push(<span slot='title'>({(count)})</span>)
} }
return vnodes return vnodes
} }
......
...@@ -4,14 +4,21 @@ ...@@ -4,14 +4,21 @@
<template v-if="hasOneShowingChild(item.children,item) && (!onlyOneChild.children||onlyOneChild.noShowingChildren)&&!item.alwaysShow"> <template v-if="hasOneShowingChild(item.children,item) && (!onlyOneChild.children||onlyOneChild.noShowingChildren)&&!item.alwaysShow">
<app-link :to="resolvePath(onlyOneChild.path)"> <app-link :to="resolvePath(onlyOneChild.path)">
<el-menu-item :index="resolvePath(onlyOneChild.path)" :class="{'submenu-title-noDropdown':!isNest}"> <el-menu-item :index="resolvePath(onlyOneChild.path)" :class="{'submenu-title-noDropdown':!isNest}">
<item v-if="onlyOneChild.meta" :icon="onlyOneChild.meta.icon||item.meta.icon" :title="generateTitle(onlyOneChild.meta.title)" /> <item
v-if="onlyOneChild.meta"
:count="showCount(item) ? normalizedReportsCount : null"
:icon="onlyOneChild.meta.icon||item.meta.icon"
:title="generateTitle(onlyOneChild.meta.title)" />
</el-menu-item> </el-menu-item>
</app-link> </app-link>
</template> </template>
<el-submenu v-else ref="subMenu" :index="resolvePath(item.path)"> <el-submenu v-else ref="subMenu" :index="resolvePath(item.path)">
<template slot="title"> <template slot="title">
<item v-if="item.meta" :icon="item.meta.icon" :title="generateTitle(item.meta.title)" /> <item
v-if="item.meta"
:count="showCount(item) ? normalizedReportsCount : null"
:icon="item.meta.icon"
:title="generateTitle(item.meta.title)" />
</template> </template>
<template v-for="child in item.children"> <template v-for="child in item.children">
...@@ -26,7 +33,11 @@ ...@@ -26,7 +33,11 @@
<app-link v-else :to="resolvePath(child.path)" :key="child.name"> <app-link v-else :to="resolvePath(child.path)" :key="child.name">
<el-menu-item :index="resolvePath(child.path)"> <el-menu-item :index="resolvePath(child.path)">
<item v-if="child.meta" :icon="child.meta.icon" :title="generateTitle(child.meta.title)" /> <item
v-if="child.meta"
:count="showCount(item) ? normalizedReportsCount : null"
:icon="child.meta.icon"
:title="generateTitle(child.meta.title)" />
</el-menu-item> </el-menu-item>
</app-link> </app-link>
</template> </template>
...@@ -43,6 +54,7 @@ import { isExternal } from '@/utils' ...@@ -43,6 +54,7 @@ import { isExternal } from '@/utils'
import Item from './Item' import Item from './Item'
import AppLink from './Link' import AppLink from './Link'
import FixiOSBug from './FixiOSBug' import FixiOSBug from './FixiOSBug'
import numeral from 'numeral'
export default { export default {
name: 'SidebarItem', name: 'SidebarItem',
...@@ -71,6 +83,9 @@ export default { ...@@ -71,6 +83,9 @@ export default {
computed: { computed: {
invitesEnabled() { invitesEnabled() {
return this.basePath === '/invites' ? this.$store.state.app.invitesEnabled : true return this.basePath === '/invites' ? this.$store.state.app.invitesEnabled : true
},
normalizedReportsCount() {
return numeral(this.$store.state.reports.totalReportsCount).format('0a')
} }
}, },
methods: { methods: {
...@@ -104,6 +119,9 @@ export default { ...@@ -104,6 +119,9 @@ export default {
} }
return path.resolve(this.basePath, routePath) return path.resolve(this.basePath, routePath)
}, },
showCount(item) {
return item.path === '/reports'
},
isExternalLink(routePath) { isExternalLink(routePath) {
return isExternal(routePath) return isExternal(routePath)
}, },
......
...@@ -31,6 +31,10 @@ export default { ...@@ -31,6 +31,10 @@ export default {
isCollapse() { isCollapse() {
return !this.sidebar.opened return !this.sidebar.opened
} }
},
mounted() {
this.$store.dispatch('SetReportsFilter', 'open')
this.$store.dispatch('FetchReports', 1)
} }
} }
</script> </script>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment