mirror of
https://github.com/zadam/trilium.git
synced 2025-10-20 23:29:02 +02:00
fix(view/table): most type errors
This commit is contained in:
parent
84db4ed57c
commit
2cbb49681a
@ -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 {
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
|
@ -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) {
|
||||
|
@ -8,10 +8,10 @@ export default function applyHeaderCustomization(baseEl: HTMLElement, api: GridA
|
||||
return;
|
||||
}
|
||||
|
||||
header.addEventListener("contextmenu", (e) => {
|
||||
header.addEventListener("contextmenu", (_e) => {
|
||||
const e = _e as MouseEvent;
|
||||
e.preventDefault();
|
||||
|
||||
|
||||
contextMenu.show({
|
||||
items: [
|
||||
{
|
||||
|
@ -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 icons
|
||||
let icon = document.createElement("i");
|
||||
icon.classList.add("bx");
|
||||
@ -27,8 +28,8 @@ function headerMenu(){
|
||||
|
||||
//create menu item
|
||||
menu.push({
|
||||
label:label,
|
||||
action:function(e){
|
||||
label: label,
|
||||
action: function (e) {
|
||||
//prevent menu closing
|
||||
e.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;
|
||||
};
|
||||
|
@ -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));
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user