Skip to content

Commit 62d540e

Browse files
committed
fix: TT-167 Date picker disable future dates
1 parent c138f40 commit 62d540e

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@
9191
[class.is-invalid]="start_date.invalid && start_date.touched"
9292
required
9393
(ngModelChange)="onStartDateChange($event)"
94+
[max]="getActualDate()"
95+
onkeydown="return false"
9496
/>
9597
</div>
9698

@@ -118,6 +120,8 @@
118120
aria-describedby="inputGroup-sizing-sm"
119121
[class.is-invalid]="end_date.invalid && end_date.touched"
120122
required
123+
[max]="getActualDate()"
124+
onkeydown="return false"
121125
/>
122126
</div>
123127

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,12 @@ describe('DetailsFieldsComponent', () => {
468468
expect(endDateInput.value).not.toEqual(startDateInput.value);
469469
expect(startDateInput.value).toEqual(expectedStartDate);
470470
});
471+
472+
it('on get actual date should return the actual date in isoString ', () => {
473+
const actualDateExpected = new Date().toISOString().split('T')[0];
474+
475+
expect(component.getActualDate()).toEqual(actualDateExpected);
476+
});
471477
/*
472478
TODO As part of https://github.com/ioet/time-tracker-ui/issues/424 a new parameter was added to the details-field-component,
473479
and now these couple of tests are failing. A solution to this error might be generate a Test Wrapper Component. More details here:

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,10 @@ export class DetailsFieldsComponent implements OnChanges, OnInit {
171171
this.selectedTechnologies = $event;
172172
}
173173

174+
getActualDate(): string {
175+
return new Date().toISOString().split('T')[0];
176+
}
177+
174178
get project_id() {
175179
return this.entryForm.get('project_id');
176180
}

0 commit comments

Comments
 (0)