mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-28 16:26:00 +00:00
fixed hiding columns + simplified algorithm #1
This commit is contained in:
@@ -157,7 +157,7 @@ export abstract class GridDisplay {
|
|||||||
}
|
}
|
||||||
|
|
||||||
get hiddenColumnIndexes() {
|
get hiddenColumnIndexes() {
|
||||||
return (this.config.hiddenColumns || []).map(x => _.findIndex(this.columns, y => y.uniqueName == x));
|
return (this.config.hiddenColumns || []).map(x => _.findIndex(this.allColumns, y => y.uniqueName == x));
|
||||||
}
|
}
|
||||||
|
|
||||||
isColumnChecked(column: DisplayColumn) {
|
isColumnChecked(column: DisplayColumn) {
|
||||||
|
|||||||
@@ -697,6 +697,10 @@
|
|||||||
// $: console.log('rowHeight', rowHeight);
|
// $: console.log('rowHeight', rowHeight);
|
||||||
// $: console.log('containerHeight', containerHeight);
|
// $: console.log('containerHeight', containerHeight);
|
||||||
|
|
||||||
|
// $: console.log('COLUMNS', columns);
|
||||||
|
// $: console.log('realColumnUniqueNames', realColumnUniqueNames);
|
||||||
|
// $: console.log('columnSizes.realCount', columnSizes.realCount);
|
||||||
|
|
||||||
$: realColumnUniqueNames = _.range(columnSizes.realCount).map(
|
$: realColumnUniqueNames = _.range(columnSizes.realCount).map(
|
||||||
realIndex => (columns[columnSizes.realToModel(realIndex)] || {}).uniqueName
|
realIndex => (columns[columnSizes.realToModel(realIndex)] || {}).uniqueName
|
||||||
);
|
);
|
||||||
@@ -1317,7 +1321,10 @@
|
|||||||
<ErrorInfo message={errorMessage} alignTop />
|
<ErrorInfo message={errorMessage} alignTop />
|
||||||
{:else if isDynamicStructure && isLoadedAll && grider?.rowCount == 0}
|
{:else if isDynamicStructure && isLoadedAll && grider?.rowCount == 0}
|
||||||
<div>
|
<div>
|
||||||
<ErrorInfo alignTop message="No rows loaded, check filter or add new documents. You could copy documents from ohter collections/tables with Copy advanved/Copy as JSON command." />
|
<ErrorInfo
|
||||||
|
alignTop
|
||||||
|
message="No rows loaded, check filter or add new documents. You could copy documents from ohter collections/tables with Copy advanved/Copy as JSON command."
|
||||||
|
/>
|
||||||
{#if display.filterCount > 0}
|
{#if display.filterCount > 0}
|
||||||
<FormStyledButton value="Reset filter" on:click={() => display.clearFilters()} />
|
<FormStyledButton value="Reset filter" on:click={() => display.clearFilters()} />
|
||||||
{/if}
|
{/if}
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ export class SeriesSizes {
|
|||||||
private scrollItems: SeriesSizeItem[] = [];
|
private scrollItems: SeriesSizeItem[] = [];
|
||||||
private positions: number[] = [];
|
private positions: number[] = [];
|
||||||
private scrollIndexes: number[] = [];
|
private scrollIndexes: number[] = [];
|
||||||
|
private modelIndexes: number[] = [];
|
||||||
private frozenItems: SeriesSizeItem[] = [];
|
private frozenItems: SeriesSizeItem[] = [];
|
||||||
|
|
||||||
public get scrollCount(): number {
|
public get scrollCount(): number {
|
||||||
@@ -96,6 +97,11 @@ export class SeriesSizes {
|
|||||||
this.frozenItems.push(item);
|
this.frozenItems.push(item);
|
||||||
lastpos += size;
|
lastpos += size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.modelIndexes = _.range(0, this.count);
|
||||||
|
if (this.hiddenAndFrozenModelIndexes) {
|
||||||
|
this.modelIndexes = this.modelIndexes.filter(col => !this.hiddenAndFrozenModelIndexes.includes(col));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public getScrollIndexOnPosition(position: number): number {
|
public getScrollIndexOnPosition(position: number): number {
|
||||||
@@ -303,27 +309,32 @@ export class SeriesSizes {
|
|||||||
this.buildIndex();
|
this.buildIndex();
|
||||||
}
|
}
|
||||||
public realToModel(realIndex: number): number {
|
public realToModel(realIndex: number): number {
|
||||||
if (this.hiddenAndFrozenModelIndexes == null && this.frozenModelIndexes == null) return realIndex;
|
return this.modelIndexes[realIndex] ?? -1;
|
||||||
if (realIndex < 0) return -1;
|
// console.log('realToModel', realIndex);
|
||||||
if (realIndex < this.frozenCount && this.frozenModelIndexes != null) return this.frozenModelIndexes[realIndex];
|
// if (this.hiddenAndFrozenModelIndexes == null && this.frozenModelIndexes == null) return realIndex;
|
||||||
if (this.hiddenAndFrozenModelIndexes == null) return realIndex;
|
// if (realIndex < 0) return -1;
|
||||||
realIndex -= this.frozenCount;
|
// if (realIndex < this.frozenCount && this.frozenModelIndexes != null) return this.frozenModelIndexes[realIndex];
|
||||||
for (let hidItem of this.hiddenAndFrozenModelIndexes) {
|
// if (this.hiddenAndFrozenModelIndexes == null) return realIndex;
|
||||||
if (realIndex < hidItem) return realIndex;
|
// realIndex -= this.frozenCount;
|
||||||
realIndex++;
|
// console.log('this.hiddenAndFrozenModelIndexes', this.hiddenAndFrozenModelIndexes);
|
||||||
}
|
// for (let hidItem of this.hiddenAndFrozenModelIndexes) {
|
||||||
return realIndex;
|
// if (realIndex < hidItem) return realIndex;
|
||||||
|
// realIndex++;
|
||||||
|
// }
|
||||||
|
// console.log('realToModel RESP', realIndex);
|
||||||
|
// return realIndex;
|
||||||
}
|
}
|
||||||
public modelToReal(modelIndex: number): number {
|
public modelToReal(modelIndex: number): number {
|
||||||
if (this.hiddenAndFrozenModelIndexes == null && this.frozenModelIndexes == null) return modelIndex;
|
return this.modelIndexes.indexOf(modelIndex);
|
||||||
if (modelIndex < 0) return -1;
|
// if (this.hiddenAndFrozenModelIndexes == null && this.frozenModelIndexes == null) return modelIndex;
|
||||||
let frozenIndex: number = this.frozenModelIndexes != null ? _.indexOf(this.frozenModelIndexes, modelIndex) : -1;
|
// if (modelIndex < 0) return -1;
|
||||||
if (frozenIndex >= 0) return frozenIndex;
|
// let frozenIndex: number = this.frozenModelIndexes != null ? _.indexOf(this.frozenModelIndexes, modelIndex) : -1;
|
||||||
if (this.hiddenAndFrozenModelIndexes == null) return modelIndex;
|
// if (frozenIndex >= 0) return frozenIndex;
|
||||||
let hiddenIndex: number = _.sortedIndex(this.hiddenAndFrozenModelIndexes, modelIndex);
|
// if (this.hiddenAndFrozenModelIndexes == null) return modelIndex;
|
||||||
if (this.hiddenAndFrozenModelIndexes[hiddenIndex] == modelIndex) return -1;
|
// let hiddenIndex: number = _.sortedIndex(this.hiddenAndFrozenModelIndexes, modelIndex);
|
||||||
if (hiddenIndex >= 0) return modelIndex - hiddenIndex + this.frozenCount;
|
// if (this.hiddenAndFrozenModelIndexes[hiddenIndex] == modelIndex) return -1;
|
||||||
return modelIndex;
|
// if (hiddenIndex >= 0) return modelIndex - hiddenIndex + this.frozenCount;
|
||||||
|
// return modelIndex;
|
||||||
}
|
}
|
||||||
public getFrozenPosition(frozenIndex: number): number {
|
public getFrozenPosition(frozenIndex: number): number {
|
||||||
return this.frozenItems[frozenIndex].position;
|
return this.frozenItems[frozenIndex].position;
|
||||||
|
|||||||
Reference in New Issue
Block a user