2018-09-11 17:20:41 +00:00
< template >
2018-12-25 15:03:51 +00:00
< div class = "fullpage" >
2020-09-05 20:35:52 +00:00
< a @click ="back()" class = "close" >
2018-12-25 15:03:51 +00:00
< icon : icon = "['far', 'times-circle']" >
< / icon >
< / a >
2018-09-11 17:20:41 +00:00
< h3 > Create a new namespace < / h3 >
2020-03-04 19:27:27 +00:00
< div class = "field is-grouped" >
< p class = "control is-expanded" v -bind : class = "{ 'is-loading': namespaceService.loading}" >
2020-09-05 20:35:52 +00:00
< input
2020-03-04 19:27:27 +00:00
@ keyup . enter = "newNamespace()"
@ keyup . esc = "back()"
2020-09-05 20:35:52 +00:00
class = "input"
placeholder = "The namespace's name goes here..."
type = "text"
: class = "{ 'disabled': namespaceService.loading}"
v - focus
v - model = "namespace.title" / >
2020-03-04 19:27:27 +00:00
< / p >
< p class = "control" >
2021-01-17 17:57:57 +00:00
< x -button
: disabled = "namespace.title === ''"
@ click = "newNamespace()"
: shadow = "false"
icon = "plus"
>
2020-03-04 19:27:27 +00:00
Add
2021-01-17 17:57:57 +00:00
< / x - b u t t o n >
2020-03-04 19:27:27 +00:00
< / p >
< / div >
2020-06-17 17:10:48 +00:00
< p class = "help is-danger" v-if ="showError && namespace.title === ''" >
Please specify a title .
2020-03-04 19:27:27 +00:00
< / p >
2020-09-05 20:35:52 +00: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 19:27:27 +00:00
What ' s a namespace ? < / p >
2018-09-11 17:20:41 +00:00
< / div >
< / template >
< script >
2020-09-05 20:35:52 +00:00
import router from '../../router'
import NamespaceModel from '../../models/namespace'
import NamespaceService from '../../services/namespace'
import { IS _FULLPAGE } from '@/store/mutation-types'
2018-09-11 17:20:41 +00:00
2020-09-05 20:35:52 +00:00
export default {
name : 'NewNamespace' ,
data ( ) {
return {
showError : false ,
namespace : NamespaceModel ,
namespaceService : NamespaceService ,
}
} ,
created ( ) {
this . namespace = new NamespaceModel ( )
this . namespaceService = new NamespaceService ( )
this . $store . commit ( IS _FULLPAGE , true )
} ,
mounted ( ) {
this . setTitle ( 'Create a new namespace' )
} ,
methods : {
newNamespace ( ) {
if ( this . namespace . title === '' ) {
this . showError = true
return
2018-12-25 15:03:51 +00:00
}
2020-09-05 20:35:52 +00:00
this . showError = false
this . namespaceService . create ( this . namespace )
. then ( r => {
this . $store . commit ( 'namespaces/addNamespace' , r )
this . success ( { message : 'The namespace was successfully created.' } , this )
router . back ( )
} )
. catch ( e => {
this . error ( e , this )
} )
2018-12-25 15:03:51 +00:00
} ,
2020-09-05 20:35:52 +00:00
back ( ) {
router . go ( - 1 )
2020-07-07 20:07:13 +00:00
} ,
2020-09-05 20:35:52 +00:00
} ,
}
2018-09-11 17:20:41 +00:00
< / script >