Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Revert "fix: TT-304 Handle message: the data could not be load (#716)" (
#723)

This reverts commit d2fc2a0.
  • Loading branch information
scastillo-jp authored Aug 16, 2021
commit 1c67624e66477703e3aac95b4ae2d94d8cc4bd33
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
</ng-template>
<ng-template #listView>
<div id="listView">
<table class="table table-sm table-striped mb-0" datatable [dtTrigger]="dtTrigger" [dtOptions]="dtOptions" *ngIf="timeEntriesDataSource$ | async as dataSource">
<table class="table table-sm table-striped mb-0" *ngIf="timeEntriesDataSource$ | async as dataSource">
<thead class="thead-blue">
<tr class="d-flex">
<th class="col">Date</th>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -668,11 +668,4 @@ describe('TimeEntriesComponent', () => {

expect(HTMLTimeEntriesView).not.toBeNull();
});

it('after the component is initialized it should initialize the table', () => {
spyOn(component.dtTrigger, 'next');
component.ngAfterViewInit();

expect(component.dtTrigger.next).toHaveBeenCalled();
});
});
36 changes: 3 additions & 33 deletions src/app/modules/time-entries/pages/time-entries.component.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Component, OnDestroy, OnInit, ViewChild, AfterViewInit } from '@angular/core';
import { Component, OnDestroy, OnInit } from '@angular/core';
import { ActionsSubject, select, Store } from '@ngrx/store';
import { ToastrService } from 'ngx-toastr';
import { Observable, Subscription, Subject } from 'rxjs';
import { Observable, Subscription } from 'rxjs';
import { delay, filter } from 'rxjs/operators';
import { ProjectSelectedEvent } from '../../shared/components/details-fields/project-selected-event';
import { SaveEntryEvent } from '../../shared/components/details-fields/save-entry-event';
Expand All @@ -14,13 +14,12 @@ import { EntryActionTypes } from './../../time-clock/store/entry.actions';
import { getActiveTimeEntry, getTimeEntriesDataSource } from './../../time-clock/store/entry.selectors';
import { CookieService } from 'ngx-cookie-service';
import { FeatureToggle } from './../../../../environments/enum';
import { DataTableDirective } from 'angular-datatables';
@Component({
selector: 'app-time-entries',
templateUrl: './time-entries.component.html',
styleUrls: ['./time-entries.component.scss'],
})
export class TimeEntriesComponent implements OnInit, OnDestroy, AfterViewInit {
export class TimeEntriesComponent implements OnInit, OnDestroy {
entryId: string;
entry: Entry;
activeTimeEntry: Entry;
Expand All @@ -39,11 +38,6 @@ export class TimeEntriesComponent implements OnInit, OnDestroy, AfterViewInit {
selectedYear: number;
selectedMonthAsText: string;
isActiveEntryOverlapping = false;
dtOptions: any = {};
dtTrigger: Subject<any> = new Subject();
@ViewChild(DataTableDirective, { static: false })
dtElement: DataTableDirective;
rerenderTableSubscription: Subscription;
constructor(
private store: Store<EntryState>,
private toastrService: ToastrService,
Expand All @@ -55,18 +49,8 @@ export class TimeEntriesComponent implements OnInit, OnDestroy, AfterViewInit {
}
ngOnDestroy(): void {
this.entriesSubscription.unsubscribe();
this.rerenderTableSubscription.unsubscribe();
this.dtTrigger.unsubscribe();
}
ngOnInit(): void {
this.dtOptions = {
scrollY: '325px',
paging: false,
responsive: true,
};
this.rerenderTableSubscription = this.timeEntriesDataSource$.subscribe((ds) => {
this.rerenderDataTable();
});
this.loadActiveEntry();
this.isFeatureToggleCalendarActive = (this.cookiesService.get(FeatureToggle.TIME_TRACKER_CALENDAR) === 'true');
this.entriesSubscription = this.actionsSubject$.pipe(
Expand All @@ -81,9 +65,6 @@ export class TimeEntriesComponent implements OnInit, OnDestroy, AfterViewInit {
this.store.dispatch(new entryActions.LoadEntries(this.selectedMonth, this.selectedYear));
});
}
ngAfterViewInit(): void {
this.rerenderDataTable();
}
newEntry() {
if (this.wasEditingExistingTimeEntry) {
this.entry = null;
Expand Down Expand Up @@ -235,15 +216,4 @@ export class TimeEntriesComponent implements OnInit, OnDestroy, AfterViewInit {
});
}
}

private rerenderDataTable(): void {
if (this.dtElement && this.dtElement.dtInstance) {
this.dtElement.dtInstance.then((dtInstance: DataTables.Api) => {
dtInstance.destroy();
this.dtTrigger.next();
});
} else {
this.dtTrigger.next();
}
}
}