Add focus next in home page search and activate dropdown when search is focused

This commit is contained in:
Konstantinos Triantafyllou 2022-06-01 17:41:28 +03:00
parent 9bf87f1f74
commit 11567b2593
4 changed files with 108 additions and 93 deletions

View File

@ -27,13 +27,13 @@
<div class="uk-text-primary">All linked together through citations and semantics.</div>
</div>
<div [class.uk-invisible]="disableSelect" class="uk-margin-medium-top uk-width-4-5@l uk-width-3-5@xl">
<advanced-search-input (searchEmitter)="goTo(true)">
<advanced-search-input #advanced (searchEmitter)="goTo(true)">
<entities-selection #entities [simpleView]="true" currentEntity="all" [selectedEntity]="selectedEntity"
(selectionChange)="entityChanged($event)" (disableSelectEmitter)="disableSelectChange($event)"
(selectionChange)="entityChanged($event);advanced.focusNext(input, $event)" (disableSelectEmitter)="disableSelectChange($event)"
[onChangeNavigate]="false"></entities-selection>
<div input placeholder="Scholary works" [hint]="'Search in OpenAIRE'" [(value)]="keyword"></div>
<div input #input placeholder="Scholary works" [hint]="'Search in OpenAIRE'" [(value)]="keyword"></div>
</advanced-search-input>
<div *ngIf="selectedEntity === 'result' && !entities.input.focused" class="uk-dropdown uk-display-block uk-margin-small-top uk-width-auto">
<div *ngIf="selectedEntity === 'result' && input.focused" class="uk-dropdown uk-display-block uk-margin-small-top uk-width-auto">
<div class="uk-padding-small">
<quick-selections [resultTypes]="resultTypes" [quickFilter]="resultsQuickFilter"></quick-selections>
</div>

View File

@ -9,7 +9,7 @@ import {
ViewChild,
ViewChildren
} from '@angular/core';
import {Observable, of, Subscriber, zip} from 'rxjs';
import {of, Subscriber, zip} from 'rxjs';
import {ActivatedRoute, Router} from '@angular/router';
import {Location} from '@angular/common';
import {Meta, Title} from '@angular/platform-browser';
@ -31,14 +31,14 @@ import {Filter} from "../openaireLibrary/searchPages/searchUtils/searchHelperCla
import {properties} from "../../environments/environment";
import {Numbers, NumbersComponent} from "../openaireLibrary/sharedComponents/numbers/numbers.component";
import {StringUtils} from "../openaireLibrary/utils/string-utils.class";
import { NumberUtils } from '../openaireLibrary/utils/number-utils.class';
import {NumberUtils} from '../openaireLibrary/utils/number-utils.class';
@Component({
selector: 'home',
templateUrl: 'home.component.html',
styleUrls: ['home.component.css']
})
export class HomeComponent implements OnInit, OnDestroy, AfterViewInit{
export class HomeComponent implements OnInit, OnDestroy, AfterViewInit {
// MAX 12 logos in every slide
public logos = {
"publication": [
@ -162,7 +162,7 @@ export class HomeComponent implements OnInit, OnDestroy, AfterViewInit{
filterOperator: "or"
};
public pageContents = null;
@ViewChild("numbersComponent", { static: true }) numbersComponent: NumbersComponent;
@ViewChild("numbersComponent", {static: true}) numbersComponent: NumbersComponent;
specialSubjects = [
{value: "Physics::Atomic Physics", label: "Atomic Physics"},
{value: "Mathematics::Combinatorics", label: "Mathematics Combinatorics"},
@ -261,13 +261,28 @@ export class HomeComponent implements OnInit, OnDestroy, AfterViewInit{
this.showDataProviders = !!showEntity["datasource"];
this.showOrganizations = !!showEntity["organization"];
if (this.showPublications) {
this.resultTypes.values.push({name: this.openaireEntities.PUBLICATIONS, id: "publications", selected: false, number: 0});
this.resultTypes.values.push({
name: this.openaireEntities.PUBLICATIONS,
id: "publications",
selected: false,
number: 0
});
}
if (this.showDatasets) {
this.resultTypes.values.push({name: this.openaireEntities.DATASETS, id: "datasets", selected: false, number: 0});
this.resultTypes.values.push({
name: this.openaireEntities.DATASETS,
id: "datasets",
selected: false,
number: 0
});
}
if (this.showSoftware) {
this.resultTypes.values.push({name: this.openaireEntities.SOFTWARE, id: "software", selected: false, number: 0});
this.resultTypes.values.push({
name: this.openaireEntities.SOFTWARE,
id: "software",
selected: false,
number: 0
});
}
if (this.showOrp) {
this.resultTypes.values.push({name: this.openaireEntities.OTHER, id: "other", selected: false, number: 0});
@ -283,13 +298,12 @@ export class HomeComponent implements OnInit, OnDestroy, AfterViewInit{
}
public ngOnDestroy() {
this.clear();
}
ngAfterViewInit() {
if(typeof window !== "undefined") {
if (typeof window !== "undefined") {
this.createObserver();
}
}
@ -344,13 +358,13 @@ export class HomeComponent implements OnInit, OnDestroy, AfterViewInit{
}
if (this.resultsQuickFilter && this.resultsQuickFilter.selected) {
parameterNames.push(this.resultsQuickFilter.filterId);
parameterValues.push('"'+ encodeURIComponent(this.resultsQuickFilter.value)+'"');
parameterValues.push('"' + encodeURIComponent(this.resultsQuickFilter.value) + '"');
}
}
} else if (this.selectedEntity == "all") {
if (this.resultsQuickFilter && this.resultsQuickFilter.selected) {
parameterNames.push(this.resultsQuickFilter.filterId);
parameterValues.push('"'+ encodeURIComponent(this.resultsQuickFilter.value)+'"');
parameterValues.push('"' + encodeURIComponent(this.resultsQuickFilter.value) + '"');
}
}
if (this.keyword.length > 0) {
@ -361,8 +375,9 @@ export class HomeComponent implements OnInit, OnDestroy, AfterViewInit{
}
this._router.navigate([url], {queryParams: this.routerHelper.createQueryParams(parameterNames, parameterValues)});
}
getSubjectParameter(param){
return {'f0':'resultsubject','fv0':'"' +(param)+'"', size:50};
getSubjectParameter(param) {
return {'f0': 'resultsubject', 'fv0': '"' + (param) + '"', size: 50};
}
init(getDatasetsLinked = false, getSoftwareLinked = false, getPublications = true, getDatasets = true,
@ -419,7 +434,7 @@ export class HomeComponent implements OnInit, OnDestroy, AfterViewInit{
}
public get showContentWithNumbers() {
if(this.numbers && this.numbers.publicationsSize && this.numbers.datasetsSize && this.numbers.softwareSize && this.numbers.datasourcesSize && this.numbers.projectsSize && this.numbers.organizationsSize) {
if (this.numbers && this.numbers.publicationsSize && this.numbers.datasetsSize && this.numbers.softwareSize && this.numbers.datasourcesSize && this.numbers.projectsSize && this.numbers.organizationsSize) {
return true;
}
}

@ -1 +1 @@
Subproject commit b0c9ee3736c841087538cd0456dac20233969da3
Subproject commit 7ef6ae148150348c5deafd03c6c5cd53869dbda2

@ -1 +1 @@
Subproject commit a071d1f9bb6131282f69c314f94f6d94f7c85286
Subproject commit 46e2d2d0ce2ea045c627fa676e555dade9247620