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>
|
2018-12-25 16:03:51 +01:00
|
|
|
<form @submit.prevent="newNamespace" @keyup.esc="back()">
|
2018-09-11 19:20:41 +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': namespaceService.loading}">
|
|
|
|
<input v-focus class="input" v-bind:class="{ 'disabled': namespaceService.loading}" v-model="namespace.name" type="text" placeholder="The namespace's name goes here...">
|
2018-09-11 19:20:41 +02:00
|
|
|
</p>
|
|
|
|
<p class="control">
|
2018-12-25 16:03:51 +01:00
|
|
|
<button type="submit" class="button is-success noshadow">
|
2018-09-11 19:20:41 +02:00
|
|
|
<span class="icon is-small">
|
|
|
|
<icon icon="plus"/>
|
|
|
|
</span>
|
|
|
|
Add
|
|
|
|
</button>
|
|
|
|
</p>
|
|
|
|
</div>
|
|
|
|
</form>
|
2018-12-25 16:03:51 +01:00
|
|
|
<p class="small" v-tooltip.bottom="'A namespace is a collection of lists you can share and use to organize your lists with.<br/>In fact, every list belongs to a namepace.'">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 auth from '../../auth'
|
|
|
|
import router from '../../router'
|
|
|
|
import message from '../../message'
|
2019-03-02 11:25:10 +01:00
|
|
|
import NamespaceModel from "../../models/namespace";
|
|
|
|
import NamespaceService from "../../services/namespace";
|
2018-09-11 19:20:41 +02:00
|
|
|
|
2018-12-25 16:03:51 +01:00
|
|
|
export default {
|
|
|
|
name: "NewNamespace",
|
|
|
|
data() {
|
|
|
|
return {
|
2019-03-02 11:25:10 +01:00
|
|
|
namespace: NamespaceModel,
|
|
|
|
namespaceService: NamespaceService,
|
2018-12-25 16:03:51 +01:00
|
|
|
}
|
|
|
|
},
|
|
|
|
beforeMount() {
|
|
|
|
// Check if the user is already logged in, if so, redirect him to the homepage
|
|
|
|
if (!auth.user.authenticated) {
|
|
|
|
router.push({name: 'home'})
|
|
|
|
}
|
|
|
|
},
|
|
|
|
created() {
|
2019-03-02 11:25:10 +01:00
|
|
|
this.namespace = new NamespaceModel()
|
|
|
|
this.namespaceService = new NamespaceService()
|
2018-12-25 16:03:51 +01:00
|
|
|
this.$parent.setFullPage();
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
newNamespace() {
|
2019-03-02 11:25:10 +01:00
|
|
|
this.namespaceService.create(this.namespace)
|
2018-12-25 16:03:51 +01:00
|
|
|
.then(() => {
|
|
|
|
this.$parent.loadNamespaces()
|
2019-03-02 11:25:10 +01:00
|
|
|
message.success({message: 'The namespace was successfully created.'}, this)
|
2018-12-25 16:03:51 +01:00
|
|
|
router.push({name: 'home'})
|
|
|
|
})
|
|
|
|
.catch(e => {
|
2019-03-02 11:25:10 +01:00
|
|
|
message.error(e, this)
|
2018-12-25 16:03:51 +01:00
|
|
|
})
|
|
|
|
},
|
|
|
|
back() {
|
|
|
|
router.go(-1)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-09-11 19:20:41 +02:00
|
|
|
</script>
|