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

81 lines
1.9 KiB
TypeScript
Raw Normal View History

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 {
overflow: hidden;
position: relative;
height: 100%;
2025-07-19 18:44:50 +03:00
padding: 1em;
2025-07-19 18:29:31 +03:00
user-select: none;
}
.board-view-container {
height: 100%;
2025-07-19 18:44:50 +03:00
display: flex;
gap: 1em;
}
.board-view-container .board-column {
min-width: 200px;
}
.board-view-container .board-column h3 {
font-size: 1.2em;
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);
this.$container = this.$root.find(".board-view-container");
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) {
const $noteEl = $("<div>").addClass("board-note").text(note.title); // Assuming FNote has a title property
$columnEl.append($noteEl);
}
$(el).append($columnEl);
}
2025-07-19 18:29:31 +03:00
}
}