mirror of
https://github.com/zadam/trilium.git
synced 2025-10-09 07:05:31 +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[] = [
|
let columnDefs: ColumnDefinition[] = [
|
||||||
{
|
{
|
||||||
title: "#",
|
title: "#",
|
||||||
|
|
|
@ -7,7 +7,7 @@ import FNote from "../../../entities/fnote.js";
|
||||||
*
|
*
|
||||||
* The value of the cell must be the note ID.
|
* 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();
|
let noteId = cell.getValue();
|
||||||
if (!noteId) {
|
if (!noteId) {
|
||||||
return "";
|
return "";
|
||||||
|
@ -30,7 +30,7 @@ export function NoteFormatter(cell: CellComponent, _formatterParams, onRendered)
|
||||||
if (cachedNote) {
|
if (cachedNote) {
|
||||||
// Cache hit, build the link immediately
|
// Cache hit, build the link immediately
|
||||||
const el = buildLink(cachedNote);
|
const el = buildLink(cachedNote);
|
||||||
return el?.outerHTML;
|
return el?.outerHTML ?? "";
|
||||||
} else {
|
} else {
|
||||||
// Cache miss, load the note asynchronously
|
// Cache miss, load the note asynchronously
|
||||||
onRendered(async () => {
|
onRendered(async () => {
|
||||||
|
@ -44,9 +44,9 @@ export function NoteFormatter(cell: CellComponent, _formatterParams, onRendered)
|
||||||
cell.getElement().appendChild(el);
|
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);
|
const { definitions: rowData, hasSubtree: hasChildren, rowNumber } = await buildRowDefinitions(this.parentNote, info, this.maxDepth);
|
||||||
this.rowNumberHint = rowNumber;
|
this.rowNumberHint = rowNumber;
|
||||||
const movableRows = canReorderRows(this.parentNote) && !hasChildren;
|
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 = {
|
let opts: Options = {
|
||||||
layout: "fitDataFill",
|
layout: "fitDataFill",
|
||||||
index: "branchId",
|
index: "branchId",
|
||||||
|
@ -228,7 +233,13 @@ export default class TableView extends ViewMode<StateInfo> {
|
||||||
}
|
}
|
||||||
|
|
||||||
const info = getAttributeDefinitionInformation(this.parentNote);
|
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.api.setColumns(columnDefs);
|
||||||
this.colEditing?.resetNewAttributePosition();
|
this.colEditing?.resetNewAttributePosition();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue