2018-09-14 19:19:50 +02:00
|
|
|
<template>
|
2021-01-30 17:17:04 +01:00
|
|
|
<create-edit
|
2021-01-21 23:33:16 +01:00
|
|
|
title="Create a new team"
|
|
|
|
@create="newTeam()"
|
|
|
|
:create-disabled="team.name === ''"
|
|
|
|
>
|
|
|
|
<div class="field">
|
|
|
|
<label class="label" for="teamName">Team Name</label>
|
|
|
|
<div
|
|
|
|
class="control is-expanded"
|
|
|
|
:class="{ 'is-loading': teamService.loading }"
|
|
|
|
>
|
|
|
|
<input
|
|
|
|
:class="{ 'disabled': teamService.loading }"
|
|
|
|
class="input"
|
|
|
|
id="teamName"
|
|
|
|
placeholder="The team's name goes here..."
|
|
|
|
type="text"
|
|
|
|
v-focus
|
|
|
|
v-model="team.name"
|
|
|
|
@keyup.enter="newTeam"
|
|
|
|
/>
|
2018-09-14 19:19:50 +02:00
|
|
|
</div>
|
2021-01-21 23:33:16 +01:00
|
|
|
</div>
|
|
|
|
<p class="help is-danger" v-if="showError && team.name === ''">
|
|
|
|
Please specify a name.
|
|
|
|
</p>
|
2021-01-30 17:17:04 +01:00
|
|
|
</create-edit>
|
2018-09-14 19:19:50 +02:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2020-09-05 22:35:52 +02:00
|
|
|
import TeamModel from '../../models/team'
|
|
|
|
import TeamService from '../../services/team'
|
2021-01-30 17:17:04 +01:00
|
|
|
import CreateEdit from '@/components/misc/create-edit'
|
2018-09-14 19:19:50 +02:00
|
|
|
|
2020-09-05 22:35:52 +02:00
|
|
|
export default {
|
|
|
|
name: 'NewTeam',
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
teamService: TeamService,
|
|
|
|
team: TeamModel,
|
|
|
|
showError: false,
|
|
|
|
}
|
|
|
|
},
|
2021-01-21 23:33:16 +01:00
|
|
|
components: {
|
2021-01-30 17:17:04 +01:00
|
|
|
CreateEdit,
|
2021-01-21 23:33:16 +01:00
|
|
|
},
|
2020-09-05 22:35:52 +02:00
|
|
|
created() {
|
|
|
|
this.teamService = new TeamService()
|
|
|
|
this.team = new TeamModel()
|
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
this.setTitle('Create a new Team')
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
newTeam() {
|
|
|
|
if (this.team.name === '') {
|
|
|
|
this.showError = true
|
|
|
|
return
|
2018-09-14 19:19:50 +02:00
|
|
|
}
|
2020-09-05 22:35:52 +02:00
|
|
|
this.showError = false
|
|
|
|
|
2021-01-21 23:33:16 +01:00
|
|
|
this.teamService
|
|
|
|
.create(this.team)
|
|
|
|
.then((response) => {
|
2021-02-20 17:24:40 +01:00
|
|
|
this.$router.push({
|
2021-01-21 23:33:16 +01:00
|
|
|
name: 'teams.edit',
|
|
|
|
params: { id: response.id },
|
|
|
|
})
|
2021-06-22 22:07:57 +02:00
|
|
|
this.success({message: 'The team was successfully created.'})
|
2020-09-05 22:35:52 +02:00
|
|
|
})
|
2021-01-21 23:33:16 +01:00
|
|
|
.catch((e) => {
|
2021-06-22 22:07:57 +02:00
|
|
|
this.error(e)
|
2020-09-05 22:35:52 +02:00
|
|
|
})
|
2018-09-14 19:19:50 +02:00
|
|
|
},
|
2020-09-05 22:35:52 +02:00
|
|
|
},
|
|
|
|
}
|
2018-09-14 19:19:50 +02:00
|
|
|
</script>
|