mirror of
https://github.com/YunoHost/yunohost-admin.git
synced 2024-09-03 20:06:15 +02:00
refactor: rework async UserCreate
This commit is contained in:
parent
f7c563afb2
commit
1e2a1e2663
1 changed files with 8 additions and 14 deletions
|
@ -6,7 +6,6 @@ import { useRouter } from 'vue-router'
|
||||||
import api from '@/api'
|
import api from '@/api'
|
||||||
import { useDomains, useUsersAndGroups } from '@/composables/data'
|
import { useDomains, useUsersAndGroups } from '@/composables/data'
|
||||||
import { useForm } from '@/composables/form'
|
import { useForm } from '@/composables/form'
|
||||||
import { useInitialQueries } from '@/composables/useInitialQueries'
|
|
||||||
import {
|
import {
|
||||||
alphalownumdot_,
|
alphalownumdot_,
|
||||||
minLength,
|
minLength,
|
||||||
|
@ -20,13 +19,12 @@ import type { FieldProps, FormFieldDict } from '@/types/form'
|
||||||
|
|
||||||
const { t } = useI18n()
|
const { t } = useI18n()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const { loading } = useInitialQueries(
|
|
||||||
[
|
await api.fetchAll([
|
||||||
{ uri: 'users', cachePath: 'users' },
|
{ uri: 'users', cachePath: 'users' },
|
||||||
{ uri: 'domains', cachePath: 'domains' },
|
{ uri: 'domains', cachePath: 'domains' },
|
||||||
],
|
])
|
||||||
{ onQueriesResponse },
|
|
||||||
)
|
|
||||||
const { usernames } = useUsersAndGroups()
|
const { usernames } = useUsersAndGroups()
|
||||||
const { domainsAsChoices, mainDomain } = useDomains()
|
const { domainsAsChoices, mainDomain } = useDomains()
|
||||||
|
|
||||||
|
@ -105,10 +103,6 @@ const fields = {
|
||||||
|
|
||||||
const { v, onSubmit } = useForm(form, fields)
|
const { v, onSubmit } = useForm(form, fields)
|
||||||
|
|
||||||
function onQueriesResponse() {
|
|
||||||
form.value.domain = mainDomain.value
|
|
||||||
}
|
|
||||||
|
|
||||||
const onUserCreate = onSubmit(async (onError) => {
|
const onUserCreate = onSubmit(async (onError) => {
|
||||||
const data = await formatForm(form)
|
const data = await formatForm(form)
|
||||||
api
|
api
|
||||||
|
@ -126,7 +120,7 @@ const onUserCreate = onSubmit(async (onError) => {
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<ViewBase :loading="loading" skeleton="CardFormSkeleton">
|
<div>
|
||||||
<CardForm
|
<CardForm
|
||||||
v-model="form"
|
v-model="form"
|
||||||
icon="user-plus"
|
icon="user-plus"
|
||||||
|
@ -145,5 +139,5 @@ const onUserCreate = onSubmit(async (onError) => {
|
||||||
</BInputGroup>
|
</BInputGroup>
|
||||||
</template>
|
</template>
|
||||||
</CardForm>
|
</CardForm>
|
||||||
</ViewBase>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
Loading…
Add table
Reference in a new issue