mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
Add NotificationsDropdownFilter story, refactor
- rename incorrectly named varaibles - use filterOptions to remove unneccessary computed routes Co-authored-by: @alina-beck
This commit is contained in:
parent
3ae71544d6
commit
542647f418
@ -0,0 +1,18 @@
|
|||||||
|
import { storiesOf } from '@storybook/vue'
|
||||||
|
import { withA11y } from '@storybook/addon-a11y'
|
||||||
|
import { action } from '@storybook/addon-actions'
|
||||||
|
import NotificationsDropdownFilter from '~/components/NotificationsDropdownFilter/NotificationsDropdownFilter'
|
||||||
|
import helpers from '~/storybook/helpers'
|
||||||
|
|
||||||
|
helpers.init()
|
||||||
|
|
||||||
|
storiesOf('NotificationsDropdownFilter', module)
|
||||||
|
.addDecorator(withA11y)
|
||||||
|
.addDecorator(helpers.layout)
|
||||||
|
.add('filter dropdown', () => ({
|
||||||
|
components: { NotificationsDropdownFilter },
|
||||||
|
methods: {
|
||||||
|
filterNotifications: action('filterNotifications'),
|
||||||
|
},
|
||||||
|
template: '<notifications-dropdown-filter @filterNotifications="filterNotifications" />',
|
||||||
|
}))
|
||||||
@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<dropdown>
|
<dropdown offset="8">
|
||||||
<a
|
<a
|
||||||
slot="default"
|
slot="default"
|
||||||
slot-scope="{ toggleMenu }"
|
slot-scope="{ toggleMenu }"
|
||||||
@ -7,7 +7,7 @@
|
|||||||
href="#"
|
href="#"
|
||||||
@click.prevent="toggleMenu()"
|
@click.prevent="toggleMenu()"
|
||||||
>
|
>
|
||||||
<ds-icon style="margin-right: 2px;" name="sort" />
|
<ds-icon style="margin-right: 2px;" name="filter" />
|
||||||
{{ selected }}
|
{{ selected }}
|
||||||
<ds-icon style="margin-left: 2px" size="xx-small" name="angle-down" />
|
<ds-icon style="margin-left: 2px" size="xx-small" name="angle-down" />
|
||||||
</a>
|
</a>
|
||||||
@ -15,7 +15,7 @@
|
|||||||
slot="popover"
|
slot="popover"
|
||||||
slot-scope="{ toggleMenu }"
|
slot-scope="{ toggleMenu }"
|
||||||
class="locale-menu-popover"
|
class="locale-menu-popover"
|
||||||
:routes="routes"
|
:routes="filterOptions"
|
||||||
>
|
>
|
||||||
<ds-menu-item
|
<ds-menu-item
|
||||||
slot="menuitem"
|
slot="menuitem"
|
||||||
@ -23,7 +23,7 @@
|
|||||||
class="locale-menu-item"
|
class="locale-menu-item"
|
||||||
:route="item.route"
|
:route="item.route"
|
||||||
:parents="item.parents"
|
:parents="item.parents"
|
||||||
@click.stop.prevent="sortNotifications(item.route, toggleMenu)"
|
@click.stop.prevent="filterNotifications(item.route, toggleMenu)"
|
||||||
>
|
>
|
||||||
{{ item.route.label }}
|
{{ item.route.label }}
|
||||||
</ds-menu-item>
|
</ds-menu-item>
|
||||||
@ -39,28 +39,17 @@ export default {
|
|||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
selected: this.$t('notifications.sortingLabel.all'),
|
selected: this.$t('notifications.filterLabel.all'),
|
||||||
sortingOptions: [
|
filterOptions: [
|
||||||
{ label: this.$t('notifications.sortingLabel.all'), value: null },
|
{ label: this.$t('notifications.filterLabel.all'), value: null },
|
||||||
{ label: this.$t('notifications.sortingLabel.read'), value: true },
|
{ label: this.$t('notifications.filterLabel.read'), value: true },
|
||||||
{ label: this.$t('notifications.sortingLabel.unread'), value: false },
|
{ label: this.$t('notifications.filterLabel.unread'), value: false },
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
|
||||||
routes() {
|
|
||||||
let routes = this.sortingOptions.map(option => {
|
|
||||||
return {
|
|
||||||
label: option.label,
|
|
||||||
value: option.value,
|
|
||||||
}
|
|
||||||
})
|
|
||||||
return routes
|
|
||||||
},
|
|
||||||
},
|
|
||||||
methods: {
|
methods: {
|
||||||
sortNotifications(option, toggleMenu) {
|
filterNotifications(option, toggleMenu) {
|
||||||
this.$emit('sortNotifications', option)
|
this.$emit('filterNotifications', option.value)
|
||||||
this.selected = option.label
|
this.selected = option.label
|
||||||
toggleMenu()
|
toggleMenu()
|
||||||
},
|
},
|
||||||
|
|||||||
@ -181,7 +181,7 @@
|
|||||||
"post": "Beitrag",
|
"post": "Beitrag",
|
||||||
"user": "Benutzer",
|
"user": "Benutzer",
|
||||||
"content": "Inhalt",
|
"content": "Inhalt",
|
||||||
"sortingLabel": {
|
"filterLabel": {
|
||||||
"all": "Alle",
|
"all": "Alle",
|
||||||
"read": "Lesen ",
|
"read": "Lesen ",
|
||||||
"unread": "Ungelesen"
|
"unread": "Ungelesen"
|
||||||
|
|||||||
@ -182,7 +182,7 @@
|
|||||||
"post": "Post",
|
"post": "Post",
|
||||||
"user": "User",
|
"user": "User",
|
||||||
"content": "Content",
|
"content": "Content",
|
||||||
"sortingLabel": {
|
"filterLabel": {
|
||||||
"all": "All",
|
"all": "All",
|
||||||
"read": "Read",
|
"read": "Read",
|
||||||
"unread": "Unread"
|
"unread": "Unread"
|
||||||
|
|||||||
@ -194,7 +194,7 @@
|
|||||||
"post": "Post",
|
"post": "Post",
|
||||||
"user": "Usuário",
|
"user": "Usuário",
|
||||||
"content": "Conteúdo",
|
"content": "Conteúdo",
|
||||||
"sortingLabel": {
|
"filterLabel": {
|
||||||
"all": "Todos",
|
"all": "Todos",
|
||||||
"read": "Lido",
|
"read": "Lido",
|
||||||
"unread": "Não lido"
|
"unread": "Não lido"
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
</ds-flex-item>
|
</ds-flex-item>
|
||||||
<ds-flex-item class="sorting-dropdown">
|
<ds-flex-item class="sorting-dropdown">
|
||||||
<client-only>
|
<client-only>
|
||||||
<notifications-dropdown-filter @sortNotifications="sortNotifications" />
|
<notifications-dropdown-filter @filterNotifications="filterNotifications" />
|
||||||
</client-only>
|
</client-only>
|
||||||
</ds-flex-item>
|
</ds-flex-item>
|
||||||
</ds-flex>
|
</ds-flex>
|
||||||
@ -48,8 +48,8 @@ export default {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
sortNotifications(option) {
|
filterNotifications(value) {
|
||||||
this.notificationRead = option.value
|
this.notificationRead = value
|
||||||
this.$apollo.queries.notifications.refresh()
|
this.$apollo.queries.notifications.refresh()
|
||||||
},
|
},
|
||||||
async markNotificationAsRead(notificationSourceId) {
|
async markNotificationAsRead(notificationSourceId) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user