2018-09-11 19:20:41 +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-11 19:20:41 +02:00
|
|
|
<h3>Create a new namespace</h3>
|
2020-03-04 20:27:27 +01:00
|
|
|
<div class="field is-grouped">
|
|
|
|
<p class="control is-expanded" v-bind:class="{ 'is-loading': namespaceService.loading}">
|
|
|
|
<input v-focus
|
|
|
|
class="input"
|
|
|
|
v-bind:class="{ 'disabled': namespaceService.loading}"
|
2020-05-16 12:31:16 +02:00
|
|
|
v-model="namespace.title"
|
2020-03-04 20:27:27 +01:00
|
|
|
type="text"
|
|
|
|
@keyup.enter="newNamespace()"
|
|
|
|
@keyup.esc="back()"
|
|
|
|
placeholder="The namespace's name goes here..."/>
|
|
|
|
</p>
|
|
|
|
<p class="control">
|
2020-06-17 19:10:48 +02:00
|
|
|
<button class="button is-success noshadow" @click="newNamespace()" :disabled="namespace.title === ''">
|
2018-09-11 19:20:41 +02:00
|
|
|
<span class="icon is-small">
|
|
|
|
<icon icon="plus"/>
|
|
|
|
</span>
|
2020-03-04 20:27:27 +01:00
|
|
|
Add
|
|
|
|
</button>
|
|
|
|
</p>
|
|
|
|
</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>
|
2020-08-31 22:36:47 +02:00
|
|
|
<p class="small" 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.'">
|
2020-03-04 20:27:27 +01:00
|
|
|
What's a namespace?</p>
|
2018-09-11 19:20:41 +02:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2018-12-25 16:03:51 +01:00
|
|
|
import router from '../../router'
|
2019-03-02 11:25:10 +01:00
|
|
|
import NamespaceModel from "../../models/namespace";
|
|
|
|
import NamespaceService from "../../services/namespace";
|
2020-05-08 20:43:51 +02:00
|
|
|
import {IS_FULLPAGE} from '../../store/mutation-types'
|
2018-09-11 19:20:41 +02:00
|
|
|
|
2018-12-25 16:03:51 +01:00
|
|
|
export default {
|
|
|
|
name: "NewNamespace",
|
|
|
|
data() {
|
|
|
|
return {
|
2020-03-04 20:27:27 +01:00
|
|
|
showError: false,
|
2019-03-02 11:25:10 +01:00
|
|
|
namespace: NamespaceModel,
|
|
|
|
namespaceService: NamespaceService,
|
2018-12-25 16:03:51 +01:00
|
|
|
}
|
|
|
|
},
|
|
|
|
created() {
|
2019-03-02 11:25:10 +01:00
|
|
|
this.namespace = new NamespaceModel()
|
|
|
|
this.namespaceService = new NamespaceService()
|
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 namespace')
|
|
|
|
},
|
2018-12-25 16:03:51 +01:00
|
|
|
methods: {
|
|
|
|
newNamespace() {
|
2020-06-17 19:10:48 +02:00
|
|
|
if (this.namespace.title === '') {
|
2020-03-04 20:27:27 +01:00
|
|
|
this.showError = true
|
|
|
|
return
|
|
|
|
}
|
|
|
|
this.showError = false
|
|
|
|
|
2019-03-02 11:25:10 +01:00
|
|
|
this.namespaceService.create(this.namespace)
|
2020-05-08 20:43:51 +02:00
|
|
|
.then(r => {
|
|
|
|
this.$store.commit('namespaces/addNamespace', r)
|
2020-01-30 22:47:08 +01:00
|
|
|
this.success({message: 'The namespace was successfully created.'}, this)
|
2020-05-08 20:43:51 +02:00
|
|
|
router.back()
|
2018-12-25 16:03:51 +01:00
|
|
|
})
|
|
|
|
.catch(e => {
|
2020-01-30 22:47:08 +01:00
|
|
|
this.error(e, this)
|
2018-12-25 16:03:51 +01:00
|
|
|
})
|
|
|
|
},
|
|
|
|
back() {
|
|
|
|
router.go(-1)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-09-11 19:20:41 +02:00
|
|
|
</script>
|