Skip to content

Commit 1c67624

Browse files
authored
Revert "fix: TT-304 Handle message: the data could not be load (#716)" (#723)
This reverts commit d2fc2a0.
1 parent 67bcf3b commit 1c67624

File tree

3 files changed

+4
-41
lines changed

3 files changed

+4
-41
lines changed

src/app/modules/time-entries/pages/time-entries.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
</ng-template>
4343
<ng-template #listView>
4444
<div id="listView">
45-
<table class="table table-sm table-striped mb-0" datatable [dtTrigger]="dtTrigger" [dtOptions]="dtOptions" *ngIf="timeEntriesDataSource$ | async as dataSource">
45+
<table class="table table-sm table-striped mb-0" *ngIf="timeEntriesDataSource$ | async as dataSource">
4646
<thead class="thead-blue">
4747
<tr class="d-flex">
4848
<th class="col">Date</th>

src/app/modules/time-entries/pages/time-entries.component.spec.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -668,11 +668,4 @@ describe('TimeEntriesComponent', () => {
668668

669669
expect(HTMLTimeEntriesView).not.toBeNull();
670670
});
671-
672-
it('after the component is initialized it should initialize the table', () => {
673-
spyOn(component.dtTrigger, 'next');
674-
component.ngAfterViewInit();
675-
676-
expect(component.dtTrigger.next).toHaveBeenCalled();
677-
});
678671
});

src/app/modules/time-entries/pages/time-entries.component.ts

Lines changed: 3 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { Component, OnDestroy, OnInit, ViewChild, AfterViewInit } from '@angular/core';
1+
import { Component, OnDestroy, OnInit } from '@angular/core';
22
import { ActionsSubject, select, Store } from '@ngrx/store';
33
import { ToastrService } from 'ngx-toastr';
4-
import { Observable, Subscription, Subject } from 'rxjs';
4+
import { Observable, Subscription } from 'rxjs';
55
import { delay, filter } from 'rxjs/operators';
66
import { ProjectSelectedEvent } from '../../shared/components/details-fields/project-selected-event';
77
import { SaveEntryEvent } from '../../shared/components/details-fields/save-entry-event';
@@ -14,13 +14,12 @@ import { EntryActionTypes } from './../../time-clock/store/entry.actions';
1414
import { getActiveTimeEntry, getTimeEntriesDataSource } from './../../time-clock/store/entry.selectors';
1515
import { CookieService } from 'ngx-cookie-service';
1616
import { FeatureToggle } from './../../../../environments/enum';
17-
import { DataTableDirective } from 'angular-datatables';
1817
@Component({
1918
selector: 'app-time-entries',
2019
templateUrl: './time-entries.component.html',
2120
styleUrls: ['./time-entries.component.scss'],
2221
})
23-
export class TimeEntriesComponent implements OnInit, OnDestroy, AfterViewInit {
22+
export class TimeEntriesComponent implements OnInit, OnDestroy {
2423
entryId: string;
2524
entry: Entry;
2625
activeTimeEntry: Entry;
@@ -39,11 +38,6 @@ export class TimeEntriesComponent implements OnInit, OnDestroy, AfterViewInit {
3938
selectedYear: number;
4039
selectedMonthAsText: string;
4140
isActiveEntryOverlapping = false;
42-
dtOptions: any = {};
43-
dtTrigger: Subject<any> = new Subject();
44-
@ViewChild(DataTableDirective, { static: false })
45-
dtElement: DataTableDirective;
46-
rerenderTableSubscription: Subscription;
4741
constructor(
4842
private store: Store<EntryState>,
4943
private toastrService: ToastrService,
@@ -55,18 +49,8 @@ export class TimeEntriesComponent implements OnInit, OnDestroy, AfterViewInit {
5549
}
5650
ngOnDestroy(): void {
5751
this.entriesSubscription.unsubscribe();
58-
this.rerenderTableSubscription.unsubscribe();
59-
this.dtTrigger.unsubscribe();
6052
}
6153
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-
});
7054
this.loadActiveEntry();
7155
this.isFeatureToggleCalendarActive = (this.cookiesService.get(FeatureToggle.TIME_TRACKER_CALENDAR) === 'true');
7256
this.entriesSubscription = this.actionsSubject$.pipe(
@@ -81,9 +65,6 @@ export class TimeEntriesComponent implements OnInit, OnDestroy, AfterViewInit {
8165
this.store.dispatch(new entryActions.LoadEntries(this.selectedMonth, this.selectedYear));
8266
});
8367
}
84-
ngAfterViewInit(): void {
85-
this.rerenderDataTable();
86-
}
8768
newEntry() {
8869
if (this.wasEditingExistingTimeEntry) {
8970
this.entry = null;
@@ -235,15 +216,4 @@ export class TimeEntriesComponent implements OnInit, OnDestroy, AfterViewInit {
235216
});
236217
}
237218
}
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-
}
249219
}

0 commit comments

Comments
 (0)