Files
Trilium/apps/client/src/widgets/view_widgets/board_view/index.ts

103 lines
2.6 KiB
TypeScript
Raw Normal View History

import { setupHorizontalScrollViaWheel } from "../../widget_utils";
2025-07-19 18:29:31 +03:00
import ViewMode, { ViewModeArgs } from "../view_mode";
import { getBoardData } from "./data";
2025-07-19 18:29:31 +03:00
const TPL = /*html*/`
<div class="board-view">
<style>
.board-view {
2025-07-19 19:23:42 +03:00
overflow-x: auto;
2025-07-19 18:29:31 +03:00
position: relative;
height: 100%;
user-select: none;
}
.board-view-container {
height: 100%;
2025-07-19 18:44:50 +03:00
display: flex;
2025-07-19 19:20:32 +03:00
gap: 1.5em;
2025-07-19 19:23:42 +03:00
padding: 1em;
2025-07-19 18:44:50 +03:00
}
.board-view-container .board-column {
2025-07-19 19:20:32 +03:00
width: 250px;
2025-07-19 19:23:42 +03:00
flex-shrink: 0;
2025-07-19 18:44:50 +03:00
}
.board-view-container .board-column h3 {
font-size: 1em;
}
.board-view-container .board-note {
box-shadow: 1px 1px 4px rgba(0, 0, 0, 0.25);
margin: 0.65em 0;
padding: 0.5em;
border-radius: 5px;
2025-07-19 18:29:31 +03:00
}
2025-07-19 19:16:39 +03:00
.board-view-container .board-note .icon {
margin-right: 0.25em;
}
2025-07-19 18:29:31 +03:00
</style>
2025-07-19 18:44:50 +03:00
<div class="board-view-container"></div>
2025-07-19 18:29:31 +03:00
</div>
`;
export interface StateInfo {
};
export default class BoardView extends ViewMode<StateInfo> {
private $root: JQuery<HTMLElement>;
private $container: JQuery<HTMLElement>;
constructor(args: ViewModeArgs) {
super(args, "board");
this.$root = $(TPL);
setupHorizontalScrollViaWheel(this.$root);
2025-07-19 18:29:31 +03:00
this.$container = this.$root.find(".board-view-container");
2025-07-19 18:29:31 +03:00
args.$parent.append(this.$root);
}
async renderList(): Promise<JQuery<HTMLElement> | undefined> {
2025-07-19 18:44:50 +03:00
this.$container.empty();
2025-07-19 18:29:31 +03:00
this.renderBoard(this.$container[0]);
2025-07-19 18:44:50 +03:00
2025-07-19 18:29:31 +03:00
return this.$root;
}
private async renderBoard(el: HTMLElement) {
const data = await getBoardData(this.noteIds, "status");
2025-07-19 18:44:50 +03:00
for (const column of data.byColumn.keys()) {
const columnNotes = data.byColumn.get(column);
if (!columnNotes) {
continue;
}
const $columnEl = $("<div>")
.addClass("board-column")
.append($("<h3>").text(column));
for (const note of columnNotes) {
2025-07-19 19:16:39 +03:00
const $iconEl = $("<span>")
.addClass("icon")
.addClass(note.getIcon());
const $noteEl = $("<div>")
.addClass("board-note")
.text(note.title); // Assuming FNote has a title property
$noteEl.prepend($iconEl);
2025-07-19 18:44:50 +03:00
$columnEl.append($noteEl);
}
$(el).append($columnEl);
}
2025-07-19 18:29:31 +03:00
}
}