Move creating new labels to new create component
This commit is contained in:
parent
cd11b205ba
commit
6e48753b71
|
@ -1,42 +1,39 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="fullpage">
|
<create
|
||||||
<a @click="back()" class="close">
|
title="Create a new label"
|
||||||
<icon :icon="['far', 'times-circle']"/>
|
@create="newLabel()"
|
||||||
</a>
|
:create-disabled="label.title === ''"
|
||||||
<h3>Create a new label</h3>
|
>
|
||||||
<form @keyup.esc="back()" @submit.prevent="newlabel">
|
<div class="field">
|
||||||
<div class="field is-grouped">
|
<label class="label" for="labelTitle">Label Title</label>
|
||||||
<p class="control is-expanded" v-bind:class="{ 'is-loading': labelService.loading }">
|
<div
|
||||||
<input
|
class="control is-expanded"
|
||||||
:class="{ 'disabled': labelService.loading }"
|
:class="{ 'is-loading': labelService.loading }"
|
||||||
class="input"
|
>
|
||||||
placeholder="The label title goes here..." type="text"
|
<input
|
||||||
v-focus
|
:class="{ disabled: labelService.loading }"
|
||||||
v-model="label.title"/>
|
class="input"
|
||||||
</p>
|
placeholder="The label title goes here..."
|
||||||
<p class="control">
|
type="text"
|
||||||
<x-button
|
id="labelTitle"
|
||||||
:shadow="false"
|
v-focus
|
||||||
icon="plus"
|
v-model="label.title"
|
||||||
@click="newlabel"
|
@keyup.enter="newLabel()"
|
||||||
>
|
/>
|
||||||
Add
|
|
||||||
</x-button>
|
|
||||||
</p>
|
|
||||||
</div>
|
</div>
|
||||||
<p class="help is-danger" v-if="showError && label.title === ''">
|
</div>
|
||||||
Please specify a title.
|
<p class="help is-danger" v-if="showError && label.title === ''">
|
||||||
</p>
|
Please specify a title.
|
||||||
</form>
|
</p>
|
||||||
</div>
|
</create>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import labelModel from '../../models/label'
|
import labelModel from '../../models/label'
|
||||||
import labelService from '../../services/label'
|
import labelService from '../../services/label'
|
||||||
import {IS_FULLPAGE} from '@/store/mutation-types'
|
|
||||||
import LabelModel from '../../models/label'
|
import LabelModel from '../../models/label'
|
||||||
import LabelService from '../../services/label'
|
import LabelService from '../../services/label'
|
||||||
|
import Create from '@/components/misc/create'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'NewLabel',
|
name: 'NewLabel',
|
||||||
|
@ -47,29 +44,37 @@ export default {
|
||||||
showError: false,
|
showError: false,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
components: {
|
||||||
|
Create,
|
||||||
|
},
|
||||||
created() {
|
created() {
|
||||||
this.labelService = new LabelService()
|
this.labelService = new LabelService()
|
||||||
this.label = new LabelModel()
|
this.label = new LabelModel()
|
||||||
this.$store.commit(IS_FULLPAGE, true)
|
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.setTitle('Create a new label')
|
this.setTitle('Create a new label')
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
newlabel() {
|
newLabel() {
|
||||||
|
|
||||||
if (this.label.title === '') {
|
if (this.label.title === '') {
|
||||||
this.showError = true
|
this.showError = true
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
this.showError = false
|
this.showError = false
|
||||||
|
|
||||||
this.labelService.create(this.label)
|
this.labelService
|
||||||
.then(response => {
|
.create(this.label)
|
||||||
this.$router.push({name: 'labels.index', params: {id: response.id}})
|
.then((response) => {
|
||||||
this.success({message: 'The label was successfully created.'}, this)
|
this.$router.push({
|
||||||
|
name: 'labels.index',
|
||||||
|
params: { id: response.id },
|
||||||
|
})
|
||||||
|
this.success(
|
||||||
|
{ message: 'The label was successfully created.' },
|
||||||
|
this
|
||||||
|
)
|
||||||
})
|
})
|
||||||
.catch(e => {
|
.catch((e) => {
|
||||||
this.error(e, this)
|
this.error(e, this)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
Reference in New Issue
Block a user