[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)).
This commit is contained in:
parent
f3cc4520ad
commit
362dd1cc80
|
@ -186,6 +186,22 @@
|
|||
<ng-container *ngTemplateOutlet="enermaps_tab;"></ng-container>
|
||||
</my-tab>
|
||||
</my-small-tabs>
|
||||
<div class="uk-margin-small-top uk-flex" uk-sticky="bottom: true" [attr.offset]="offset">
|
||||
<!-- Last Index Info-->
|
||||
<div class="uk-width-2-3@m uk-width-1-2">
|
||||
<img src="assets/common-assets/graph.svg" style="opacity: 0.4; width:20px; height:22px" loading="lazy"
|
||||
alt="graph">
|
||||
<span class="uk-margin-small-left uk-text-baseline uk-text-muted">Powered by <a href="https://graph.openaire.eu" class="graph-color">OpenAIRE Research Graph</a></span>
|
||||
<span *ngIf="indexUpdateDate" class="uk-text-baseline uk-text-muted">
|
||||
. Last update of records in OpenAIRE: {{indexUpdateDate | date: 'MMM dd, yyyy'}}
|
||||
</span>
|
||||
</div>
|
||||
<!--Feedback-->
|
||||
<div class="uk-width-expand uk-text-right">
|
||||
<span class="uk-text-muted">Any information missing or wrong?</span>
|
||||
<a (click)="showFeedback = true; scroll()" class="portal-link space">Report an Issue</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- right box-->
|
||||
|
@ -487,22 +503,6 @@
|
|||
|
||||
<!-- </ng-template>-->
|
||||
</div>
|
||||
<div class="uk-margin-small-top uk-flex">
|
||||
<!-- Last Index Info-->
|
||||
<div class="uk-width-2-3@m uk-width-1-2">
|
||||
<img src="assets/common-assets/graph.svg" style="opacity: 0.4; width:20px; height:22px" loading="lazy"
|
||||
alt="graph">
|
||||
<span class="uk-margin-small-left uk-text-baseline uk-text-muted">Powered by <a href="https://graph.openaire.eu" class="graph-color">OpenAIRE Research Graph</a></span>
|
||||
<span *ngIf="indexUpdateDate" class="uk-text-baseline uk-text-muted">
|
||||
. Last update of records in OpenAIRE: {{indexUpdateDate | date: 'MMM dd, yyyy'}}
|
||||
</span>
|
||||
</div>
|
||||
<!--Feedback-->
|
||||
<div class="uk-width-expand uk-text-right">
|
||||
<span class="uk-text-muted">Any information missing or wrong?</span>
|
||||
<a (click)="showFeedback = true; scroll()" class="portal-link space">Report an Issue</a>
|
||||
</div>
|
||||
</div>
|
||||
<!-- B2 Note-->
|
||||
<div *ngIf="properties.b2noteAPIURL && resultLandingInfo" class="uk-margin-medium-top">
|
||||
<b2note #annotation [id]="id" [landingInfo]="resultLandingInfo" (pidEmitter)="pidInit($event)"></b2note>
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -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:[
|
||||
],
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue