mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-22 21:36:00 +00:00
designer - column filter
This commit is contained in:
@@ -48,6 +48,8 @@
|
|||||||
import ChooseColorModal from '../modals/ChooseColorModal.svelte';
|
import ChooseColorModal from '../modals/ChooseColorModal.svelte';
|
||||||
import { currentThemeDefinition } from '../stores';
|
import { currentThemeDefinition } from '../stores';
|
||||||
import { extendDatabaseInfoFromApps } from 'dbgate-tools';
|
import { extendDatabaseInfoFromApps } from 'dbgate-tools';
|
||||||
|
import SearchInput from '../elements/SearchInput.svelte';
|
||||||
|
import CloseSearchButton from '../buttons/CloseSearchButton.svelte';
|
||||||
|
|
||||||
export let value;
|
export let value;
|
||||||
export let onChange;
|
export let onChange;
|
||||||
@@ -64,6 +66,7 @@
|
|||||||
let canvasHeight = 3000;
|
let canvasHeight = 3000;
|
||||||
let dragStartPoint = null;
|
let dragStartPoint = null;
|
||||||
let dragCurrentPoint = null;
|
let dragCurrentPoint = null;
|
||||||
|
let columnFilter;
|
||||||
|
|
||||||
const sourceDragColumn$ = writable(null);
|
const sourceDragColumn$ = writable(null);
|
||||||
const targetDragColumn$ = writable(null);
|
const targetDragColumn$ = writable(null);
|
||||||
@@ -80,7 +83,15 @@
|
|||||||
|
|
||||||
const tableRefs = {};
|
const tableRefs = {};
|
||||||
const referenceRefs = {};
|
const referenceRefs = {};
|
||||||
$: domTables = _.pickBy(_.mapValues(tableRefs, (tbl: any) => tbl?.getDomTable()));
|
let domTables;
|
||||||
|
$: {
|
||||||
|
tableRefs;
|
||||||
|
recomputeDomTables();
|
||||||
|
}
|
||||||
|
|
||||||
|
function recomputeDomTables() {
|
||||||
|
domTables = _.pickBy(_.mapValues(tableRefs, (tbl: any) => tbl?.getDomTable()));
|
||||||
|
}
|
||||||
|
|
||||||
function fixPositions(tables) {
|
function fixPositions(tables) {
|
||||||
const minLeft = _.min(tables.map(x => x.left));
|
const minLeft = _.min(tables.map(x => x.left));
|
||||||
@@ -835,6 +846,14 @@
|
|||||||
],
|
],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$: {
|
||||||
|
columnFilter;
|
||||||
|
tick().then(() => {
|
||||||
|
recomputeReferencePositions();
|
||||||
|
recomputeDomTables();
|
||||||
|
});
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="wrapper noselect" use:contextMenu={createMenu}>
|
<div class="wrapper noselect" use:contextMenu={createMenu}>
|
||||||
@@ -896,6 +915,7 @@
|
|||||||
onAddAllReferences={handleAddTableReferences}
|
onAddAllReferences={handleAddTableReferences}
|
||||||
onChangeTableColor={handleChangeTableColor}
|
onChangeTableColor={handleChangeTableColor}
|
||||||
onMoveReferences={recomputeReferencePositions}
|
onMoveReferences={recomputeReferencePositions}
|
||||||
|
{columnFilter}
|
||||||
{table}
|
{table}
|
||||||
{conid}
|
{conid}
|
||||||
{database}
|
{database}
|
||||||
@@ -930,6 +950,12 @@
|
|||||||
</svg>
|
</svg>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
|
{#if tables?.length > 0}
|
||||||
|
<div class="searchbox">
|
||||||
|
<SearchInput bind:value={columnFilter} placeholder="Filter columns" />
|
||||||
|
<CloseSearchButton bind:filter={columnFilter} />
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
@@ -946,6 +972,13 @@
|
|||||||
.canvas {
|
.canvas {
|
||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
|
.searchbox {
|
||||||
|
position: absolute;
|
||||||
|
right: 16px;
|
||||||
|
top: 0;
|
||||||
|
width: 200px;
|
||||||
|
display: flex;
|
||||||
|
}
|
||||||
|
|
||||||
svg.drag-rect {
|
svg.drag-rect {
|
||||||
visibility: hidden;
|
visibility: hidden;
|
||||||
|
|||||||
@@ -51,6 +51,7 @@
|
|||||||
export let designer;
|
export let designer;
|
||||||
export let onMoveReferences;
|
export let onMoveReferences;
|
||||||
export let settings;
|
export let settings;
|
||||||
|
export let columnFilter;
|
||||||
|
|
||||||
let movingPosition = null;
|
let movingPosition = null;
|
||||||
let domWrapper;
|
let domWrapper;
|
||||||
@@ -68,7 +69,7 @@
|
|||||||
$: specificDb = settings?.tableSpecificDb ? settings?.tableSpecificDb(designerId) : null;
|
$: specificDb = settings?.tableSpecificDb ? settings?.tableSpecificDb(designerId) : null;
|
||||||
$: filterParentRows = settings?.hasFilterParentRowsFlag ? settings?.hasFilterParentRowsFlag(designerId) : false;
|
$: filterParentRows = settings?.hasFilterParentRowsFlag ? settings?.hasFilterParentRowsFlag(designerId) : false;
|
||||||
$: isGrayed = settings?.isGrayedTable ? settings?.isGrayedTable(designerId) : false;
|
$: isGrayed = settings?.isGrayedTable ? settings?.isGrayedTable(designerId) : false;
|
||||||
$: flatColumns = getFlatColumns(columns, '', 0);
|
$: flatColumns = getFlatColumns(columns, columnFilter, 0);
|
||||||
|
|
||||||
function getFlatColumns(columns, filter, level) {
|
function getFlatColumns(columns, filter, level) {
|
||||||
if (!columns) return [];
|
if (!columns) return [];
|
||||||
|
|||||||
@@ -37,10 +37,10 @@ export default class DomTableRef {
|
|||||||
columnName = this.settings?.getParentColumnName(columnName);
|
columnName = this.settings?.getParentColumnName(columnName);
|
||||||
col = this.domRefs[columnName];
|
col = this.domRefs[columnName];
|
||||||
}
|
}
|
||||||
if (!col) return null;
|
const tableRect = this.getRect();
|
||||||
|
if (!col) return tableRect.top + 12;
|
||||||
const rect = col.getBoundingClientRect();
|
const rect = col.getBoundingClientRect();
|
||||||
const wrap = this.domWrapper.getBoundingClientRect();
|
const wrap = this.domWrapper.getBoundingClientRect();
|
||||||
const tableRect = this.getRect();
|
|
||||||
let res = (rect.top + rect.bottom) / 2 - wrap.top;
|
let res = (rect.top + rect.bottom) / 2 - wrap.top;
|
||||||
if (res < tableRect.top) res = tableRect.top;
|
if (res < tableRect.top) res = tableRect.top;
|
||||||
if (res > tableRect.bottom) res = tableRect.bottom;
|
if (res > tableRect.bottom) res = tableRect.bottom;
|
||||||
|
|||||||
Reference in New Issue
Block a user