Fix notification associated pages count=0
This commit is contained in:
parent
47d9dfac0b
commit
dd7bad469c
|
@ -49,6 +49,20 @@ if( /^\/(\w+)(?:\/?.*)$/.test(window.gstore.data.URI) ){
|
|||
|
||||
// Functions
|
||||
window.gstore.add('func', {
|
||||
nav: function(router, uri){
|
||||
|
||||
// {1} Update view (vue-router) //
|
||||
router.push('/'+uri);
|
||||
|
||||
// {2} Activate current menu_item //
|
||||
window.gstore.data.menu_item_active = uri;
|
||||
|
||||
// {3} Manage notifications //
|
||||
for( var notif of window.gstore.data.notif )
|
||||
if( notif.link == uri ) // if notif links to current page
|
||||
notif.count = 0;
|
||||
|
||||
},
|
||||
toggleMenuSize: function(){ window.gstore.data.min_menu=!window.gstore.data.min_menu; },
|
||||
sendMessage: function(msg){
|
||||
/* (1) Send message to WebSocket */
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
<!-- Header Notif -->
|
||||
<div id='header-notif'>
|
||||
<div v-for='(notif, index) in gstore.notif' @click='show_notif(index, notif.link)' :class='"hnotif " + notif.class' :data-count='notif.count'></div>
|
||||
<div v-for='notif in gstore.notif' @click='show_notif(notif.link)' :class='"hnotif " + notif.class' :data-count='notif.count'></div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
@ -25,15 +25,8 @@ export default {
|
|||
name: 'HEADER',
|
||||
data(){ return { gstore: window.gstore.data }; },
|
||||
methods: {
|
||||
show_notif(index, link){
|
||||
|
||||
// {1} Load link //
|
||||
window.gstore.data.menu_item_active = link;
|
||||
|
||||
// {2} Reset notification count to 0 //
|
||||
window.gstore.data.notif[index].count = 0;
|
||||
|
||||
|
||||
show_notif(uri){
|
||||
window.gstore.data.func.nav(this.$router, uri);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
<div v-for='(item, index) in gstore.menu_item' class='menu-item-wrapper'>
|
||||
|
||||
<div :class="(index == gstore.menu_item_active) ? 'menu-item active' : 'menu-item'" @click='navigate_menu(index)' :style='"background-image: url(/image/menu/" + item.icon + ".svg@333333"'>
|
||||
<div :class="(index == gstore.menu_item_active) ? 'menu-item active' : 'menu-item'" @click='navigate(index)' :style='"background-image: url(/image/menu/" + item.icon + ".svg@333333"'>
|
||||
<span>{{ item.label }}</span>
|
||||
</div>
|
||||
|
||||
|
@ -20,16 +20,8 @@ export default {
|
|||
name: 'MENU',
|
||||
data(){ return { gstore: window.gstore.data }; },
|
||||
methods: {
|
||||
navigate_menu(page){
|
||||
|
||||
// (1) Update URL
|
||||
console.log('Loading page \''+page+'\'');
|
||||
console.log(this.$router)
|
||||
this.$router.push('/'+page);
|
||||
|
||||
// (2) Activate current element
|
||||
this.gstore.menu_item_active = page;
|
||||
|
||||
navigate(uri){
|
||||
window.gstore.data.func.nav(this.$router, uri);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue