Ver Fonte

fixed #382

ali há 2 anos atrás
pai
commit
d906f4b9b4

+ 19 - 0
src/components/Template/Header/UserPanelHeader.vue

@@ -36,6 +36,10 @@
                  :to="{name: 'UserPanel.Notice.List'}">
             <q-icon name="notifications_none" />
             پیام ها
+            <q-badge v-if="myNotSeenNotificationsCount !== 0"
+                     color="warning">
+              {{ myNotSeenNotificationsCount }}
+            </q-badge>
           </q-btn>
           <q-btn flat>
             <svg id="_000000ff"
@@ -85,6 +89,7 @@
 <script>
 import { mapMutations } from 'vuex'
 import { User } from 'src/models/User.js'
+import { APIGateway } from 'src/api/APIGateway.js'
 
 export default {
   name: 'UserPanelHeader',
@@ -126,6 +131,14 @@ export default {
     }
   },
   computed: {
+    myNotSeenNotificationsCount: {
+      get () {
+        return this.$store.getters['Auth/myNotSeenNotificationsCount']
+      },
+      set (newValue) {
+        return this.$store.commit('Auth/updateMyNotSeenNotificationsCount', newValue)
+      }
+    },
     isAdminPage () {
       return this.$route.name && this.$route.name.includes('Admin.')
     },
@@ -140,6 +153,12 @@ export default {
     this.loadAuthData()
   },
   methods: {
+    getMyNotSeenNotificationsCount () {
+      APIGateway.noticeReceiver.myNotSeenNotificationsCount()
+        .then((count) => {
+          this.myNotSeenNotificationsCount = count
+        })
+    },
     loadAuthData () {
       this.user = this.$store.getters['Auth/user']
     },

+ 10 - 1
src/components/Widgets/Notice/NoticeList/NoticeList.vue

@@ -104,7 +104,6 @@ export default {
   data () {
     return {
       filterType: 'all',
-      myNotSeenNotificationsCount: 0,
       api: APIGateway.noticeReceiver.APIAdresses.base,
       tableKeys: {
         data: 'results',
@@ -152,6 +151,16 @@ export default {
       createRouteName: ''
     }
   },
+  computed: {
+    myNotSeenNotificationsCount: {
+      get () {
+        return this.$store.getters['Auth/myNotSeenNotificationsCount']
+      },
+      set (newValue) {
+        return this.$store.commit('Auth/updateMyNotSeenNotificationsCount', newValue)
+      }
+    }
+  },
   mounted() {
     this.mounted = true
     this.updateBreadcrumbs()

+ 3 - 0
src/store/Auth/getters.js

@@ -24,3 +24,6 @@ export function redirectTo (state) {
 export function incompleteProfile (state) {
   return state.incompleteProfile
 }
+export function myNotSeenNotificationsCount (state) {
+  return state.myNotSeenNotificationsCount
+}

+ 3 - 0
src/store/Auth/mutations.js

@@ -32,3 +32,6 @@ export function setAccessToken() {
 export function updateIncompleteProfile(state, newInfo) {
   state.incompleteProfile = newInfo
 }
+export function updateMyNotSeenNotificationsCount(state, newInfo) {
+  state.myNotSeenNotificationsCount = newInfo
+}

+ 2 - 1
src/store/Auth/state.js

@@ -3,6 +3,7 @@ export default function () {
     user: null,
     redirectTo: null,
     accessToken: null,
-    incompleteProfile: false
+    incompleteProfile: false,
+    myNotSeenNotificationsCount: 0
   }
 }