Skip to content
This repository has been archived by the owner on Sep 15, 2023. It is now read-only.

Commit

Permalink
finished date picker with testing settings as temporary solution.
Browse files Browse the repository at this point in the history
  • Loading branch information
haraldloesing committed Mar 14, 2023
1 parent b9f43fc commit 9a2bd35
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
16 changes: 8 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ export class DateFromToFieldsetComponent implements OnInit, OnDestroy {
@Input() dateFromFormControl: UntypedFormControl;
@Input() dateToFormControl: UntypedFormControl;
@Input() label: string;
@Input() MIN_DATE = moment('2021-05-01');
// ToDo final version needs to subtract 2 years. For testing we used 2 months
@Input() MIN_DATE = moment('2023-05-01');

subscription: Subscription;

Expand All @@ -29,13 +30,12 @@ export class DateFromToFieldsetComponent implements OnInit, OnDestroy {
) {}

ngOnInit() {
// Works like usual until 1.05.2021(default MIN_DATE), after that it will only accept 2 years in the past
// TODO Correct Validation & Notification
const now = moment();
if (now > this.MIN_DATE.clone().add(2, 'years')) {
this.MIN_DATE = now.subtract(2, 'years');
// ToDo final version needs to subtract 2 years. For testing we used 2 months
const twoYearsAgo = now.subtract(2, 'months');
if (twoYearsAgo.isBefore(this.MIN_DATE)) {
this.MIN_DATE = twoYearsAgo;
}

this.subscription = this.reportService.reset$.subscribe(() => {
this.dateFromFormControl.reset();
this.dateToFormControl.reset();
Expand Down

0 comments on commit 9a2bd35

Please sign in to comment.