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.

Modernize update category page

Smaug6739a38a4a4a711c
diff --git a/frontend/app/components/AppRadio.vue b/frontend/app/components/AppRadio.vue
new file mode 100644
index 00000000..1f464b4c
--- /dev/null
+++ b/frontend/app/components/AppRadio.vue
@@ -0,0 +1,45 @@
+<template>
+ <div class="segmented">
+ <button v-for="item in items" :key="item.id" :class="{ active: item.id === selected }" @click="selectItem(item.id)">{{ item.name }}</button>
+ </div>
+</template>
+
+<script setup lang="ts">
+const props = defineProps<{
+ items: Array<{ id: number; name: string }>;
+ modelValue: number | null;
+}>();
+
+const emit = defineEmits<{
+ (e: 'update:modelValue', value: number | null): void;
+}>();
+
+const selected = ref(props.modelValue);
+
+const selectItem = (id: number) => {
+ selected.value = id;
+ emit('update:modelValue', id);
+};
+</script>
+
+<style scoped lang="scss">
+.segmented {
+ display: flex;
+ gap: 0.5rem;
+
+ button {
+ flex: 1;
+ padding: 0.6rem;
+ border: 1px solid #ddd;
+ background: #f8f8f8;
+ border-radius: 0.5rem;
+ cursor: pointer;
+
+ &.active {
+ background: #2563eb;
+ color: white;
+ border-color: #2563eb;
+ }
+ }
+}
+</style>
diff --git a/frontend/app/pages/dashboard/categories/[id]/edit.vue b/frontend/app/pages/dashboard/categories/[id]/edit.vue
index ba527012..d2e0fd1e 100644
--- a/frontend/app/pages/dashboard/categories/[id]/edit.vue
+++ b/frontend/app/pages/dashboard/categories/[id]/edit.vue
@@ -1,6 +1,6 @@
<template>
<div class="card-component">
- <h1 style="font-size: 20px">Update category & workspace</h1>
+ <h1 style="font-size: 24px">Category & workspace</h1>
<form v-if="category" @submit.prevent>
<div class="form-row">
<div class="form-column">
@@ -8,23 +8,31 @@
<input id="id" v-model="category.id" type="text" disabled />
</div>
<div class="form-column">
- <label for="order">Order</label>
- <input id="order" v-model.number="category.order" type="number" />
+ <label>Role</label>
+ <AppRadio
+ v-model="category.role"
+ :items="[
+ { id: 1, name: 'Category' },
+ { id: 2, name: 'Workspace' },
+ ]"
+ />
</div>
</div>
<label>Name</label>
<input id="name" v-model="category.name" type="text" required />
- <label>Role</label>
- <select v-model="category.role">
- <option :value="1">Category</option>
- <option :value="2">Workspace</option>
- </select>
+ <div class="form-row">
+ <div class="form-column">
+ <label>Parent</label>
+ <AppSelect v-model="category.parent_id" :items="categoriesItem" placeholder="Select a category parent" />
+ </div>
+ <div class="form-column">
+ <label for="order">Order</label>
+ <input id="order" v-model.number="category.order" type="number" />
+ </div>
+ </div>
<label style="display: flex; align-items: center">Icon <AppHint text="SVG supported" /></label>
<textarea v-model="category.icon" type="text" rows="5" />
- <label>Parent</label>
- <AppSelect v-model="category.parent_id" :items="categoriesItem" placeholder="Select a category parent" />
-
<label for="color">Color</label>
<AppColorPicker v-model:selected-color="category.color" name="color" :nullable="true" />