2021-01-30 16:17:04 +00:00
|
|
|
<template>
|
|
|
|
<create-edit
|
2021-06-23 23:24:57 +00:00
|
|
|
:title="title"
|
2021-01-30 16:17:04 +00:00
|
|
|
primary-icon=""
|
2021-06-23 23:24:57 +00:00
|
|
|
:primary-label="$t('misc.save')"
|
2021-01-30 16:17:04 +00:00
|
|
|
@primary="save"
|
2022-01-04 18:58:06 +00:00
|
|
|
:tertiary="$t('misc.delete')"
|
|
|
|
@tertiary="$router.push({ name: 'namespace.settings.delete', params: { id: $route.params.id } })"
|
2021-01-30 16:17:04 +00:00
|
|
|
>
|
|
|
|
<form @submit.prevent="save()">
|
|
|
|
<div class="field">
|
2021-06-23 23:24:57 +00:00
|
|
|
<label class="label" for="namespacetext">{{ $t('namespace.attributes.title') }}</label>
|
2021-01-30 16:17:04 +00:00
|
|
|
<div class="control">
|
|
|
|
<input
|
|
|
|
:class="{ 'disabled': namespaceService.loading}"
|
2022-05-22 15:08:37 +00:00
|
|
|
:disabled="namespaceService.loading || undefined"
|
2021-01-30 16:17:04 +00:00
|
|
|
class="input"
|
|
|
|
id="namespacetext"
|
2021-06-23 23:24:57 +00:00
|
|
|
:placeholder="$t('namespace.attributes.titlePlaceholder')"
|
2021-01-30 16:17:04 +00:00
|
|
|
type="text"
|
|
|
|
v-focus
|
|
|
|
v-model="namespace.title"/>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="field">
|
2021-06-23 23:24:57 +00:00
|
|
|
<label class="label" for="namespacedescription">{{ $t('namespace.attributes.description') }}</label>
|
2021-01-30 16:17:04 +00:00
|
|
|
<div class="control">
|
|
|
|
<editor
|
|
|
|
:class="{ 'disabled': namespaceService.loading}"
|
|
|
|
:preview-is-default="false"
|
|
|
|
id="namespacedescription"
|
2021-06-23 23:24:57 +00:00
|
|
|
:placeholder="$t('namespace.attributes.descriptionPlaceholder')"
|
2021-01-30 16:17:04 +00:00
|
|
|
v-if="editorActive"
|
|
|
|
v-model="namespace.description"
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="field">
|
2021-06-23 23:24:57 +00:00
|
|
|
<label class="label" for="isArchivedCheck">{{ $t('namespace.attributes.archived') }}</label>
|
2021-01-30 16:17:04 +00:00
|
|
|
<div class="control">
|
|
|
|
<fancycheckbox
|
|
|
|
v-model="namespace.isArchived"
|
2021-06-23 23:24:57 +00:00
|
|
|
v-tooltip="$t('namespace.archive.description')">
|
|
|
|
{{ $t('namespace.attributes.isArchived') }}
|
2021-01-30 16:17:04 +00:00
|
|
|
</fancycheckbox>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="field">
|
2021-06-23 23:24:57 +00:00
|
|
|
<label class="label">{{ $t('namespace.attributes.color') }}</label>
|
2021-01-30 16:17:04 +00:00
|
|
|
<div class="control">
|
|
|
|
<color-picker v-model="namespace.hexColor"/>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</form>
|
|
|
|
</create-edit>
|
|
|
|
</template>
|
|
|
|
|
2022-02-15 12:07:34 +00:00
|
|
|
<script lang="ts">
|
2022-02-15 12:07:59 +00:00
|
|
|
import {defineComponent} from 'vue'
|
|
|
|
|
2021-08-23 19:18:29 +00:00
|
|
|
import AsyncEditor from '@/components/input/AsyncEditor'
|
|
|
|
|
2021-01-30 16:17:04 +00:00
|
|
|
import NamespaceService from '@/services/namespace'
|
|
|
|
import NamespaceModel from '@/models/namespace'
|
2021-07-25 13:27:15 +00:00
|
|
|
import Fancycheckbox from '@/components/input/fancycheckbox.vue'
|
|
|
|
import ColorPicker from '@/components/input/colorPicker.vue'
|
|
|
|
import CreateEdit from '@/components/misc/create-edit.vue'
|
2021-01-30 16:17:04 +00:00
|
|
|
|
2022-02-15 12:07:59 +00:00
|
|
|
export default defineComponent({
|
2021-01-30 16:17:04 +00:00
|
|
|
name: 'namespace-setting-edit',
|
|
|
|
data() {
|
|
|
|
return {
|
2021-09-08 09:59:38 +00:00
|
|
|
namespaceService: new NamespaceService(),
|
|
|
|
namespace: new NamespaceModel(),
|
2021-01-30 16:17:04 +00:00
|
|
|
editorActive: false,
|
2021-06-23 23:24:57 +00:00
|
|
|
title: '',
|
2021-01-30 16:17:04 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
components: {
|
|
|
|
CreateEdit,
|
|
|
|
ColorPicker,
|
|
|
|
Fancycheckbox,
|
2021-08-23 19:18:29 +00:00
|
|
|
editor: AsyncEditor,
|
2021-01-30 16:17:04 +00:00
|
|
|
},
|
2022-06-12 12:59:53 +00:00
|
|
|
props: {
|
|
|
|
namespaceId: {
|
|
|
|
type: Number,
|
|
|
|
required: true,
|
|
|
|
},
|
2021-01-30 16:17:04 +00:00
|
|
|
},
|
|
|
|
watch: {
|
|
|
|
// call again the method if the route changes
|
2022-06-12 12:59:53 +00:00
|
|
|
namespaceId: {
|
2021-09-08 09:59:38 +00:00
|
|
|
handler: 'loadNamespace',
|
|
|
|
immediate: true,
|
|
|
|
},
|
2021-01-30 16:17:04 +00:00
|
|
|
},
|
|
|
|
methods: {
|
2021-10-11 17:37:20 +00:00
|
|
|
async loadNamespace() {
|
|
|
|
// HACK: This makes the editor trigger its mounted function again which makes it forget every input
|
2021-01-30 16:17:04 +00:00
|
|
|
// it currently has in its textarea. This is a counter-hack to a hack inside of vue-easymde
|
|
|
|
// which made it impossible to detect change from the outside. Therefore the component would
|
|
|
|
// not update if new content from the outside was made available.
|
|
|
|
// See https://github.com/NikulinIlya/vue-easymde/issues/3
|
|
|
|
this.editorActive = false
|
|
|
|
this.$nextTick(() => this.editorActive = true)
|
|
|
|
|
2022-06-12 12:59:53 +00:00
|
|
|
this.namespace = await this.namespaceService.get({id: this.namespaceId})
|
2021-10-11 17:37:20 +00:00
|
|
|
// This will trigger the dynamic loading of components once we actually have all the data to pass to them
|
|
|
|
this.manageTeamsComponent = 'manageSharing'
|
|
|
|
this.manageUsersComponent = 'manageSharing'
|
|
|
|
this.title = this.$t('namespace.edit.title', {namespace: this.namespace.title})
|
|
|
|
this.setTitle(this.title)
|
2021-01-30 16:17:04 +00:00
|
|
|
},
|
2021-10-11 17:37:20 +00:00
|
|
|
|
|
|
|
async save() {
|
|
|
|
const namespace = await this.namespaceService.update(this.namespace)
|
|
|
|
// Update the namespace in the parent
|
|
|
|
this.$store.commit('namespaces/setNamespaceById', namespace)
|
|
|
|
this.$message.success({message: this.$t('namespace.edit.success')})
|
|
|
|
this.$router.back()
|
2021-01-30 16:17:04 +00:00
|
|
|
},
|
|
|
|
},
|
2022-02-15 12:07:59 +00:00
|
|
|
})
|
2021-01-30 16:17:04 +00:00
|
|
|
</script>
|