mirror of
https://github.com/jwinterm/modoboa.git
synced 2026-10-17 05:41:25 +02:00
Improved Resources and role selection for accounts
This commit is contained in:
@@ -11,7 +11,7 @@
|
||||
@create="submit"
|
||||
>
|
||||
<template v-slot:form.role="{ step }">
|
||||
<account-role-form :ref="`form_${step}`" v-model="account.role" :account="account" />
|
||||
<account-role-form :ref="`form_${step}`" v-model="account.role" :account="account" :authUserRole="authUser.role" />
|
||||
</template>
|
||||
<template v-slot:form.identification="{ step }">
|
||||
<account-general-form v-if="step >= 2" :ref="`form_${step}`" v-model="account" />
|
||||
@@ -50,6 +50,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { mapGetters } from 'vuex'
|
||||
import { bus } from '@/main'
|
||||
import accounts from '@/api/accounts'
|
||||
import AccountAliasForm from './AccountAliasForm'
|
||||
@@ -70,6 +71,9 @@ export default {
|
||||
needsMailbox () {
|
||||
return this.account.role !== 'SuperAdmins' || (this.account.username && this.account.username.indexOf('@') !== -1)
|
||||
},
|
||||
...mapGetters({
|
||||
authUser: 'auth/authUser'
|
||||
}),
|
||||
summarySections () {
|
||||
const result = [
|
||||
{
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
</v-row>
|
||||
</v-expansion-panel-header>
|
||||
<v-expansion-panel-content>
|
||||
<account-role-form ref="roleForm" v-model="editedAccount.role" :account="editedAccount" />
|
||||
<account-role-form ref="roleForm" v-model="editedAccount.role" :account="editedAccount" :authUserRole="authUser.role"/>
|
||||
</v-expansion-panel-content>
|
||||
</v-expansion-panel>
|
||||
<v-expansion-panel>
|
||||
@@ -137,15 +137,37 @@
|
||||
<v-expansion-panel
|
||||
v-if="limitsConfig.params && limitsConfig.params.enable_admin_limits && account.role !== 'SimpleUsers' && account.role !== 'SuperAdmins'"
|
||||
>
|
||||
<v-expansion-panel-header>
|
||||
<v-expansion-panel-header v-slot="{ open }">
|
||||
<v-row no-gutters>
|
||||
<v-col cols="4">
|
||||
<translate>Resources</translate>
|
||||
</v-col>
|
||||
<v-col
|
||||
cols="8"
|
||||
class="text--secondary"
|
||||
>
|
||||
<v-fade-transition leave-absolute>
|
||||
<span v-if="open"></span>
|
||||
<v-row
|
||||
v-else
|
||||
no-gutters
|
||||
style="width: 100%"
|
||||
>
|
||||
<template v-if="account.resources != undefined && account.resources.length == 2">
|
||||
<v-col cols="6">
|
||||
<translate class="mr-2">Mailbox: </translate> <translate>Number of allowed mailbox: </translate> {{ account.resources[0].max_value}}
|
||||
</v-col>
|
||||
<v-col cols="6">
|
||||
<translate class="mr-2">Mailbox aliases: </translate> <translate>Number of allowed mailbox aliases: </translate> {{ account.resources[1].max_value}}
|
||||
</v-col>
|
||||
</template>
|
||||
</v-row>
|
||||
</v-fade-transition>
|
||||
</v-col>
|
||||
</v-row>
|
||||
</v-expansion-panel-header>
|
||||
<v-expansion-panel-content>
|
||||
<resources-form ref="resourcesForm" :resources="editedAccount.resources" />
|
||||
<resources-form ref="resourcesForm" v-model="editedAccount.resources" />
|
||||
</v-expansion-panel-content>
|
||||
</v-expansion-panel>
|
||||
</v-expansion-panels>
|
||||
@@ -161,6 +183,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { mapGetters } from 'vuex'
|
||||
import _isEmpty from 'lodash/isEmpty'
|
||||
import { bus } from '@/main'
|
||||
import accounts from '@/api/accounts'
|
||||
@@ -183,7 +206,10 @@ export default {
|
||||
computed: {
|
||||
usernameIsEmail () {
|
||||
return this.editedAccount.username && this.editedAccount.username.indexOf('@') !== -1
|
||||
}
|
||||
},
|
||||
...mapGetters({
|
||||
authUser: 'auth/authUser'
|
||||
})
|
||||
},
|
||||
data () {
|
||||
return {
|
||||
|
||||
@@ -34,7 +34,7 @@ export default {
|
||||
components: {
|
||||
ChoiceField
|
||||
},
|
||||
props: ['value', 'account'],
|
||||
props: ['value', 'account', 'role', 'authUserRole'],
|
||||
computed: {
|
||||
roleLabel () {
|
||||
const role = this.accountRoles.find(role => role.value === this.account.role)
|
||||
@@ -43,6 +43,17 @@ export default {
|
||||
roleHelp () {
|
||||
const role = this.accountRoles.find(role => role.value === this.account.role)
|
||||
return role !== undefined ? role.help : ''
|
||||
},
|
||||
accountRoles () {
|
||||
if (this.authUserRole === 'SuperAdmins') {
|
||||
return [...this.domainAdminsRole, ...this.resellerRole, ...this.simpleUserRole, ...this.superAdminsRole]
|
||||
} else if (this.authUserRole === 'DomainAdmins') {
|
||||
return this.simpleUserRole
|
||||
} else if (this.authUserRole === 'Resellers') {
|
||||
return [...this.domainAdminsRole, ...this.simpleUserRole]
|
||||
} else {
|
||||
return []
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
@@ -50,22 +61,28 @@ export default {
|
||||
},
|
||||
data () {
|
||||
return {
|
||||
accountRoles: [
|
||||
{
|
||||
label: this.$gettext('Domain administrator'),
|
||||
value: 'DomainAdmins',
|
||||
help: this.$gettext('A user with privileges on one or more domain. He will be allowed to administer mailboxes and he can also have a mailbox.')
|
||||
},
|
||||
{
|
||||
label: this.$gettext('Reseller'),
|
||||
value: 'Resellers',
|
||||
help: this.$gettext('help')
|
||||
},
|
||||
simpleUserRole: [
|
||||
{
|
||||
label: this.$gettext('Simple user'),
|
||||
value: 'SimpleUsers',
|
||||
help: this.$gettext('A user with no privileges but with a mailbox. He will be allowed to use all end-user features: webmail, calendar, contacts, filters.')
|
||||
},
|
||||
}
|
||||
],
|
||||
domainAdminsRole: [
|
||||
{
|
||||
label: this.$gettext('Domain administrator'),
|
||||
value: 'DomainAdmins',
|
||||
help: this.$gettext('A user with privileges on one or more domain. He will be allowed to administer mailboxes and he can also have a mailbox.')
|
||||
}
|
||||
],
|
||||
resellerRole: [
|
||||
{
|
||||
label: this.$gettext('Reseller'),
|
||||
value: 'Resellers',
|
||||
help: this.$gettext('help')
|
||||
}
|
||||
],
|
||||
superAdminsRole: [
|
||||
{
|
||||
label: this.$gettext('Super administrator'),
|
||||
value: 'SuperAdmins',
|
||||
|
||||
Reference in New Issue
Block a user