Notebook Views grid fixes (#17170)

This commit is contained in:
Daniel Grajeda
2021-09-28 15:52:00 -06:00
committed by GitHub
parent 508630411d
commit 08acd6aadc
4 changed files with 16 additions and 20 deletions

View File

@@ -49,10 +49,6 @@ export class NotebookViewsCardComponent extends AngularDisposable implements OnI
} }
ngOnInit() { ngOnInit() {
this.initActionBar();
}
ngAfterViewInit() {
this.initialize(); this.initialize();
} }

View File

@@ -15,6 +15,6 @@
{{emptyText}} {{emptyText}}
</div> </div>
<div *ngIf="!loaded" style="display: block; position: absolute; height: 100%; width: 100%; z-index: 9999; background: #fff;"> <div *ngIf="!loaded" style="display: block; position: absolute; height: 100%; width: 100%; z-index: 1; background: #fff;">
<loading-spinner [loading]="!loaded" [loadingMessage]="loadingMessage"></loading-spinner> <loading-spinner [loading]="!loaded" [loadingMessage]="loadingMessage"></loading-spinner>
</div> </div>

View File

@@ -40,7 +40,7 @@ export class NotebookViewsGridComponent extends AngularDisposable implements OnI
protected _activeCell: ICellModel; protected _activeCell: ICellModel;
protected _options: INotebookViewsGridOptions = { protected _options: INotebookViewsGridOptions = {
cellHeight: 60 cellHeight: 30
};; };;
constructor( constructor(
@@ -89,9 +89,6 @@ export class NotebookViewsGridComponent extends AngularDisposable implements OnI
this._grid = undefined; this._grid = undefined;
} }
} }
if (this.activeView && this.activeView.guid !== this._gridView?.guid) {
this.activeView.initialize();
}
if (this.model?.activeCell?.id !== this._activeCell?.id) { if (this.model?.activeCell?.id !== this._activeCell?.id) {
this._activeCell = this.model.activeCell; this._activeCell = this.model.activeCell;
@@ -102,7 +99,6 @@ export class NotebookViewsGridComponent extends AngularDisposable implements OnI
ngAfterViewChecked() { ngAfterViewChecked() {
// If activeView has changed, rebuild the grid // If activeView has changed, rebuild the grid
if (this.activeView && this.activeView.guid !== this._gridView?.guid) { if (this.activeView && this.activeView.guid !== this._gridView?.guid) {
this._gridView = this.activeView;
if (!this._grid) { if (!this._grid) {
this.createGrid(); this.createGrid();
@@ -119,6 +115,7 @@ export class NotebookViewsGridComponent extends AngularDisposable implements OnI
private destroyGrid() { private destroyGrid() {
if (this._grid) { if (this._grid) {
this._loaded = false;
this._gridEnabled = false; this._gridEnabled = false;
this._grid.destroy(false); this._grid.destroy(false);
} }
@@ -126,6 +123,7 @@ export class NotebookViewsGridComponent extends AngularDisposable implements OnI
private createGrid() { private createGrid() {
const isNew = this.activeView.isNew; const isNew = this.activeView.isNew;
this._gridView = this.activeView;
if (this._grid) { if (this._grid) {
this.destroyGrid(); this.destroyGrid();
@@ -140,15 +138,15 @@ export class NotebookViewsGridComponent extends AngularDisposable implements OnI
alwaysShowResizeHandle: false, alwaysShowResizeHandle: false,
styleInHead: true, styleInHead: true,
margin: 2, margin: 2,
cellHeight: this._options.cellHeight,
staticGrid: false, staticGrid: false,
}); });
this._gridEnabled = true; this._gridEnabled = true;
if (isNew) {
this.updateGrid(); this.updateGrid();
} }
}
/** /**
* Updates the grid layout based on changes to the view model * Updates the grid layout based on changes to the view model
@@ -161,12 +159,14 @@ export class NotebookViewsGridComponent extends AngularDisposable implements OnI
this._grid.batchUpdate(); this._grid.batchUpdate();
this.activeView.cells.forEach(cell => { this.activeView.cells.forEach(cell => {
const el = this._grid.getGridItems().find(x => x.getAttribute('data-cell-id') === cell.cellGuid); const el = this._grid.getGridItems().find(x => x.getAttribute('data-cell-id') === cell.cellGuid);
if (el) {
const cellData = this.activeView.getCellMetadata(cell); const cellData = this.activeView.getCellMetadata(cell);
this._grid.update(el, { x: cellData.x, y: cellData.y, w: cellData.width, h: cellData.height }); this._grid.update(el, { x: cellData.x, y: cellData.y, w: cellData.width, h: cellData.height });
if (cellData?.hidden) { if (cellData?.hidden) {
this._grid.removeWidget(el, false); // Do not trigger event for batch update this._grid.removeWidget(el, false); // Do not trigger event for batch update
} }
}
}); });
this._grid.commit(); this._grid.commit();
} }

View File

@@ -69,13 +69,13 @@ class CellDisplayGroup extends DisplayGroup<ICellModel> {
//For graphs //For graphs
if (this.hasGraph(cell)) { if (this.hasGraph(cell)) {
visInfo.width = 6; visInfo.width = 6;
visInfo.height = 4; visInfo.height = 12;
} }
//For tables //For tables
else if (this.hasTable(cell)) { else if (this.hasTable(cell)) {
visInfo.height = Math.min(meta?.height, 3); visInfo.height = Math.min(meta?.height, 6);
} else { } else {
visInfo.height = Math.min(meta?.height, 3); visInfo.height = Math.min(meta?.height, 6);
} }
visInfo.display = true; visInfo.display = true;