Follow @alina-beck and @Tirokk suggestions

- following PR reviews
This commit is contained in:
mattwr18 2019-10-25 13:12:20 +02:00
parent e8cf51095a
commit 58b1f7948c
4 changed files with 70 additions and 23 deletions

View File

@ -9,14 +9,14 @@
</ds-button> </ds-button>
</template> </template>
<template slot="popover"> <template slot="popover">
<ds-space centered>
<ds-button primary fullwidth :path="{ name: 'notifications' }">
{{ $t('notifications.pageLink') }}
</ds-button>
</ds-space>
<div class="notifications-menu-popover"> <div class="notifications-menu-popover">
<notification-list :notifications="displayedNotifications" @markAsRead="markAsRead" /> <notification-list :notifications="displayedNotifications" @markAsRead="markAsRead" />
</div> </div>
<ds-space centered>
<nuxt-link to="/notifications">
{{ $t('notifications.pageLink') }}
</nuxt-link>
</ds-space>
</template> </template>
</dropdown> </dropdown>
</template> </template>
@ -113,7 +113,7 @@ export default {
} }
</script> </script>
<style> <style lang="scss" scoped>
.notifications-menu { .notifications-menu {
display: flex; display: flex;
align-items: center; align-items: center;
@ -122,4 +122,13 @@ export default {
.notifications-menu-popover { .notifications-menu-popover {
max-width: 500px; max-width: 500px;
} }
.link-bg {
position: sticky;
width: 100%;
background-color: $background-color-primary-active;
text-align: center;
}
.notifications-link {
color: $text-color-softer;
}
</style> </style>

View File

@ -185,7 +185,8 @@
"all": "Alle", "all": "Alle",
"read": "Lesen ", "read": "Lesen ",
"unread": "Ungelesen" "unread": "Ungelesen"
} },
"empty": "Sorry, du hast im Moment keine Benachrichtigungen."
}, },
"search": { "search": {
"placeholder": "Suchen", "placeholder": "Suchen",

View File

@ -186,7 +186,8 @@
"all": "All", "all": "All",
"read": "Read", "read": "Read",
"unread": "Unread" "unread": "Unread"
} },
"empty": "Sorry, you don't have any notifications at the moment."
}, },
"search": { "search": {
"placeholder": "Search", "placeholder": "Search",

View File

@ -44,19 +44,35 @@
:fields="fields" :fields="fields"
class="notifications-table" class="notifications-table"
> >
<template slot="icon" slot-scope="scope">
<ds-icon
v-if="scope.row.from.post"
name="comment"
v-tooltip="{ content: $t('notifications.comment'), placement: 'right' }"
/>
<ds-icon
v-else
name="bookmark"
v-tooltip="{ content: $t('notifications.post'), placement: 'right' }"
/>
</template>
<template slot="user" slot-scope="scope"> <template slot="user" slot-scope="scope">
<ds-space margin-bottom="base"> <ds-space margin-bottom="base">
<hc-user <hc-user
:user="scope.row.from.author" :user="scope.row.from.author"
:date-time="scope.row.from.createdAt" :date-time="scope.row.from.createdAt"
:trunc="35" :trunc="35"
:class="{ 'notification-status': scope.row.read }"
/> />
</ds-space> </ds-space>
{{ $t(`notifications.reason.${scope.row.reason}`) }} <ds-text :class="{ 'notification-status': scope.row.read }">
{{ $t(`notifications.reason.${scope.row.reason}`) }}
</ds-text>
</template> </template>
<template slot="post" slot-scope="scope"> <template slot="post" slot-scope="scope">
<nuxt-link <nuxt-link
class="notification-mention-post" class="notification-mention-post"
:class="{ 'notification-status': scope.row.read }"
:to="{ :to="{
name: 'post-id-slug', name: 'post-id-slug',
params: { params: {
@ -71,16 +87,18 @@
}, },
hash: scope.row.from.__typename === 'Comment' ? `#commentId-${scope.row.from.id}` : {}, hash: scope.row.from.__typename === 'Comment' ? `#commentId-${scope.row.from.id}` : {},
}" }"
@click.native="$emit('read')" @click.native="markNotificationAsRead(scope.row.from.id)"
> >
<b>{{ scope.row.from.title || scope.row.from.post.title | truncate(50) }}</b> <b>{{ scope.row.from.title || scope.row.from.post.title | truncate(50) }}</b>
</nuxt-link> </nuxt-link>
</template> </template>
<template slot="content" slot-scope="scope"> <template slot="content" slot-scope="scope">
<b>{{ scope.row.from.contentExcerpt || scope.row.from.contentExcerpt | removeHtml }}</b> <b :class="{ 'notification-status': scope.row.read }">
{{ scope.row.from.contentExcerpt || scope.row.from.contentExcerpt | removeHtml }}
</b>
</template> </template>
</ds-table> </ds-table>
<hc-empty v-else icon="alert" :message="$t('moderation.reports.empty')" /> <hc-empty v-else icon="alert" :message="$t('notifications.empty')" />
</ds-card> </ds-card>
</template> </template>
@ -88,7 +106,7 @@
import HcUser from '~/components/User/User' import HcUser from '~/components/User/User'
import HcEmpty from '~/components/Empty.vue' import HcEmpty from '~/components/Empty.vue'
import Dropdown from '~/components/Dropdown' import Dropdown from '~/components/Dropdown'
import { notificationQuery } from '~/graphql/User' import { notificationQuery, markAsReadMutation } from '~/graphql/User'
export default { export default {
components: { components: {
@ -111,7 +129,14 @@ export default {
computed: { computed: {
fields() { fields() {
return { return {
user: this.$t('notifications.user'), icon: {
label: ' ',
width: '60px',
},
user: {
label: this.$t('notifications.user'),
width: '350px',
},
post: this.$t('notifications.post'), post: this.$t('notifications.post'),
content: this.$t('notifications.content'), content: this.$t('notifications.content'),
} }
@ -133,6 +158,16 @@ export default {
this.$apollo.queries.notifications.refresh() this.$apollo.queries.notifications.refresh()
toggleMenu() toggleMenu()
}, },
async markNotificationAsRead(notificationSourceId) {
try {
await this.$apollo.mutate({
mutation: markAsReadMutation(this.$i18n),
variables: { id: notificationSourceId },
})
} catch (error) {
this.$toast.error(error.message)
}
},
}, },
apollo: { apollo: {
notifications: { notifications: {
@ -160,7 +195,8 @@ export default {
.sorting-dropdown { .sorting-dropdown {
float: right; float: right;
} }
.notifications-table td { .notification-status {
width: 500px; opacity: 0.6; /* Real browsers */
filter: alpha(opacity = 60); /* MSIE */
} }
</style> </style>