mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-21 02:25:59 +00:00
perspective refactor WIP
This commit is contained in:
@@ -9,14 +9,16 @@
|
||||
export let config: PerspectiveConfig;
|
||||
export let setConfig: ChangePerspectiveConfigFunc;
|
||||
|
||||
$: parentUniqueName = column.dataNode?.parentNode?.uniqueName || '';
|
||||
$: uniqueName = column.dataNode.uniqueName;
|
||||
$: order = config.sort?.[parentUniqueName]?.find(x => x.uniqueName == uniqueName)?.order;
|
||||
$: orderIndex =
|
||||
config.sort?.[parentUniqueName]?.length > 1
|
||||
? _.findIndex(config.sort?.[parentUniqueName], x => x.uniqueName == uniqueName)
|
||||
: -1;
|
||||
$: isSortDefined = config.sort?.[parentUniqueName]?.length > 0;
|
||||
$: parentDesignerId = column.dataNode?.parentNode?.designerId || '';
|
||||
$: nodeDesignerId = column.dataNode.designerId;
|
||||
$: nodeConfig = column.dataNode.nodeConfig;
|
||||
$: order = nodeConfig?.sort?.find(x => x.columnName == column.dataNode.columnName)?.order;
|
||||
$: orderIndex = -1;
|
||||
// $: orderIndex =
|
||||
// config.sort?.[parentUniqueName]?.length > 1
|
||||
// ? _.findIndex(config.sort?.[parentUniqueName], x => x.uniqueName == uniqueName)
|
||||
// : -1;
|
||||
$: isSortDefined = nodeConfig?.sort?.length > 0;
|
||||
</script>
|
||||
|
||||
{#if column.isVisible(columnLevel)}
|
||||
@@ -49,7 +51,7 @@
|
||||
<th
|
||||
colspan={column.getColSpan(columnLevel)}
|
||||
class="tableHeader"
|
||||
data-tableNodeUniqueName={column.getParentTableUniqueName(columnLevel)}
|
||||
data-tableNodeDesignerId={column.getParentTableDesignerId(columnLevel)}
|
||||
>
|
||||
<div class="wrap">
|
||||
{column.getParentName(columnLevel)}
|
||||
|
||||
@@ -66,7 +66,7 @@
|
||||
const loadProps = node.getNodeLoadProps(parentRows);
|
||||
let { rows, incomplete } = await node.dataProvider.loadData({
|
||||
...loadProps,
|
||||
topCount: counts[node.uniqueName] || PERSPECTIVE_PAGE_SIZE,
|
||||
topCount: counts[node.designerId] || PERSPECTIVE_PAGE_SIZE,
|
||||
});
|
||||
// console.log('ROWS', rows, node.isRoot);
|
||||
|
||||
@@ -76,7 +76,7 @@
|
||||
|
||||
if (incomplete) {
|
||||
parentRows.push({
|
||||
incompleteRowsIndicator: [node.uniqueName],
|
||||
incompleteRowsIndicator: [node.designerId],
|
||||
});
|
||||
}
|
||||
} else {
|
||||
@@ -90,7 +90,7 @@
|
||||
}
|
||||
if (incomplete && lastRowWithChildren) {
|
||||
lastRowWithChildren[node.fieldName].push({
|
||||
incompleteRowsIndicator: [node.uniqueName],
|
||||
incompleteRowsIndicator: [node.designerId],
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -188,8 +188,8 @@
|
||||
td.classList.remove('highlight');
|
||||
});
|
||||
|
||||
const tableNodeUniqueName = td.getAttribute('data-tableNodeUniqueName');
|
||||
const tableNode = root?.findNodeByUniqueName(tableNodeUniqueName);
|
||||
const tableNodeDesignerId = td.getAttribute('data-tableNodeDesignerId');
|
||||
const tableNode = root?.findNodeByDesignerId(tableNodeDesignerId);
|
||||
|
||||
if (tableNode?.headerTableAttributes) {
|
||||
const { pureName, schemaName, conid, database } = tableNode?.headerTableAttributes;
|
||||
@@ -212,36 +212,36 @@
|
||||
});
|
||||
}
|
||||
|
||||
if (tableNode?.supportsParentFilter) {
|
||||
const isParentFilter = (config.parentFilters || []).find(x => x.uniqueName == tableNode.uniqueName);
|
||||
if (isParentFilter) {
|
||||
res.push({
|
||||
text: 'Cancel filter parent rows',
|
||||
onClick: () => {
|
||||
setConfig(
|
||||
cfg => ({
|
||||
...cfg,
|
||||
parentFilters: cfg.parentFilters.filter(x => x.uniqueName != tableNode.uniqueName),
|
||||
}),
|
||||
true
|
||||
);
|
||||
},
|
||||
});
|
||||
} else {
|
||||
res.push({
|
||||
text: 'Filter parent rows',
|
||||
onClick: () => {
|
||||
setConfig(
|
||||
cfg => ({
|
||||
...cfg,
|
||||
parentFilters: [...(cfg.parentFilters || []), { uniqueName: tableNode.uniqueName }],
|
||||
}),
|
||||
true
|
||||
);
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
// if (tableNode?.supportsParentFilter) {
|
||||
// const isParentFilter = (config.parentFilters || []).find(x => x.uniqueName == tableNode.uniqueName);
|
||||
// if (isParentFilter) {
|
||||
// res.push({
|
||||
// text: 'Cancel filter parent rows',
|
||||
// onClick: () => {
|
||||
// setConfig(
|
||||
// cfg => ({
|
||||
// ...cfg,
|
||||
// parentFilters: cfg.parentFilters.filter(x => x.uniqueName != tableNode.uniqueName),
|
||||
// }),
|
||||
// true
|
||||
// );
|
||||
// },
|
||||
// });
|
||||
// } else {
|
||||
// res.push({
|
||||
// text: 'Filter parent rows',
|
||||
// onClick: () => {
|
||||
// setConfig(
|
||||
// cfg => ({
|
||||
// ...cfg,
|
||||
// parentFilters: [...(cfg.parentFilters || []), { uniqueName: tableNode.uniqueName }],
|
||||
// }),
|
||||
// true
|
||||
// );
|
||||
// },
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
|
||||
const rowIndex = tr?.getAttribute('data-rowIndex');
|
||||
if (rowIndex != null) {
|
||||
@@ -296,18 +296,18 @@
|
||||
});
|
||||
}
|
||||
|
||||
res.push({
|
||||
text: 'Filter this value',
|
||||
onClick: () => {
|
||||
setConfig(cfg => ({
|
||||
...cfg,
|
||||
filters: {
|
||||
...cfg.filters,
|
||||
[dataNode.uniqueName]: getFilterValueExpression(value, dataNode.column.dataType),
|
||||
},
|
||||
}));
|
||||
},
|
||||
});
|
||||
// res.push({
|
||||
// text: 'Filter this value',
|
||||
// onClick: () => {
|
||||
// setConfig(cfg => ({
|
||||
// ...cfg,
|
||||
// filters: {
|
||||
// ...cfg.filters,
|
||||
// [dataNode.uniqueName]: getFilterValueExpression(value, dataNode.column.dataType),
|
||||
// },
|
||||
// }));
|
||||
// },
|
||||
// });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,8 +95,9 @@
|
||||
}
|
||||
|
||||
$: dbInfos = useMultipleDatabaseInfo(extractPerspectiveDatabases({ conid, database }, config));
|
||||
$: tableInfo = useTableInfo({ conid, database, ...config?.rootObject });
|
||||
$: viewInfo = useViewInfo({ conid, database, ...config?.rootObject });
|
||||
$: rootObject = config?.nodes?.find(x => x.designerId == config?.rootDesignerId);
|
||||
$: tableInfo = useTableInfo({ conid, database, ...rootObject });
|
||||
$: viewInfo = useViewInfo({ conid, database, ...rootObject });
|
||||
|
||||
$: dataProvider = new PerspectiveDataProvider(cache, loader);
|
||||
$: loader = new PerspectiveDataLoader(apiCall);
|
||||
@@ -109,7 +110,8 @@
|
||||
setConfig,
|
||||
dataProvider,
|
||||
{ conid, database },
|
||||
null
|
||||
null,
|
||||
config.rootDesignerId
|
||||
)
|
||||
: null;
|
||||
</script>
|
||||
|
||||
@@ -107,6 +107,8 @@
|
||||
cache.clear();
|
||||
loadedCounts.set({});
|
||||
}
|
||||
|
||||
$: console.log('PERSPECTIVE', $modelState.value);
|
||||
</script>
|
||||
|
||||
<ToolStripContainer>
|
||||
|
||||
Reference in New Issue
Block a user