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
fix: #172 Create-time-entries-manually
  • Loading branch information
DiegoTinitana committed May 11, 2020
commit b3c016d4957924fe2e9deee8e149cfb789e3bc91
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,17 @@ export class DetailsFieldsComponent implements OnChanges, OnInit {
ngOnChanges(): void {
if (this.entryToEdit) {
this.selectedTechnology = this.entryToEdit.technologies;
<<<<<<< HEAD
this.project = this.listProjects.find((p) => p.id === this.entryToEdit.project_id);
const activity = this.activities.find((a) => a.id === this.entryToEdit.activity_id);
this.projectName = this.project.name;
this.entryForm.setValue({
=======
const project = this.listProjects.find((p) => p.id === this.entryToEdit.project_id);
const activity = this.activities.find((a) => a.id === this.entryToEdit.activity_id);
this.entryForm.setValue({
project: project ? project.name : '',
>>>>>>> fix: #172 Create-time-entries-manually
activity: activity ? activity.name : '',
description: this.entryToEdit.description,
start_date: this.entryToEdit.start_date ? formatDate(this.entryToEdit.start_date, 'yyyy-MM-dd', 'en') : '',
Expand All @@ -102,9 +109,14 @@ export class DetailsFieldsComponent implements OnChanges, OnInit {
});
} else {
this.selectedTechnology = [];
<<<<<<< HEAD
this.project = '';
this.projectName = '';
this.entryForm.setValue({
=======
this.entryForm.setValue({
project: '',
>>>>>>> fix: #172 Create-time-entries-manually
activity: '',
description: '',
start_date: formatDate(new Date(), 'yyyy-MM-dd', 'en'),
Expand Down Expand Up @@ -138,9 +150,14 @@ export class DetailsFieldsComponent implements OnChanges, OnInit {

onSubmit() {
const activity = this.activities.find((a) => a.name === this.entryForm.value.activity);
<<<<<<< HEAD
this.project = this.projectName.id ? this.projectName : this.project;
const entry = {
project_id: this.project.id,
=======
const entry = {
project_id: this.entryForm.value.project.id,
>>>>>>> fix: #172 Create-time-entries-manually
activity_id: activity ? activity.id : null,
technologies: this.selectedTechnology,
description: this.entryForm.value.description,
Expand Down
3 changes: 1 addition & 2 deletions src/app/modules/time-entries/pages/time-entries.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ export class TimeEntriesComponent implements OnInit {
const duration: any = moment.duration(endDate.diff(startDate));
time = `${duration._data.hours} hour and ${duration._data.minutes} minutes`;
}
const date = moment(entry.start_date).format('YYYY-MM-DD');
const item = { ...entry, time, date };
const item = { ...entry, time };
return [...acc, item];
}
return [];
Expand Down