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.

Bugs fixes, pin system

Smaug67390c5ae9487434
diff --git a/backend/controllers/nodes.controller.go b/backend/controllers/nodes.controller.go
index 39cbeaa2..0bb3a04a 100644
--- a/backend/controllers/nodes.controller.go
+++ b/backend/controllers/nodes.controller.go
@@ -168,6 +168,7 @@ func (ctr *Controller) UpdateNode(c *gin.Context) (int, any) {
Name: node.Name,
Description: node.Description,
Tags: node.Tags,
+ Role: node.Role,
Thumbnail: node.Thumbnail,
Theme: node.Theme,
Icon: node.Icon,
diff --git a/backend/services/node.service.go b/backend/services/node.service.go
index d74ce1ef..742d507f 100644
--- a/backend/services/node.service.go
+++ b/backend/services/node.service.go
@@ -189,11 +189,12 @@ func (s *Service) CreateNode(node *models.Node) error {
}
func (s *Service) UpdateNode(node *models.Node) error {
- _, err := s.db.Exec("UPDATE nodes SET `parent_id` = ?, `name` = ?, `description` = ?, `tags` = ?, `color` = ?, `icon` = ?, `thumbnail` = ?, `theme` = ?, `accessibility` = ?, `display` = ?, `order` = ?, `content` = ?, `content_compiled` = ?, `metadata` = ?, `updated_timestamp` = ? WHERE id = ?",
+ _, err := s.db.Exec("UPDATE nodes SET `parent_id` = ?, `name` = ?, `description` = ?, `tags` = ?, `role` = ?, `color` = ?, `icon` = ?, `thumbnail` = ?, `theme` = ?, `accessibility` = ?, `display` = ?, `order` = ?, `content` = ?, `content_compiled` = ?, `metadata` = ?, `updated_timestamp` = ? WHERE id = ?",
node.ParentId,
node.Name,
node.Description,
node.Tags,
+ node.Role,
node.Color,
node.Icon,
node.Thumbnail,
diff --git a/frontend/app/components/DocumentDotMenu.vue b/frontend/app/components/DocumentDotMenu.vue
index 893d9ae3..c87f9836 100644
--- a/frontend/app/components/DocumentDotMenu.vue
+++ b/frontend/app/components/DocumentDotMenu.vue
@@ -31,7 +31,7 @@ const emit = defineEmits<{
}>();
defineExpose({ close: () => dotMenu.value?.close() });
-const numericDate = (timestamp: string): string => {
+const numericDate = (timestamp: number): string => {
const date = new Date(timestamp);
return date.toLocaleDateString('en-US', {
year: 'numeric',
@@ -51,7 +51,7 @@ const emitDelete = () => {
emit('delete');
};
const pin = async () => {
- await useNodesStore().update({ ...props.document });
+ await useNodesStore().update({ ...props.document, order: props.document.order === -1 ? 0 : -1 });
};
</script>
diff --git a/frontend/app/pages/dashboard/categories/_modals/CreateCategoryModal.vue b/frontend/app/pages/dashboard/categories/_modals/CreateCategoryModal.vue
index 215ccef8..3b130f32 100644
--- a/frontend/app/pages/dashboard/categories/_modals/CreateCategoryModal.vue
+++ b/frontend/app/pages/dashboard/categories/_modals/CreateCategoryModal.vue
@@ -3,7 +3,6 @@
<h2>New {{ role == 1 ? 'workspace' : 'category' }}</h2>
<label for="name">Name</label>
<input id="name" v-model="category.name" class="entry" type="text" required placeholder="Display name" />
-
<label>Parent</label>
<div>
<AppSelect v-model="category.parent_id" class="entry" :items="categoriesItem" placeholder="Select a category parent" />
@@ -31,7 +30,9 @@ import type { Node } from '~/stores';
const categoriesStore = useNodesStore();
const sidebarTree = useSidebarTree();
const sidebar = useSidebar();
-const categoriesItem = computed(() => new TreeStructure(sidebarTree.nodes.value).generateTree().filter(i => i.data.role == 1));
+const categoriesItem = computed(() =>
+ new TreeStructure(sidebarTree.nodes.value.filter(c => c.data.role == 1 || c.data.role == 2)).generateTree().filter(i => i.data.role == 1),
+);
const props = defineProps<{ role: 1 | 2 }>();
const category = ref<Partial<Node>>({
diff --git a/frontend/app/pages/dashboard/categories/_modals/DeleteCategoryModal.vue b/frontend/app/pages/dashboard/categories/_modals/DeleteCategoryModal.vue
index 7c23219d..0ec3a56f 100644
--- a/frontend/app/pages/dashboard/categories/_modals/DeleteCategoryModal.vue
+++ b/frontend/app/pages/dashboard/categories/_modals/DeleteCategoryModal.vue
@@ -4,6 +4,7 @@
<p>Are you sure you want to delete this category ?</p>
<p style="opacity: 0.7">This action is irreversible</p>
<p v-if="allChildren.length > 0" class="warn">This category has {{ allChildren.length }} child documents/categories. They will be deleted too.</p>
+ <p v-else class="warn">If this category has children, they will be deleted too.</p>
<div class="footer">
<AppButton type="secondary" @click="emit('close')">Cancel</AppButton>
<AppButton type="danger" @click="deleteDoc">Confirm</AppButton>
@@ -19,6 +20,7 @@ const deleteDoc = () => {
.then(() => {
useNotifications().add({ type: 'success', title: 'Category successfully deleted' });
emit('close');
+ useRouter().push('/dashboard/categories');
})
.catch(e => {
useNotifications().add({ type: 'error', title: 'Error during deletion', message: e });
diff --git a/frontend/app/pages/dashboard/docs/_modals/DocumentMeta.vue b/frontend/app/pages/dashboard/docs/_modals/DocumentMeta.vue
index 2d4df6a7..7566609a 100644
--- a/frontend/app/pages/dashboard/docs/_modals/DocumentMeta.vue
+++ b/frontend/app/pages/dashboard/docs/_modals/DocumentMeta.vue
@@ -25,7 +25,7 @@
</div>
<div style="display: flex; align-items: center; gap: 10px">
<label for="pinned">Pinned</label>
- <!--<AppToggle id="pinned" v-model="pinnedToggle" />-->
+ <AppToggle id="pinned" v-model="pinnedToggle" />
</div>
<label for="parent">Parent Document</label>
@@ -51,11 +51,11 @@ const store = useNodesStore();
const props = defineProps<{ doc: Node }>();
const document = ref<Node>(props.doc);
-//const pinnedToggle = ref(!!document.value.);
+const pinnedToggle = ref(document.value.order == -1);
const link = computed(() => `${window.location.origin}/doc/${document.value.id}`);
const documentsTree = computed(() => useSidebarTree().groupedByWorkspace());
-//watch(pinnedToggle, val => (document.value.pinned = val ? 1 : 0));
+watch(pinnedToggle, val => (document.value.order = val ? -1 : 0));
watch(
document.value,
debounce(() => store.update(document.value), 500),
diff --git a/frontend/app/stores/documents.store.ts b/frontend/app/stores/documents.store.ts
index 8679cf88..752b6bef 100644
--- a/frontend/app/stores/documents.store.ts
+++ b/frontend/app/stores/documents.store.ts
@@ -143,15 +143,12 @@ export const useNodesStore = defineStore('nodes', {
},
async update(node: Node) {
- console.log(node);
if (node.partial) {
console.log('[store/nodes] Node is partial, cannot update it directly.');
const full_node = await this.fetch({ id: node.id });
if (!full_node) throw 'Node not found';
- console.log(full_node);
node = { ...full_node, ...node, partial: false }; // Merge with full nodeument data
}
- console.log(node);
const request = await makeRequest(`nodes/${node.id}`, 'PUT', node);
if (request.status == 'success') return (this.nodes = this.nodes.map(d => (d.id == node.id ? node : d)));
else throw request.message;