@@ -25,9 +25,18 @@ import { AppComponent } from '../app.component';
25
25
import { Subject } from 'rxjs' ;
26
26
import { CanvasTableColumn } from '../canvastable/canvastablecolumn' ;
27
27
28
+ interface Message {
29
+ rowid : number ;
30
+ from : string ;
31
+ date : string ;
32
+ subject : string ;
33
+ unread : boolean ;
34
+ }
35
+
28
36
@Component ( {
29
37
selector : 'app-nativemessagelist' ,
30
38
templateUrl : 'nativemessagelist.component.html' ,
39
+ styleUrls : [ 'nativemessagelist.component.scss' ] ,
31
40
} )
32
41
export class NativeMessageListComponent implements MessageListComponent {
33
42
sortColumn = 2 ;
@@ -38,7 +47,13 @@ export class NativeMessageListComponent implements MessageListComponent {
38
47
visibleRowsChanged : Subject < number [ ] > = new Subject ( ) ;
39
48
rowSelected : EventEmitter < RowSelection > = new EventEmitter ( ) ;
40
49
rows : MessageDisplay ;
41
- shownRows : any [ ] = [ ] ;
50
+ shownRows : Message [ ] = [ ] ;
51
+
52
+ offset = 0 ;
53
+ rowsDisplayed = 10 ;
54
+ upto : number ;
55
+ rowCount : number ;
56
+ remaining : number ;
42
57
43
58
columns : CanvasTableColumn [ ] ;
44
59
columnNames : string [ ] ;
@@ -49,20 +64,28 @@ export class NativeMessageListComponent implements MessageListComponent {
49
64
return ;
50
65
}
51
66
this . shownRows = [ ] ;
52
- let limit = 25 ;
53
- if ( this . rows . rowCount ( ) < 25 ) {
54
- limit = this . rows . rowCount ( ) ;
67
+ this . upto = this . offset + this . rowsDisplayed ;
68
+ this . rowCount = this . rows . rowCount ( ) ;
69
+ if ( this . rowCount < this . upto ) {
70
+ this . upto = this . rowCount ;
55
71
}
56
- for ( let i = 0 ; i < limit ; i ++ ) {
72
+ for ( let i = this . offset ; i < this . upto ; i ++ ) {
57
73
const row = this . columns . map ( c => {
58
74
let value = c . getValue ( i ) ;
59
75
if ( c . getFormattedValue ) {
60
76
value = c . getFormattedValue ( value ) ;
61
77
}
62
78
return value ;
63
79
} ) ;
64
- this . shownRows . push ( row ) ;
80
+ this . shownRows . push ( {
81
+ rowid : i ,
82
+ from : row [ this . columnsByName [ 'From' ] ] ,
83
+ subject : row [ this . columnsByName [ 'Subject' ] ] ,
84
+ date : row [ this . columnsByName [ 'Date' ] ] ,
85
+ unread : this . rows . getRowSeen ( i ) ,
86
+ } ) ;
65
87
}
88
+ this . remaining = this . rowCount - this . upto ;
66
89
}
67
90
68
91
resetColumns ( app : AppComponent ) : void {
@@ -89,7 +112,16 @@ export class NativeMessageListComponent implements MessageListComponent {
89
112
} ) ;
90
113
}
91
114
92
- scrollDown ( ) : void { }
93
- scrollUp ( ) : void { }
94
- scrollTop ( ) : void { }
115
+ scrollDown ( ) : void {
116
+ this . offset += this . rowsDisplayed ;
117
+ this . detectChanges ( ) ;
118
+ }
119
+ scrollUp ( ) : void {
120
+ this . offset -= this . rowsDisplayed ;
121
+ this . detectChanges ( ) ;
122
+ }
123
+ scrollTop ( ) : void {
124
+ this . offset = 0 ;
125
+ this . detectChanges ( ) ;
126
+ }
95
127
}
0 commit comments