2018-09-11 19:20:41 +02:00
|
|
|
<template>
|
2021-01-21 23:33:16 +01:00
|
|
|
<create
|
|
|
|
title="Create a new namespace"
|
|
|
|
@create="newNamespace()"
|
|
|
|
:create-disabled="namespace.title === ''"
|
|
|
|
>
|
|
|
|
<div class="field">
|
|
|
|
<label class="label" for="namespaceTitle">Namespace Title</label>
|
|
|
|
<div
|
|
|
|
class="control is-expanded"
|
|
|
|
:class="{ 'is-loading': namespaceService.loading }"
|
|
|
|
>
|
2020-09-05 22:35:52 +02:00
|
|
|
<input
|
2020-03-04 20:27:27 +01:00
|
|
|
@keyup.enter="newNamespace()"
|
|
|
|
@keyup.esc="back()"
|
2020-09-05 22:35:52 +02:00
|
|
|
class="input"
|
|
|
|
placeholder="The namespace's name goes here..."
|
|
|
|
type="text"
|
2021-01-21 23:33:16 +01:00
|
|
|
:class="{ disabled: namespaceService.loading }"
|
2020-09-05 22:35:52 +02:00
|
|
|
v-focus
|
2021-01-21 23:33:16 +01:00
|
|
|
v-model="namespace.title"
|
|
|
|
/>
|
|
|
|
</div>
|
2020-03-04 20:27:27 +01:00
|
|
|
</div>
|
2020-06-17 19:10:48 +02:00
|
|
|
<p class="help is-danger" v-if="showError && namespace.title === ''">
|
|
|
|
Please specify a title.
|
2020-03-04 20:27:27 +01:00
|
|
|
</p>
|
2021-01-21 23:33:16 +01:00
|
|
|
<div class="field">
|
|
|
|
<label class="label">Color</label>
|
|
|
|
<div class="control">
|
|
|
|
<color-picker v-model="namespace.hexColor" />
|
|
|
|
</div>
|
|
|
|
</div>
|
2020-09-05 22:35:52 +02:00
|
|
|
<p
|
2021-01-21 23:33:16 +01:00
|
|
|
class="is-small has-text-centered"
|
|
|
|
v-tooltip.bottom="
|
|
|
|
'A namespace is a collection of lists you can share and use to organize your lists with. In fact, every list belongs to a namepace.'
|
|
|
|
"
|
|
|
|
>
|
|
|
|
What's a namespace?
|
|
|
|
</p>
|
|
|
|
</create>
|
2018-09-11 19:20:41 +02:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2020-09-05 22:35:52 +02:00
|
|
|
import NamespaceModel from '../../models/namespace'
|
|
|
|
import NamespaceService from '../../services/namespace'
|
2021-01-21 23:33:16 +01:00
|
|
|
import Create from '@/components/misc/create'
|
|
|
|
import ColorPicker from '../../components/input/colorPicker'
|
2018-09-11 19:20:41 +02:00
|
|
|
|
2020-09-05 22:35:52 +02:00
|
|
|
export default {
|
|
|
|
name: 'NewNamespace',
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
showError: false,
|
|
|
|
namespace: NamespaceModel,
|
|
|
|
namespaceService: NamespaceService,
|
|
|
|
}
|
|
|
|
},
|
2021-01-21 23:33:16 +01:00
|
|
|
components: {
|
|
|
|
ColorPicker,
|
|
|
|
Create,
|
|
|
|
},
|
2020-09-05 22:35:52 +02:00
|
|
|
created() {
|
|
|
|
this.namespace = new NamespaceModel()
|
|
|
|
this.namespaceService = new NamespaceService()
|
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
this.setTitle('Create a new namespace')
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
newNamespace() {
|
|
|
|
if (this.namespace.title === '') {
|
|
|
|
this.showError = true
|
|
|
|
return
|
2018-12-25 16:03:51 +01:00
|
|
|
}
|
2020-09-05 22:35:52 +02:00
|
|
|
this.showError = false
|
|
|
|
|
2021-01-21 23:33:16 +01:00
|
|
|
this.namespaceService
|
|
|
|
.create(this.namespace)
|
|
|
|
.then((r) => {
|
2020-09-05 22:35:52 +02:00
|
|
|
this.$store.commit('namespaces/addNamespace', r)
|
2021-01-21 23:33:16 +01:00
|
|
|
this.success(
|
|
|
|
{ message: 'The namespace was successfully created.' },
|
|
|
|
this
|
|
|
|
)
|
|
|
|
this.$router.back()
|
2020-09-05 22:35:52 +02:00
|
|
|
})
|
2021-01-21 23:33:16 +01:00
|
|
|
.catch((e) => {
|
2020-09-05 22:35:52 +02:00
|
|
|
this.error(e, this)
|
|
|
|
})
|
2018-12-25 16:03:51 +01:00
|
|
|
},
|
2020-09-05 22:35:52 +02:00
|
|
|
},
|
|
|
|
}
|
2018-09-11 19:20:41 +02:00
|
|
|
</script>
|