This repository has been archived on 2024-02-08. You can view files and clone it, but cannot push or open issues or pull requests.
frontend/src/views/teams/NewTeam.vue

69 lines
1.5 KiB
Vue
Raw Normal View History

2018-09-14 17:19:50 +00:00
<template>
<create-edit
:title="$t('team.create.title')"
@create="newTeam()"
2021-10-17 15:28:44 +00:00
: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': teamService.loading }"
>
<input
:class="{ 'disabled': teamService.loading }"
class="input"
id="teamName"
:placeholder="$t('team.attributes.namePlaceholder')"
type="text"
v-focus
v-model="team.name"
@keyup.enter="newTeam"
/>
2018-09-14 17:19:50 +00:00
</div>
</div>
<p class="help is-danger" v-if="showError && team.name === ''">
{{ $t('team.attributes.nameRequired') }}
</p>
</create-edit>
2018-09-14 17:19:50 +00:00
</template>
2022-02-15 12:07:34 +00:00
<script lang="ts">
import TeamModel from '../../models/team'
import TeamService from '../../services/team'
import CreateEdit from '@/components/misc/create-edit.vue'
2018-09-14 17:19:50 +00:00
export default {
name: 'NewTeam',
data() {
return {
teamService: new TeamService(),
team: new TeamModel(),
showError: false,
}
},
components: {
CreateEdit,
},
mounted() {
this.setTitle(this.$t('team.create.title'))
},
methods: {
async newTeam() {
if (this.team.name === '') {
this.showError = true
return
2018-09-14 17:19:50 +00:00
}
this.showError = false
const response = await this.teamService.create(this.team)
this.$router.push({
name: 'teams.edit',
params: { id: response.id },
})
this.$message.success({message: this.$t('team.create.success') })
2018-09-14 17:19:50 +00:00
},
},
}
2018-09-14 17:19:50 +00:00
</script>