2018-09-14 19:19:50 +02:00
|
|
|
<template>
|
2018-12-25 16:03:51 +01:00
|
|
|
<div class="fullpage">
|
|
|
|
<a class="close" @click="back()">
|
|
|
|
<icon :icon="['far', 'times-circle']">
|
|
|
|
</icon>
|
|
|
|
</a>
|
2018-09-14 19:19:50 +02:00
|
|
|
<h3>Create a new team</h3>
|
2018-12-25 16:03:51 +01:00
|
|
|
<form @submit.prevent="newTeam" @keyup.esc="back()">
|
2018-09-14 19:19:50 +02:00
|
|
|
<div class="field is-grouped">
|
2019-03-02 11:25:10 +01:00
|
|
|
<p class="control is-expanded" v-bind:class="{ 'is-loading': teamService.loading}">
|
2020-04-26 18:32:34 +02:00
|
|
|
<input
|
|
|
|
v-focus
|
|
|
|
class="input"
|
|
|
|
:class="{ 'disabled': teamService.loading}" v-model="team.name"
|
|
|
|
type="text"
|
|
|
|
placeholder="The team's name goes here..."/>
|
2018-09-14 19:19:50 +02:00
|
|
|
</p>
|
|
|
|
<p class="control">
|
2018-12-25 16:03:51 +01:00
|
|
|
<button type="submit" class="button is-success noshadow">
|
2018-09-14 19:19:50 +02:00
|
|
|
<span class="icon is-small">
|
|
|
|
<icon icon="plus"/>
|
|
|
|
</span>
|
|
|
|
Add
|
|
|
|
</button>
|
|
|
|
</p>
|
|
|
|
</div>
|
2020-06-17 19:10:48 +02:00
|
|
|
<p class="help is-danger" v-if="showError && team.name === ''">
|
|
|
|
Please specify a name.
|
2020-04-26 18:32:34 +02:00
|
|
|
</p>
|
2018-09-14 19:19:50 +02:00
|
|
|
</form>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import router from '../../router'
|
2019-03-02 11:25:10 +01:00
|
|
|
import TeamModel from '../../models/team'
|
|
|
|
import TeamService from '../../services/team'
|
2020-05-08 20:43:51 +02:00
|
|
|
import {IS_FULLPAGE} from '../../store/mutation-types'
|
2018-09-14 19:19:50 +02:00
|
|
|
|
|
|
|
export default {
|
2020-06-17 19:10:48 +02:00
|
|
|
name: 'NewTeam',
|
2018-09-14 19:19:50 +02:00
|
|
|
data() {
|
|
|
|
return {
|
2019-03-02 11:25:10 +01:00
|
|
|
teamService: TeamService,
|
|
|
|
team: TeamModel,
|
2020-04-26 18:32:34 +02:00
|
|
|
showError: false,
|
2018-09-14 19:19:50 +02:00
|
|
|
}
|
|
|
|
},
|
2018-12-25 16:03:51 +01:00
|
|
|
created() {
|
2019-03-02 11:25:10 +01:00
|
|
|
this.teamService = new TeamService()
|
2019-10-26 14:19:56 +02:00
|
|
|
this.team = new TeamModel()
|
2020-05-08 20:43:51 +02:00
|
|
|
this.$store.commit(IS_FULLPAGE, true)
|
2018-12-25 16:03:51 +01:00
|
|
|
},
|
2020-07-07 22:07:13 +02:00
|
|
|
mounted() {
|
|
|
|
this.setTitle('Create a new Team')
|
|
|
|
},
|
2018-09-14 19:19:50 +02:00
|
|
|
methods: {
|
|
|
|
newTeam() {
|
2020-04-26 18:32:34 +02:00
|
|
|
|
2020-06-17 19:10:48 +02:00
|
|
|
if (this.team.name === '') {
|
2020-04-26 18:32:34 +02:00
|
|
|
this.showError = true
|
|
|
|
return
|
|
|
|
}
|
|
|
|
this.showError = false
|
|
|
|
|
2019-03-02 11:25:10 +01:00
|
|
|
this.teamService.create(this.team)
|
2018-09-14 19:19:50 +02:00
|
|
|
.then(response => {
|
2020-06-17 22:24:37 +02:00
|
|
|
router.push({name: 'teams.edit', params: {id: response.id}})
|
2020-01-30 22:47:08 +01:00
|
|
|
this.success({message: 'The team was successfully created.'}, this)
|
2018-09-14 19:19:50 +02:00
|
|
|
})
|
|
|
|
.catch(e => {
|
2020-01-30 22:47:08 +01:00
|
|
|
this.error(e, this)
|
2018-09-14 19:19:50 +02:00
|
|
|
})
|
|
|
|
},
|
2018-12-25 16:03:51 +01:00
|
|
|
back() {
|
|
|
|
router.go(-1)
|
|
|
|
},
|
2018-09-14 19:19:50 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|