mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-26 01:46:02 +00:00
fixed column visibility
This commit is contained in:
@@ -80,6 +80,10 @@ export abstract class GridDisplay {
|
|||||||
return this.driver?.engine;
|
return this.driver?.engine;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get allColumns() {
|
||||||
|
return this.columns;
|
||||||
|
}
|
||||||
|
|
||||||
reload() {
|
reload() {
|
||||||
this.setCache((cache) => ({
|
this.setCache((cache) => ({
|
||||||
...cache,
|
...cache,
|
||||||
|
|||||||
@@ -175,7 +175,7 @@ async function loadRowCount(props) {
|
|||||||
export default function DataGridCore(props) {
|
export default function DataGridCore(props) {
|
||||||
const { conid, database, display, changeSetState, dispatchChangeSet, tabVisible, jslid } = props;
|
const { conid, database, display, changeSetState, dispatchChangeSet, tabVisible, jslid } = props;
|
||||||
// console.log('RENDER GRID', display.baseTable.pureName);
|
// console.log('RENDER GRID', display.baseTable.pureName);
|
||||||
const columns = React.useMemo(() => display.getGridColumns(), [display]);
|
const columns = React.useMemo(() => display.allColumns, [display]);
|
||||||
|
|
||||||
// usePropsCompare(props);
|
// usePropsCompare(props);
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ export class SeriesSizes {
|
|||||||
return this.frozenModelIndexes != null ? this.frozenModelIndexes.length : 0;
|
return this.frozenModelIndexes != null ? this.frozenModelIndexes.length : 0;
|
||||||
}
|
}
|
||||||
public get frozenSize(): number {
|
public get frozenSize(): number {
|
||||||
return _.sumBy(this.frozenItems, x => x.size);
|
return _.sumBy(this.frozenItems, (x) => x.size);
|
||||||
}
|
}
|
||||||
public get realCount(): number {
|
public get realCount(): number {
|
||||||
return this.frozenCount + this.scrollCount;
|
return this.frozenCount + this.scrollCount;
|
||||||
@@ -63,13 +63,13 @@ export class SeriesSizes {
|
|||||||
public buildIndex(): void {
|
public buildIndex(): void {
|
||||||
this.scrollItems = [];
|
this.scrollItems = [];
|
||||||
this.scrollIndexes = _.filter(
|
this.scrollIndexes = _.filter(
|
||||||
_.map(this.intKeys(this.sizeOverridesByModelIndex), x => this.modelToReal(x) - this.frozenCount),
|
_.map(_.range(this.count), (x) => this.modelToReal(x) - this.frozenCount),
|
||||||
x => x >= 0
|
(x) => x >= 0
|
||||||
);
|
);
|
||||||
this.scrollIndexes.sort();
|
this.scrollIndexes.sort();
|
||||||
let lastScrollIndex: number = -1;
|
let lastScrollIndex: number = -1;
|
||||||
let lastEndPosition: number = 0;
|
let lastEndPosition: number = 0;
|
||||||
this.scrollIndexes.forEach(scrollIndex => {
|
this.scrollIndexes.forEach((scrollIndex) => {
|
||||||
let modelIndex: number = this.realToModel(scrollIndex + this.frozenCount);
|
let modelIndex: number = this.realToModel(scrollIndex + this.frozenCount);
|
||||||
let size: number = this.sizeOverridesByModelIndex[modelIndex];
|
let size: number = this.sizeOverridesByModelIndex[modelIndex];
|
||||||
let item = new SeriesSizeItem();
|
let item = new SeriesSizeItem();
|
||||||
@@ -81,7 +81,7 @@ export class SeriesSizes {
|
|||||||
lastScrollIndex = scrollIndex;
|
lastScrollIndex = scrollIndex;
|
||||||
lastEndPosition = item.endPosition;
|
lastEndPosition = item.endPosition;
|
||||||
});
|
});
|
||||||
this.positions = _.map(this.scrollItems, x => x.position);
|
this.positions = _.map(this.scrollItems, (x) => x.position);
|
||||||
this.frozenItems = [];
|
this.frozenItems = [];
|
||||||
let lastpos: number = 0;
|
let lastpos: number = 0;
|
||||||
for (let i: number = 0; i < this.frozenCount; i++) {
|
for (let i: number = 0; i < this.frozenCount; i++) {
|
||||||
@@ -108,7 +108,7 @@ export class SeriesSizes {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
public getFrozenIndexOnPosition(position: number): number {
|
public getFrozenIndexOnPosition(position: number): number {
|
||||||
this.frozenItems.forEach(function(item) {
|
this.frozenItems.forEach(function (item) {
|
||||||
if (position >= item.position && position <= item.endPosition) return item.frozenIndex;
|
if (position >= item.position && position <= item.endPosition) return item.frozenIndex;
|
||||||
});
|
});
|
||||||
return -1;
|
return -1;
|
||||||
@@ -156,11 +156,11 @@ export class SeriesSizes {
|
|||||||
public getScroll(sourceScrollIndex: number, targetScrollIndex: number): number {
|
public getScroll(sourceScrollIndex: number, targetScrollIndex: number): number {
|
||||||
if (sourceScrollIndex < targetScrollIndex) {
|
if (sourceScrollIndex < targetScrollIndex) {
|
||||||
return -_.sum(
|
return -_.sum(
|
||||||
_.map(_.range(sourceScrollIndex, targetScrollIndex - sourceScrollIndex), x => this.getSizeByScrollIndex(x))
|
_.map(_.range(sourceScrollIndex, targetScrollIndex - sourceScrollIndex), (x) => this.getSizeByScrollIndex(x))
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
return _.sum(
|
return _.sum(
|
||||||
_.map(_.range(targetScrollIndex, sourceScrollIndex - targetScrollIndex), x => this.getSizeByScrollIndex(x))
|
_.map(_.range(targetScrollIndex, sourceScrollIndex - targetScrollIndex), (x) => this.getSizeByScrollIndex(x))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -170,15 +170,15 @@ export class SeriesSizes {
|
|||||||
}
|
}
|
||||||
public getTotalScrollSizeSum(): number {
|
public getTotalScrollSizeSum(): number {
|
||||||
let scrollSizeOverrides = _.map(
|
let scrollSizeOverrides = _.map(
|
||||||
_.filter(this.intKeys(this.sizeOverridesByModelIndex), x => this.modelIndexIsInScrollArea(x)),
|
_.filter(this.intKeys(this.sizeOverridesByModelIndex), (x) => this.modelIndexIsInScrollArea(x)),
|
||||||
x => this.sizeOverridesByModelIndex[x]
|
(x) => this.sizeOverridesByModelIndex[x]
|
||||||
);
|
);
|
||||||
return _.sum(scrollSizeOverrides) + (this.count - scrollSizeOverrides.length) * this.defaultSize;
|
return _.sum(scrollSizeOverrides) + (this.count - scrollSizeOverrides.length) * this.defaultSize;
|
||||||
}
|
}
|
||||||
public getVisibleScrollSizeSum(): number {
|
public getVisibleScrollSizeSum(): number {
|
||||||
let scrollSizeOverrides = _.map(
|
let scrollSizeOverrides = _.map(
|
||||||
_.filter(this.intKeys(this.sizeOverridesByModelIndex), x => !_.includes(this.hiddenAndFrozenModelIndexes, x)),
|
_.filter(this.intKeys(this.sizeOverridesByModelIndex), (x) => !_.includes(this.hiddenAndFrozenModelIndexes, x)),
|
||||||
x => this.sizeOverridesByModelIndex[x]
|
(x) => this.sizeOverridesByModelIndex[x]
|
||||||
);
|
);
|
||||||
return (
|
return (
|
||||||
_.sum(scrollSizeOverrides) +
|
_.sum(scrollSizeOverrides) +
|
||||||
@@ -186,7 +186,7 @@ export class SeriesSizes {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
private intKeys(value): number[] {
|
private intKeys(value): number[] {
|
||||||
return _.keys(value).map(x => _.parseInt(x));
|
return _.keys(value).map((x) => _.parseInt(x));
|
||||||
}
|
}
|
||||||
public getPositionByRealIndex(realIndex: number): number {
|
public getPositionByRealIndex(realIndex: number): number {
|
||||||
if (realIndex < 0) return 0;
|
if (realIndex < 0) return 0;
|
||||||
@@ -288,13 +288,13 @@ export class SeriesSizes {
|
|||||||
}
|
}
|
||||||
public setExtraordinaryIndexes(hidden: number[], frozen: number[]): void {
|
public setExtraordinaryIndexes(hidden: number[], frozen: number[]): void {
|
||||||
//this._hiddenAndFrozenModelIndexes = _.clone(hidden);
|
//this._hiddenAndFrozenModelIndexes = _.clone(hidden);
|
||||||
hidden = hidden.filter(x => x >= 0);
|
hidden = hidden.filter((x) => x >= 0);
|
||||||
frozen = frozen.filter(x => x >= 0);
|
frozen = frozen.filter((x) => x >= 0);
|
||||||
|
|
||||||
hidden.sort((a, b) => a - b);
|
hidden.sort((a, b) => a - b);
|
||||||
frozen.sort((a, b) => a - b);
|
frozen.sort((a, b) => a - b);
|
||||||
this.frozenModelIndexes = _.filter(frozen, x => !_.includes(hidden, x));
|
this.frozenModelIndexes = _.filter(frozen, (x) => !_.includes(hidden, x));
|
||||||
this.hiddenModelIndexes = _.filter(hidden, x => !_.includes(frozen, x));
|
this.hiddenModelIndexes = _.filter(hidden, (x) => !_.includes(frozen, x));
|
||||||
this.hiddenAndFrozenModelIndexes = _.concat(hidden, this.frozenModelIndexes);
|
this.hiddenAndFrozenModelIndexes = _.concat(hidden, this.frozenModelIndexes);
|
||||||
this.frozenModelIndexes.sort((a, b) => a - b);
|
this.frozenModelIndexes.sort((a, b) => a - b);
|
||||||
if (this.hiddenAndFrozenModelIndexes.length == 0) this.hiddenAndFrozenModelIndexes = null;
|
if (this.hiddenAndFrozenModelIndexes.length == 0) this.hiddenAndFrozenModelIndexes = null;
|
||||||
|
|||||||
@@ -3,12 +3,13 @@ import { SeriesSizes } from './SeriesSizes';
|
|||||||
import { CellAddress } from './selection';
|
import { CellAddress } from './selection';
|
||||||
|
|
||||||
export function countColumnSizes(loadedRows, columns, containerWidth, display) {
|
export function countColumnSizes(loadedRows, columns, containerWidth, display) {
|
||||||
|
const columnSizes = new SeriesSizes();
|
||||||
|
if (!loadedRows || !columns) return columnSizes;
|
||||||
|
|
||||||
let canvas = document.createElement('canvas');
|
let canvas = document.createElement('canvas');
|
||||||
let context = canvas.getContext('2d');
|
let context = canvas.getContext('2d');
|
||||||
|
|
||||||
//return this.context.measureText(txt).width;
|
//return this.context.measureText(txt).width;
|
||||||
const columnSizes = new SeriesSizes();
|
|
||||||
if (!loadedRows || !columns) return columnSizes;
|
|
||||||
|
|
||||||
// console.log('countColumnSizes', loadedRows.length, containerWidth);
|
// console.log('countColumnSizes', loadedRows.length, containerWidth);
|
||||||
|
|
||||||
@@ -113,7 +114,7 @@ export function filterCellForRow(cell, row: number): CellAddress | null {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function filterCellsForRow(cells, row: number): CellAddress[] | null {
|
export function filterCellsForRow(cells, row: number): CellAddress[] | null {
|
||||||
const res = (cells || []).filter(x => x[0] == row || _.isString(x[0]));
|
const res = (cells || []).filter((x) => x[0] == row || _.isString(x[0]));
|
||||||
return res.length > 0 ? res : null;
|
return res.length > 0 ? res : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user