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
refactor: TT-328 rename of certain variable to make the code more rea…
…dable
  • Loading branch information
bytesantiago committed Sep 1, 2021
commit 3feff1b9a6b90f140fcea38772fec3a6b3a10e43
Original file line number Diff line number Diff line change
Expand Up @@ -381,14 +381,18 @@ describe('TimeEntriesComponent', () => {
it('should preload data of last entry when a project is selected while creating new entry ', waitForAsync(() => {
component.entry = null;
component.entryId = null;
const defaultSeconds = 0;
const currentDate = new Date();
currentDate.setSeconds(defaultSeconds);
const emptyDate = new Date(new Date().setHours(0, 0, 0, 0));
const lastEntry = {
description: 'testing is fun',
technologies: [],
uri: 'http://testing.is.fun',
activity_id: 'sss',
project_id: 'id',
start_date: new Date(new Date().setSeconds(0)),
end_date: new Date(new Date().setHours(0, 0, 0, 0))
start_date: currentDate,
end_date: emptyDate
};
state.timeEntriesDataSource.data = [lastEntry];
mockEntriesSelector = store.overrideSelector(getTimeEntriesDataSource, state.timeEntriesDataSource);
Expand Down
9 changes: 6 additions & 3 deletions src/app/modules/time-entries/pages/time-entries.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,15 +139,18 @@ export class TimeEntriesComponent implements OnInit, OnDestroy {
this.store.pipe(select(getTimeEntriesDataSource)).subscribe(ds => {
const dataToUse = ds.data.find(item => item.project_id === event.projectId);
if (dataToUse && this.isNewEntry()) {
const startDate = new Date(new Date().setHours(0, 0, 0, 0));
const defaultSeconds = 0;
const currentDate = new Date();
currentDate.setSeconds(defaultSeconds);
const emptyDate = new Date(new Date().setHours(0, 0, 0, 0));
const entry = {
description: dataToUse.description ? dataToUse.description : '',
technologies: dataToUse.technologies ? dataToUse.technologies : [],
uri: dataToUse.uri ? dataToUse.uri : '',
activity_id: dataToUse.activity_id,
project_id: dataToUse.project_id,
start_date: new Date(new Date().setSeconds(0)),
end_date: startDate
start_date: currentDate,
end_date: emptyDate
};
this.entry = entry;
}
Expand Down