diff options
| author | Maksim Pechnikov <parallel588@gmail.com> | 2019-10-17 16:19:52 +0300 |
|---|---|---|
| committer | Maksim Pechnikov <parallel588@gmail.com> | 2019-10-17 16:19:52 +0300 |
| commit | 60828f119c5b8f5de1ba6f6a9d774ef0e813405b (patch) | |
| tree | 3012f4e6616719a3635068cedb28d0259381f12e | |
| parent | d2079ecef496047e114591b1aaf8f6a0a3474c91 (diff) | |
updated FollowCard component
| -rw-r--r-- | src/components/follow_button/follow_button.js | 4 | ||||
| -rw-r--r-- | src/components/follow_button/follow_button.vue | 2 | ||||
| -rw-r--r-- | src/components/follow_card/follow_card.js | 21 | ||||
| -rw-r--r-- | src/components/follow_card/follow_card.vue | 35 |
4 files changed, 12 insertions, 50 deletions
diff --git a/src/components/follow_button/follow_button.js b/src/components/follow_button/follow_button.js index 4123c9fd..12da2645 100644 --- a/src/components/follow_button/follow_button.js +++ b/src/components/follow_button/follow_button.js @@ -1,6 +1,6 @@ import { requestFollow, requestUnfollow } from '../../services/follow_manipulate/follow_manipulate' export default { - props: ['user'], + props: ['user', 'labelFollowing', 'buttonClass'], data () { return { inProgress: false @@ -23,7 +23,7 @@ export default { if (this.inProgress) { return this.$t('user_card.follow_progress') } else if (this.user.following) { - return this.$t('user_card.following') + return this.labelFollowing || this.$t('user_card.following') } else if (this.user.requested) { return this.$t('user_card.follow_sent') } else { diff --git a/src/components/follow_button/follow_button.vue b/src/components/follow_button/follow_button.vue index f0cbb94b..66d899b9 100644 --- a/src/components/follow_button/follow_button.vue +++ b/src/components/follow_button/follow_button.vue @@ -1,7 +1,7 @@ <template> <button class="btn btn-default follow-button" - :class="{ pressed: isPressed }" + :class="[buttonClass, { pressed: isPressed}]" :disabled="inProgress" :title="title" @click="onClick" diff --git a/src/components/follow_card/follow_card.js b/src/components/follow_card/follow_card.js index 118d0c7c..2c3231a9 100644 --- a/src/components/follow_card/follow_card.js +++ b/src/components/follow_card/follow_card.js @@ -1,6 +1,6 @@ import BasicUserCard from '../basic_user_card/basic_user_card.vue' import RemoteFollow from '../remote_follow/remote_follow.vue' -import { requestFollow, requestUnfollow } from '../../services/follow_manipulate/follow_manipulate' +import FollowButton from '../follow_button/follow_button.vue' const FollowCard = { props: [ @@ -8,13 +8,12 @@ const FollowCard = { 'noFollowsYou' ], data () { - return { - inProgress: false - } + return { } }, components: { BasicUserCard, - RemoteFollow + RemoteFollow, + FollowButton }, computed: { isMe () { @@ -25,18 +24,6 @@ const FollowCard = { } }, methods: { - followUser () { - this.inProgress = true - requestFollow(this.user, this.$store).then(() => { - this.inProgress = false - }) - }, - unfollowUser () { - this.inProgress = true - requestUnfollow(this.user, this.$store).then(() => { - this.inProgress = false - }) - } } } diff --git a/src/components/follow_card/follow_card.vue b/src/components/follow_card/follow_card.vue index a9d237bb..a43cac4e 100644 --- a/src/components/follow_card/follow_card.vue +++ b/src/components/follow_card/follow_card.vue @@ -16,36 +16,11 @@ </div> </template> <template v-else> - <button - v-if="!user.following" - class="btn btn-default follow-card-follow-button" - :disabled="inProgress" - :title="user.requested ? $t('user_card.follow_again') : ''" - @click="followUser" - > - <template v-if="inProgress"> - {{ $t('user_card.follow_progress') }} - </template> - <template v-else-if="user.requested"> - {{ $t('user_card.follow_sent') }} - </template> - <template v-else> - {{ $t('user_card.follow') }} - </template> - </button> - <button - v-else - class="btn btn-default follow-card-follow-button pressed" - :disabled="inProgress" - @click="unfollowUser" - > - <template v-if="inProgress"> - {{ $t('user_card.follow_progress') }} - </template> - <template v-else> - {{ $t('user_card.follow_unfollow') }} - </template> - </button> + <FollowButton + :user="user" + button-class="follow-card-follow-button" + :label-following="$t('user_card.follow_unfollow')" + /> </template> </div> </basic-user-card> |
