mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-21 02:25:59 +00:00
form view columns filter
This commit is contained in:
@@ -33,6 +33,7 @@ export interface GridConfig extends GridConfigColumns {
|
|||||||
formViewKey?: { [uniqueName: string]: string };
|
formViewKey?: { [uniqueName: string]: string };
|
||||||
formViewKeyRequested?: { [uniqueName: string]: string };
|
formViewKeyRequested?: { [uniqueName: string]: string };
|
||||||
formFilterColumns: string[];
|
formFilterColumns: string[];
|
||||||
|
formColumnFilterText?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface GridCache {
|
export interface GridCache {
|
||||||
|
|||||||
@@ -152,9 +152,12 @@
|
|||||||
function isDataCell(cell) {
|
function isDataCell(cell) {
|
||||||
return cell[1] % 2 == 1;
|
return cell[1] % 2 == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import { filterName } from 'dbgate-datalib';
|
||||||
|
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
|
|
||||||
import { getContext } from 'svelte';
|
import { getContext } from 'svelte';
|
||||||
@@ -210,7 +213,10 @@
|
|||||||
|
|
||||||
$: rowCount = Math.floor((wrapperHeight - 22) / (rowHeight + 2));
|
$: rowCount = Math.floor((wrapperHeight - 22) / (rowHeight + 2));
|
||||||
|
|
||||||
$: columnChunks = _.chunk(formDisplay.columns, rowCount) as any[][];
|
$: columnChunks = _.chunk(
|
||||||
|
formDisplay.columns.filter(x => filterName(formDisplay.config.formColumnFilterText, x.columnName)),
|
||||||
|
rowCount
|
||||||
|
) as any[][];
|
||||||
|
|
||||||
$: rowCountInfo = getRowCountInfo(rowCountBefore, allRowCount);
|
$: rowCountInfo = getRowCountInfo(rowCountBefore, allRowCount);
|
||||||
|
|
||||||
@@ -380,10 +386,24 @@
|
|||||||
(event.keyCode >= keycodes.n0 && event.keyCode <= keycodes.n9) ||
|
(event.keyCode >= keycodes.n0 && event.keyCode <= keycodes.n9) ||
|
||||||
event.keyCode == keycodes.dash)
|
event.keyCode == keycodes.dash)
|
||||||
) {
|
) {
|
||||||
// @ts-ignore
|
if (currentCell[1] % 2 == 0) {
|
||||||
event.preventDefault();
|
setConfig(x => ({
|
||||||
dispatchInsplaceEditor({ type: 'show', text: event.key, cell: currentCell });
|
...x,
|
||||||
// console.log('event', event.nativeEvent);
|
// @ts-ignore
|
||||||
|
formColumnFilterText: (x.formColumnFilterText || '') + event.key,
|
||||||
|
}));
|
||||||
|
} else {
|
||||||
|
// @ts-ignore
|
||||||
|
event.preventDefault();
|
||||||
|
dispatchInsplaceEditor({ type: 'show', text: event.key, cell: currentCell });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (event.keyCode == keycodes.escape) {
|
||||||
|
setConfig(x => ({
|
||||||
|
...x,
|
||||||
|
formColumnFilterText: '',
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.keyCode == keycodes.f2) {
|
if (event.keyCode == keycodes.f2) {
|
||||||
@@ -441,6 +461,7 @@
|
|||||||
function handleSetFormView(rowData, column) {
|
function handleSetFormView(rowData, column) {
|
||||||
openReferenceForm(rowData, column, conid, database);
|
openReferenceForm(rowData, column, conid, database);
|
||||||
}
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="outer">
|
<div class="outer">
|
||||||
@@ -594,4 +615,5 @@
|
|||||||
right: 40px;
|
right: 40px;
|
||||||
bottom: 20px;
|
bottom: 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -2,19 +2,46 @@
|
|||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
|
|
||||||
import ManagerInnerContainer from '../elements/ManagerInnerContainer.svelte';
|
import ManagerInnerContainer from '../elements/ManagerInnerContainer.svelte';
|
||||||
|
import keycodes from '../utility/keycodes';
|
||||||
import FormViewFilterColumn from './FormViewFilterColumn.svelte';
|
import FormViewFilterColumn from './FormViewFilterColumn.svelte';
|
||||||
import PrimaryKeyFilterEditor from './PrimaryKeyFilterEditor.svelte';
|
import PrimaryKeyFilterEditor from './PrimaryKeyFilterEditor.svelte';
|
||||||
|
|
||||||
export let managerSize;
|
export let managerSize;
|
||||||
export let formDisplay;
|
export let formDisplay;
|
||||||
|
export let setConfig;
|
||||||
|
|
||||||
$: baseTable = formDisplay?.baseTable;
|
$: baseTable = formDisplay?.baseTable;
|
||||||
$: formFilterColumns = formDisplay?.config?.formFilterColumns;
|
$: formFilterColumns = formDisplay?.config?.formFilterColumns;
|
||||||
$: filters = formDisplay?.config?.filters;
|
$: filters = formDisplay?.config?.filters;
|
||||||
|
|
||||||
$: allFilterNames = _.union(_.keys(filters || {}), formFilterColumns || []);
|
$: allFilterNames = _.union(_.keys(filters || {}), formFilterColumns || []);
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<div class="m-1">
|
||||||
|
<div>Column filter</div>
|
||||||
|
<div class="flex">
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
value={formDisplay?.config?.formColumnFilterText || ''}
|
||||||
|
on:keydown={e => {
|
||||||
|
if (e.keyCode == keycodes.escape) {
|
||||||
|
setConfig(x => ({
|
||||||
|
...x,
|
||||||
|
formColumnFilterText: '',
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
on:input={e =>
|
||||||
|
setConfig(x => ({
|
||||||
|
...x,
|
||||||
|
// @ts-ignore
|
||||||
|
formColumnFilterText: e.target.value,
|
||||||
|
}))}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
{#if baseTable?.primaryKey}
|
{#if baseTable?.primaryKey}
|
||||||
<ManagerInnerContainer width={managerSize}>
|
<ManagerInnerContainer width={managerSize}>
|
||||||
{#each baseTable.primaryKey.columns as col}
|
{#each baseTable.primaryKey.columns as col}
|
||||||
|
|||||||
Reference in New Issue
Block a user