|
|
@ -1,6 +1,8 @@
|
|
|
|
import {
|
|
|
|
import {
|
|
|
|
|
|
|
|
AfterViewChecked,
|
|
|
|
AfterViewInit,
|
|
|
|
AfterViewInit,
|
|
|
|
ChangeDetectionStrategy,
|
|
|
|
ChangeDetectionStrategy,
|
|
|
|
|
|
|
|
ChangeDetectorRef,
|
|
|
|
Component,
|
|
|
|
Component,
|
|
|
|
ElementRef,
|
|
|
|
ElementRef,
|
|
|
|
EventEmitter,
|
|
|
|
EventEmitter,
|
|
|
@ -27,10 +29,9 @@ import {LoggingService} from "../../../../../services/logging/logging.service";
|
|
|
|
styleUrls: ["./file-grid.component.scss"],
|
|
|
|
styleUrls: ["./file-grid.component.scss"],
|
|
|
|
changeDetection: ChangeDetectionStrategy.OnPush
|
|
|
|
changeDetection: ChangeDetectionStrategy.OnPush
|
|
|
|
})
|
|
|
|
})
|
|
|
|
export class FileGridComponent implements OnChanges, OnInit, AfterViewInit {
|
|
|
|
export class FileGridComponent implements OnChanges, OnInit, AfterViewInit, AfterViewChecked {
|
|
|
|
|
|
|
|
|
|
|
|
@Input() files: File[] = [];
|
|
|
|
@Input() files: File[] = [];
|
|
|
|
@Input() columns: number = 6;
|
|
|
|
|
|
|
|
@Input() preselectedFile: File | undefined;
|
|
|
|
@Input() preselectedFile: File | undefined;
|
|
|
|
@Output() fileOpen = new EventEmitter<File>();
|
|
|
|
@Output() fileOpen = new EventEmitter<File>();
|
|
|
|
@Output() fileSelect = new EventEmitter<File[]>();
|
|
|
|
@Output() fileSelect = new EventEmitter<File[]>();
|
|
|
@ -44,11 +45,14 @@ export class FileGridComponent implements OnChanges, OnInit, AfterViewInit {
|
|
|
|
public selectedEntries: Selectable<File>[] = [];
|
|
|
|
public selectedEntries: Selectable<File>[] = [];
|
|
|
|
public partitionedGridEntries: Selectable<File>[][] = [];
|
|
|
|
public partitionedGridEntries: Selectable<File>[][] = [];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private columns = 6;
|
|
|
|
|
|
|
|
private entrySizePx = 260;
|
|
|
|
private shiftClicked = false;
|
|
|
|
private shiftClicked = false;
|
|
|
|
private ctrlClicked = false;
|
|
|
|
private ctrlClicked = false;
|
|
|
|
private gridEntries: Selectable<File>[] = [];
|
|
|
|
private gridEntries: Selectable<File>[] = [];
|
|
|
|
|
|
|
|
|
|
|
|
constructor(
|
|
|
|
constructor(
|
|
|
|
|
|
|
|
private changeDetector: ChangeDetectorRef,
|
|
|
|
private logger: LoggingService,
|
|
|
|
private logger: LoggingService,
|
|
|
|
private tabService: TabService,
|
|
|
|
private tabService: TabService,
|
|
|
|
private fileService: FileService,
|
|
|
|
private fileService: FileService,
|
|
|
@ -64,6 +68,11 @@ export class FileGridComponent implements OnChanges, OnInit, AfterViewInit {
|
|
|
|
|
|
|
|
|
|
|
|
public ngAfterViewInit(): void {
|
|
|
|
public ngAfterViewInit(): void {
|
|
|
|
this.focus();
|
|
|
|
this.focus();
|
|
|
|
|
|
|
|
this.calculateColumnCount();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public ngAfterViewChecked(): void {
|
|
|
|
|
|
|
|
this.calculateColumnCount();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ngOnChanges(changes: SimpleChanges): void {
|
|
|
|
ngOnChanges(changes: SimpleChanges): void {
|
|
|
@ -190,6 +199,20 @@ export class FileGridComponent implements OnChanges, OnInit, AfterViewInit {
|
|
|
|
this.fileChanged.next();
|
|
|
|
this.fileChanged.next();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public calculateColumnCount() {
|
|
|
|
|
|
|
|
if (this.inner && this.inner.nativeElement) {
|
|
|
|
|
|
|
|
const width = Math.abs(this.inner.nativeElement.clientWidth);
|
|
|
|
|
|
|
|
const columns = Math.floor(width / this.entrySizePx);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (columns != this.columns) {
|
|
|
|
|
|
|
|
console.debug("grid displaying", columns, "columns");
|
|
|
|
|
|
|
|
this.columns = Math.max(columns, 1);
|
|
|
|
|
|
|
|
this.setPartitionedGridEntries();
|
|
|
|
|
|
|
|
this.changeDetector.detectChanges();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private setPartitionedGridEntries() {
|
|
|
|
private setPartitionedGridEntries() {
|
|
|
|
this.partitionedGridEntries = [];
|
|
|
|
this.partitionedGridEntries = [];
|
|
|
|
let scrollToIndex = -1;
|
|
|
|
let scrollToIndex = -1;
|
|
|
|