2018-09-11 19:20:41 +02:00
|
|
|
<template>
|
2021-01-30 17:17:04 +01:00
|
|
|
<create-edit
|
2021-06-24 01:24:57 +02:00
|
|
|
:title="$t('namespace.create.title')"
|
2021-01-21 23:33:16 +01:00
|
|
|
@create="newNamespace()"
|
|
|
|
:create-disabled="namespace.title === ''"
|
|
|
|
>
|
|
|
|
<div class="field">
|
2021-06-24 01:24:57 +02:00
|
|
|
<label class="label" for="namespaceTitle">{{ $t('namespace.attributes.title') }}</label>
|
2021-01-21 23:33:16 +01:00
|
|
|
<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"
|
2021-06-24 01:24:57 +02:00
|
|
|
:placeholder="$t('namespace.attributes.titlePlaceholder')"
|
2020-09-05 22:35:52 +02:00
|
|
|
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 === ''">
|
2021-06-24 01:24:57 +02:00
|
|
|
{{ $t('namespace.create.titleRequired') }}
|
2020-03-04 20:27:27 +01:00
|
|
|
</p>
|
2021-01-21 23:33:16 +01:00
|
|
|
<div class="field">
|
2021-06-24 01:24:57 +02:00
|
|
|
<label class="label">{{ $t('namespace.attributes.color') }}</label>
|
2021-01-21 23:33:16 +01:00
|
|
|
<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"
|
2021-06-24 01:24:57 +02:00
|
|
|
v-tooltip.bottom="$t('namespace.create.explanation')"
|
2021-01-21 23:33:16 +01:00
|
|
|
>
|
2021-06-24 01:24:57 +02:00
|
|
|
{{ $t('namespace.create.tooltip') }}
|
2021-01-21 23:33:16 +01:00
|
|
|
</p>
|
2021-01-30 17:17:04 +01:00
|
|
|
</create-edit>
|
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-07-25 15:27:15 +02:00
|
|
|
import CreateEdit from '@/components/misc/create-edit.vue'
|
2021-01-21 23:33:16 +01:00
|
|
|
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,
|
2021-09-08 11:59:38 +02:00
|
|
|
namespace: new NamespaceModel(),
|
|
|
|
namespaceService: new NamespaceService(),
|
2020-09-05 22:35:52 +02:00
|
|
|
}
|
|
|
|
},
|
2021-01-21 23:33:16 +01:00
|
|
|
components: {
|
|
|
|
ColorPicker,
|
2021-01-30 17:17:04 +01:00
|
|
|
CreateEdit,
|
2021-01-21 23:33:16 +01:00
|
|
|
},
|
2020-09-05 22:35:52 +02:00
|
|
|
mounted() {
|
2021-06-24 01:24:57 +02:00
|
|
|
this.setTitle(this.$t('namespace.create.title'))
|
2020-09-05 22:35:52 +02:00
|
|
|
},
|
|
|
|
methods: {
|
2021-10-11 19:37:20 +02:00
|
|
|
async newNamespace() {
|
2020-09-05 22:35:52 +02:00
|
|
|
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-10-16 17:20:14 +02:00
|
|
|
const namespace = await this.namespaceService.create(this.namespace)
|
2021-10-11 19:37:20 +02:00
|
|
|
this.$store.commit('namespaces/addNamespace', namespace)
|
|
|
|
this.$message.success({message: this.$t('namespace.create.success') })
|
|
|
|
this.$router.back()
|
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>
|