openaire-library/utils/rangeFilter/rangeFilter.component.html

118 lines
7.0 KiB
HTML
Raw Normal View History

<div class="uk-margin-small-bottom">
<div class="uk-margin-small-top uk-margin-bottom uk-grid uk-flex uk-flex-bottom">
<h6 class="uk-margin-bottom-remove">{{_formatTitle(filter.title)}}</h6>
<a *ngIf="filter.selectedFromValue || filter.selectedToValue" (click)="clearFilter()"
[class]="(isDisabled ? 'uk-disabled' : '') + ' portal-link'">
Clear
</a>
</div>
<div aria-expanded="false">
<div>
<div class = "uk-animation-fade filterItem searchFilterItem uk-text-small">
<div class="searchFilterBoxValues ">
<form [class]="(isDisabled ? 'uk-disabled' : '') + ' uk-inline uk-text-small form-group uk-margin-remove-bottom'"
#rangeForm="ngForm" fromYearAfterToYear [rangeRequired]="mandatoryRange">
<input class=" uk-input form-control uk-width-1-3 uk-form-small" (focus)="focusedInput = 'from'"
(blur)="focusedInput = ''"
[(ngModel)]="filter.selectedFromValue" name="yearFrom" #yearFrom="ngModel" inValidYear
[maxYear]="yearMax" [minYear]="yearMin"
[placeholder]="'e.g. ' + yearMin " />
<span class="uk-margin-small-left uk-margin-small-right">-</span>
<input class=" uk-input form-control uk-width-1-3 uk-form-small" (focus)="focusedInput = 'to'"
(blur)="focusedInput = ''"
[(ngModel)]="filter.selectedToValue" name="yearTo" #yearTo="ngModel" inValidYear
[maxYear]="yearMax" [minYear]="yearMin"
[placeholder]="'e.g. ' + yearMax "/>
<button type="submit" (click)="yearChanged()"
[ngStyle]="{'cursor': (rangeForm.valid && (yearFrom.dirty || yearTo.dirty)) ? 'pointer' : 'default'}"
2022-03-15 12:13:28 +01:00
class="uk-icon uk-icon-button uk-button-default uk-margin-small-left"
[class.uk-disabled]="isDisabled || rangeForm.invalid || (!yearFrom.dirty && !yearTo.dirty)"
[disabled]="isDisabled || rangeForm.invalid || (!yearFrom.dirty && !yearTo.dirty)">
<svg width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"
icon="chevron-right" ratio="1">
<polyline fill="none" stroke="#000" stroke-width="1.03" points="7 4 13 10 7 16"></polyline>
</svg>
<span class="visually-hidden">GO</span>
</button>
<div *ngIf="(yearFrom.invalid && focusedInput != 'from' && (yearFrom.dirty || yearFrom.touched)) ||
(yearTo.invalid && focusedInput != 'to' && (yearTo.dirty || yearTo.touched))"
class="alert alert-danger uk-margin-small-top uk-margin-remove-bottom">
<div *ngIf="(yearFrom.errors && yearFrom.errors.inValidYear) || (yearTo.errors && yearTo.errors.inValidYear)">
Year must be between {{yearMin}} and {{yearMax}}.
</div>
</div>
<div *ngIf="yearFrom.valid && yearTo.valid && rangeForm.errors?.fromYearAfterToYear && (rangeForm.touched || rangeForm.dirty)"
class="alert alert-danger uk-margin-small-top uk-margin-remove-bottom">
Starting year must be greater than or equal to ending year.
</div>
<div *ngIf="yearFrom.valid && yearTo.valid && !rangeForm.errors?.fromYearAfterToYear &&
(rangeForm.touched || rangeForm.dirty) && mandatoryRange && rangeForm.errors?.rangeRequired"
class="alert alert-danger uk-margin-small-top uk-margin-remove-bottom">
Both starting and ending year are required
</div>
<div *ngIf="showQuickButtons">
<!-- Natalia's suggestion-->
<div class="uk-margin-small uk-margin-top uk-text-left">
2022-03-15 12:13:28 +01:00
<ul class="uk-text-small uk-grid uk-grid-small uk-grid-divider" uk-grid>
<!-- + (isDisabled ? ' uk-disabled uk-text-muted' : '')"-->
<li>
<a *ngIf="actionRoute" [routerLink]="getRoute()"
[queryParams]="getParams(0,(stringToNum(filter.selectedToValue) ==
currentYear
&&stringToNum(filter.selectedFromValue) == currentYear))"
2022-03-15 12:13:28 +01:00
[class]="'uk-text-center '
+ ((stringToNum(filter.selectedFromValue) == currentYear && stringToNum(filter.selectedToValue) == currentYear) ? ' uk-text-bold' : '')
"
(click)="yearChanged(0)"
>This year</a>
<a *ngIf="!actionRoute"
2022-03-15 12:13:28 +01:00
[class]="'uk-text-center '
+ ((stringToNum(filter.selectedFromValue) == currentYear && stringToNum(filter.selectedToValue) == currentYear) ? ' uk-text-bold' : '')
"
(click)="yearChanged(0)"
>This year</a>
</li>
<li><a *ngIf="actionRoute" [routerLink]="getRoute()"
[queryParams]="getParams(4,(stringToNum(filter.selectedToValue) == currentYear
&&stringToNum(filter.selectedFromValue) == currentYear-4))"
2022-03-15 12:13:28 +01:00
[class]="'uk-text-center '
+ ((stringToNum(filter.selectedToValue) == currentYear && stringToNum(filter.selectedFromValue) == currentYear-4) ? ' uk-text-bold' : '')
"
(click)="yearChanged(4)"
>Last 5 years</a>
<a *ngIf="!actionRoute"
2022-03-15 12:13:28 +01:00
[class]="'uk-text-center '
+ ((stringToNum(filter.selectedToValue) == currentYear && stringToNum(filter.selectedFromValue) == currentYear-4) ? ' uk-text-bold' : '')
"
(click)="yearChanged(4)"
>Last 5 years</a>
</li>
<li><a *ngIf="actionRoute" [routerLink]="getRoute()"
[queryParams]="getParams(9,(stringToNum(filter.selectedToValue) == currentYear &&stringToNum(filter.selectedFromValue) == currentYear-9))"
2022-03-15 12:13:28 +01:00
[class]="'uk-text-center '
+ ((stringToNum(filter.selectedToValue) == currentYear && stringToNum(filter.selectedFromValue) == currentYear-9) ? ' uk-text-bold' : '')
"
(click)="yearChanged(9)"
>Last 10 years</a>
<a *ngIf="!actionRoute"
2022-03-15 12:13:28 +01:00
[class]="'uk-text-center '
+ ((stringToNum(filter.selectedToValue) == currentYear && stringToNum(filter.selectedFromValue) == currentYear-9) ? ' uk-text-bold' : '')
"
(click)="yearChanged(9)"
>Last 10 years</a>
</li>
</ul>
</div>
<!-- End of Natalia's suggestion -->
</div>
</form>
</div>
</div>
</div>
</div>
</div>