mirror of
https://github.com/zadam/trilium.git
synced 2025-10-06 13:39:51 +08:00
chore(client): fix type errors
This commit is contained in:
parent
1298b968f2
commit
c874333a37
3 changed files with 26 additions and 7 deletions
|
@ -41,7 +41,15 @@ const labelTypeMappings: Record<ColumnType, Partial<ColumnDefinition>> = {
|
|||
}
|
||||
};
|
||||
|
||||
export function buildColumnDefinitions(info: AttributeDefinitionInformation[], movableRows: boolean, existingColumnData: ColumnDefinition[] | undefined, rowNumberHint: number, position?: number) {
|
||||
interface BuildColumnArgs {
|
||||
info: AttributeDefinitionInformation[];
|
||||
movableRows: boolean;
|
||||
existingColumnData: ColumnDefinition[] | undefined;
|
||||
rowNumberHint: number;
|
||||
position?: number;
|
||||
}
|
||||
|
||||
export function buildColumnDefinitions({ info, movableRows, existingColumnData, rowNumberHint, position }: BuildColumnArgs) {
|
||||
let columnDefs: ColumnDefinition[] = [
|
||||
{
|
||||
title: "#",
|
||||
|
|
|
@ -7,7 +7,7 @@ import FNote from "../../../entities/fnote.js";
|
|||
*
|
||||
* The value of the cell must be the note ID.
|
||||
*/
|
||||
export function NoteFormatter(cell: CellComponent, _formatterParams, onRendered) {
|
||||
export function NoteFormatter(cell: CellComponent, _formatterParams, onRendered): string {
|
||||
let noteId = cell.getValue();
|
||||
if (!noteId) {
|
||||
return "";
|
||||
|
@ -30,7 +30,7 @@ export function NoteFormatter(cell: CellComponent, _formatterParams, onRendered)
|
|||
if (cachedNote) {
|
||||
// Cache hit, build the link immediately
|
||||
const el = buildLink(cachedNote);
|
||||
return el?.outerHTML;
|
||||
return el?.outerHTML ?? "";
|
||||
} else {
|
||||
// Cache miss, load the note asynchronously
|
||||
onRendered(async () => {
|
||||
|
@ -44,9 +44,9 @@ export function NoteFormatter(cell: CellComponent, _formatterParams, onRendered)
|
|||
cell.getElement().appendChild(el);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return "";
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -141,7 +141,12 @@ export default class TableView extends ViewMode<StateInfo> {
|
|||
const { definitions: rowData, hasSubtree: hasChildren, rowNumber } = await buildRowDefinitions(this.parentNote, info, this.maxDepth);
|
||||
this.rowNumberHint = rowNumber;
|
||||
const movableRows = canReorderRows(this.parentNote) && !hasChildren;
|
||||
const columnDefs = buildColumnDefinitions(info, movableRows, this.persistentData.columns, this.rowNumberHint);
|
||||
const columnDefs = buildColumnDefinitions({
|
||||
info,
|
||||
movableRows,
|
||||
existingColumnData: this.persistentData.columns,
|
||||
rowNumberHint: this.rowNumberHint
|
||||
});
|
||||
let opts: Options = {
|
||||
layout: "fitDataFill",
|
||||
index: "branchId",
|
||||
|
@ -228,7 +233,13 @@ export default class TableView extends ViewMode<StateInfo> {
|
|||
}
|
||||
|
||||
const info = getAttributeDefinitionInformation(this.parentNote);
|
||||
const columnDefs = buildColumnDefinitions(info, !!this.api.options.movableRows, this.persistentData?.columns, this.colEditing?.getNewAttributePosition(), this.rowNumberHint);
|
||||
const columnDefs = buildColumnDefinitions({
|
||||
info,
|
||||
movableRows: !!this.api.options.movableRows,
|
||||
existingColumnData: this.persistentData?.columns,
|
||||
rowNumberHint: this.rowNumberHint,
|
||||
position: this.colEditing?.getNewAttributePosition()
|
||||
});
|
||||
this.api.setColumns(columnDefs);
|
||||
this.colEditing?.resetNewAttributePosition();
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue