mirror of
https://github.com/jwinterm/modoboa.git
synced 2026-12-02 12:13:54 +01:00
Added more actions on identities:
* create/edit/delete alias * edit/delete account
This commit is contained in:
@@ -0,0 +1,158 @@
|
||||
<template>
|
||||
<div class="d-flex justify-center inner">
|
||||
<v-stepper v-model="currentStep">
|
||||
<v-stepper-header class="align-center px-10">
|
||||
<v-img
|
||||
src="../../assets/Modoboa_RVB-BLEU-SANS.png"
|
||||
max-width="190"
|
||||
/>
|
||||
<v-stepper-step
|
||||
v-for="(step, index) in steps"
|
||||
:key="index"
|
||||
:complete="currentStep > index + 1" :step="index + 1">
|
||||
{{ step.title }}
|
||||
</v-stepper-step>
|
||||
<v-stepper-step :step="steps.length + 1">
|
||||
<translate>Summary</translate>
|
||||
</v-stepper-step>
|
||||
<v-btn icon @click="close">
|
||||
<v-icon color="primary" x-large>mdi-close</v-icon>
|
||||
</v-btn>
|
||||
</v-stepper-header>
|
||||
<v-stepper-items class="mt-4 d-flex justify-center">
|
||||
<v-stepper-content
|
||||
v-for="(step, index) in steps"
|
||||
:key="index"
|
||||
:step="index + 1"
|
||||
class="flex-grow-0"
|
||||
>
|
||||
<div class="mb-6 text-h5">
|
||||
<translate class="grey--text text--darken-1">{{ title }}</translate> /
|
||||
<translate>{{ step.title }}</translate>
|
||||
</div>
|
||||
<slot :name="`form.${step.name}`" v-bind:step="index + 1" />
|
||||
<div class="d-flex justify-end mt-4">
|
||||
<v-btn v-if="index + 1 > 1" @click="currentStep = index" class="mr-10" text>
|
||||
<translate>Back</translate>
|
||||
</v-btn>
|
||||
<v-btn
|
||||
color="primary"
|
||||
@click="goToNextStep(index + 1, index + 2)"
|
||||
large
|
||||
>
|
||||
<translate>Next</translate>
|
||||
</v-btn>
|
||||
</div>
|
||||
</v-stepper-content>
|
||||
<v-stepper-content :step="steps.length + 1" class="flex-grow-0">
|
||||
<div class="text-center text-h3"><translate>Summary</translate></div>
|
||||
<creation-summary
|
||||
:sections="summarySections"
|
||||
@modify-step="val => currentStep = val"
|
||||
>
|
||||
<template v-for="(_, slot) of $scopedSlots" v-slot:[slot]="scope">
|
||||
<slot :name="slot" v-bind="scope" />
|
||||
</template>
|
||||
</creation-summary>
|
||||
<div class="d-flex justify-center mt-8">
|
||||
<v-btn
|
||||
color="primary"
|
||||
@click="$emit('create')"
|
||||
large
|
||||
>
|
||||
<translate>Confirm and create</translate>
|
||||
</v-btn>
|
||||
</div>
|
||||
</v-stepper-content>
|
||||
</v-stepper-items>
|
||||
</v-stepper>
|
||||
<confirm-dialog ref="confirm" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import ConfirmDialog from '@/components/layout/ConfirmDialog'
|
||||
import CreationSummary from '@/components/tools/CreationSummary'
|
||||
|
||||
export default {
|
||||
components: {
|
||||
ConfirmDialog,
|
||||
CreationSummary
|
||||
},
|
||||
props: {
|
||||
title: String,
|
||||
steps: Array,
|
||||
summarySections: Array,
|
||||
formObserverGetter: Function,
|
||||
validateObject: Function
|
||||
},
|
||||
data () {
|
||||
return {
|
||||
currentStep: 1
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
async close (withConfirm) {
|
||||
if (withConfirm) {
|
||||
const confirm = await this.$refs.confirm.open(
|
||||
this.$gettext('Warning'),
|
||||
this.$gettext('If you close this form now, your modifications won\'t be saved. Do you confirm?'),
|
||||
{
|
||||
color: 'error'
|
||||
}
|
||||
)
|
||||
if (!confirm) {
|
||||
return
|
||||
}
|
||||
}
|
||||
this.$emit('close')
|
||||
this.currentStep = 1
|
||||
this.steps.forEach((item, index) => {
|
||||
const observer = this.formObserverGetter(index + 1)
|
||||
if (observer !== undefined) {
|
||||
observer.reset()
|
||||
}
|
||||
})
|
||||
},
|
||||
async goToNextStep (current, next) {
|
||||
const observer = this.formObserverGetter(current)
|
||||
if (observer !== undefined) {
|
||||
const valid = await observer.validate()
|
||||
if (!valid) {
|
||||
return
|
||||
}
|
||||
try {
|
||||
await this.validateObject()
|
||||
} catch (error) {
|
||||
observer.setErrors(error.response.data)
|
||||
return
|
||||
}
|
||||
}
|
||||
this.currentStep = next
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
.inner {
|
||||
background-color: #fff;
|
||||
}
|
||||
.v-stepper {
|
||||
width: 100%;
|
||||
overflow: auto;
|
||||
|
||||
&__content {
|
||||
width: 60%;
|
||||
}
|
||||
|
||||
&__items {
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
&__wrapper {
|
||||
padding: 0 10px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -4,6 +4,7 @@
|
||||
ref="input"
|
||||
v-model="input"
|
||||
outlined
|
||||
dense
|
||||
v-bind="$attrs"
|
||||
v-on="$listeners"
|
||||
@input="update"
|
||||
@@ -31,7 +32,13 @@
|
||||
import { mapGetters } from 'vuex'
|
||||
|
||||
export default {
|
||||
props: ['value'],
|
||||
props: {
|
||||
value: String,
|
||||
allowAdd: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
...mapGetters({
|
||||
domains: 'identities/domains'
|
||||
@@ -75,6 +82,8 @@ export default {
|
||||
// on enter or tab
|
||||
if (this.filteredDomains.length > 0) {
|
||||
this.selectDomain(this.filteredDomains[this.selectionIndex])
|
||||
} else if (this.allowAdd) {
|
||||
this.selectDomain()
|
||||
}
|
||||
e.preventDefault()
|
||||
} else if (keyCode === 27) {
|
||||
@@ -100,7 +109,9 @@ export default {
|
||||
}
|
||||
},
|
||||
selectDomain (domain) {
|
||||
this.input = this.input.split('@')[0] + '@' + domain.name
|
||||
if (domain !== undefined) {
|
||||
this.input = this.input.split('@')[0] + '@' + domain.name
|
||||
}
|
||||
this.showMenu = false
|
||||
this.$emit('input', this.input)
|
||||
this.$emit('domain-selected')
|
||||
@@ -108,7 +119,11 @@ export default {
|
||||
update (value) {
|
||||
if (this.input.indexOf('@') !== -1) {
|
||||
this.domainSearch = this.input.split('@')[1]
|
||||
this.showMenu = true
|
||||
if (this.allowAdd) {
|
||||
this.showMenu = this.filteredDomains.length > 0
|
||||
} else {
|
||||
this.showMenu = true
|
||||
}
|
||||
} else {
|
||||
this.showMenu = false
|
||||
}
|
||||
@@ -132,6 +147,11 @@ export default {
|
||||
this.$nextTick(() => {
|
||||
this.updateMinWidthProperty()
|
||||
})
|
||||
},
|
||||
watch: {
|
||||
value (newValue) {
|
||||
this.input = newValue
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user