From 4a1c7c284133c13594907e528b41f606765ae912 Mon Sep 17 00:00:00 2001 From: Angelina Filippova Date: Thu, 5 Nov 2020 23:19:37 +0300 Subject: [PATCH] Fix adding and removing tags after implementing select --- src/lang/en.js | 3 +- .../users/components/ModerationDropdown.vue | 66 ++++++++++--------- 2 files changed, 37 insertions(+), 32 deletions(-) diff --git a/src/lang/en.js b/src/lang/en.js index 7bd4ea2a..4a4fbdc2 100644 --- a/src/lang/en.js +++ b/src/lang/en.js @@ -283,7 +283,8 @@ export default { confirmEnablingTagPolicy: 'Are you sure you want to add TagPolicy to the list of enabled MRF policies?', enableTagPolicySuccessMessage: 'MRF TagPolicy was enabled', customTags: 'Custom Tags', - defaultTags: 'Default Tags' + defaultTags: 'Default Tags', + tags: 'Tags' }, statuses: { statuses: 'Statuses', diff --git a/src/views/users/components/ModerationDropdown.vue b/src/views/users/components/ModerationDropdown.vue index 3f5e0eb4..450c8391 100644 --- a/src/views/users/components/ModerationDropdown.vue +++ b/src/views/users/components/ModerationDropdown.vue @@ -83,36 +83,39 @@ @click.native="disableMfa(user.nickname)"> {{ $t('users.disableMfa') }} + + {{ $t('users.tags') }}: + + class="select-tags" + @change="toggleTag($event, user)"> - {{ value }} - + v-for="option in defaultTags" + :value="option.tag" + :key="option.tag" + :label="option.label" + :class="{ 'active-tag': user.tags.includes(option.tag) }"> + {{ option.label }} - {{ item }} - + v-for="option in customTags" + :value="option.tag" + :key="option.tag" + :label="option.label" + :class="{ 'active-tag': user.tags.includes(option.tag) }" + class="capitalize"> + {{ option.label }} @@ -146,11 +149,6 @@ export default { default: '' } }, - data() { - return { - selectedTags: [] - } - }, computed: { actorType: { get() { @@ -166,18 +164,21 @@ export default { } }, customTags() { - return this.$store.state.users.tags.filter(tag => !Object.keys(this.mapTags).includes(tag)) + return this.$store.state.users.tags + .filter(tag => !Object.keys(this.mapTags).includes(tag)) + .map(tag => { + return { tag, label: tag.charAt(0).toUpperCase() + tag.slice(1) } + }) }, defaultTags() { const tagsByType = this.user.local ? Object.keys(this.mapTags) : Object.keys(this.mapRemoteTags) return tagsByType.filter(tag => this.$store.state.users.tags.includes(tag)) - .reduce((acc, el) => { + .map(tag => { if (this.user.local) { - acc[el] = this.mapTags[el] + return { tag, label: this.mapTags[tag] } } else { - acc[el] = this.mapRemoteTags[el] + return { tag, label: this.mapRemoteTags[tag] } } - return acc }, {}) }, isDesktop() { @@ -203,6 +204,9 @@ export default { 'mrf_tag:disable-any-subscription': 'Disable any subscription' } }, + selectedTags() { + return this.user.tags + }, tagPolicyEnabled() { return this.$store.state.users.mrfPolicies.includes('Pleroma.Web.ActivityPub.MRF.TagPolicy') } @@ -295,10 +299,10 @@ export default { ? this.$store.dispatch('ActivateUsers', { users: [user], _userId: user.id }) : this.$store.dispatch('DeactivateUsers', { users: [user], _userId: user.id }) }, - toggleTag(user, tag) { - user.tags.includes(tag) - ? this.$store.dispatch('RemoveTag', { users: [user], tag, _userId: user.id, _statusId: this.statusId }) - : this.$store.dispatch('AddTag', { users: [user], tag, _userId: user.id, _statusId: this.statusId }) + toggleTag(tags, user) { + tags.length > user.tags.length + ? this.$store.dispatch('AddTag', { users: [user], tag: tags.filter(tag => !user.tags.includes(tag))[0] }) + : this.$store.dispatch('RemoveTag', { users: [user], tag: user.tags.filter(tag => !tags.includes(tag))[0] }) }, toggleUserRight(user, right) { user.roles[right]