Skip to content

πŸ“š The open-source, offline-first Notion, Obsidian & Confluence alternative. Advanced Markdown, multi-tenant teams, OIDC/SSO, and local S3 backups. Deploy in one command.

Introduce document meta modal

Smaug67398e5911ac3f8a
diff --git a/frontend/app/pages/dashboard/docs/_components/DocumentCardHeaderActionRow.vue b/frontend/app/pages/dashboard/docs/_components/DocumentCardHeaderActionRow.vue
index d1b24ca1..bcb00cb5 100644
--- a/frontend/app/pages/dashboard/docs/_components/DocumentCardHeaderActionRow.vue
+++ b/frontend/app/pages/dashboard/docs/_components/DocumentCardHeaderActionRow.vue
@@ -8,11 +8,7 @@
</svg>
</NuxtLink>
<NuxtLink @click="exportMarkdown">
- <svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 -960 960 960" width="24px">
- <path
- d="m640-360 120-120-42-43-48 48v-125h-60v125l-48-48-42 43 120 120ZM160-160q-33 0-56.5-23.5T80-240v-480q0-33 23.5-56.5T160-800h640q33 0 56.5 23.5T880-720v480q0 33-23.5 56.5T800-160H160Zm0-80h640v-480H160v480Zm0 0v-480 480Zm60-120h60v-180h40v120h60v-120h40v180h60v-200q0-17-11.5-28.5T440-600H260q-17 0-28.5 11.5T220-560v200Z"
- />
- </svg>
+ <Icon name="markdown" :big="true" fill="var(--font-color)" />
</NuxtLink>
<NuxtLink @click="print">
<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 -960 960 960" width="24">
@@ -21,6 +17,9 @@
/>
</svg>
</NuxtLink>
+ <NuxtLink @click="openEditModal">
+ <Icon name="settings" :big="true" fill="var(--font-color)" />
+ </NuxtLink>
<NuxtLink @click="openDeleteModal">
<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 -960 960 960" width="24">
<path
@@ -33,11 +32,13 @@
<script setup lang="ts">
import DeleteDocumentModal from '../_modals/DeleteDocumentModal.vue';
+import DocumentMeta from '../_modals/DocumentMeta.vue';
import type { Document } from '~/stores';
const props = defineProps<{ doc: Document }>();
const print = () => window.print();
-const openDeleteModal = () => useModal().add(new Modal(shallowRef(DeleteDocumentModal), { documentId: props.doc.id }));
+const openDeleteModal = () => useModal().add(new Modal(shallowRef(DeleteDocumentModal), { props: { documentId: props.doc.id } }));
+const openEditModal = () => useModal().add(new Modal(shallowRef(DocumentMeta), { props: { doc: props.doc }, size: 'small' }));
function exportMarkdown() {
const blob = new Blob([props.doc.content_markdown || ''], { type: 'text/markdown' });
diff --git a/frontend/app/pages/dashboard/docs/_modals/DocumentMeta.vue b/frontend/app/pages/dashboard/docs/_modals/DocumentMeta.vue
new file mode 100644
index 00000000..b9115dcb
--- /dev/null
+++ b/frontend/app/pages/dashboard/docs/_modals/DocumentMeta.vue
@@ -0,0 +1,73 @@
+<!-- This components is a modal for advanced editing document metadata -->
+<template>
+ <div class="modal">
+ <h2>Document Metadata <tag blue>New</tag></h2>
+ <form @submit.prevent>
+ <label for="title">Title</label>
+ <input id="title" v-model="document.name" type="text" />
+
+ <label for="description">Description</label>
+ <textarea id="description" v-model="document.description"></textarea>
+ <label for="accessibility">Accessibility</label>
+ <AppSelect v-model="document.accessibility" :items="accessibilities" placeholder="Access" />
+ <div style="display: flex; align-items: center; gap: 10px">
+ <label for="pinned">Pinned</label>
+ <AppToggle id="pinned" v-model="pinnedToggle" />
+ </div>
+
+ <label for="category">Category</label>
+ <AppSelect v-model="document.category" :items="categories" placeholder="Select category" />
+ <label for="parent">Parent Document</label>
+ <AppSelect
+ v-model="document.parent_id as string"
+ :items="documentsTree"
+ :disabled="(i) => (i as Item).data?.type !== 'document'"
+ placeholder="Select a document parent"
+ :nullable="true"
+ />
+
+ <hr />
+ <div style="display: flex; gap: 5px">
+ <AppButton type="secondary" @click="close">Cencel</AppButton>
+ <AppButton type="primary" @click="save">Save</AppButton>
+ </div>
+ </form>
+ </div>
+</template>
+
+<script setup lang="ts">
+import type { Document } from '@/stores';
+
+const store = useDocumentsStore();
+const notifications = useNotifications();
+
+const props = defineProps<{ doc: Document }>();
+const emit = defineEmits(['close']);
+const document = ref<Document>(props.doc);
+const pinnedToggle = ref(!!document.value.pinned);
+
+const categories = new TreeStructure(useSidebarTree().categories.value).generateTree().filter(i => i.data.type === 'category' && i.data.role == 2);
+const documentsTree = computed(() => useSidebarTree().groupedByWorkspace());
+
+const accessibilities: ANode[] = [
+ { id: 1, label: 'Visible', parent_id: '' },
+ { id: 2, label: 'Draft', parent_id: '' },
+ { id: 3, label: 'Archive', parent_id: '' },
+];
+
+const close = () => emit('close');
+watch(pinnedToggle, val => (document.value.pinned = val ? 1 : 0));
+
+function save() {
+ store
+ .update(document.value)
+ .then(() => notifications.add({ type: 'success', title: 'Document successfully updated' }))
+ .catch(e => notifications.add({ type: 'error', title: 'Error', message: e }));
+}
+</script>
+
+<style scoped>
+.modal {
+ padding: 0 6px;
+}
+</style>