mirror of
https://github.com/zadam/trilium.git
synced 2025-10-28 17:56:02 +08:00
chore(view/table): leftover files
This commit is contained in:
parent
2cbb49681a
commit
7c943fe4ac
2 changed files with 0 additions and 95 deletions
|
|
@ -1,46 +0,0 @@
|
|||
import {
|
||||
IHeaderParams,
|
||||
IHeaderComp,
|
||||
} from 'ag-grid-community';
|
||||
|
||||
export default class TableAddColumnButton implements IHeaderComp {
|
||||
private eGui!: HTMLElement;
|
||||
private params!: IHeaderParams;
|
||||
|
||||
public init(params: IHeaderParams): void {
|
||||
this.params = params;
|
||||
|
||||
const container = document.createElement('div');
|
||||
container.style.display = 'flex';
|
||||
container.style.justifyContent = 'space-between';
|
||||
container.style.alignItems = 'center';
|
||||
|
||||
const label = document.createElement('span');
|
||||
label.innerText = params.displayName;
|
||||
|
||||
const button = document.createElement('button');
|
||||
button.textContent = '+';
|
||||
button.title = 'Add Row';
|
||||
button.onclick = () => {
|
||||
alert(`Add row for column: ${params.displayName}`);
|
||||
// Optionally trigger insert logic here
|
||||
};
|
||||
|
||||
container.appendChild(label);
|
||||
container.appendChild(button);
|
||||
|
||||
this.eGui = container;
|
||||
}
|
||||
|
||||
public getGui(): HTMLElement {
|
||||
return this.eGui;
|
||||
}
|
||||
|
||||
refresh(params: IHeaderParams): boolean {
|
||||
return false;
|
||||
}
|
||||
|
||||
public destroy(): void {
|
||||
// Optional: clean up if needed
|
||||
}
|
||||
}
|
||||
|
|
@ -1,49 +0,0 @@
|
|||
import { GridApi } from "ag-grid-community";
|
||||
import contextMenu, { MenuItem } from "../../../menus/context_menu.js";
|
||||
import { TableData } from "./data.js";
|
||||
|
||||
export default function applyHeaderCustomization(baseEl: HTMLElement, api: GridApi<TableData>) {
|
||||
const header = baseEl.querySelector(".ag-header");
|
||||
if (!header) {
|
||||
return;
|
||||
}
|
||||
|
||||
header.addEventListener("contextmenu", (_e) => {
|
||||
const e = _e as MouseEvent;
|
||||
e.preventDefault();
|
||||
|
||||
contextMenu.show({
|
||||
items: [
|
||||
{
|
||||
title: "Columns",
|
||||
items: buildColumnChooser(api)
|
||||
}
|
||||
],
|
||||
x: e.pageX,
|
||||
y: e.pageY,
|
||||
selectMenuItemHandler: () => {}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export function buildColumnChooser(api: GridApi<TableData>) {
|
||||
const items: MenuItem<unknown>[] = [];
|
||||
|
||||
for (const column of api.getColumns() ?? []) {
|
||||
const colDef = column.getColDef();
|
||||
if (!colDef) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const visible = column.isVisible();
|
||||
items.push({
|
||||
title: colDef.headerName ?? api.getDisplayNameForColumn(column, "header") ?? "",
|
||||
checked: visible,
|
||||
handler() {
|
||||
api.setColumnsVisible([ column ], !visible);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return items;
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue