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()"
|
2021-10-17 17:28:44 +02:00
|
|
|
:primary-disabled="namespace.title === ''"
|
2021-01-21 23:33:16 +01:00
|
|
|
>
|
|
|
|
<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">
|
2021-11-28 15:18:27 +01:00
|
|
|
<color-picker v-model="namespace.hexColor"/>
|
2021-01-21 23:33:16 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
2021-11-22 19:41:00 +01:00
|
|
|
|
2021-11-28 15:18:27 +01:00
|
|
|
<message class="mt-4">
|
2021-11-22 19:41:00 +01:00
|
|
|
<h4 class="title">{{ $t('namespace.create.tooltip') }}</h4>
|
|
|
|
|
|
|
|
{{ $t('namespace.create.explanation') }}
|
2021-11-28 15:18:27 +01:00
|
|
|
</message>
|
2021-01-30 17:17:04 +01:00
|
|
|
</create-edit>
|
2018-09-11 19:20:41 +02:00
|
|
|
</template>
|
|
|
|
|
2022-02-15 13:07:34 +01:00
|
|
|
<script lang="ts">
|
2021-11-28 15:18:27 +01:00
|
|
|
import Message from '@/components/misc/message'
|
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: {
|
2021-11-28 15:18:27 +01:00
|
|
|
Message,
|
2021-01-21 23:33:16 +01:00
|
|
|
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)
|
2021-11-28 15:18:27 +01:00
|
|
|
this.$message.success({message: this.$t('namespace.create.success')})
|
2021-10-11 19:37:20 +02:00
|
|
|
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>
|