mirror of
https://github.com/zadam/trilium.git
synced 2025-11-02 11:26:15 +01:00
feat(collections/board): support archived notes
This commit is contained in:
@@ -26,6 +26,7 @@ export default function Card({
|
|||||||
const isEditing = branch.branchId === branchIdToEdit;
|
const isEditing = branch.branchId === branchIdToEdit;
|
||||||
const colorClass = note.getColorClass() || '';
|
const colorClass = note.getColorClass() || '';
|
||||||
const editorRef = useRef<HTMLInputElement>(null);
|
const editorRef = useRef<HTMLInputElement>(null);
|
||||||
|
const isArchived = note.isArchived;
|
||||||
const [ title, setTitle ] = useState(note.title);
|
const [ title, setTitle ] = useState(note.title);
|
||||||
|
|
||||||
const handleDragStart = useCallback((e: DragEvent) => {
|
const handleDragStart = useCallback((e: DragEvent) => {
|
||||||
@@ -61,7 +62,7 @@ export default function Card({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className={`board-note ${colorClass} ${isDragging ? 'dragging' : ''} ${isEditing ? "editing" : ""}`}
|
className={`board-note ${colorClass} ${isDragging ? 'dragging' : ''} ${isEditing ? "editing" : ""} ${isArchived ? "archived" : ""}`}
|
||||||
draggable="true"
|
draggable="true"
|
||||||
onDragStart={handleDragStart}
|
onDragStart={handleDragStart}
|
||||||
onDragEnd={handleDragEnd}
|
onDragEnd={handleDragEnd}
|
||||||
|
|||||||
@@ -7,11 +7,11 @@ export type ColumnMap = Map<string, {
|
|||||||
note: FNote;
|
note: FNote;
|
||||||
}[]>;
|
}[]>;
|
||||||
|
|
||||||
export async function getBoardData(parentNote: FNote, groupByColumn: string, persistedData: BoardViewData) {
|
export async function getBoardData(parentNote: FNote, groupByColumn: string, persistedData: BoardViewData, includeArchived: boolean) {
|
||||||
const byColumn: ColumnMap = new Map();
|
const byColumn: ColumnMap = new Map();
|
||||||
|
|
||||||
// First, scan all notes to find what columns actually exist
|
// First, scan all notes to find what columns actually exist
|
||||||
await recursiveGroupBy(parentNote.getChildBranches(), byColumn, groupByColumn);
|
await recursiveGroupBy(parentNote.getChildBranches(), byColumn, groupByColumn, includeArchived);
|
||||||
|
|
||||||
// Get all columns that exist in the notes
|
// Get all columns that exist in the notes
|
||||||
const columnsFromNotes = [...byColumn.keys()];
|
const columnsFromNotes = [...byColumn.keys()];
|
||||||
@@ -61,13 +61,13 @@ export async function getBoardData(parentNote: FNote, groupByColumn: string, per
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
async function recursiveGroupBy(branches: FBranch[], byColumn: ColumnMap, groupByColumn: string) {
|
async function recursiveGroupBy(branches: FBranch[], byColumn: ColumnMap, groupByColumn: string, includeArchived: boolean) {
|
||||||
for (const branch of branches) {
|
for (const branch of branches) {
|
||||||
const note = await branch.getNote();
|
const note = await branch.getNote();
|
||||||
if (!note || note.isArchived) continue;
|
if (!note || (!includeArchived && note.isArchived)) continue;
|
||||||
|
|
||||||
if (note.hasChildren()) {
|
if (note.hasChildren()) {
|
||||||
await recursiveGroupBy(note.getChildBranches(), byColumn, groupByColumn);
|
await recursiveGroupBy(note.getChildBranches(), byColumn, groupByColumn, includeArchived);
|
||||||
}
|
}
|
||||||
|
|
||||||
const group = note.getLabelValue(groupByColumn);
|
const group = note.getLabelValue(groupByColumn);
|
||||||
|
|||||||
@@ -132,6 +132,10 @@
|
|||||||
transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.15s ease, margin-top 0.2s ease;
|
transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.15s ease, margin-top 0.2s ease;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.board-view-container .board-note.archived {
|
||||||
|
opacity: 0.5;
|
||||||
|
}
|
||||||
|
|
||||||
.board-view-container .board-note .icon {
|
.board-view-container .board-note .icon {
|
||||||
margin-right: 0.25em;
|
margin-right: 0.25em;
|
||||||
display: inline;
|
display: inline;
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { Dispatch, StateUpdater, useCallback, useEffect, useMemo, useRef, useSta
|
|||||||
import { ViewModeProps } from "../interface";
|
import { ViewModeProps } from "../interface";
|
||||||
import "./index.css";
|
import "./index.css";
|
||||||
import { ColumnMap, getBoardData } from "./data";
|
import { ColumnMap, getBoardData } from "./data";
|
||||||
import { useNoteLabelWithDefault, useTriliumEvent } from "../../react/hooks";
|
import { useNoteLabelBoolean, useNoteLabelWithDefault, useTriliumEvent } from "../../react/hooks";
|
||||||
import Icon from "../../react/Icon";
|
import Icon from "../../react/Icon";
|
||||||
import { t } from "../../../services/i18n";
|
import { t } from "../../../services/i18n";
|
||||||
import Api from "./api";
|
import Api from "./api";
|
||||||
@@ -41,6 +41,7 @@ export const BoardViewContext = createContext<BoardViewContextData>({});
|
|||||||
|
|
||||||
export default function BoardView({ note: parentNote, noteIds, viewConfig, saveConfig }: ViewModeProps<BoardViewData>) {
|
export default function BoardView({ note: parentNote, noteIds, viewConfig, saveConfig }: ViewModeProps<BoardViewData>) {
|
||||||
const [ statusAttribute ] = useNoteLabelWithDefault(parentNote, "board:groupBy", "status");
|
const [ statusAttribute ] = useNoteLabelWithDefault(parentNote, "board:groupBy", "status");
|
||||||
|
const [ includeArchived ] = useNoteLabelBoolean(parentNote, "includeArchived");
|
||||||
const [ byColumn, setByColumn ] = useState<ColumnMap>();
|
const [ byColumn, setByColumn ] = useState<ColumnMap>();
|
||||||
const [ columns, setColumns ] = useState<string[]>();
|
const [ columns, setColumns ] = useState<string[]>();
|
||||||
const [ draggedCard, setDraggedCard ] = useState<{ noteId: string, branchId: string, fromColumn: string, index: number } | null>(null);
|
const [ draggedCard, setDraggedCard ] = useState<{ noteId: string, branchId: string, fromColumn: string, index: number } | null>(null);
|
||||||
@@ -72,7 +73,7 @@ export default function BoardView({ note: parentNote, noteIds, viewConfig, saveC
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
function refresh() {
|
function refresh() {
|
||||||
getBoardData(parentNote, statusAttribute, viewConfig ?? {}).then(({ byColumn, newPersistedData }) => {
|
getBoardData(parentNote, statusAttribute, viewConfig ?? {}, includeArchived).then(({ byColumn, newPersistedData }) => {
|
||||||
setByColumn(byColumn);
|
setByColumn(byColumn);
|
||||||
|
|
||||||
if (newPersistedData) {
|
if (newPersistedData) {
|
||||||
|
|||||||
Reference in New Issue
Block a user