From 362dd1cc803a1f5b174f07dce9d5d12ad389b1ca Mon Sep 17 00:00:00 2001 From: "konstantina.galouni" Date: Tue, 5 Apr 2022 16:50:49 +0300 Subject: [PATCH] [Library | new-theme]: Delete fromYearAfterToYear.directive.ts, inValidYear.directive.ts, rangeYearsRequired.directive.ts directives from rangeFilter folder (validator functions moved to string-utils.class.ts (previous commit)). --- .../result/resultLanding.component.html | 32 +++++++++---------- .../fromYearAfterToYear.directive.ts | 19 ----------- utils/rangeFilter/inValidYear.directive.ts | 21 ------------ utils/rangeFilter/rangeFilter.module.ts | 5 +-- .../rangeYearsRequired.directive.ts | 23 ------------- 5 files changed, 17 insertions(+), 83 deletions(-) delete mode 100644 utils/rangeFilter/fromYearAfterToYear.directive.ts delete mode 100644 utils/rangeFilter/inValidYear.directive.ts delete mode 100644 utils/rangeFilter/rangeYearsRequired.directive.ts diff --git a/landingPages/result/resultLanding.component.html b/landingPages/result/resultLanding.component.html index 34450613..b3cebf6e 100644 --- a/landingPages/result/resultLanding.component.html +++ b/landingPages/result/resultLanding.component.html @@ -186,6 +186,22 @@ +
+ +
+ graph + Powered by OpenAIRE Research Graph + + . Last update of records in OpenAIRE: {{indexUpdateDate | date: 'MMM dd, yyyy'}} + +
+ +
+ Any information missing or wrong? + Report an Issue +
+
@@ -487,22 +503,6 @@ -
- -
- graph - Powered by OpenAIRE Research Graph - - . Last update of records in OpenAIRE: {{indexUpdateDate | date: 'MMM dd, yyyy'}} - -
- -
- Any information missing or wrong? - Report an Issue -
-
diff --git a/utils/rangeFilter/fromYearAfterToYear.directive.ts b/utils/rangeFilter/fromYearAfterToYear.directive.ts deleted file mode 100644 index d4980473..00000000 --- a/utils/rangeFilter/fromYearAfterToYear.directive.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { Directive } from '@angular/core'; -import { AbstractControl, FormGroup, NG_VALIDATORS, ValidationErrors, Validator, ValidatorFn } from '@angular/forms'; - -export const fromYearAfterToYearValidator: ValidatorFn = (control: FormGroup): ValidationErrors | null => { - const yearFrom = control.get('yearFrom'); - const yearTo = control.get('yearTo'); - - return ((yearFrom && yearTo && (parseInt(yearFrom.value, 10) > parseInt(yearTo.value, 10))) ? { 'fromYearAfterToYear': true } : null); -}; - -@Directive({ - selector: '[fromYearAfterToYear]', - providers: [{ provide: NG_VALIDATORS, useExisting: FromYearAfterToYearValidatorDirective, multi: true }] -}) -export class FromYearAfterToYearValidatorDirective implements Validator { - validate(control: AbstractControl): ValidationErrors { - return fromYearAfterToYearValidator(control) - } -} diff --git a/utils/rangeFilter/inValidYear.directive.ts b/utils/rangeFilter/inValidYear.directive.ts deleted file mode 100644 index 52e5d147..00000000 --- a/utils/rangeFilter/inValidYear.directive.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { Directive, Input, OnChanges, SimpleChanges } from '@angular/core'; -import { AbstractControl, NG_VALIDATORS, Validator, ValidatorFn, Validators } from '@angular/forms'; -import { Dates } from "../string-utils.class"; - -export function inValidYearValidator(minYear, maxYear): ValidatorFn { - return (control: AbstractControl): {[key: string]: any} | null => { - return ((control.value && !Dates.isValidYear(control.value, minYear, maxYear)) ? {'inValidYear': {value: control.value}} : null); - }; -} - -@Directive({ - selector: '[inValidYear]', - providers: [{provide: NG_VALIDATORS, useExisting: InValidYearValidatorDirective, multi: true}] -}) -export class InValidYearValidatorDirective implements Validator { - @Input() maxYear = Dates.yearMax; - @Input() minYear = Dates.yearMin; - validate(control: AbstractControl): {[key: string]: any} | null { - return inValidYearValidator(this.minYear, this.maxYear)(control); - } -} diff --git a/utils/rangeFilter/rangeFilter.module.ts b/utils/rangeFilter/rangeFilter.module.ts index 95069b5f..c1504406 100644 --- a/utils/rangeFilter/rangeFilter.module.ts +++ b/utils/rangeFilter/rangeFilter.module.ts @@ -4,9 +4,6 @@ import {ReactiveFormsModule} from '@angular/forms'; import {RouterModule} from '@angular/router'; import {RangeFilterComponent} from './rangeFilter.component'; -import {InValidYearValidatorDirective} from "./inValidYear.directive"; -import {FromYearAfterToYearValidatorDirective} from "./fromYearAfterToYear.directive"; -import {RangeYearsRequiredDirective} from "./rangeYearsRequired.directive"; import {InputModule} from "../../sharedComponents/input/input.module"; @NgModule({ @@ -14,7 +11,7 @@ import {InputModule} from "../../sharedComponents/input/input.module"; CommonModule, RouterModule, InputModule, ReactiveFormsModule ], declarations: [ - RangeFilterComponent, InValidYearValidatorDirective, FromYearAfterToYearValidatorDirective, RangeYearsRequiredDirective + RangeFilterComponent ], providers:[ ], diff --git a/utils/rangeFilter/rangeYearsRequired.directive.ts b/utils/rangeFilter/rangeYearsRequired.directive.ts deleted file mode 100644 index efd7d1c7..00000000 --- a/utils/rangeFilter/rangeYearsRequired.directive.ts +++ /dev/null @@ -1,23 +0,0 @@ -import {Directive, Input} from '@angular/core'; -import { AbstractControl, NG_VALIDATORS, ValidationErrors, Validator, ValidatorFn } from '@angular/forms'; - - -export function rangeRequired( enabled:boolean): ValidatorFn { - return (control: AbstractControl): ValidationErrors | null => { - const yearFrom = control.get('yearFrom'); - const yearTo = control.get('yearTo'); - return ((yearFrom && yearTo && enabled && (yearFrom.value == "" || yearTo.value == "")) ? { 'rangeRequired': true } : null); - }; -} - - -@Directive({ - selector: '[rangeRequired]', - providers: [{ provide: NG_VALIDATORS, useExisting: RangeYearsRequiredDirective, multi: true }] -}) -export class RangeYearsRequiredDirective implements Validator { - @Input('rangeRequired') enabled:boolean = false; - validate(control: AbstractControl): ValidationErrors { - return rangeRequired(this.enabled)(control) - } -}