From 4a22e3d2d4dcda19e0132f91ec526347c9909465 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Wed, 25 Jun 2025 19:25:01 +0300 Subject: [PATCH] feat(book/table): hide promoted attributes --- .../ribbon_widgets/promoted_attributes.ts | 2 +- .../table_view/header-add-column-button.ts | 46 +++++++++++++++++++ 2 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 apps/client/src/widgets/view_widgets/table_view/header-add-column-button.ts diff --git a/apps/client/src/widgets/ribbon_widgets/promoted_attributes.ts b/apps/client/src/widgets/ribbon_widgets/promoted_attributes.ts index d94cfdbd1..33341dd3f 100644 --- a/apps/client/src/widgets/ribbon_widgets/promoted_attributes.ts +++ b/apps/client/src/widgets/ribbon_widgets/promoted_attributes.ts @@ -117,7 +117,7 @@ export default class PromotedAttributesWidget extends NoteContextAwareWidget { // the order of attributes is important as well ownedAttributes.sort((a, b) => a.position - b.position); - if (promotedDefAttrs.length === 0) { + if (promotedDefAttrs.length === 0 || note.getLabelValue("viewType") === "table") { this.toggleInt(false); return; } diff --git a/apps/client/src/widgets/view_widgets/table_view/header-add-column-button.ts b/apps/client/src/widgets/view_widgets/table_view/header-add-column-button.ts new file mode 100644 index 000000000..cf02950c3 --- /dev/null +++ b/apps/client/src/widgets/view_widgets/table_view/header-add-column-button.ts @@ -0,0 +1,46 @@ +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 + } +}