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.

feat(ui): add new advanced nodes view with bulk actions (#708)

Sairam Polisetty403a7faf10a5
diff --git a/frontend/app/components/AppTagInput.vue b/frontend/app/components/AppTagInput.vue
index 27ca4a57..3a40676e 100644
--- a/frontend/app/components/AppTagInput.vue
+++ b/frontend/app/components/AppTagInput.vue
@@ -133,6 +133,8 @@ function removeTag(tag: string) {
selectedTags.value = selectedTags.value.filter(t => t !== tag);
emit('update:modelValue', selectedTags.value.join(','));
}
+
+defineExpose({ addTag });
</script>
<style scoped lang="scss">
diff --git a/frontend/app/components/DataTable.vue b/frontend/app/components/DataTable.vue
index b19a24d3..56a9ff47 100644
--- a/frontend/app/components/DataTable.vue
+++ b/frontend/app/components/DataTable.vue
@@ -10,7 +10,7 @@
<thead>
<tr>
<th>
- <input type="checkbox" style="width: 20px" :checked="selectedRows.length > 0" @change="toggleSelectAll" />
+ <input type="checkbox" style="width: 20px" :checked="selectedRows.length === data.length && data.length > 0" @change="toggleSelectAll" />
</th>
<th v-for="header in headers" :key="header.key" :class="header.align && `align-${header.align}`">
<span>{{ header.label }}</span>
diff --git a/frontend/app/components/Node/AdvancedView.vue b/frontend/app/components/Node/AdvancedView.vue
new file mode 100644
index 00000000..adea3f56
--- /dev/null
+++ b/frontend/app/components/Node/AdvancedView.vue
@@ -0,0 +1,147 @@
+<template>
+ <div class="line-container" style="padding-top: 10px;">
+ <DataTable ref="tableRef" :headers="headers" :rows="rows">
+ <template #bulk-actions="{ selected }">
+ <div class="bulk-actions">
+ <span class="selected-count">{{ selected.length }}</span>
+ <span class="divider" />
+ <AppSelect
+ v-model="bulkParentId"
+ :items="parentNodes"
+ :placeholder="t('common.placeholder.parent')"
+ size="240px"
+ @update:model-value="parentId => bulkSetParent(selected, parentId)"
+ />
+ <span class="divider" />
+ <span @click="bulkDelete(selected)"><Icon name="delete" fill="var(--text-secondary)" class="action-btn" /></span>
+ </div>
+ </template>
+ <template #name="{ cell }">
+ <div style="display:flex;align-items:center;gap:8px;">
+ <Icon :name="asNode(cell?.data)?.icon || 'files'" />
+ <NuxtLink :to="`/dashboard/docs/${asNode(cell?.data)?.id}`">{{ asNode(cell?.data)?.name }}</NuxtLink>
+ </div>
+ </template>
+ <template #tags="{ cell }">
+ <NodeTagList v-if="cell?.data" :tags="asNode(cell.data).tags" class="tags" />
+ </template>
+ <template #action="{ cell }">
+ <NuxtLink :to="`/dashboard/docs/${asNode(cell?.data)?.id}`"><Icon name="edit" style="margin-right: 10px" /></NuxtLink>
+ <span style="cursor: pointer" @click="() => deleteNode(asNode(cell?.data))"><Icon name="delete" /></span>
+ </template>
+ </DataTable>
+ </div>
+</template>
+
+<script setup lang="ts">
+import NodeDeleteModal from '~/components/Node/Modals/Delete.vue';
+import { assignParent } from '~/helpers/resources-parent';
+import type { Node } from '~/stores';
+import type { Field } from '~/components/DataTable.vue';
+
+const props = defineProps<{ nodes: Node[] }>();
+
+const asNode = (data: unknown) => data as Node;
+const nodesStore = useNodesStore();
+const modals = useModal();
+const { getAppAccent } = useAppColors();
+const { t } = useI18nT();
+const { numericDate } = useDateFormatters();
+const notifications = useNotifications();
+const tree = useNodesTree();
+const parentNodes = tree.getTreeUpToRole(3);
+
+const tableRef = ref<{ selectedRows: Field[] } | null>(null);
+const bulkParentId = ref<string | number>('');
+
+const headers = [
+ { key: 'name', label: t('common.labels.name') },
+ { key: 'type', label: t('common.labels.type') },
+ { key: 'parent', label: t('common.labels.parent') },
+ { key: 'tags', label: 'Tags' },
+ { key: 'date', label: t('common.labels.date') },
+ { key: 'action', label: t('common.labels.action') },
+];
+
+const rows: ComputedRef<Field[]> = computed(() =>
+ props.nodes.map(res => {
+ const parent = res.parent_id ? nodesStore.getById(res.parent_id) : null;
+ return {
+ action: { data: res, type: 'slot' },
+ date: { content: numericDate(res.updated_timestamp), type: 'text' },
+ name: { data: res, type: 'slot' },
+ parent: { content: parent ? `<tag class="${getAppAccent(parent.color as number, true)}">${parent.name}</tag>` : '', type: 'html' },
+ tags: { data: res.tags, type: 'slot' },
+ type: { content: `<tag class="primary">Document</tag>`, type: 'html' },
+ };
+ }),
+);
+
+// Actions
+const bulkDelete = async (lines: Field[]) => {
+ const nodes = lines.map(line => line.action?.data as Node);
+ modals.add(new Modal(shallowRef(NodeDeleteModal), { props: { nodes: nodes, redirectTo: '/dashboard' }, size: 'small' }));
+};
+
+const bulkSetParent = async (lines: Field[], parentId: string | number) => {
+ if (!parentId) return;
+ const nodesToUpdate = assignParent(
+ lines.map(line => line.action?.data as Node),
+ parentId as string,
+ );
+ try {
+ await Promise.all(nodesToUpdate.map(node => nodesStore.update(node)));
+ bulkParentId.value = '';
+ if (tableRef.value) tableRef.value.selectedRows = [];
+ notifications.add({ title: t('common.actions.update'), type: 'success' });
+ } catch (e) {
+ notifications.add({ message: String(e), title: 'Error', type: 'error' });
+ }
+};
+
+const deleteNode = (node: Node) => {
+ modals.add(new Modal(shallowRef(NodeDeleteModal), { props: { node: node, redirectTo: '/dashboard' }, size: 'small' }));
+};
+</script>
+
+<style scoped lang="scss">
+.bulk-actions {
+ display: flex;
+ align-items: center;
+ gap: 8px;
+ width: 100%;
+}
+
+.action-btn {
+ cursor: pointer;
+
+ &:hover {
+ background: var(--surface-transparent);
+ }
+}
+
+.selected-count {
+ display: flex;
+ justify-content: center;
+ align-items: center;
+ width: 32px;
+ height: 34px;
+ padding: 4px;
+ border: 1px solid var(--border);
+ border-radius: var(--radius-xs);
+ font-size: 12px;
+ font-weight: bold;
+ color: var(--text-secondary);
+}
+
+.divider {
+ height: 32px;
+ margin-left: 4px;
+ border-left: 1px solid var(--border);
+}
+
+.line-container {
+ display: flex;
+ flex-direction: column;
+}
+</style>
diff --git a/frontend/app/components/Node/ContainerView.vue b/frontend/app/components/Node/ContainerView.vue
index 38cca789..57070313 100644
--- a/frontend/app/components/Node/ContainerView.vue
+++ b/frontend/app/components/Node/ContainerView.vue
@@ -57,8 +57,11 @@
</Teleport>
<!-- Content based on view mode -->
<div v-if="filteredNodes.length" class="node-content">
+ <!-- Advanced DataTable View -->
+ <NodeAdvancedView v-if="view === 'advanced'" :nodes="filteredNodes" />
+
<!-- Table/List View -->
- <div v-if="view === 'table'" class="line-container">
+ <div v-else-if="view === 'table'" class="line-container">
<NodeListInline v-for="document of filteredNodes" :key="document.id" :document="document" class="line-item" />
</div>
@@ -76,6 +79,12 @@
@update-metadata="updateKanbanMetadata"
@create-document="createDocumentInColumn"
/>
+
+ <!-- Fallback View (Just in case view is undefined or unrecognized) -->
+ <div v-else class="line-container fallback-view">
+ <div style="padding: 20px; color: red;">DEBUG: View is unrecognized or undefined. Current value: {{ view }}</div>
+ <NodeListInline v-for="document of filteredNodes" :key="document.id" :document="document" class="line-item" />
+ </div>
</div>
<NoContent v-else-if="!nodesStore.isFetching" :title="t('nodes.container.noDocuments')" :description="t('nodes.container.noDocumentsDescription')">
@@ -109,6 +118,7 @@ const router = useRouter();
const slots = useSlots();
const connectedId = userStore.user?.id;
+
const view = ref<ViewMode>();
const filteredNodes = ref<Node[]>(props.nodes);
const kanbanBoard = ref<InstanceType<typeof KanbanBoard> | null>(null);
@@ -121,6 +131,7 @@ watch(
);
// Actions
+
const resetKanban = () => {
modals.add(
new Modal(shallowRef(ResetBoardModal), {
diff --git a/frontend/app/components/ViewSelection.vue b/frontend/app/components/ViewSelection.vue
index 44d5b224..6354f084 100644
--- a/frontend/app/components/ViewSelection.vue
+++ b/frontend/app/components/ViewSelection.vue
@@ -9,7 +9,7 @@
<script setup lang="ts">
import localForage from 'localforage';
-export type ViewMode = 'kanban' | 'list' | 'table';
+export type ViewMode = 'kanban' | 'list' | 'table' | 'advanced';
const props = withDefaults(
defineProps<{
@@ -21,6 +21,7 @@ const props = withDefaults(
);
const { t } = useI18nT();
+const preferences = usePreferencesStore();
const view = defineModel<ViewMode>();
const viewOptions = computed(() => {
@@ -28,6 +29,9 @@ const viewOptions = computed(() => {
{ icon: 'table', label: t('components.viewSelection.list'), value: 'list' as ViewMode },
{ icon: 'list', label: t('components.viewSelection.table'), value: 'table' as ViewMode },
];
+ if (preferences.get('advancedView').value) {
+ options.push({ icon: 'grid', label: 'Advanced', value: 'advanced' as ViewMode });
+ }
if (props.showKanban) {
options.push({ icon: 'kanban', label: t('components.viewSelection.kanban'), value: 'kanban' as ViewMode });
}
@@ -41,6 +45,7 @@ watch(view, newView => {
onMounted(async () => {
const storedView = await localForage.getItem<ViewMode>('viewSelection');
const list = ['table', 'list'];
+ if (preferences.get('advancedView').value) list.push('advanced');
if (props.showKanban) list.push('kanban');
if (storedView && list.includes(storedView)) view.value = storedView as ViewMode;
else view.value = 'table';
diff --git a/frontend/app/composables/useDateFormatters.ts b/frontend/app/composables/useDateFormatters.ts
index 5e5e5878..2b44fe1d 100644
--- a/frontend/app/composables/useDateFormatters.ts
+++ b/frontend/app/composables/useDateFormatters.ts
@@ -9,7 +9,10 @@ export const useDateFormatters = () => {
/** Format a timestamp to a numeric date string (e.g., "12/15/2024") */
function numericDate(timestamp?: number | string): string {
- return new Date(timestamp || '').toLocaleDateString(locale.value, {
+ if (!timestamp) return '';
+ const date = new Date(timestamp);
+ if (isNaN(date.getTime())) return '';
+ return date.toLocaleDateString(locale.value, {
year: 'numeric',
month: '2-digit',
day: '2-digit',
diff --git a/frontend/app/pages/dashboard/settings/_views/other.vue b/frontend/app/pages/dashboard/settings/_views/other.vue
index 5e242d65..293955de 100644
--- a/frontend/app/pages/dashboard/settings/_views/other.vue
+++ b/frontend/app/pages/dashboard/settings/_views/other.vue
@@ -32,6 +32,13 @@ const options = computed<Array<{ label: string; options: InterfaceOption[] }>>((
{ label: '250', id: 250 },
],
},
+ {
+ label: 'Enable Advanced View',
+ description: 'Enable the advanced datatable view with bulk actions for Categories and Workspaces.',
+ type: 'toggle',
+ key: 'advancedView',
+ tag: t('settings.nav.new'),
+ },
],
},
{
diff --git a/frontend/app/stores/preferences/constants.ts b/frontend/app/stores/preferences/constants.ts
index 4f9d9183..915a7f39 100644
--- a/frontend/app/stores/preferences/constants.ts
+++ b/frontend/app/stores/preferences/constants.ts
@@ -15,6 +15,7 @@ export const DEFAULT_PREFERENCES = {
displayFeatureTags: true as boolean,
displayUncategorizedResources: true as boolean,
displayTabs: false as boolean,
+ advancedView: false as boolean,
datatableItemsCount: 10 as number,
view_dock: true as boolean,
primaryColor: -2 as number, // -2 default primary; -1 unset; >= 0 app color index
@@ -100,6 +101,7 @@ export const GENERAL_KEYS: PreferenceKey[] = [
'displayFeatureTags',
'displayUncategorizedResources',
'displayTabs',
+ 'advancedView',
'datatableItemsCount',
'view_dock',
'primaryColor',