mirror of
https://dev.azure.com/hugendubel/ISA/_git/ISA-Frontend
synced 2025-12-28 22:42:11 +01:00
Merged PR 1625: #4255 Fixed Publication Date Range Filter issues
#4255 Fixed Publication Date Range Filter issues
This commit is contained in:
committed by
Andreas Schickinger
parent
cf38eef3b8
commit
a7f0522d57
@@ -4,6 +4,7 @@ import { IOption, Option } from '../../../tree';
|
||||
import { FormControl, FormGroup } from '@angular/forms';
|
||||
import { DateValidator } from '@shared/forms';
|
||||
import { UiDatepickerComponent } from '@ui/datepicker';
|
||||
import moment from 'moment';
|
||||
|
||||
@Component({
|
||||
selector: 'shared-input-option-date-range',
|
||||
@@ -112,7 +113,8 @@ export class FilterInputOptionDateRangeComponent {
|
||||
}
|
||||
|
||||
setStratValue(date: Date) {
|
||||
if (!date) {
|
||||
// 06.09.2023 Nino Righi --- Code abgeändert, da nicht richtig funktioniert -> Bugticket #4255 HSC // Neue Filteroption - Erscheinungsdatum
|
||||
if (new Date(date)?.toString() === 'Invalid Date') {
|
||||
this.uiStartOption?.setValue(undefined);
|
||||
this.formGroup.patchValue({ start: undefined });
|
||||
this.startDatepicker?.setDisplayed(undefined);
|
||||
@@ -120,7 +122,7 @@ export class FilterInputOptionDateRangeComponent {
|
||||
return;
|
||||
}
|
||||
|
||||
const startDate = new Date(date);
|
||||
const startDate = moment(date, 'L').toDate();
|
||||
startDate.setHours(0, 0, 0, 0);
|
||||
|
||||
if (this.startDate === date) {
|
||||
@@ -138,7 +140,8 @@ export class FilterInputOptionDateRangeComponent {
|
||||
}
|
||||
|
||||
setStopValue(date: Date) {
|
||||
if (!date) {
|
||||
// 06.09.2023 Nino Righi --- Code abgeändert, da nicht richtig funktioniert -> Bugticket #4255 HSC // Neue Filteroption - Erscheinungsdatum
|
||||
if (new Date(date)?.toString() === 'Invalid Date') {
|
||||
this.uiStopOption?.setValue(undefined);
|
||||
this.formGroup.patchValue({ stop: undefined });
|
||||
this.stopDatepicker?.setDisplayed(undefined);
|
||||
@@ -146,7 +149,7 @@ export class FilterInputOptionDateRangeComponent {
|
||||
return;
|
||||
}
|
||||
|
||||
const stopDate = new Date(date);
|
||||
const stopDate = moment(date, 'L').toDate();
|
||||
stopDate.setHours(23, 59, 59, 999);
|
||||
|
||||
if (this.stopDate === date) {
|
||||
|
||||
@@ -23,7 +23,7 @@ export class DateInputDirective implements ControlValueAccessor {
|
||||
value: any;
|
||||
|
||||
@HostBinding('value')
|
||||
displayValue: string;
|
||||
displayValue: string = '';
|
||||
|
||||
@HostBinding('disabled')
|
||||
disabled: boolean;
|
||||
@@ -52,14 +52,20 @@ export class DateInputDirective implements ControlValueAccessor {
|
||||
|
||||
if (value instanceof Date) {
|
||||
date = value;
|
||||
} else if (DE_DATE_REGEX.test(value)) {
|
||||
const mom = moment(value, 'L');
|
||||
date = mom.toDate();
|
||||
} else if (ISO_DATE_REGEX.test(value)) {
|
||||
} else {
|
||||
date = new Date(value);
|
||||
}
|
||||
|
||||
if (date) {
|
||||
// 06.09.2023 Nino Righi --- Code Auskommentiert und abgeändert, da nicht richtig funktioniert -> Bugticket #4255 HSC // Neue Filteroption - Erscheinungsdatum
|
||||
|
||||
// else if (DE_DATE_REGEX.test(value)) {
|
||||
// const mom = moment(value, 'L');
|
||||
// date = mom.toDate();
|
||||
// } else if (ISO_DATE_REGEX.test(value)) {
|
||||
// date = new Date(value);
|
||||
// }
|
||||
|
||||
if (date && date.toString() !== 'Invalid Date') {
|
||||
this.displayValue = moment(date).format('L');
|
||||
} else {
|
||||
this.displayValue = value ?? '';
|
||||
|
||||
@@ -9,14 +9,18 @@ export function DateValidator(control: AbstractControl) {
|
||||
if (control.value instanceof Date) {
|
||||
date = control.value;
|
||||
} else if (typeof control.value === 'string') {
|
||||
if (DE_DATE_REGEX.test(control.value)) {
|
||||
date = moment(control.value, 'L').toDate();
|
||||
} else if (ISO_DATE_REGEX.test(control.value)) {
|
||||
date = new Date(control.value);
|
||||
}
|
||||
date = new Date(control.value);
|
||||
|
||||
// 06.09.2023 Nino Righi --- Code Auskommentiert und abgeändert, da nicht richtig funktioniert -> Bugticket #4255 HSC // Neue Filteroption - Erscheinungsdatum
|
||||
|
||||
// if (DE_DATE_REGEX.test(control.value)) {
|
||||
// date = moment(control.value, 'L').toDate();
|
||||
// } else if (ISO_DATE_REGEX.test(control.value)) {
|
||||
// date = new Date(control.value);
|
||||
// }
|
||||
}
|
||||
|
||||
if (date === null) {
|
||||
if (date?.toString() === 'Invalid Date' || date === null) {
|
||||
return { date: 'Datum ist ungültig' };
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user