Skip to content

Commit

Permalink
fixup! fixup! Fix reactive model of table
Browse files Browse the repository at this point in the history
  • Loading branch information
shadowbas authored and bas080 committed Dec 5, 2024
1 parent 5f257ba commit 972eb6a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/app/accessible-table/accessible-table.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ export class AccessibleTableComponent implements AfterViewChecked, OnChanges {
@Output() rowClicked = new EventEmitter<any>();
@Output() selectionDragStarted = new EventEmitter<any>();

firstRowHeight: number = 100;
private lastCheckedRow: number|null = null
private firstRowHeight: number = 100;

private shiftKey = false;
private ctrlKey = false;
Expand Down Expand Up @@ -97,7 +97,7 @@ export class AccessibleTableComponent implements AfterViewChecked, OnChanges {
.parentElement
?.querySelector('tbody')
?.offsetHeight
|| 100;
|| this.firstRowHeight
}

onAllCheckboxChange({checked}) {
Expand Down
18 changes: 10 additions & 8 deletions src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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 = '';
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -1451,6 +1449,7 @@ export class AppComponent implements OnInit, AfterViewInit, CanvasTableSelectLis
}

updateRows() {

this.rows = (() => {
if (!this.canvastable?.rows?.rows?.length) return []

Expand All @@ -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) {
Expand Down
2 changes: 2 additions & 0 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down Expand Up @@ -143,6 +144,7 @@ const routes: Routes = [

@NgModule({
imports: [BrowserModule, FormsModule,
DatePipe,
HttpClientModule,
AccessibleTableComponent,
HttpClientJsonpModule,
Expand Down

0 comments on commit 972eb6a

Please sign in to comment.