Skip to content

Commit 664dfb3

Browse files
author
Guido Quezada
committed
TT-101 fix: allow to create new entry
1 parent 2d8b1e2 commit 664dfb3

File tree

2 files changed

+2
-7
lines changed

2 files changed

+2
-7
lines changed

src/app/modules/shared/components/details-fields/details-fields.component.spec.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,6 @@ describe('DetailsFieldsComponent', () => {
213213

214214
it('should emit saveEntry event', () => {
215215
spyOn(component.saveEntry, 'emit');
216-
component.entryToEdit = { ...entryToEdit };
217216
component.entryForm.setValue({
218217
project_id: 'p1',
219218
project_name: 'p-name',
@@ -311,7 +310,6 @@ describe('DetailsFieldsComponent', () => {
311310
component.goingToWorkOnThis = true;
312311
spyOn(component.saveEntry, 'emit');
313312

314-
component.entryToEdit = { ...entryToEdit };
315313
component.entryForm.setValue({ ...formValues, start_date: '2020-06-11', end_date: '2020-06-11' });
316314

317315
component.onSubmit();
@@ -392,7 +390,6 @@ describe('DetailsFieldsComponent', () => {
392390
it('displays error message when the date selected is in the future', () => {
393391
spyOn(toastrServiceStub, 'error');
394392

395-
component.entryToEdit = { ...entryToEdit };
396393
const futureDate = moment().add(1, 'days').format(DATE_FORMAT_YEAR);
397394
component.entryForm.setValue({ ...formValues, start_date: futureDate, end_date: futureDate });
398395
component.onSubmit();
@@ -403,7 +400,6 @@ describe('DetailsFieldsComponent', () => {
403400
it('when start_date is in the future and end_date is OK then throws an error', () => {
404401
spyOn(toastrServiceStub, 'error');
405402

406-
component.entryToEdit = { ...entryToEdit };
407403
const futureDate = moment().add(1, 'days').format(DATE_FORMAT_YEAR);
408404
const currentDate = moment().format(DATE_FORMAT_YEAR);
409405
component.entryForm.setValue({ ...formValues, start_date: futureDate, end_date: currentDate });
@@ -415,7 +411,6 @@ describe('DetailsFieldsComponent', () => {
415411
it('when start_date is OK and end_date is in the future then throws an error future', () => {
416412
spyOn(toastrServiceStub, 'error');
417413

418-
component.entryToEdit = { ...entryToEdit };
419414
const futureDate = moment().add(1, 'days').format(DATE_FORMAT_YEAR);
420415
const currentDate = moment().format(DATE_FORMAT_YEAR);
421416
component.entryForm.setValue({ ...formValues, start_date: currentDate, end_date: futureDate });

src/app/modules/shared/components/details-fields/details-fields.component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,9 +202,9 @@ export class DetailsFieldsComponent implements OnChanges, OnInit {
202202
dateToSubmit(date, hour) {
203203
const entryFormDate = this.entryForm.value[date];
204204
const updatedHour = this.entryForm.value[hour];
205-
const initialDate = this.entryToEdit[date];
206205
const updatedDate = new Date(`${entryFormDate}T${updatedHour.trim()}`).toISOString();
207-
const initialHour = formatDate(get(this.entryToEdit, date, '00:00'), 'HH:mm', 'en');
206+
const initialDate = get(this.entryToEdit, date, updatedDate);
207+
const initialHour = formatDate(get(this.entryToEdit, date, updatedDate), 'HH:mm', 'en');
208208
const dateHasNotChanged = updatedHour === initialHour;
209209
const result = dateHasNotChanged ? initialDate : updatedDate;
210210
return result;

0 commit comments

Comments
 (0)