Move new team to new create component

This commit is contained in:
kolaente 2021-01-21 21:31:01 +01:00
parent 5708476ce5
commit cd11b205ba
Signed by: konrad
GPG Key ID: F40E70337AB24C9B

View File

@ -1,38 +1,38 @@
<template> <template>
<div class="fullpage"> <create
<a @click="back()" class="close"> title="Create a new team"
<icon :icon="['far', 'times-circle']"> @create="newTeam()"
</icon> :create-disabled="team.name === ''"
</a> >
<h3>Create a new team</h3> <div class="field">
<form @keyup.esc="back()" @submit.prevent="newTeam"> <label class="label" for="teamName">Team Name</label>
<div class="field is-grouped"> <div
<p class="control is-expanded" v-bind:class="{ 'is-loading': teamService.loading}"> class="control is-expanded"
<input :class="{ 'is-loading': teamService.loading }"
:class="{ 'disabled': teamService.loading}" >
class="input" <input
placeholder="The team's name goes here..." type="text" :class="{ 'disabled': teamService.loading }"
v-focus class="input"
v-model="team.name"/> id="teamName"
</p> placeholder="The team's name goes here..."
<p class="control"> type="text"
<x-button :shadow="false" @click="newTeam" icon="plus"> v-focus
Add v-model="team.name"
</x-button> @keyup.enter="newTeam"
</p> />
</div> </div>
<p class="help is-danger" v-if="showError && team.name === ''"> </div>
Please specify a name. <p class="help is-danger" v-if="showError && team.name === ''">
</p> Please specify a name.
</form> </p>
</div> </create>
</template> </template>
<script> <script>
import router from '../../router' import router from '../../router'
import TeamModel from '../../models/team' import TeamModel from '../../models/team'
import TeamService from '../../services/team' import TeamService from '../../services/team'
import {IS_FULLPAGE} from '@/store/mutation-types' import Create from '@/components/misc/create'
export default { export default {
name: 'NewTeam', name: 'NewTeam',
@ -43,29 +43,37 @@ export default {
showError: false, showError: false,
} }
}, },
components: {
Create,
},
created() { created() {
this.teamService = new TeamService() this.teamService = new TeamService()
this.team = new TeamModel() this.team = new TeamModel()
this.$store.commit(IS_FULLPAGE, true)
}, },
mounted() { mounted() {
this.setTitle('Create a new Team') this.setTitle('Create a new Team')
}, },
methods: { methods: {
newTeam() { newTeam() {
if (this.team.name === '') { if (this.team.name === '') {
this.showError = true this.showError = true
return return
} }
this.showError = false this.showError = false
this.teamService.create(this.team) this.teamService
.then(response => { .create(this.team)
router.push({name: 'teams.edit', params: {id: response.id}}) .then((response) => {
this.success({message: 'The team was successfully created.'}, this) router.push({
name: 'teams.edit',
params: { id: response.id },
})
this.success(
{ message: 'The team was successfully created.' },
this
)
}) })
.catch(e => { .catch((e) => {
this.error(e, this) this.error(e, this)
}) })
}, },