From 972eb6a54d75ff71a752bb83f643c199e38683c1 Mon Sep 17 00:00:00 2001 From: Bas Date: Thu, 5 Dec 2024 14:07:16 +0000 Subject: [PATCH] fixup! fixup! Fix reactive model of table --- .../accessible-table.component.ts | 4 ++-- src/app/app.component.ts | 18 ++++++++++-------- src/app/app.module.ts | 2 ++ 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/app/accessible-table/accessible-table.component.ts b/src/app/accessible-table/accessible-table.component.ts index 1912d728..1e68a8b0 100644 --- a/src/app/accessible-table/accessible-table.component.ts +++ b/src/app/accessible-table/accessible-table.component.ts @@ -39,8 +39,8 @@ export class AccessibleTableComponent implements AfterViewChecked, OnChanges { @Output() rowClicked = new EventEmitter(); @Output() selectionDragStarted = new EventEmitter(); + firstRowHeight: number = 100; private lastCheckedRow: number|null = null - private firstRowHeight: number = 100; private shiftKey = false; private ctrlKey = false; @@ -97,7 +97,7 @@ export class AccessibleTableComponent implements AfterViewChecked, OnChanges { .parentElement ?.querySelector('tbody') ?.offsetHeight - || 100; + || this.firstRowHeight } onAllCheckboxChange({checked}) { diff --git a/src/app/app.component.ts b/src/app/app.component.ts index abbfd248..6ecd63a7 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -64,8 +64,6 @@ import { StorageService } from './storage.service'; import { SearchMessageDisplay } from './xapian/searchmessagedisplay'; import { UsageReportsService } from './common/usage-reports.service'; import { objectEqualWithKeys } from './common/util'; -import { DatePipe } from '@angular/common'; -import { FollowsMouseComponent } from './follows-mouse/follows-mouse.component'; const LOCAL_STORAGE_SETTING_MAILVIEWER_ON_RIGHT_SIDE_IF_MOBILE = 'mailViewerOnRightSideIfMobile'; const LOCAL_STORAGE_SETTING_MAILVIEWER_ON_RIGHT_SIDE = 'mailViewerOnRightSide'; @@ -83,16 +81,15 @@ const TOOLBAR_LIST_BUTTON_WIDTH = 30; selector: 'app', styleUrls: ['app.component.scss'], templateUrl: 'app.component.html', - imports: [DatePipe], }) export class AppComponent implements OnInit, AfterViewInit, CanvasTableSelectListener, DoCheck { showSelectOperations: boolean; showSelectMarkOpMenu: boolean; - private rows = []; - private selectedRow = null; - private selectedRows = []; + rows = []; + selectedRow = null; + selectedRows = []; lastSearchText = ''; searchText = ''; @@ -246,7 +243,6 @@ export class AppComponent implements OnInit, AfterViewInit, CanvasTableSelectLis this.messageActionsHandler.snackBar = snackBar; this.renderer.listen(window, 'keydown', (evt: KeyboardEvent) => { - // TODO: figure out how to get from this messageid to the selectedRow if (this.singlemailviewer.messageId) { if (evt.code === 'ArrowUp') { // slightly ugly as we need to call *this* rowSelected, not @@ -945,6 +941,8 @@ export class AppComponent implements OnInit, AfterViewInit, CanvasTableSelectLis public rowSelected(rowIndex: number, columnIndex: number, multiSelect?: boolean) { const isSelect = (columnIndex === 0) || multiSelect + this.selectedRow = this.rows[rowIndex] + if ((this.selectedFolder === this.messagelistservice.templateFolderName) && !isSelect) { this.draftDeskService.newTemplateDraft( this.canvastable.rows.getRowMessageId(rowIndex) @@ -1451,6 +1449,7 @@ export class AppComponent implements OnInit, AfterViewInit, CanvasTableSelectLis } updateRows() { + this.rows = (() => { if (!this.canvastable?.rows?.rows?.length) return [] @@ -1474,11 +1473,14 @@ export class AppComponent implements OnInit, AfterViewInit, CanvasTableSelectLis return this.canvastable.rows.rows || [] })() + + this.selectedRow = this.rows.find(x => x.id === this.singlemailviewer.messageId) + console.log('rows', this.rows) } onSelectedRowChange(event) { - this.singlemailviewer.messageId = event.id; + this.rowSelected(this.rows.indexOf(event), 3, false); } onSelectionDragStarted(event) { diff --git a/src/app/app.module.ts b/src/app/app.module.ts index d835c8d2..abd57131 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -91,6 +91,7 @@ import { HelpModule } from './help/help.module'; import { DomainRegisterRedirectComponent } from './domainregister/domreg-redirect.component'; import { HumanBytesPipe } from './human-bytes.pipe'; import { FollowsMouseComponent } from './follows-mouse/follows-mouse.component'; +import { DatePipe } from '@angular/common'; window.addEventListener('dragover', (event) => event.preventDefault()); window.addEventListener('drop', (event) => event.preventDefault()); @@ -143,6 +144,7 @@ const routes: Routes = [ @NgModule({ imports: [BrowserModule, FormsModule, + DatePipe, HttpClientModule, AccessibleTableComponent, HttpClientJsonpModule,