Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
fix(view/table): most type errors
Elian Doran2cbb49681aae
diff --git a/apps/client/src/widgets/floating_buttons/help_button.ts b/apps/client/src/widgets/floating_buttons/help_button.tsindex a68cb57112..3102ee59a2 100644--- a/apps/client/src/widgets/floating_buttons/help_button.ts+++ b/apps/client/src/widgets/floating_buttons/help_button.ts@@ -34,7 +34,8 @@ export const byNoteType: Record<Exclude<NoteType, "book">, string | null> = {export const byBookType: Record<ViewTypeOptions, string | null> = {list: null,grid: null,- calendar: "xWbu3jpNWapp"+ calendar: "xWbu3jpNWapp",+ table: null};export default class ContextualHelpButton extends NoteContextAwareWidget {diff --git a/apps/client/src/widgets/search_result.ts b/apps/client/src/widgets/search_result.tsindex 155c3d2b69..09b199ccf4 100644--- a/apps/client/src/widgets/search_result.ts+++ b/apps/client/src/widgets/search_result.ts@@ -65,7 +65,13 @@ export default class SearchResultWidget extends NoteContextAwareWidget {return;}- const noteListRenderer = new NoteListRenderer(this.$content, note, note.getChildNoteIds(), true);+ // this.$content, note, note.getChildNoteIds(), true+ const noteListRenderer = new NoteListRenderer({+ $parent: this.$content,+ parentNote: note,+ noteIds: note.getChildNoteIds(),+ showNotePath: true+ });await noteListRenderer.renderList();}diff --git a/apps/client/src/widgets/view_widgets/table_view/data.ts b/apps/client/src/widgets/view_widgets/table_view/data.tsindex 285187b13c..3ad275821a 100644--- a/apps/client/src/widgets/view_widgets/table_view/data.ts+++ b/apps/client/src/widgets/view_widgets/table_view/data.ts@@ -4,6 +4,7 @@ import type { ColumnDefinition } from "tabulator-tables";import link from "../../../services/link.js";export type TableData = {+ iconClass: string;noteId: string;title: string;labels: Record<string, boolean | string | null>;@@ -120,7 +121,7 @@ export function buildColumnDefinitions(info: PromotedAttributeInformation[]) {}export async function buildRowDefinitions(parentNote: FNote, notes: FNote[], infos: PromotedAttributeInformation[]) {- const definitions: GridOptions<TableData>["rowData"] = [];+ const definitions: TableData[] = [];for (const branch of parentNote.getChildBranches()) {const note = await branch.getNote();if (!note) {diff --git a/apps/client/src/widgets/view_widgets/table_view/header-customization.ts b/apps/client/src/widgets/view_widgets/table_view/header-customization.tsindex 6907a36647..46484895fe 100644--- a/apps/client/src/widgets/view_widgets/table_view/header-customization.ts+++ b/apps/client/src/widgets/view_widgets/table_view/header-customization.ts@@ -8,10 +8,10 @@ export default function applyHeaderCustomization(baseEl: HTMLElement, api: GridAreturn;}- header.addEventListener("contextmenu", (e) => {+ header.addEventListener("contextmenu", (_e) => {+ const e = _e as MouseEvent;e.preventDefault();-contextMenu.show({items: [{diff --git a/apps/client/src/widgets/view_widgets/table_view/header-menu.ts b/apps/client/src/widgets/view_widgets/table_view/header-menu.tsindex 9397757b49..4f53fbbe43 100644--- a/apps/client/src/widgets/view_widgets/table_view/header-menu.ts+++ b/apps/client/src/widgets/view_widgets/table_view/header-menu.ts@@ -1,16 +1,17 @@+import type { CellComponent, MenuObject, Tabulator } from "tabulator-tables";+export function applyHeaderMenu(columns) {//apply header menu to each column- for(let column of columns){+ for (let column of columns) {column.headerMenu = headerMenu;}}-function headerMenu(){- var menu = [];- var columns = this.getColumns();-- for(let column of columns){+function headerMenu(this: Tabulator) {+ const menu: MenuObject<CellComponent>[] = [];+ const columns = this.getColumns();+ for (let column of columns) {//create checkbox element using font awesome iconslet icon = document.createElement("i");icon.classList.add("bx");@@ -27,8 +28,8 @@ function headerMenu(){//create menu itemmenu.push({- label:label,- action:function(e){+ label: label,+ action: function (e) {//prevent menu closinge.stopPropagation();@@ -36,10 +37,10 @@ function headerMenu(){column.toggle();//change menu item icon- if(column.isVisible()){+ if (column.isVisible()) {icon.classList.remove("bx-empty");icon.classList.add("bx-check");- }else{+ } else {icon.classList.remove("bx-check");icon.classList.add("bx-empty");}@@ -47,5 +48,5 @@ function headerMenu(){});}- return menu;+ return menu;};diff --git a/apps/client/src/widgets/view_widgets/table_view/index.ts b/apps/client/src/widgets/view_widgets/table_view/index.tsindex 7f731ce8c3..5a06384cb8 100644--- a/apps/client/src/widgets/view_widgets/table_view/index.ts+++ b/apps/client/src/widgets/view_widgets/table_view/index.ts@@ -224,12 +224,20 @@ export default class TableView extends ViewMode<StateInfo> {}#manageColumnUpdate() {+ if (!this.api) {+ return;+ }+const info = getPromotedAttributeInformation(this.parentNote);const columnDefs = buildColumnDefinitions(info);this.api.setColumns(columnDefs);}async #manageRowsUpdate() {+ if (!this.api) {+ return;+ }+const notes = await froca.getNotes(this.args.noteIds);const info = getPromotedAttributeInformation(this.parentNote);this.api.setData(await buildRowDefinitions(this.parentNote, notes, info));diff --git a/apps/client/src/widgets/view_widgets/view_mode.ts b/apps/client/src/widgets/view_widgets/view_mode.tsindex f50c7841b9..350b84dcb1 100644--- a/apps/client/src/widgets/view_widgets/view_mode.ts+++ b/apps/client/src/widgets/view_widgets/view_mode.ts@@ -7,7 +7,7 @@ import ViewModeStorage from "./view_mode_storage.js";export interface ViewModeArgs {$parent: JQuery<HTMLElement>;parentNote: FNote;- parentNotePath: string | null | undefined;+ parentNotePath?: string | null;noteIds: string[];showNotePath?: boolean;}