forked from AkkomaGang/admin-fe
Fix adding and removing tags after implementing select
This commit is contained in:
parent
3711248435
commit
4a1c7c2841
2 changed files with 37 additions and 32 deletions
|
@ -283,7 +283,8 @@ export default {
|
||||||
confirmEnablingTagPolicy: 'Are you sure you want to add TagPolicy to the list of enabled MRF policies?',
|
confirmEnablingTagPolicy: 'Are you sure you want to add TagPolicy to the list of enabled MRF policies?',
|
||||||
enableTagPolicySuccessMessage: 'MRF TagPolicy was enabled',
|
enableTagPolicySuccessMessage: 'MRF TagPolicy was enabled',
|
||||||
customTags: 'Custom Tags',
|
customTags: 'Custom Tags',
|
||||||
defaultTags: 'Default Tags'
|
defaultTags: 'Default Tags',
|
||||||
|
tags: 'Tags'
|
||||||
},
|
},
|
||||||
statuses: {
|
statuses: {
|
||||||
statuses: 'Statuses',
|
statuses: 'Statuses',
|
||||||
|
|
|
@ -83,36 +83,39 @@
|
||||||
@click.native="disableMfa(user.nickname)">
|
@click.native="disableMfa(user.nickname)">
|
||||||
{{ $t('users.disableMfa') }}
|
{{ $t('users.disableMfa') }}
|
||||||
</el-dropdown-item>
|
</el-dropdown-item>
|
||||||
|
<el-dropdown-item
|
||||||
|
v-if="tagPolicyEnabled">
|
||||||
|
{{ $t('users.tags') }}:
|
||||||
|
</el-dropdown-item>
|
||||||
<el-select
|
<el-select
|
||||||
v-if="tagPolicyEnabled"
|
v-if="tagPolicyEnabled"
|
||||||
v-model="selectedTags"
|
:value="selectedTags"
|
||||||
multiple
|
multiple
|
||||||
filterable
|
filterable
|
||||||
allow-create
|
allow-create
|
||||||
placeholder="Select Tags"
|
placeholder="Select Tags"
|
||||||
size="small"
|
size="small"
|
||||||
class="select-tags">
|
class="select-tags"
|
||||||
|
@change="toggleTag($event, user)">
|
||||||
<el-option-group :label="$t('users.defaultTags')">
|
<el-option-group :label="$t('users.defaultTags')">
|
||||||
<el-option
|
<el-option
|
||||||
v-for="(value, name) in defaultTags"
|
v-for="option in defaultTags"
|
||||||
:key="name"
|
:value="option.tag"
|
||||||
:value="name"
|
:key="option.tag"
|
||||||
:class="{ 'active-tag': user.tags.includes(name) }"
|
:label="option.label"
|
||||||
@click.native="toggleTag(user, name)">
|
:class="{ 'active-tag': user.tags.includes(option.tag) }">
|
||||||
{{ value }}
|
{{ option.label }}
|
||||||
<i v-if="user.tags.includes(name)" class="el-icon-check"/>
|
|
||||||
</el-option>
|
</el-option>
|
||||||
</el-option-group>
|
</el-option-group>
|
||||||
<el-option-group :label="$t('users.customTags')">
|
<el-option-group :label="$t('users.customTags')">
|
||||||
<el-option
|
<el-option
|
||||||
v-for="item in customTags"
|
v-for="option in customTags"
|
||||||
:key="item"
|
:value="option.tag"
|
||||||
:value="item"
|
:key="option.tag"
|
||||||
:class="{ 'active-tag': user.tags.includes(item) }"
|
:label="option.label"
|
||||||
class="capitalize"
|
:class="{ 'active-tag': user.tags.includes(option.tag) }"
|
||||||
@click.native="toggleTag(user, item)">
|
class="capitalize">
|
||||||
{{ item }}
|
{{ option.label }}
|
||||||
<i v-if="user.tags.includes(item)" class="el-icon-check"/>
|
|
||||||
</el-option>
|
</el-option>
|
||||||
</el-option-group>
|
</el-option-group>
|
||||||
</el-select>
|
</el-select>
|
||||||
|
@ -146,11 +149,6 @@ export default {
|
||||||
default: ''
|
default: ''
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
selectedTags: []
|
|
||||||
}
|
|
||||||
},
|
|
||||||
computed: {
|
computed: {
|
||||||
actorType: {
|
actorType: {
|
||||||
get() {
|
get() {
|
||||||
|
@ -166,18 +164,21 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
customTags() {
|
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() {
|
defaultTags() {
|
||||||
const tagsByType = this.user.local ? Object.keys(this.mapTags) : Object.keys(this.mapRemoteTags)
|
const tagsByType = this.user.local ? Object.keys(this.mapTags) : Object.keys(this.mapRemoteTags)
|
||||||
return tagsByType.filter(tag => this.$store.state.users.tags.includes(tag))
|
return tagsByType.filter(tag => this.$store.state.users.tags.includes(tag))
|
||||||
.reduce((acc, el) => {
|
.map(tag => {
|
||||||
if (this.user.local) {
|
if (this.user.local) {
|
||||||
acc[el] = this.mapTags[el]
|
return { tag, label: this.mapTags[tag] }
|
||||||
} else {
|
} else {
|
||||||
acc[el] = this.mapRemoteTags[el]
|
return { tag, label: this.mapRemoteTags[tag] }
|
||||||
}
|
}
|
||||||
return acc
|
|
||||||
}, {})
|
}, {})
|
||||||
},
|
},
|
||||||
isDesktop() {
|
isDesktop() {
|
||||||
|
@ -203,6 +204,9 @@ export default {
|
||||||
'mrf_tag:disable-any-subscription': 'Disable any subscription'
|
'mrf_tag:disable-any-subscription': 'Disable any subscription'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
selectedTags() {
|
||||||
|
return this.user.tags
|
||||||
|
},
|
||||||
tagPolicyEnabled() {
|
tagPolicyEnabled() {
|
||||||
return this.$store.state.users.mrfPolicies.includes('Pleroma.Web.ActivityPub.MRF.TagPolicy')
|
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('ActivateUsers', { users: [user], _userId: user.id })
|
||||||
: this.$store.dispatch('DeactivateUsers', { users: [user], _userId: user.id })
|
: this.$store.dispatch('DeactivateUsers', { users: [user], _userId: user.id })
|
||||||
},
|
},
|
||||||
toggleTag(user, tag) {
|
toggleTag(tags, user) {
|
||||||
user.tags.includes(tag)
|
tags.length > user.tags.length
|
||||||
? this.$store.dispatch('RemoveTag', { users: [user], tag, _userId: user.id, _statusId: this.statusId })
|
? this.$store.dispatch('AddTag', { users: [user], tag: tags.filter(tag => !user.tags.includes(tag))[0] })
|
||||||
: this.$store.dispatch('AddTag', { users: [user], tag, _userId: user.id, _statusId: this.statusId })
|
: this.$store.dispatch('RemoveTag', { users: [user], tag: user.tags.filter(tag => !tags.includes(tag))[0] })
|
||||||
},
|
},
|
||||||
toggleUserRight(user, right) {
|
toggleUserRight(user, right) {
|
||||||
user.roles[right]
|
user.roles[right]
|
||||||
|
|
Loading…
Reference in a new issue