Rename event deletePost to removePostFromList

Co-Authored-By: mattwr18 <mattwr18@gmail.com>
This commit is contained in:
Wolfgang Huß 2019-06-12 15:58:23 +02:00
parent 1c6016ddcc
commit 8eb089d218
7 changed files with 52 additions and 54 deletions

View File

@ -164,7 +164,7 @@ describe('DeleteModal.vue', () => {
expect(propsData.callbacks.confirm).toHaveBeenCalledTimes(1)
})
it('emits close', () => {
expect(wrapper.emitted().close).toBeTruthy()
expect(wrapper.emitted().close).toHaveLength(1)
})
it('resets success', () => {

View File

@ -103,8 +103,8 @@ export default {
return this.user.id === this.post.author.id
},
menuModalsData() {
// "this.post" may not always be defined at the beginning
return PostHelpers.postMenuModalsData(
// "this.post" may not always be defined at the beginning
this.post ? this.$filters.truncate(this.post.title, 30) : '',
this.deletePostCallback,
)
@ -115,7 +115,7 @@ export default {
try {
await this.$apollo.mutate(PostHelpers.deletePostMutationData(this.post.id))
this.$toast.success(this.$t('delete.contribution.success'))
this.$emit('deletePost')
this.$emit('removePostFromList')
} catch (err) {
this.$toast.error(err.message)
}

View File

@ -1,7 +1,7 @@
import gql from 'graphql-tag'
export default {
postMenuModalsData: (postNameShort, confirmCallback) => {
postMenuModalsData(postNameShort, confirmCallback) {
return {
delete: {
titleIdent: 'delete.contribution.title',

View File

@ -9,7 +9,7 @@
:key="post.id"
:post="post"
:width="{ base: '100%', xs: '100%', md: '50%', xl: '33%' }"
@deletePost="deletePost(index, post.id)"
@removePostFromList="deletePost(index, post.id)"
/>
</ds-flex>
<no-ssr>

View File

@ -210,9 +210,9 @@ export default {
}, 50)
},
computed: {
// "this.post" may not always be defined at the beginning
menuModalsData() {
return PostHelpers.postMenuModalsData(
// "this.post" may not always be defined at the beginning
this.post ? this.$filters.truncate(this.post.title, 30) : '',
this.deletePostCallback,
)

View File

@ -1,13 +1,10 @@
<template>
<ds-card>
<h2 style="margin-bottom: .2em;">
Mehr Informationen
</h2>
<h2 style="margin-bottom: .2em;">Mehr Informationen</h2>
<p>Hier findest du weitere infos zum Thema.</p>
<ds-space />
<ds-space/>
<h3>
<ds-icon name="compass" />
Themenkategorien
<ds-icon name="compass"/>Themenkategorien
</h3>
<div class="tags">
<ds-icon
@ -16,20 +13,18 @@
v-tooltip="{ content: category.name, placement: 'top-start', delay: { show: 300 } }"
:name="category.icon"
size="large"
/>
&nbsp;
/>&nbsp;
<!--<ds-tag
v-for="category in post.categories"
:key="category.id"><ds-icon :name="category.icon" /> {{ category.name }}</ds-tag>-->
</div>
<template v-if="post.tags && post.tags.length">
<h3>
<ds-icon name="tags" />
Schlagwörter
<ds-icon name="tags"/>Schlagwörter
</h3>
<div class="tags">
<ds-tag v-for="tag in post.tags" :key="tag.id">
<ds-icon name="tag" />
<ds-icon name="tag"/>
{{ tag.name }}
</ds-tag>
</div>
@ -42,12 +37,12 @@
:key="relatedPost.id"
:post="relatedPost"
:width="{ base: '100%', lg: 1 }"
@deletePost="post.relatedContributions.splice(index, 1)"
@removePostFromList="post.relatedContributions.splice(index, 1)"
/>
</ds-flex>
<hc-empty v-else margin="large" icon="file" message="No related Posts" />
<hc-empty v-else margin="large" icon="file" message="No related Posts"/>
</ds-section>
<ds-space margin-bottom="large" />
<ds-space margin-bottom="large"/>
</ds-card>
</template>

View File

@ -3,15 +3,15 @@
<ds-card v-if="user && user.image">
<p>PROFILE IMAGE</p>
</ds-card>
<ds-space />
<ds-space/>
<ds-flex v-if="user" :width="{ base: '100%' }" gutter="base">
<ds-flex-item :width="{ base: '100%', sm: 2, md: 2, lg: 1 }">
<ds-card
:class="{ 'disabled-content': user.disabled }"
style="position: relative; height: auto;"
>
<hc-upload v-if="myProfile" :user="user" />
<hc-avatar v-else :user="user" class="profile-avatar" size="x-large" />
<hc-upload v-if="myProfile" :user="user"/>
<hc-avatar v-else :user="user" class="profile-avatar" size="x-large"/>
<!-- Menu -->
<no-ssr>
<content-menu
@ -25,28 +25,30 @@
<ds-space margin="small">
<ds-heading tag="h3" align="center" no-margin>{{ userName }}</ds-heading>
<ds-text v-if="user.location" align="center" color="soft" size="small">
<ds-icon name="map-marker" />
<ds-icon name="map-marker"/>
{{ user.location.name }}
</ds-text>
<ds-text align="center" color="soft" size="small">
{{ $t('profile.memberSince') }} {{ user.createdAt | date('MMMM yyyy') }}
</ds-text>
<ds-text
align="center"
color="soft"
size="small"
>{{ $t('profile.memberSince') }} {{ user.createdAt | date('MMMM yyyy') }}</ds-text>
</ds-space>
<ds-space v-if="user.badges && user.badges.length" margin="x-small">
<hc-badges :badges="user.badges" />
<hc-badges :badges="user.badges"/>
</ds-space>
<ds-flex>
<ds-flex-item>
<no-ssr>
<ds-number :label="$t('profile.followers')">
<hc-count-to slot="count" :end-val="followedByCount" />
<hc-count-to slot="count" :end-val="followedByCount"/>
</ds-number>
</no-ssr>
</ds-flex-item>
<ds-flex-item>
<no-ssr>
<ds-number :label="$t('profile.following')">
<hc-count-to slot="count" :end-val="Number(user.followingCount) || 0" />
<hc-count-to slot="count" :end-val="Number(user.followingCount) || 0"/>
</ds-number>
</no-ssr>
</ds-flex-item>
@ -61,16 +63,14 @@
/>
</ds-space>
<template v-if="user.about">
<hr />
<hr>
<ds-space margin-top="small" margin-bottom="small">
<ds-text color="soft" size="small">{{ user.about }}</ds-text>
</ds-space>
</template>
</ds-card>
<ds-space />
<ds-heading tag="h3" soft style="text-align: center; margin-bottom: 10px;">
Netzwerk
</ds-heading>
<ds-space/>
<ds-heading tag="h3" soft style="text-align: center; margin-bottom: 10px;">Netzwerk</ds-heading>
<ds-card style="position: relative; height: auto;">
<ds-space v-if="user.following && user.following.length" margin="x-small">
<ds-text tag="h5" color="soft">Wem folgt {{ userName | truncate(15) }}?</ds-text>
@ -79,20 +79,21 @@
<ds-space v-for="follow in uniq(user.following)" :key="follow.id" margin="x-small">
<!-- TODO: find better solution for rendering errors -->
<no-ssr>
<user :user="follow" :trunc="15" />
<user :user="follow" :trunc="15"/>
</no-ssr>
</ds-space>
<ds-space v-if="user.followingCount - user.following.length" margin="small">
<ds-text size="small" color="softer">
und {{ user.followingCount - user.following.length }} weitere
</ds-text>
<ds-text
size="small"
color="softer"
>und {{ user.followingCount - user.following.length }} weitere</ds-text>
</ds-space>
</template>
<template v-else>
<p style="text-align: center; opacity: .5;">{{ userName }} folgt niemandem</p>
</template>
</ds-card>
<ds-space />
<ds-space/>
<ds-card style="position: relative; height: auto;">
<ds-space v-if="user.followedBy && user.followedBy.length" margin="x-small">
<ds-text tag="h5" color="soft">Wer folgt {{ userName | truncate(15) }}?</ds-text>
@ -101,13 +102,14 @@
<ds-space v-for="follow in uniq(user.followedBy)" :key="follow.id" margin="x-small">
<!-- TODO: find better solution for rendering errors -->
<no-ssr>
<user :user="follow" :trunc="15" />
<user :user="follow" :trunc="15"/>
</no-ssr>
</ds-space>
<ds-space v-if="user.followedByCount - user.followedBy.length" margin="small">
<ds-text size="small" color="softer">
und {{ user.followedByCount - user.followedBy.length }} weitere
</ds-text>
<ds-text
size="small"
color="softer"
>und {{ user.followedByCount - user.followedBy.length }} weitere</ds-text>
</ds-space>
</template>
<template v-else>
@ -117,13 +119,14 @@
<ds-space v-if="user.socialMedia && user.socialMedia.length" margin="large">
<ds-card style="position: relative; height: auto;">
<ds-space margin="x-small">
<ds-text tag="h5" color="soft">
{{ $t('profile.socialMedia') }} {{ user.name | truncate(15) }}?
</ds-text>
<ds-text
tag="h5"
color="soft"
>{{ $t('profile.socialMedia') }} {{ user.name | truncate(15) }}?</ds-text>
<template>
<ds-space v-for="link in socialMediaLinks" :key="link.username" margin="x-small">
<a :href="link.url">
<ds-avatar :image="link.favicon" />
<ds-avatar :image="link.favicon"/>
{{ 'link.username' }}
</a>
</ds-space>
@ -150,7 +153,7 @@
<!-- TODO: find better solution for rendering errors -->
<no-ssr>
<ds-number :label="$t('common.post', null, user.contributionsCount)">
<hc-count-to slot="count" :end-val="user.contributionsCount" />
<hc-count-to slot="count" :end-val="user.contributionsCount"/>
</ds-number>
</no-ssr>
</ds-space>
@ -169,7 +172,7 @@
<no-ssr>
<ds-number :label="$t('profile.commented')">
<hc-count-to slot="count" :end-val="user.commentsCount" />
<hc-count-to slot="count" :end-val="user.commentsCount"/>
</ds-number>
</no-ssr>
</ds-space>
@ -187,7 +190,7 @@
<!-- TODO: find better solution for rendering errors -->
<no-ssr>
<ds-number :label="$t('profile.shouted')">
<hc-count-to slot="count" :end-val="user.shoutedCount" />
<hc-count-to slot="count" :end-val="user.shoutedCount"/>
</ds-number>
</no-ssr>
</ds-space>
@ -212,16 +215,16 @@
:key="post.id"
:post="post"
:width="{ base: '100%', md: '100%', xl: '50%' }"
@deletePost="user.contributions.splice(index, 1)"
@removePostFromList="user.contributions.splice(index, 1)"
/>
</template>
<template v-else>
<ds-flex-item :width="{ base: '100%' }">
<hc-empty margin="xx-large" icon="file" />
<hc-empty margin="xx-large" icon="file"/>
</ds-flex-item>
</template>
</ds-flex>
<hc-load-more v-if="hasMore" :loading="$apollo.loading" @click="showMoreContributions" />
<hc-load-more v-if="hasMore" :loading="$apollo.loading" @click="showMoreContributions"/>
</ds-flex-item>
</ds-flex>
</div>