59 lines
1.3 KiB
Vue
59 lines
1.3 KiB
Vue
<template>
|
|
<create-edit
|
|
:title="$t('team.create.title')"
|
|
@create="newTeam()"
|
|
:primary-disabled="team.name === ''"
|
|
>
|
|
<div class="field">
|
|
<label class="label" for="teamName">{{ $t('team.attributes.name') }}</label>
|
|
<div
|
|
class="control is-expanded"
|
|
:class="{ 'is-loading': teamServiceLoading }"
|
|
>
|
|
<input
|
|
:class="{ 'disabled': teamServiceLoading }"
|
|
class="input"
|
|
id="teamName"
|
|
:placeholder="$t('team.attributes.namePlaceholder')"
|
|
type="text"
|
|
v-focus
|
|
v-model="team.name"
|
|
@keyup.enter="newTeam"
|
|
/>
|
|
</div>
|
|
</div>
|
|
<p class="help is-danger" v-if="showError && team.name === ''">
|
|
{{ $t('team.attributes.nameRequired') }}
|
|
</p>
|
|
</create-edit>
|
|
</template>
|
|
|
|
<script setup>
|
|
import { ref } from 'vue'
|
|
import { useI18n } from 'vue-i18n'
|
|
|
|
import CreateEdit from '@/components/misc/create-edit.vue'
|
|
|
|
import { useTeam } from '@/stores/teams'
|
|
import { useTitle } from '@/composables/useTitle'
|
|
|
|
const { t } = useI18n()
|
|
useTitle(() => t('team.create.title'))
|
|
|
|
const showError = ref(false)
|
|
|
|
const {teamServiceLoading, team, newTeam: newTeamAction} = useTeam()
|
|
|
|
async function newTeam() {
|
|
try {
|
|
await newTeamAction()
|
|
} catch(e) {
|
|
if (e.message === t('team.attributes.nameRequired')) {
|
|
showError.value = true
|
|
} else {
|
|
throw e
|
|
}
|
|
}
|
|
}
|
|
</script>
|