mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-24 02:36:00 +00:00
perspective: open table ctx menu
This commit is contained in:
@@ -47,6 +47,10 @@ export class PerspectiveDisplayColumn {
|
|||||||
return this.parentNodes[level]?.title;
|
return this.parentNodes[level]?.title;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getParentDataAttributes(level) {
|
||||||
|
return this.parentNodes[level]?.headerDataAttributes;
|
||||||
|
}
|
||||||
|
|
||||||
// hasParentNode(node: PerspectiveTreeNode) {
|
// hasParentNode(node: PerspectiveTreeNode) {
|
||||||
// return this.parentNodes.includes(node);
|
// return this.parentNodes.includes(node);
|
||||||
// }
|
// }
|
||||||
|
|||||||
@@ -68,6 +68,9 @@ export abstract class PerspectiveTreeNode {
|
|||||||
get fieldName() {
|
get fieldName() {
|
||||||
return this.codeName;
|
return this.codeName;
|
||||||
}
|
}
|
||||||
|
get headerDataAttributes() {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
get dataField() {
|
get dataField() {
|
||||||
return this.codeName;
|
return this.codeName;
|
||||||
}
|
}
|
||||||
@@ -375,6 +378,18 @@ export class PerspectiveTableColumnNode extends PerspectiveTreeNode {
|
|||||||
|
|
||||||
return condition;
|
return condition;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get headerDataAttributes() {
|
||||||
|
if (this.foreignKey) {
|
||||||
|
return {
|
||||||
|
schemaName: this.foreignKey.refSchemaName,
|
||||||
|
pureName: this.foreignKey.refTableName,
|
||||||
|
conid: this.databaseConfig.conid,
|
||||||
|
database: this.databaseConfig.database,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class PerspectiveTableNode extends PerspectiveTreeNode {
|
export class PerspectiveTableNode extends PerspectiveTreeNode {
|
||||||
@@ -432,6 +447,15 @@ export class PerspectiveTableNode extends PerspectiveTreeNode {
|
|||||||
getBaseTableFromThis() {
|
getBaseTableFromThis() {
|
||||||
return this.table;
|
return this.table;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get headerDataAttributes() {
|
||||||
|
return {
|
||||||
|
schemaName: this.table.schemaName,
|
||||||
|
pureName: this.table.pureName,
|
||||||
|
conid: this.databaseConfig.conid,
|
||||||
|
database: this.databaseConfig.database,
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class PerspectiveViewNode extends PerspectiveTreeNode {
|
export class PerspectiveViewNode extends PerspectiveTreeNode {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { ChangePerspectiveConfigFunc, PerspectiveConfig, PerspectiveDisplayColumn } from 'dbgate-datalib';
|
import { ChangePerspectiveConfigFunc, PerspectiveConfig, PerspectiveDisplayColumn } from 'dbgate-datalib';
|
||||||
import _ from 'lodash';
|
import _, { mapKeys } from 'lodash';
|
||||||
|
|
||||||
import DropDownButton from '../buttons/DropDownButton.svelte';
|
import DropDownButton from '../buttons/DropDownButton.svelte';
|
||||||
import FontIcon from '../icons/FontIcon.svelte';
|
import FontIcon from '../icons/FontIcon.svelte';
|
||||||
@@ -17,15 +17,10 @@
|
|||||||
? _.findIndex(config.sort?.[parentUniqueName], x => x.uniqueName == uniqueName)
|
? _.findIndex(config.sort?.[parentUniqueName], x => x.uniqueName == uniqueName)
|
||||||
: -1;
|
: -1;
|
||||||
$: isSortDefined = config.sort?.[parentUniqueName]?.length > 0;
|
$: isSortDefined = config.sort?.[parentUniqueName]?.length > 0;
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if column.isVisible(columnLevel)}
|
{#if column.isVisible(columnLevel)}
|
||||||
<th
|
<th rowspan={column.rowSpan} class="columnHeader" data-column={column.columnIndex}>
|
||||||
rowspan={column.rowSpan}
|
|
||||||
class="columnHeader"
|
|
||||||
data-column={column.columnIndex}
|
|
||||||
>
|
|
||||||
<div class="wrap">
|
<div class="wrap">
|
||||||
<div class="label">
|
<div class="label">
|
||||||
{column.title}
|
{column.title}
|
||||||
@@ -51,7 +46,12 @@
|
|||||||
</th>
|
</th>
|
||||||
{/if}
|
{/if}
|
||||||
{#if column.showParent(columnLevel)}
|
{#if column.showParent(columnLevel)}
|
||||||
<th colspan={column.getColSpan(columnLevel)} class="tableHeader">{column.getParentName(columnLevel)}</th>
|
<th
|
||||||
|
colspan={column.getColSpan(columnLevel)}
|
||||||
|
class="tableHeader"
|
||||||
|
{..._.mapKeys(column.getParentDataAttributes(columnLevel), (v, k) => `data-${k}`)}
|
||||||
|
>{column.getParentName(columnLevel)}</th
|
||||||
|
>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
|||||||
@@ -30,6 +30,7 @@
|
|||||||
import PerspectiveHeaderControl from './PerspectiveHeaderControl.svelte';
|
import PerspectiveHeaderControl from './PerspectiveHeaderControl.svelte';
|
||||||
import createRef from '../utility/createRef';
|
import createRef from '../utility/createRef';
|
||||||
import { getPerspectiveNodeMenu } from './perspectiveMenu';
|
import { getPerspectiveNodeMenu } from './perspectiveMenu';
|
||||||
|
import openNewTab from '../utility/openNewTab';
|
||||||
|
|
||||||
const dbg = debug('dbgate:PerspectivaTable');
|
const dbg = debug('dbgate:PerspectivaTable');
|
||||||
export const activator = createActivator('PerspectiveTable', true);
|
export const activator = createActivator('PerspectiveTable', true);
|
||||||
@@ -176,6 +177,28 @@
|
|||||||
registerCloseHandler(() => {
|
registerCloseHandler(() => {
|
||||||
td.classList.remove('highlight');
|
td.classList.remove('highlight');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const pureName = td.getAttribute('data-pureName');
|
||||||
|
const schemaName = td.getAttribute('data-schemaName');
|
||||||
|
if (pureName) {
|
||||||
|
res.push({
|
||||||
|
text: `Open table ${pureName}`,
|
||||||
|
onClick: () => {
|
||||||
|
openNewTab({
|
||||||
|
title: pureName,
|
||||||
|
icon: 'img table',
|
||||||
|
tabComponent: 'TableDataTab',
|
||||||
|
props: {
|
||||||
|
schemaName,
|
||||||
|
pureName,
|
||||||
|
conid,
|
||||||
|
database,
|
||||||
|
objectTypeField: 'tables',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
res.push([
|
res.push([
|
||||||
|
|||||||
Reference in New Issue
Block a user