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

Commit

Permalink
error message with start date enhanced
Browse files Browse the repository at this point in the history
  • Loading branch information
Armin-Isenring-Bit committed Mar 15, 2023
1 parent 9a2bd35 commit d7f0adc
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
</mat-error>
<ng-template #dateFromTooSmall>
<mat-error *ngIf="dateFromFormControl.hasError('matDatepickerMin'); else periodTooBig">
{{ "reports.dateFromTo.dateTooSmall" | translate }}
{{ "reports.dateFromTo.dateTooSmall" | translate : { startDate: START_DATE } }}
</mat-error>
<ng-template #periodTooBig>
<mat-error *ngIf="dateFromFormControl.hasError('maxPeriodDays')">
Expand All @@ -49,7 +49,7 @@
</mat-error>
<ng-template #dateToTooSmall>
<mat-error *ngIf="dateToFormControl.hasError('matDatepickerMin')">
{{ "reports.dateFromTo.dateTooSmall" | translate }}
{{ "reports.dateFromTo.dateTooSmall" | translate : { startDate: START_DATE } }}
</mat-error>
</ng-template>
</mat-form-field>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,15 @@ export class DateFromToFieldsetComponent implements OnInit, OnDestroy {
@Input() dateFromFormControl: UntypedFormControl;
@Input() dateToFormControl: UntypedFormControl;
@Input() label: string;
// ToDo final version needs to subtract 2 years. For testing we used 2 months
@Input() MIN_DATE = moment('2023-05-01');
// temporary value for testing purposes
@Input() MIN_DATE = moment('2021-01-01');
// original value
// @Input() MIN_DATE = moment('2021-05-01');

subscription: Subscription;

readonly TODAY = moment();
START_DATE = '';

constructor(
public readonly translate: TranslateService,
Expand All @@ -31,11 +34,12 @@ export class DateFromToFieldsetComponent implements OnInit, OnDestroy {

ngOnInit() {
const now = moment();
// 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)) {
const twoYearsAgo = now.subtract(2, 'years');
if (twoYearsAgo.isAfter(this.MIN_DATE)) {
this.MIN_DATE = twoYearsAgo;
}
this.START_DATE = this.MIN_DATE.clone().subtract(1, 'days').format('DD.MM.YYYY');

this.subscription = this.reportService.reset$.subscribe(() => {
this.dateFromFormControl.reset();
this.dateToFormControl.reset();
Expand Down
2 changes: 1 addition & 1 deletion src/assets/i18n/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@
"reports.dataRoomSelection": "Ausgewählter Kanton/Bereich:",
"reports.dateFromTo.date-from": "Anfangsdatum",
"reports.dateFromTo.date-to": "Enddatum",
"reports.dateFromTo.dateTooSmall": "Das Datum muss nach dem 30.04.2021 liegen",
"reports.dateFromTo.dateTooSmall": "Das Datum muss nach dem {{startDate}} liegen",
"reports.dateFromTo.maxPeriodDays": "Bitte reduzieren Sie den Ausstellungszeitraum auf maximal {{maxPeriodDays}} Tage",
"reports.dateFromTo.startDateBeforeEndDate": "Anfangsdatum darf nicht nach dem Enddatum liegen",
"reports.dateFromTo.text": "Bitte wählen Sie ein Anfangs- und ein Enddatum des Ausstellungszeitraums für den Report aus:",
Expand Down
2 changes: 1 addition & 1 deletion src/assets/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@
"reports.dataRoomSelection": "Canton/area selected:",
"reports.dateFromTo.date-from": "Start date",
"reports.dateFromTo.date-to": "End date",
"reports.dateFromTo.dateTooSmall": "The date must be after 30.04.2021",
"reports.dateFromTo.dateTooSmall": "The date must be after {{startDate}}",
"reports.dateFromTo.maxPeriodDays": "Please limit the issuing period to no more than {{maxPeriodDays}} days",
"reports.dateFromTo.startDateBeforeEndDate": "Start date must not be after the end date",
"reports.dateFromTo.text": "Please select a start and end date for the issue period for the report:",
Expand Down
2 changes: 1 addition & 1 deletion src/assets/i18n/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@
"reports.dataRoomSelection": "Canton/domaine sélectionné:",
"reports.dateFromTo.date-from": "Date de début",
"reports.dateFromTo.date-to": "Date de fin",
"reports.dateFromTo.dateTooSmall": "La date doit être située après le 30.04.2021",
"reports.dateFromTo.dateTooSmall": "La date doit être située après le {{startDate}}",
"reports.dateFromTo.maxPeriodDays": "Veuillez limiter la période d'émission à un maximum de {{maxPeriodDays}} jours",
"reports.dateFromTo.startDateBeforeEndDate": "La date de début ne doit pas être postérieure à la date de fin",
"reports.dateFromTo.text": "Veuillez sélectionner une date de début et une date de fin de la période d’émission pour le rapport:",
Expand Down
2 changes: 1 addition & 1 deletion src/assets/i18n/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@
"reports.dataRoomSelection": "Cantone/settore selezionato:",
"reports.dateFromTo.date-from": "Data di inizio",
"reports.dateFromTo.date-to": "Data di fine",
"reports.dateFromTo.dateTooSmall": "La data deve essere successiva al 30.04.2021",
"reports.dateFromTo.dateTooSmall": "La data deve essere successiva al {{startDate}}",
"reports.dateFromTo.maxPeriodDays": "Si prega di limitare il periodo di emissione a non più di {{maxPeriodDays}} giorni",
"reports.dateFromTo.startDateBeforeEndDate": "La data di inizio non deve essere successiva alla data di fine",
"reports.dateFromTo.text": "Selezionare una data di inizio e una data di fine del periodo di emissione per il rapporto:",
Expand Down

0 comments on commit d7f0adc

Please sign in to comment.