perspective refactor WIP

This commit is contained in:
Jan Prochazka 2022-08-25 13:18:55 +02:00
parent 2a98918857
commit aeceb34d19
7 changed files with 293 additions and 157 deletions

View File

@ -1,10 +1,11 @@
import { DatabaseInfo, ForeignKeyInfo, NamedObjectInfo } from 'dbgate-types'; import { DatabaseInfo, ForeignKeyInfo, NamedObjectInfo, TableInfo } from 'dbgate-types';
import uuidv1 from 'uuid/v1';
export interface PerspectiveConfigColumns { // export interface PerspectiveConfigColumns {
expandedColumns: string[]; // expandedColumns: string[];
checkedColumns: string[]; // checkedColumns: string[];
uncheckedColumns: string[]; // uncheckedColumns: string[];
} // }
export interface PerspectiveCustomJoinConfig { export interface PerspectiveCustomJoinConfig {
joinid: string; joinid: string;
@ -28,32 +29,81 @@ export interface PerspectiveFilterColumnInfo {
foreignKey: ForeignKeyInfo; foreignKey: ForeignKeyInfo;
} }
export interface PerspectiveParentFilterConfig { // export interface PerspectiveParentFilterConfig {
uniqueName: string; // uniqueName: string;
} // }
export interface PerspectiveConfig extends PerspectiveConfigColumns { // export interface PerspectiveConfig extends PerspectiveConfigColumns {
rootObject: { schemaName?: string; pureName: string }; // rootObject: { schemaName?: string; pureName: string };
filters: { [uniqueName: string]: string }; // filters: { [uniqueName: string]: string };
// sort: {
// [parentUniqueName: string]: {
// uniqueName: string;
// order: 'ASC' | 'DESC';
// }[];
// };
// customJoins: PerspectiveCustomJoinConfig[];
// parentFilters: PerspectiveParentFilterConfig[];
// }
export interface PerspectiveNodeConfig {
designerId: string;
schemaName?: string;
pureName: string;
conid?: string;
database?: string;
isParentFilter?: true | undefined;
expandedNodes: string[];
checkedNodes: string[];
uncheckedNodes: string[];
sort: { sort: {
[parentUniqueName: string]: { columnName: string;
uniqueName: string; order: 'ASC' | 'DESC';
order: 'ASC' | 'DESC'; }[];
}[];
}; filters: { [uniqueName: string]: string };
customJoins: PerspectiveCustomJoinConfig[]; isAutoGenerated?: true | undefined;
parentFilters: PerspectiveParentFilterConfig[]; }
export interface PerspectiveReferenceConfig {
designerId: string;
sourceId: string;
targetId: string;
columns: {
source: string;
target: string;
}[];
isAutoGenerated?: true | undefined;
}
export interface PerspectiveConfig {
rootDesignerId: string;
nodes: PerspectiveNodeConfig[];
references: PerspectiveReferenceConfig[];
} }
export function createPerspectiveConfig(rootObject: { schemaName?: string; pureName: string }): PerspectiveConfig { export function createPerspectiveConfig(rootObject: { schemaName?: string; pureName: string }): PerspectiveConfig {
return { const rootNode: PerspectiveNodeConfig = {
expandedColumns: [], ...rootObject,
checkedColumns: [], designerId: uuidv1(),
uncheckedColumns: [],
customJoins: [], expandedNodes: [],
checkedNodes: [],
uncheckedNodes: [],
sort: [],
filters: {}, filters: {},
sort: {}, };
rootObject, return {
parentFilters: [], nodes: [rootNode],
references: [],
rootDesignerId: rootNode.designerId,
}; };
} }
@ -74,8 +124,8 @@ export function extractPerspectiveDatabases(
res.push({ conid, database }); res.push({ conid, database });
} }
for (const custom of cfg.customJoins) { for (const node of cfg.nodes) {
add(custom.conid || conid, custom.database || database); add(node.conid || conid, node.database || database);
} }
return res; return res;
} }

View File

