diff --git a/packages/datalib/src/PerspectiveTreeNode.ts b/packages/datalib/src/PerspectiveTreeNode.ts index 3d0f76a1..a98cd57e 100644 --- a/packages/datalib/src/PerspectiveTreeNode.ts +++ b/packages/datalib/src/PerspectiveTreeNode.ts @@ -139,6 +139,12 @@ export abstract class PerspectiveTreeNode { // return this.defaultChecked; return false; } + get isSecondaryChecked() { + return false; + } + get secondaryCheckable() { + return false; + } get columnTitle() { return this.title; } @@ -192,6 +198,8 @@ export abstract class PerspectiveTreeNode { // } } + toggleSecondaryChecked(value?: boolean) {} + createReferenceConfigColumns(): PerspectiveReferenceConfig['columns'] { return null; } @@ -531,6 +539,37 @@ export class PerspectiveTableColumnNode extends PerspectiveTreeNode { return !!this.parentNode?.parentNode?.hasTableCode(this.tableCode); } + get isSecondaryChecked() { + return super.isChecked; + } + get isChecked() { + if (this.foreignKey) return !!this.config.nodes?.find(x => x.designerId == this.designerId)?.isNodeChecked; + return super.isChecked; + } + get secondaryCheckable() { + return !!this.foreignKey; + } + toggleChecked(value?: boolean) { + if (this.foreignKey) { + this.setConfig(cfg => ({ + ...cfg, + nodes: cfg.nodes.map(node => + node.designerId == this.designerId + ? { + ...node, + isNodeChecked: value == null ? !node.isNodeChecked : value, + } + : node + ), + })); + } else { + super.toggleChecked(value); + } + } + toggleSecondaryChecked(value?: boolean) { + super.toggleChecked(value == null ? !this.isSecondaryChecked : value); + } + generateChildNodes(): PerspectiveTreeNode[] { if (!this.foreignKey) return []; const tbl = this?.db?.tables?.find( diff --git a/packages/web/src/designer/DesignerTable.svelte b/packages/web/src/designer/DesignerTable.svelte index e1e3738b..bb11e0cb 100644 --- a/packages/web/src/designer/DesignerTable.svelte +++ b/packages/web/src/designer/DesignerTable.svelte @@ -236,7 +236,14 @@ >