FK secondary checkbox

This commit is contained in:
Jan Prochazka
2022-08-27 15:26:11 +02:00
parent e124291267
commit 2b68a6e1de
4 changed files with 77 additions and 1 deletions

View File

@@ -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(