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.

App components fix, style improvment, new modals

Smaug67390268d37995f6
diff --git a/frontend/components/AppButton.vue b/frontend/components/AppButton.vue
index 5b84650c..ce4323e3 100644
--- a/frontend/components/AppButton.vue
+++ b/frontend/components/AppButton.vue
@@ -13,7 +13,7 @@ const onClick = () => emit('click');
<style scoped lang="scss">
@use 'sass:color';
button {
- padding: 10px 14px;
+ padding: 10px;
border-radius: 5px;
width: fit-content;
font-size: 0.9rem;
@@ -34,7 +34,7 @@ button {
outline: 1px solid $primary-color;
color: var(--font-color);
&:hover {
- outline: 1px solid $primary-dark;
+ box-shadow: inset 0 0 0 1px $primary-dark;
}
}
.success {
diff --git a/frontend/components/AppHint.vue b/frontend/components/AppHint.vue
index 46131259..f4f60df2 100644
--- a/frontend/components/AppHint.vue
+++ b/frontend/components/AppHint.vue
@@ -16,9 +16,7 @@ const show = ref(false);
.hint-wrapper {
position: relative;
margin-left: 0.25rem;
- display: flex;
- align-items: center;
- justify-content: center;
+ display: inline-block;
}
.hint-icon {
diff --git a/frontend/components/AppSelect.vue b/frontend/components/AppSelect.vue
index 726c14bd..3adb1824 100644
--- a/frontend/components/AppSelect.vue
+++ b/frontend/components/AppSelect.vue
@@ -1,11 +1,8 @@
<template>
- <div class="category-select" :style="{ width: size + 'px' }">
- <button class="select-button" @click="toggleDropdown">
- {{ selected?.title || placeholder }}
- </button>
-
- <div v-show="open" class="dropdown">
- <ul class="tree-list">
+ <div class="category-select" :style="{ width: size ? size + 'px' : '100%' }">
+ <button @click="toggleDropdown">{{ selected?.title || placeholder }}</button>
+ <div v-if="open" class="dropdown">
+ <ul>
<AppSelectNode v-for="item in items" :key="item.id" :node="item" :level="0" @select="handleSelect" />
</ul>
</div>
@@ -20,23 +17,16 @@ const props = defineProps<{
size?: string;
}>();
const selectedId = ref<string | number>(props.modelValue || '');
-
+const open = ref(false);
const emit = defineEmits(['update:modelValue']);
-const open = ref(false);
const selected = computed(() => {
- // Find the selected item based on the selectedId
- // Recursively search through the items (and their children) to find the selected item
const findSelected = (items: ANode[]): ANode | null => {
for (const item of items) {
- if (item.id === selectedId.value) {
- return item;
- }
+ if (item.id === selectedId.value) return item;
if (item.childrens) {
const found = findSelected(item.childrens);
- if (found) {
- return found;
- }
+ if (found) return found;
}
}
return null;
@@ -55,20 +45,28 @@ function handleSelect(node: Item) {
}
</script>
-<style scoped>
+<style scoped lang="scss">
.category-select {
position: relative;
width: 200px;
}
-.select-button {
+button {
width: 100%;
padding: 6px 12px;
border: 1px solid #ccc;
background: white;
text-align: left;
- border-radius: 4px;
+ border-radius: 6px;
cursor: pointer;
+ padding: 8px 10px;
+ // ouline like input with focus or opened
+ &:focus {
+ outline: 2px solid #000;
+ }
+}
+.category-select:has(.dropdown) button {
+ outline: 2px solid #000;
}
.dropdown {
@@ -85,7 +83,7 @@ function handleSelect(node: Item) {
z-index: 1000;
}
-.tree-list {
+ul {
list-style: none;
padding: 0;
margin: 0;
diff --git a/frontend/components/MarkdownEditor/Toolbar.vue b/frontend/components/MarkdownEditor/Toolbar.vue
index 97406975..35f3c850 100644
--- a/frontend/components/MarkdownEditor/Toolbar.vue
+++ b/frontend/components/MarkdownEditor/Toolbar.vue
@@ -110,7 +110,7 @@ button {
.toolbar {
user-select: none;
display: flex;
- align-items: stretch;
+ align-items: center;
flex-wrap: wrap;
background-color: var(--bg-contrast-2);
border-radius: 8px;
diff --git a/frontend/components/ModalManager.vue b/frontend/components/ModalManager.vue
index b0b82015..8ce88dca 100644
--- a/frontend/components/ModalManager.vue
+++ b/frontend/components/ModalManager.vue
@@ -5,7 +5,7 @@
<div v-if="index !== modals.length - 1" class="modal-overlay"></div>
<div class="modal-container">
<button @click="close(modal)" class="close-btn"><Icon name="close" :big="true" /></button>
- <component :is="modal.component" v-bind="modal.props" />
+ <component :is="modal.component" v-bind="modal.props" class="modal" @close="close(modal)" />
</div>
</div>
</div>
@@ -26,7 +26,7 @@ const close = (modal: Modal) => {
<style scoped lang="scss">
.modal-container {
margin: auto;
- padding: 15px 20px;
+ padding: 12px 18px;
background-color: var(--bg-contrast);
border-radius: 10px;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.33);
@@ -61,6 +61,10 @@ const close = (modal: Modal) => {
background: none;
z-index: 1000;
}
+.modal {
+ background-color: var(--bg-contrast);
+ border-radius: 8px;
+}
.modal-mask {
position: fixed;
diff --git a/frontend/components/Sidebar/Sidebar.vue b/frontend/components/Sidebar/Sidebar.vue
index 943714d0..11cb519a 100644
--- a/frontend/components/Sidebar/Sidebar.vue
+++ b/frontend/components/Sidebar/Sidebar.vue
@@ -64,7 +64,9 @@ const navigationItemsComputed = computed<Item[]>(() =>
})),
);
const sidebarTree = useSidebarTree();
+
const tree = computed(() => [...navigationItemsComputed.value, ...sidebarTree.filtered.value].filter(i => i.title.toLowerCase().includes(filter.value.toLowerCase())));
+
const handleClickOutside = (e: MouseEvent) => {
if (isOpened.value && e.target && !(e.target as Element).closest('.sidebar') && !(e.target as Element).closest('.open-sidebar')) isOpened.value = false;
};
diff --git a/frontend/pages/dashboard/categories/_modals/CreateCategoryModal.vue b/frontend/pages/dashboard/categories/_modals/CreateCategoryModal.vue
index 369cfc45..3cf86613 100644
--- a/frontend/pages/dashboard/categories/_modals/CreateCategoryModal.vue
+++ b/frontend/pages/dashboard/categories/_modals/CreateCategoryModal.vue
@@ -1,27 +1,22 @@
<template>
<div class="modal">
<h2>Create a new {{ role == 1 ? 'category' : 'workspace' }}</h2>
- <form @submit.prevent="createCategory">
+ <form>
<label for="name">Name</label>
- <input type="text" v-model="category.name" id="name" required />
+ <input type="text" v-model="category.name" required />
<label for="icon">Icon <AppHint text="SVG supported" /></label>
<input type="text" v-model="category.icon" id="icon" />
<label for="parent">Parent</label>
- <select v-model="category.parent_id" id="parent">
- <option :value="null">None</option>
- <option v-for="pc in categoriesStore.getParents.filter(c => c.role == 1)" :key="pc.id" :value="pc.id">{{ pc.name }}</option>
- </select>
- <div v-if="role == 1">
- <label>Workspace <AppHint text="Only for root categories" /></label>
- <select v-model="category.workspace_id" style="width: 100%">
- <option :value="null">None</option>
- <option v-for="wp in categoriesStore.getAll.filter(a => a.role == 2)" :key="wp.id" :value="wp.id">{{ wp.name }}</option>
- </select>
+ <div>
+ <AppSelect v-model="category.parent_id" :items="categoriesItem" placeholder="Select a category parent" />
</div>
- <label for="order">Order</label>
+ <label for="order">Order <AppHint text="Order of the category in the sidebar" /></label>
<input type="number" v-model.number="category.order" id="order" />
- <AppButton type="primary">Create</AppButton>
</form>
+ <div class="footer">
+ <AppButton @click="emit('close')" type="secondary">Cancel</AppButton>
+ <AppButton type="primary" @click="createCategory">Create</AppButton>
+ </div>
</div>
</template>
@@ -29,25 +24,32 @@
import type { Category } from '~/stores';
const categoriesStore = useCategoriesStore();
+const categoriesItem = new TreeStructure(useSidebarTree().categories.value).generateTree().filter(i => i.data.type === 'category' && i.data.role == 2);
const props = defineProps<{ role: number }>();
-const category = ref<Category>({
+const category = ref<Partial<Category>>({
name: '',
type: 'category',
- id: '',
role: props.role,
+ id: '0',
});
+const emit = defineEmits(['close']);
const createCategory = () => {
- // categoriesStore.post(category.value)
+ categoriesStore
+ .post(category.value)
+ .then(() => {
+ useNotifications().add({ title: 'Success:', message: 'Category created', type: 'success', timeout: 3000 });
+ emit('close');
+ })
+ .catch(e => {
+ useNotifications().add({ title: 'Error:', message: e, type: 'error', timeout: 3000 });
+ });
};
</script>
<style scoped lang="scss">
.modal {
- background-color: var(--bg-contrast);
- padding: 0 1rem;
- border-radius: 8px;
min-width: 700px;
}
</style>
diff --git a/frontend/pages/dashboard/docs/_components/DocumentCardHeaderActionRow.vue b/frontend/pages/dashboard/docs/_components/DocumentCardHeaderActionRow.vue
index 4662dadc..869b4540 100644
--- a/frontend/pages/dashboard/docs/_components/DocumentCardHeaderActionRow.vue
+++ b/frontend/pages/dashboard/docs/_components/DocumentCardHeaderActionRow.vue
@@ -22,15 +22,11 @@
<script setup lang="ts">
import DeleteDocumentModal from '../_modals/DeleteDocumentModal.vue';
-import { useDocumentsStore } from '~/stores';
-const router = useRouter();
-const documentsStore = useDocumentsStore();
const props = defineProps<{ doc_id: string }>();
-
const print = () => window.print();
const openDeleteModal = () => {
- const modal = useModal().modals.value.push(new Modal(DeleteDocumentModal, 'Delete modal', {}));
+ useModal().modals.value.push(new Modal(shallowRef(DeleteDocumentModal), 'Delete modal', { documentId: props.doc_id }));
};
</script>
diff --git a/frontend/pages/dashboard/docs/_modals/DeleteDocumentModal.vue b/frontend/pages/dashboard/docs/_modals/DeleteDocumentModal.vue
index bcf1f448..9a12c342 100644
--- a/frontend/pages/dashboard/docs/_modals/DeleteDocumentModal.vue
+++ b/frontend/pages/dashboard/docs/_modals/DeleteDocumentModal.vue
@@ -1,41 +1,29 @@
<template>
<div class="modal">
<h3>Delete document</h3>
- <p>Are you sure you want to delete this document?</p>
+ <p>Are you sure you want to delete this document ?</p>
<p style="opacity: 0.7">This action is irreversible</p>
- <AppButton @click="deleteDoc" style="float: right" type="danger">Confirm</AppButton>
- <AppButton @click="close" style="float: right" type="link">Cancel</AppButton>
+ <p v-if="allChildren.length > 0" class="warn">This document has {{ allChildren.length }} child documents. They will be deleted too.</p>
+ <div class="footer">
+ <AppButton @click="emit('close')" type="secondary">Cancel</AppButton>
+ <AppButton @click="deleteDoc" type="danger">Confirm</AppButton>
+ </div>
</div>
</template>
<script setup lang="ts">
-import type { Category } from '~/stores';
-
-const categoriesStore = useCategoriesStore();
-const props = defineProps<{ role: number }>();
-
-const category = ref<Category>({
- name: '',
- type: 'category',
- id: '',
- role: props.role,
-});
-
-const deleteDoc = () => {
- // categoriesStore.post(category.value)
-};
-// Emit close event to parent component
+const props = defineProps<{ documentId: string }>();
+const deleteDoc = () => useCategoriesStore().delete(props.documentId);
const emit = defineEmits(['close']);
-const close = () => {
- emit('close');
-};
+const allChildren = useSidebarTree().getSubTreeById(props.documentId);
</script>
<style scoped lang="scss">
.modal {
- background-color: var(--bg-contrast);
- padding: 0 1rem;
- border-radius: 8px;
- min-width: 700px;
+ min-width: 500px;
+}
+.warn {
+ color: $red-dark;
+ opacity: 0.7;
}
</style>
diff --git a/frontend/stores/categories.store.ts b/frontend/stores/categories.store.ts
index 64e1151d..6b326e30 100644
--- a/frontend/stores/categories.store.ts
+++ b/frontend/stores/categories.store.ts
@@ -26,11 +26,11 @@ export const useCategoriesStore = defineStore('categories', {
} else reject(request.message);
});
},
- post(category: Category) {
+ post(category: Partial<Category>): Promise<string | number> {
return new Promise(async (resolve, reject) => {
- const request = await makeRequest(`categories`, 'POST', category);
- if (request.status == 'success') resolve(this.categories.push({ ...(request.result as DB_Category), type: 'category' }));
- else reject(request.message);
+ const response = await makeRequest(`categories`, 'POST', category);
+ if (response.status == 'success') resolve(this.categories.push({ ...(response.result as DB_Category), type: 'category' }));
+ else reject(response.message);
});
},
update(category: Category) {
diff --git a/frontend/styles/components.scss b/frontend/styles/components.scss
new file mode 100644
index 00000000..665db342
--- /dev/null
+++ b/frontend/styles/components.scss
@@ -0,0 +1,10 @@
+.modal {
+ .footer {
+ margin: 6px 0;
+ padding: 6px 0 0 0;
+ border-top: 1px solid var(--border-color);
+ display: flex;
+ justify-content: flex-end;
+ align-items: center;
+ }
+}
\ No newline at end of file
diff --git a/frontend/styles/main.scss b/frontend/styles/main.scss
index 18db68a4..471dfedd 100644
--- a/frontend/styles/main.scss
+++ b/frontend/styles/main.scss
@@ -3,6 +3,7 @@
@forward "./markdown.scss";
@forward "./document-theme.scss";
@forward "./code.scss";
+@forward "./components.scss";
/* only needed once */
* {