@ -51,8 +51,8 @@ export class PerspectiveDisplayColumn {
return this.parentNodes[level]; return this.parentNodes[level];
} }
getParentTableUniqueName(level) { getParentTableDesignerId(level) {
return this.parentNodes[level]?.headerTableAttributes ? this.parentNodes[level]?.uniqueName : ''; return this.parentNodes[level]?.headerTableAttributes ? this.parentNodes[level]?.designerId : '';
} }
// hasParentNode(node: PerspectiveTreeNode) { // hasParentNode(node: PerspectiveTreeNode) {
@ -152,7 +152,7 @@ export class PerspectiveDisplay {
} }
findColumnIndexFromNode(node: PerspectiveTreeNode) { findColumnIndexFromNode(node: PerspectiveTreeNode) {
return _findIndex(this.columns, x => x.dataNode.uniqueName == node.uniqueName); return _findIndex(this.columns, x => x.dataNode.designerId == node.designerId);
} }
collectRows(sourceRows: any[], nodes: PerspectiveTreeNode[]): CollectedPerspectiveDisplayRow[] { collectRows(sourceRows: any[], nodes: PerspectiveTreeNode[]): CollectedPerspectiveDisplayRow[] {

View File

@ -11,9 +11,9 @@ import {
ChangePerspectiveConfigFunc, ChangePerspectiveConfigFunc,
MultipleDatabaseInfo, MultipleDatabaseInfo,
PerspectiveConfig, PerspectiveConfig,
PerspectiveConfigColumns,
PerspectiveCustomJoinConfig, PerspectiveCustomJoinConfig,
PerspectiveFilterColumnInfo, PerspectiveFilterColumnInfo,
PerspectiveNodeConfig,
} from './PerspectiveConfig'; } from './PerspectiveConfig';
import _isEqual from 'lodash/isEqual'; import _isEqual from 'lodash/isEqual';
import _cloneDeep from 'lodash/cloneDeep'; import _cloneDeep from 'lodash/cloneDeep';
@ -67,13 +67,26 @@ export abstract class PerspectiveTreeNode {
public setConfig: ChangePerspectiveConfigFunc, public setConfig: ChangePerspectiveConfigFunc,
public parentNode: PerspectiveTreeNode, public parentNode: PerspectiveTreeNode,
public dataProvider: PerspectiveDataProvider, public dataProvider: PerspectiveDataProvider,
public databaseConfig: PerspectiveDatabaseConfig public databaseConfig: PerspectiveDatabaseConfig,
) {} public designerId: string
) {
this.nodeConfig = config.nodes.find(x => x.designerId == designerId);
this.parentNodeConfig = parentNode?.nodeConfig;
}
readonly nodeConfig: PerspectiveNodeConfig;
readonly parentNodeConfig: PerspectiveNodeConfig;
defaultChecked: boolean; defaultChecked: boolean;
abstract get title(); abstract get title();
abstract get codeName(); abstract get codeName();
abstract get isExpandable(); abstract get isExpandable();
abstract get childNodes(): PerspectiveTreeNode[]; childNodesCache: PerspectiveTreeNode[] = null;
get childNodes(): PerspectiveTreeNode[] {
if (!this.childNodesCache) {
this.childNodesCache = this.generateChildNodes();
}
return this.childNodesCache;
}
abstract generateChildNodes(): PerspectiveTreeNode[];
abstract get icon(): string; abstract get icon(): string;
get fieldName() { get fieldName() {
return this.codeName; return this.codeName;
@ -106,20 +119,20 @@ export abstract class PerspectiveTreeNode {
return code == this.tableCode || this.parentNode?.hasTableCode(code); return code == this.tableCode || this.parentNode?.hasTableCode(code);
} }
get uniqueName() { // get uniqueName() {
if (this.parentNode) return `${this.parentNode.uniqueName}::${this.codeName}`; // if (this.parentNode) return `${this.parentNode.uniqueName}::${this.codeName}`;
return this.codeName; // return this.codeName;
} // }
get level() { get level() {
if (this.parentNode) return this.parentNode.level + 1; if (this.parentNode) return this.parentNode.level + 1;
return 0; return 0;
} }
get isExpanded() { get isExpanded() {
return this.config.expandedColumns.includes(this.uniqueName); return this.parentNodeConfig?.expandedNodes?.includes(this.codeName);
} }
get isChecked() { get isChecked() {
if (this.config.checkedColumns.includes(this.uniqueName)) return true; if (this.parentNodeConfig?.checkedNodes?.includes(this.codeName)) return true;
if (this.config.uncheckedColumns.includes(this.uniqueName)) return false; if (this.parentNodeConfig?.uncheckedNodes?.includes(this.codeName)) return false;
return this.defaultChecked; return this.defaultChecked;
} }
get columnTitle() { get columnTitle() {
@ -158,33 +171,66 @@ export abstract class PerspectiveTreeNode {
} }
toggleExpanded(value?: boolean) { toggleExpanded(value?: boolean) {
this.includeInColumnSet('expandedColumns', this.uniqueName, value == null ? !this.isExpanded : value); this.includeInNodeSet('expandedNodes', value == null ? !this.isExpanded : value);
} }
toggleChecked(value?: boolean) { toggleChecked(value?: boolean) {
if (this.defaultChecked) { if (this.defaultChecked) {
this.includeInColumnSet('uncheckedColumns', this.uniqueName, value == null ? this.isChecked : value); this.includeInNodeSet('uncheckedNodes', value == null ? this.isChecked : value);
} else { } else {
this.includeInColumnSet('checkedColumns', this.uniqueName, value == null ? !this.isChecked : value); this.includeInNodeSet('checkedNodes', value == null ? !this.isChecked : value);
} }
} }
includeInColumnSet(field: keyof PerspectiveConfigColumns, uniqueName: string, isIncluded: boolean) { includeInNodeSet(field: 'expandedNodes' | 'uncheckedNodes' | 'checkedNodes', isIncluded: boolean) {
// this.setConfig(cfg => {
// const node = cfg.nodes.find(x=>x.designerId==this.designerId);
// if (!node) {
// }
// return {
// ...cfg,
// nodes: cfg.nodes.map(node =>
// node.designerId == this.parentNode?.designerId
// ? {
// ...node,
// [field]: [...(node[field] || []), this.codeName],
// }
// : node
// ),
// };
// });
if (isIncluded) { if (isIncluded) {
this.setConfig(cfg => ({ this.setConfig(cfg => ({
...cfg, ...cfg,
[field]: [...(cfg[field] || []), uniqueName], nodes: cfg.nodes.map(node =>
node.designerId == this.parentNode?.designerId
? {
...node,
[field]: [...(node[field] || []), this.codeName],
}
: node
),
})); }));
} else { } else {
this.setConfig(cfg => ({ this.setConfig(cfg => ({
...cfg, ...cfg,
[field]: (cfg[field] || []).filter(x => x != uniqueName), nodes: cfg.nodes.map(node =>
node.designerId == this.parentNode?.designerId
? {
...node,
[field]: (node[field] || []).filter(x => x != this.codeName),
}
: node
),
})); }));
} }
} }
getFilter() { getFilter() {
return this.config.filters[this.uniqueName]; return this.parentNodeConfig?.filters?.[this.codeName];
} }
getDataLoadColumns() { getDataLoadColumns() {
@ -217,7 +263,7 @@ export abstract class PerspectiveTreeNode {
getOrderBy(table: TableInfo | ViewInfo): PerspectiveDataLoadProps['orderBy'] { getOrderBy(table: TableInfo | ViewInfo): PerspectiveDataLoadProps['orderBy'] {
const res = _compact( const res = _compact(
this.childNodes.map(node => { this.childNodes.map(node => {
const sort = this.config?.sort?.[node?.parentNode?.uniqueName]?.find(x => x.uniqueName == node.uniqueName); const sort = this.parentNodeConfig?.sort?.find(x => x.columnName == node.columnName);
if (sort) { if (sort) {
return { return {
columnName: node.columnName, columnName: node.columnName,
@ -259,11 +305,27 @@ export abstract class PerspectiveTreeNode {
return child?.findChildNodeByUniquePath(uniquePath.slice(1)); return child?.findChildNodeByUniquePath(uniquePath.slice(1));
} }
findNodeByUniqueName(uniqueName: string): PerspectiveTreeNode { // findNodeByUniqueName(uniqueName: string): PerspectiveTreeNode {
if (!uniqueName) return null; // if (!uniqueName) return null;
const uniquePath = uniqueName.split('::'); // const uniquePath = uniqueName.split('::');
if (uniquePath[0] != this.codeName) return null; // if (uniquePath[0] != this.codeName) return null;
return this.findChildNodeByUniquePath(uniquePath.slice(1)); // return this.findChildNodeByUniquePath(uniquePath.slice(1));
// }
findNodeByDesignerId(designerId: string): PerspectiveTreeNode {
if (!designerId) return null;
if (designerId == this.designerId) {
return this;
}
for (const child of this.childNodes) {
const res = child.findNodeByDesignerId(designerId);
if (res) {
return res;
}
}
return null;
} }
get supportsParentFilter() { get supportsParentFilter() {
@ -275,12 +337,14 @@ export abstract class PerspectiveTreeNode {
} }
get isParentFilter() { get isParentFilter() {
return !!(this.config.parentFilters || []).find(x => x.uniqueName == this.uniqueName); return !!this.nodeConfig?.isParentFilter;
} }
buildParentFilterConditions(): Condition[] { buildParentFilterConditions(): Condition[] {
const leafNodes = _compact( const leafNodes = _compact(
(this.config?.parentFilters || []).map(x => this.rootNode.findNodeByUniqueName(x.uniqueName)) (this.config?.nodes || [])
.filter(x => x.isParentFilter)
.map(x => this.rootNode.findNodeByDesignerId(x.designerId))
); );
const conditions: Condition[] = _compact( const conditions: Condition[] = _compact(
leafNodes.map(leafNode => { leafNodes.map(leafNode => {
@ -298,7 +362,7 @@ export abstract class PerspectiveTreeNode {
let node = leafNode; let node = leafNode;
let index = 1; let index = 1;
let lastAlias = 'pert_0'; let lastAlias = 'pert_0';
while (node?.parentNode && node?.parentNode?.uniqueName != this?.uniqueName) { while (node?.parentNode && node?.parentNode?.designerId != this?.designerId) {
node = node.parentNode; node = node.parentNode;
let alias = `pert_${index}`; let alias = `pert_${index}`;
select.from.relations.push({ select.from.relations.push({
@ -310,7 +374,7 @@ export abstract class PerspectiveTreeNode {
lastAlias = alias; lastAlias = alias;
lastNode = node; lastNode = node;
} }
if (node?.parentNode?.uniqueName != this?.uniqueName) return null; if (node?.parentNode?.designerId != this?.designerId) return null;
select.where = { select.where = {
conditionType: 'and', conditionType: 'and',
conditions: _compact([ conditions: _compact([
@ -346,9 +410,10 @@ export class PerspectiveTableColumnNode extends PerspectiveTreeNode {
setConfig: ChangePerspectiveConfigFunc, setConfig: ChangePerspectiveConfigFunc,
dataProvider: PerspectiveDataProvider, dataProvider: PerspectiveDataProvider,
databaseConfig: PerspectiveDatabaseConfig, databaseConfig: PerspectiveDatabaseConfig,
parentNode: PerspectiveTreeNode parentNode: PerspectiveTreeNode,
designerId: string
) { ) {
super(dbs, config, setConfig, parentNode, dataProvider, databaseConfig); super(dbs, config, setConfig, parentNode, dataProvider, databaseConfig, designerId);
this.isTable = !!this.db?.tables?.find(x => x.schemaName == table.schemaName && x.pureName == table.pureName); this.isTable = !!this.db?.tables?.find(x => x.schemaName == table.schemaName && x.pureName == table.pureName);
this.isView = !!this.db?.views?.find(x => x.schemaName == table.schemaName && x.pureName == table.pureName); this.isView = !!this.db?.views?.find(x => x.schemaName == table.schemaName && x.pureName == table.pureName);
@ -450,7 +515,7 @@ export class PerspectiveTableColumnNode extends PerspectiveTreeNode {
return !!this.parentNode?.parentNode?.hasTableCode(this.tableCode); return !!this.parentNode?.parentNode?.hasTableCode(this.tableCode);
} }
get childNodes(): PerspectiveTreeNode[] { generateChildNodes(): PerspectiveTreeNode[] {
if (!this.foreignKey) return []; if (!this.foreignKey) return [];
const tbl = this?.db?.tables?.find( const tbl = this?.db?.tables?.find(
x => x.pureName == this.foreignKey?.refTableName && x.schemaName == this.foreignKey?.refSchemaName x => x.pureName == this.foreignKey?.refTableName && x.schemaName == this.foreignKey?.refSchemaName
@ -535,9 +600,10 @@ export class PerspectiveTableNode extends PerspectiveTreeNode {
setConfig: ChangePerspectiveConfigFunc, setConfig: ChangePerspectiveConfigFunc,
public dataProvider: PerspectiveDataProvider, public dataProvider: PerspectiveDataProvider,
databaseConfig: PerspectiveDatabaseConfig, databaseConfig: PerspectiveDatabaseConfig,
parentNode: PerspectiveTreeNode parentNode: PerspectiveTreeNode,
designerId: string
) { ) {
super(dbs, config, setConfig, parentNode, dataProvider, databaseConfig); super(dbs, config, setConfig, parentNode, dataProvider, databaseConfig, designerId);
} }
getNodeLoadProps(parentRows: any[]): PerspectiveDataLoadProps { getNodeLoadProps(parentRows: any[]): PerspectiveDataLoadProps {
@ -563,7 +629,7 @@ export class PerspectiveTableNode extends PerspectiveTreeNode {
return true; return true;
} }
get childNodes(): PerspectiveTreeNode[] { generateChildNodes(): PerspectiveTreeNode[] {
return getTableChildPerspectiveNodes( return getTableChildPerspectiveNodes(
this.table, this.table,
this.dbs, this.dbs,
@ -671,9 +737,10 @@ export class PerspectiveTableReferenceNode extends PerspectiveTableNode {
public dataProvider: PerspectiveDataProvider, public dataProvider: PerspectiveDataProvider,
databaseConfig: PerspectiveDatabaseConfig, databaseConfig: PerspectiveDatabaseConfig,
public isMultiple: boolean, public isMultiple: boolean,
parentNode: PerspectiveTreeNode parentNode: PerspectiveTreeNode,
designerId: string
) { ) {
super(table, dbs, config, setConfig, dataProvider, databaseConfig, parentNode); super(table, dbs, config, setConfig, dataProvider, databaseConfig, parentNode, designerId);
} }
matchChildRow(parentRow: any, childRow: any): boolean { matchChildRow(parentRow: any, childRow: any): boolean {
@ -757,9 +824,10 @@ export class PerspectiveCustomJoinTreeNode extends PerspectiveTableNode {
setConfig: ChangePerspectiveConfigFunc, setConfig: ChangePerspectiveConfigFunc,
public dataProvider: PerspectiveDataProvider, public dataProvider: PerspectiveDataProvider,
databaseConfig: PerspectiveDatabaseConfig, databaseConfig: PerspectiveDatabaseConfig,
parentNode: PerspectiveTreeNode parentNode: PerspectiveTreeNode,
designerId: string
) { ) {
super(table, dbs, config, setConfig, dataProvider, databaseConfig, parentNode); super(table, dbs, config, setConfig, dataProvider, databaseConfig, parentNode, designerId);
} }
matchChildRow(parentRow: any, childRow: any): boolean { matchChildRow(parentRow: any, childRow: any): boolean {
@ -848,7 +916,17 @@ export function getTableChildPerspectiveNodes(
const columnNodes = table.columns.map( const columnNodes = table.columns.map(
col => col =>
new PerspectiveTableColumnNode(col, table, dbs, config, setConfig, dataProvider, databaseConfig, parentColumn) new PerspectiveTableColumnNode(
col,
table,
dbs,
config,
setConfig,
dataProvider,
databaseConfig,
parentColumn,
null
)
); );
const circularColumns = columnNodes.filter(x => x.isCircular).map(x => x.columnName); const circularColumns = columnNodes.filter(x => x.isCircular).map(x => x.columnName);
const defaultColumns = getPerspectiveDefaultColumns(table, db, circularColumns); const defaultColumns = getPerspectiveDefaultColumns(table, db, circularColumns);
@ -876,7 +954,8 @@ export function getTableChildPerspectiveNodes(
dataProvider, dataProvider,
databaseConfig, databaseConfig,
isMultiple, isMultiple,
parentColumn parentColumn,
null
) )
); );
} }
@ -884,33 +963,34 @@ export function getTableChildPerspectiveNodes(
} }
res.push(..._sortBy(dependencies, 'title')); res.push(..._sortBy(dependencies, 'title'));
const customs = []; // const customs = [];
for (const join of config.customJoins || []) { // for (const join of config.customJoins || []) {
if (join.baseUniqueName == parentColumn.uniqueName) { // if (join.baseUniqueName == parentColumn.uniqueName) {
const newConfig = { ...databaseConfig }; // const newConfig = { ...databaseConfig };
if (join.conid) newConfig.conid = join.conid; // if (join.conid) newConfig.conid = join.conid;
if (join.database) newConfig.database = join.database; // if (join.database) newConfig.database = join.database;
const db = dbs?.[newConfig.conid]?.[newConfig.database]; // const db = dbs?.[newConfig.conid]?.[newConfig.database];
const table = db?.tables?.find(x => x.pureName == join.refTableName && x.schemaName == join.refSchemaName); // const table = db?.tables?.find(x => x.pureName == join.refTableName && x.schemaName == join.refSchemaName);
const view = db?.views?.find(x => x.pureName == join.refTableName && x.schemaName == join.refSchemaName); // const view = db?.views?.find(x => x.pureName == join.refTableName && x.schemaName == join.refSchemaName);
if (table || view) { // if (table || view) {
customs.push( // customs.push(
new PerspectiveCustomJoinTreeNode( // new PerspectiveCustomJoinTreeNode(
join, // join,
table || view, // table || view,
dbs, // dbs,
config, // config,
setConfig, // setConfig,
dataProvider, // dataProvider,
newConfig, // newConfig,
parentColumn // parentColumn,
) // null
); // )
} // );
} // }
} // }
res.push(..._sortBy(customs, 'title')); // }
// res.push(..._sortBy(customs, 'title'));
return res; return res;
} }

View File

@ -9,14 +9,16 @@
export let config: PerspectiveConfig; export let config: PerspectiveConfig;
export let setConfig: ChangePerspectiveConfigFunc; export let setConfig: ChangePerspectiveConfigFunc;
$: parentUniqueName = column.dataNode?.parentNode?.uniqueName || ''; $: parentDesignerId = column.dataNode?.parentNode?.designerId || '';
$: uniqueName = column.dataNode.uniqueName; $: nodeDesignerId = column.dataNode.designerId;
$: order = config.sort?.[parentUniqueName]?.find(x => x.uniqueName == uniqueName)?.order; $: nodeConfig = column.dataNode.nodeConfig;
$: orderIndex = $: order = nodeConfig?.sort?.find(x => x.columnName == column.dataNode.columnName)?.order;
config.sort?.[parentUniqueName]?.length > 1 $: orderIndex = -1;
? _.findIndex(config.sort?.[parentUniqueName], x => x.uniqueName == uniqueName) // $: orderIndex =
: -1; // config.sort?.[parentUniqueName]?.length > 1
$: isSortDefined = config.sort?.[parentUniqueName]?.length > 0; // ? _.findIndex(config.sort?.[parentUniqueName], x => x.uniqueName == uniqueName)
// : -1;
$: isSortDefined = nodeConfig?.sort?.length > 0;
</script> </script>
{#if column.isVisible(columnLevel)} {#if column.isVisible(columnLevel)}
@ -49,7 +51,7 @@
<th <th
colspan={column.getColSpan(columnLevel)} colspan={column.getColSpan(columnLevel)}
class="tableHeader" class="tableHeader"
data-tableNodeUniqueName={column.getParentTableUniqueName(columnLevel)} data-tableNodeDesignerId={column.getParentTableDesignerId(columnLevel)}
> >
<div class="wrap"> <div class="wrap">
{column.getParentName(columnLevel)} {column.getParentName(columnLevel)}

View File

@ -66,7 +66,7 @@
const loadProps = node.getNodeLoadProps(parentRows); const loadProps = node.getNodeLoadProps(parentRows);
let { rows, incomplete } = await node.dataProvider.loadData({ let { rows, incomplete } = await node.dataProvider.loadData({
...loadProps, ...loadProps,
topCount: counts[node.uniqueName] || PERSPECTIVE_PAGE_SIZE, topCount: counts[node.designerId] || PERSPECTIVE_PAGE_SIZE,
}); });
// console.log('ROWS', rows, node.isRoot); // console.log('ROWS', rows, node.isRoot);
@ -76,7 +76,7 @@
if (incomplete) { if (incomplete) {
parentRows.push({ parentRows.push({
incompleteRowsIndicator: [node.uniqueName], incompleteRowsIndicator: [node.designerId],
}); });
} }
} else { } else {
@ -90,7 +90,7 @@
} }
if (incomplete && lastRowWithChildren) { if (incomplete && lastRowWithChildren) {
lastRowWithChildren[node.fieldName].push({ lastRowWithChildren[node.fieldName].push({
incompleteRowsIndicator: [node.uniqueName], incompleteRowsIndicator: [node.designerId],
}); });
} }
} }
@ -188,8 +188,8 @@
td.classList.remove('highlight'); td.classList.remove('highlight');
}); });
const tableNodeUniqueName = td.getAttribute('data-tableNodeUniqueName'); const tableNodeDesignerId = td.getAttribute('data-tableNodeDesignerId');
const tableNode = root?.findNodeByUniqueName(tableNodeUniqueName); const tableNode = root?.findNodeByDesignerId(tableNodeDesignerId);
if (tableNode?.headerTableAttributes) { if (tableNode?.headerTableAttributes) {
const { pureName, schemaName, conid, database } = tableNode?.headerTableAttributes; const { pureName, schemaName, conid, database } = tableNode?.headerTableAttributes;
@ -212,36 +212,36 @@
}); });
} }
if (tableNode?.supportsParentFilter) { // if (tableNode?.supportsParentFilter) {
const isParentFilter = (config.parentFilters || []).find(x => x.uniqueName == tableNode.uniqueName); // const isParentFilter = (config.parentFilters || []).find(x => x.uniqueName == tableNode.uniqueName);
if (isParentFilter) { // if (isParentFilter) {
res.push({ // res.push({
text: 'Cancel filter parent rows', // text: 'Cancel filter parent rows',
onClick: () => { // onClick: () => {
setConfig( // setConfig(
cfg => ({ // cfg => ({
...cfg, // ...cfg,
parentFilters: cfg.parentFilters.filter(x => x.uniqueName != tableNode.uniqueName), // parentFilters: cfg.parentFilters.filter(x => x.uniqueName != tableNode.uniqueName),
}), // }),
true // true
); // );
}, // },
}); // });
} else { // } else {
res.push({ // res.push({
text: 'Filter parent rows', // text: 'Filter parent rows',
onClick: () => { // onClick: () => {
setConfig( // setConfig(
cfg => ({ // cfg => ({
...cfg, // ...cfg,
parentFilters: [...(cfg.parentFilters || []), { uniqueName: tableNode.uniqueName }], // parentFilters: [...(cfg.parentFilters || []), { uniqueName: tableNode.uniqueName }],
}), // }),
true // true
); // );
}, // },
}); // });
} // }
} // }
const rowIndex = tr?.getAttribute('data-rowIndex'); const rowIndex = tr?.getAttribute('data-rowIndex');
if (rowIndex != null) { if (rowIndex != null) {
@ -296,18 +296,18 @@
}); });
} }
res.push({ // res.push({
text: 'Filter this value', // text: 'Filter this value',
onClick: () => { // onClick: () => {
setConfig(cfg => ({ // setConfig(cfg => ({
...cfg, // ...cfg,
filters: { // filters: {
...cfg.filters, // ...cfg.filters,
[dataNode.uniqueName]: getFilterValueExpression(value, dataNode.column.dataType), // [dataNode.uniqueName]: getFilterValueExpression(value, dataNode.column.dataType),
}, // },
})); // }));
}, // },
}); // });
} }
} }
} }

View File

@ -95,8 +95,9 @@
} }
$: dbInfos = useMultipleDatabaseInfo(extractPerspectiveDatabases({ conid, database }, config)); $: dbInfos = useMultipleDatabaseInfo(extractPerspectiveDatabases({ conid, database }, config));
$: tableInfo = useTableInfo({ conid, database, ...config?.rootObject }); $: rootObject = config?.nodes?.find(x => x.designerId == config?.rootDesignerId);
$: viewInfo = useViewInfo({ conid, database, ...config?.rootObject }); $: tableInfo = useTableInfo({ conid, database, ...rootObject });
$: viewInfo = useViewInfo({ conid, database, ...rootObject });
$: dataProvider = new PerspectiveDataProvider(cache, loader); $: dataProvider = new PerspectiveDataProvider(cache, loader);
$: loader = new PerspectiveDataLoader(apiCall); $: loader = new PerspectiveDataLoader(apiCall);
@ -109,7 +110,8 @@
setConfig, setConfig,
dataProvider, dataProvider,
{ conid, database }, { conid, database },
null null,
config.rootDesignerId
) )
: null; : null;
</script> </script>

View File

@ -107,6 +107,8 @@
cache.clear(); cache.clear();
loadedCounts.set({}); loadedCounts.set({});
} }
$: console.log('PERSPECTIVE', $modelState.value);
</script> </script>
<ToolStripContainer> <ToolStripContainer>