Add new tag to selected user when creating a new tag

This commit is contained in:
Angelina Filippova 2020-09-25 20:56:48 +03:00
parent 36239cd16f
commit d008cbdfc7
3 changed files with 20 additions and 9 deletions

View file

@ -282,7 +282,7 @@ export default {
enableTagPolicy: 'Enable MRF TagPolicy to manage user tags', enableTagPolicy: 'Enable MRF TagPolicy to manage user tags',
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',
createCustomTag: 'Create custom tag', createCustomTag: 'Create custom tag and add it to user',
moderateTags: 'Moderate Tags' moderateTags: 'Moderate Tags'
}, },
statuses: { statuses: {

View file

@ -115,7 +115,7 @@
<el-dropdown-item <el-dropdown-item
v-if="user.local && tagPolicyEnabled" v-if="user.local && tagPolicyEnabled"
icon="el-icon-plus" icon="el-icon-plus"
@click.native="$emit('open-custom-tag-dialog')"> @click.native="$emit('open-custom-tag-dialog', user)">
{{ $t('users.createCustomTag') }} {{ $t('users.createCustomTag') }}
</el-dropdown-item> </el-dropdown-item>
</el-collapse-item> </el-collapse-item>

View file

@ -118,7 +118,7 @@
<el-dialog <el-dialog
:visible.sync="createCustomTagDialogOpen" :visible.sync="createCustomTagDialogOpen"
:show-close="false" :show-close="false"
:title="$t('users.createCustomTag')" :title="`${$t('users.createCustomTag')} ${customTagUser.nickname}`"
@open="resetForm"> @open="resetForm">
<el-form ref="customTagForm" :model="customTagForm" :label-width="isDesktop ? '120px' : '85px'"> <el-form ref="customTagForm" :model="customTagForm" :label-width="isDesktop ? '120px' : '85px'">
<el-form-item :label="$t('users.name')" prop="name"> <el-form-item :label="$t('users.name')" prop="name">
@ -127,11 +127,11 @@
<el-form-item :label="$t('users.label')" prop="label"> <el-form-item :label="$t('users.label')" prop="label">
<el-input v-model="customTagForm.label" name="label"/> <el-input v-model="customTagForm.label" name="label"/>
</el-form-item> </el-form-item>
<span slot="footer">
<el-button @click="closeCustomTagDialog">{{ $t('users.cancel') }}</el-button>
<el-button type="primary" @click="addCustomTag('customTagForm')">{{ $t('users.create') }}</el-button>
</span>
</el-form> </el-form>
<span slot="footer">
<el-button @click="closeCustomTagDialog">{{ $t('users.cancel') }}</el-button>
<el-button type="primary" @click="addCustomTag">{{ $t('users.create') }}</el-button>
</span>
</el-dialog> </el-dialog>
<div v-if="!loading" class="pagination"> <div v-if="!loading" class="pagination">
<el-pagination <el-pagination
@ -181,7 +181,8 @@ export default {
customTagForm: { customTagForm: {
name: '', name: '',
label: '' label: ''
} },
customTagUser: {}
} }
}, },
computed: { computed: {
@ -230,6 +231,15 @@ export default {
this.$store.dispatch('ClearUsersState') this.$store.dispatch('ClearUsersState')
}, },
methods: { methods: {
addCustomTag() {
this.$store.dispatch('AddTag', {
users: [this.customTagUser],
tag: this.customTagForm.name,
_userId: this.customTagUser.id,
_statusId: this.statusId
})
this.createCustomTagDialogOpen = false
},
clearSelection() { clearSelection() {
this.$refs.usersTable.clearSelection() this.$refs.usersTable.clearSelection()
}, },
@ -263,7 +273,8 @@ export default {
handleSelectionChange(value) { handleSelectionChange(value) {
this.$data.selectedUsers = value this.$data.selectedUsers = value
}, },
openCustomTagDialog() { openCustomTagDialog(user) {
this.customTagUser = user
this.createCustomTagDialogOpen = true this.createCustomTagDialogOpen = true
}, },
openResetPasswordDialog() { openResetPasswordDialog() {