mirror of
https://github.com/dbgate/dbgate
synced 2024-11-07 20:26:23 +00:00
fixed hiding columns + simplified algorithm #1
This commit is contained in:
parent
7575b59f4f
commit
bd12cd5c07
@ -157,7 +157,7 @@ export abstract class GridDisplay {
|
||||
}
|
||||
|
||||
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) {
|
||||
|
@ -697,6 +697,10 @@
|
||||
// $: console.log('rowHeight', rowHeight);
|
||||
// $: console.log('containerHeight', containerHeight);
|
||||
|
||||
// $: console.log('COLUMNS', columns);
|
||||
// $: console.log('realColumnUniqueNames', realColumnUniqueNames);
|
||||
// $: console.log('columnSizes.realCount', columnSizes.realCount);
|
||||
|
||||
$: realColumnUniqueNames = _.range(columnSizes.realCount).map(
|
||||
realIndex => (columns[columnSizes.realToModel(realIndex)] || {}).uniqueName
|
||||
);
|
||||
@ -1317,7 +1321,10 @@
|
||||
<ErrorInfo message={errorMessage} alignTop />
|
||||
{:else if isDynamicStructure && isLoadedAll && grider?.rowCount == 0}
|
||||
<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}
|
||||
<FormStyledButton value="Reset filter" on:click={() => display.clearFilters()} />
|
||||
{/if}
|
||||
|
@ -22,6 +22,7 @@ export class SeriesSizes {
|
||||
private scrollItems: SeriesSizeItem[] = [];
|
||||
private positions: number[] = [];
|
||||
private scrollIndexes: number[] = [];
|
||||
private modelIndexes: number[] = [];
|
||||
private frozenItems: SeriesSizeItem[] = [];
|
||||
|
||||
public get scrollCount(): number {
|
||||
@ -96,6 +97,11 @@ export class SeriesSizes {
|
||||
this.frozenItems.push(item);
|
||||
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 {
|
||||
@ -303,27 +309,32 @@ export class SeriesSizes {
|
||||
this.buildIndex();
|
||||
}
|
||||
public realToModel(realIndex: number): number {
|
||||
if (this.hiddenAndFrozenModelIndexes == null && this.frozenModelIndexes == null) return realIndex;
|
||||
if (realIndex < 0) return -1;
|
||||
if (realIndex < this.frozenCount && this.frozenModelIndexes != null) return this.frozenModelIndexes[realIndex];
|
||||
if (this.hiddenAndFrozenModelIndexes == null) return realIndex;
|
||||
realIndex -= this.frozenCount;
|
||||
for (let hidItem of this.hiddenAndFrozenModelIndexes) {
|
||||
if (realIndex < hidItem) return realIndex;
|
||||
realIndex++;
|
||||
}
|
||||
return realIndex;
|
||||
return this.modelIndexes[realIndex] ?? -1;
|
||||
// console.log('realToModel', realIndex);
|
||||
// if (this.hiddenAndFrozenModelIndexes == null && this.frozenModelIndexes == null) return realIndex;
|
||||
// if (realIndex < 0) return -1;
|
||||
// if (realIndex < this.frozenCount && this.frozenModelIndexes != null) return this.frozenModelIndexes[realIndex];
|
||||
// if (this.hiddenAndFrozenModelIndexes == null) return realIndex;
|
||||
// realIndex -= this.frozenCount;
|
||||
// console.log('this.hiddenAndFrozenModelIndexes', this.hiddenAndFrozenModelIndexes);
|
||||
// for (let hidItem of this.hiddenAndFrozenModelIndexes) {
|
||||
// if (realIndex < hidItem) return realIndex;
|
||||
// realIndex++;
|
||||
// }
|
||||
// console.log('realToModel RESP', realIndex);
|
||||
// return realIndex;
|
||||
}
|
||||
public modelToReal(modelIndex: number): number {
|
||||
if (this.hiddenAndFrozenModelIndexes == null && this.frozenModelIndexes == null) return modelIndex;
|
||||
if (modelIndex < 0) return -1;
|
||||
let frozenIndex: number = this.frozenModelIndexes != null ? _.indexOf(this.frozenModelIndexes, modelIndex) : -1;
|
||||
if (frozenIndex >= 0) return frozenIndex;
|
||||
if (this.hiddenAndFrozenModelIndexes == null) return modelIndex;
|
||||
let hiddenIndex: number = _.sortedIndex(this.hiddenAndFrozenModelIndexes, modelIndex);
|
||||
if (this.hiddenAndFrozenModelIndexes[hiddenIndex] == modelIndex) return -1;
|
||||
if (hiddenIndex >= 0) return modelIndex - hiddenIndex + this.frozenCount;
|
||||
return modelIndex;
|
||||
return this.modelIndexes.indexOf(modelIndex);
|
||||
// if (this.hiddenAndFrozenModelIndexes == null && this.frozenModelIndexes == null) return modelIndex;
|
||||
// if (modelIndex < 0) return -1;
|
||||
// let frozenIndex: number = this.frozenModelIndexes != null ? _.indexOf(this.frozenModelIndexes, modelIndex) : -1;
|
||||
// if (frozenIndex >= 0) return frozenIndex;
|
||||
// if (this.hiddenAndFrozenModelIndexes == null) return modelIndex;
|
||||
// let hiddenIndex: number = _.sortedIndex(this.hiddenAndFrozenModelIndexes, modelIndex);
|
||||
// if (this.hiddenAndFrozenModelIndexes[hiddenIndex] == modelIndex) return -1;
|
||||
// if (hiddenIndex >= 0) return modelIndex - hiddenIndex + this.frozenCount;
|
||||
// return modelIndex;
|
||||
}
|
||||
public getFrozenPosition(frozenIndex: number): number {
|
||||
return this.frozenItems[frozenIndex].position;
|
||||
|
Loading…
Reference in New Issue
Block a user