Skip to content

Commit c851bce

Browse files
committed
Initial commit (v1)
1 parent f0b0c47 commit c851bce

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

src/app/views/layout/components/Sidebar/SidebarItem.vue

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
v-if="item.children.length === 1 && !item.children[0].children"
66
:to="item.path !== '/' ? item.path + '/' + item.children[0].path : '/' + item.children[0].path"
77
:key="item.children[0].name"
8-
:event="''"
98
@click.native.prevent="
109
checkRouteAction($event, { meta: item.children[0].meta, path: item.path !== '/' ? item.path + '/' + item.children[0].path : '/' + item.children[0].path })
1110
"
@@ -27,12 +26,15 @@
2726
v-else
2827
:to="item.path + '/' + child.path"
2928
:key="child.name"
30-
:event="''"
3129
@click.native.prevent="checkRouteAction($event, { meta: child.meta, path: item.path + '/' + child.path })"
3230
>
33-
<el-menu-item :index="item.path + '/' + child.path" :class="generateMenuClass(child)">
31+
<el-menu-item
32+
:index="item.path + '/' + child.path"
33+
:class="generateMenuClass(child)">
3434
<i v-if="child.meta && child.meta.icon" :class="child.meta.icon" aria-hidden="true"></i>
35-
<span slot="title" v-if="child.meta && child.meta.title">{{ generateRouteTitle(child.meta.title) }}</span>
35+
<span slot="title"
36+
v-if="child.meta && child.meta.title">{{ generateRouteTitle(child.meta.title) }}
37+
</span>
3638
</el-menu-item>
3739
</router-link>
3840
</div>
@@ -55,6 +57,9 @@ export default {
5557
this.$store.dispatch("setSelectedFiles", value);
5658
},
5759
},
60+
currentRouteName() {
61+
return this.$route.path;
62+
}
5863
},
5964
props: {
6065
routes: {
@@ -73,7 +78,6 @@ export default {
7378
// Some menu Items must have disabled class because they can only be used if some specific file is selected
7479
7580
generateMenuClass: function (childItem) {
76-
console.log("Checking menu class: " + childItem.name);
7781
let cssClass = "ready";
7882
7983
// Check if there is any meta set for given route
@@ -112,11 +116,18 @@ export default {
112116
},
113117
checkRouteAction: function (event, data) {
114118
event.preventDefault();
119+
120+
// If we are already on that page lets do nothing
121+
if(data.path === this.currentRouteName){
122+
return;
123+
}
124+
115125
let pass = false;
116126
117127
if (this.generateMenuClass(data) === "ready") {
118128
pass = true;
119129
}
130+
120131
if (pass === true) {
121132
this.$router.push({
122133
path: data.path,

0 commit comments

Comments
 (0)