1
- import { Component , OnDestroy , OnInit , ViewChild , AfterViewInit } from '@angular/core' ;
1
+ import { Component , OnDestroy , OnInit } from '@angular/core' ;
2
2
import { ActionsSubject , select , Store } from '@ngrx/store' ;
3
3
import { ToastrService } from 'ngx-toastr' ;
4
- import { Observable , Subscription , Subject } from 'rxjs' ;
4
+ import { Observable , Subscription } from 'rxjs' ;
5
5
import { delay , filter } from 'rxjs/operators' ;
6
6
import { ProjectSelectedEvent } from '../../shared/components/details-fields/project-selected-event' ;
7
7
import { SaveEntryEvent } from '../../shared/components/details-fields/save-entry-event' ;
@@ -14,13 +14,12 @@ import { EntryActionTypes } from './../../time-clock/store/entry.actions';
14
14
import { getActiveTimeEntry , getTimeEntriesDataSource } from './../../time-clock/store/entry.selectors' ;
15
15
import { CookieService } from 'ngx-cookie-service' ;
16
16
import { FeatureToggle } from './../../../../environments/enum' ;
17
- import { DataTableDirective } from 'angular-datatables' ;
18
17
@Component ( {
19
18
selector : 'app-time-entries' ,
20
19
templateUrl : './time-entries.component.html' ,
21
20
styleUrls : [ './time-entries.component.scss' ] ,
22
21
} )
23
- export class TimeEntriesComponent implements OnInit , OnDestroy , AfterViewInit {
22
+ export class TimeEntriesComponent implements OnInit , OnDestroy {
24
23
entryId : string ;
25
24
entry : Entry ;
26
25
activeTimeEntry : Entry ;
@@ -39,11 +38,6 @@ export class TimeEntriesComponent implements OnInit, OnDestroy, AfterViewInit {
39
38
selectedYear : number ;
40
39
selectedMonthAsText : string ;
41
40
isActiveEntryOverlapping = false ;
42
- dtOptions : any = { } ;
43
- dtTrigger : Subject < any > = new Subject ( ) ;
44
- @ViewChild ( DataTableDirective , { static : false } )
45
- dtElement : DataTableDirective ;
46
- rerenderTableSubscription : Subscription ;
47
41
constructor (
48
42
private store : Store < EntryState > ,
49
43
private toastrService : ToastrService ,
@@ -55,18 +49,8 @@ export class TimeEntriesComponent implements OnInit, OnDestroy, AfterViewInit {
55
49
}
56
50
ngOnDestroy ( ) : void {
57
51
this . entriesSubscription . unsubscribe ( ) ;
58
- this . rerenderTableSubscription . unsubscribe ( ) ;
59
- this . dtTrigger . unsubscribe ( ) ;
60
52
}
61
53
ngOnInit ( ) : void {
62
- this . dtOptions = {
63
- scrollY : '325px' ,
64
- paging : false ,
65
- responsive : true ,
66
- } ;
67
- this . rerenderTableSubscription = this . timeEntriesDataSource$ . subscribe ( ( ds ) => {
68
- this . rerenderDataTable ( ) ;
69
- } ) ;
70
54
this . loadActiveEntry ( ) ;
71
55
this . isFeatureToggleCalendarActive = ( this . cookiesService . get ( FeatureToggle . TIME_TRACKER_CALENDAR ) === 'true' ) ;
72
56
this . entriesSubscription = this . actionsSubject$ . pipe (
@@ -81,9 +65,6 @@ export class TimeEntriesComponent implements OnInit, OnDestroy, AfterViewInit {
81
65
this . store . dispatch ( new entryActions . LoadEntries ( this . selectedMonth , this . selectedYear ) ) ;
82
66
} ) ;
83
67
}
84
- ngAfterViewInit ( ) : void {
85
- this . rerenderDataTable ( ) ;
86
- }
87
68
newEntry ( ) {
88
69
if ( this . wasEditingExistingTimeEntry ) {
89
70
this . entry = null ;
@@ -235,15 +216,4 @@ export class TimeEntriesComponent implements OnInit, OnDestroy, AfterViewInit {
235
216
} ) ;
236
217
}
237
218
}
238
-
239
- private rerenderDataTable ( ) : void {
240
- if ( this . dtElement && this . dtElement . dtInstance ) {
241
- this . dtElement . dtInstance . then ( ( dtInstance : DataTables . Api ) => {
242
- dtInstance . destroy ( ) ;
243
- this . dtTrigger . next ( ) ;
244
- } ) ;
245
- } else {
246
- this . dtTrigger . next ( ) ;
247
- }
248
- }
249
219
}
0 commit comments