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 class="uk-text-primary">All linked together through citations and semantics.</div>
</div> </div>
<div [class.uk-invisible]="disableSelect" class="uk-margin-medium-top uk-width-4-5@l uk-width-3-5@xl"> <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" <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> [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> </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"> <div class="uk-padding-small">
<quick-selections [resultTypes]="resultTypes" [quickFilter]="resultsQuickFilter"></quick-selections> <quick-selections [resultTypes]="resultTypes" [quickFilter]="resultsQuickFilter"></quick-selections>
</div> </div>

View File

@ -9,7 +9,7 @@ import {
ViewChild, ViewChild,
ViewChildren ViewChildren
} from '@angular/core'; } from '@angular/core';
import {Observable, of, Subscriber, zip} from 'rxjs'; import {of, Subscriber, zip} from 'rxjs';
import {ActivatedRoute, Router} from '@angular/router'; import {ActivatedRoute, Router} from '@angular/router';
import {Location} from '@angular/common'; import {Location} from '@angular/common';
import {Meta, Title} from '@angular/platform-browser'; import {Meta, Title} from '@angular/platform-browser';
@ -31,14 +31,14 @@ import {Filter} from "../openaireLibrary/searchPages/searchUtils/searchHelperCla
import {properties} from "../../environments/environment"; import {properties} from "../../environments/environment";
import {Numbers, NumbersComponent} from "../openaireLibrary/sharedComponents/numbers/numbers.component"; import {Numbers, NumbersComponent} from "../openaireLibrary/sharedComponents/numbers/numbers.component";
import {StringUtils} from "../openaireLibrary/utils/string-utils.class"; 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({ @Component({
selector: 'home', selector: 'home',
templateUrl: 'home.component.html', templateUrl: 'home.component.html',
styleUrls: ['home.component.css'] styleUrls: ['home.component.css']
}) })
export class HomeComponent implements OnInit, OnDestroy, AfterViewInit{ export class HomeComponent implements OnInit, OnDestroy, AfterViewInit {
// MAX 12 logos in every slide // MAX 12 logos in every slide
public logos = { public logos = {
"publication": [ "publication": [
@ -162,7 +162,7 @@ export class HomeComponent implements OnInit, OnDestroy, AfterViewInit{
filterOperator: "or" filterOperator: "or"
}; };
public pageContents = null; public pageContents = null;
@ViewChild("numbersComponent", { static: true }) numbersComponent: NumbersComponent; @ViewChild("numbersComponent", {static: true}) numbersComponent: NumbersComponent;
specialSubjects = [ specialSubjects = [
{value: "Physics::Atomic Physics", label: "Atomic Physics"}, {value: "Physics::Atomic Physics", label: "Atomic Physics"},
{value: "Mathematics::Combinatorics", label: "Mathematics Combinatorics"}, {value: "Mathematics::Combinatorics", label: "Mathematics Combinatorics"},
@ -261,13 +261,28 @@ export class HomeComponent implements OnInit, OnDestroy, AfterViewInit{
this.showDataProviders = !!showEntity["datasource"]; this.showDataProviders = !!showEntity["datasource"];
this.showOrganizations = !!showEntity["organization"]; this.showOrganizations = !!showEntity["organization"];
if (this.showPublications) { 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) { 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) { 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) { if (this.showOrp) {
this.resultTypes.values.push({name: this.openaireEntities.OTHER, id: "other", selected: false, number: 0}); 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() { public ngOnDestroy() {
this.clear(); this.clear();
} }
ngAfterViewInit() { ngAfterViewInit() {
if(typeof window !== "undefined") { if (typeof window !== "undefined") {
this.createObserver(); this.createObserver();
} }
} }
@ -344,13 +358,13 @@ export class HomeComponent implements OnInit, OnDestroy, AfterViewInit{
} }
if (this.resultsQuickFilter && this.resultsQuickFilter.selected) { if (this.resultsQuickFilter && this.resultsQuickFilter.selected) {
parameterNames.push(this.resultsQuickFilter.filterId); parameterNames.push(this.resultsQuickFilter.filterId);
parameterValues.push('"'+ encodeURIComponent(this.resultsQuickFilter.value)+'"'); parameterValues.push('"' + encodeURIComponent(this.resultsQuickFilter.value) + '"');
} }
} }
} else if (this.selectedEntity == "all") { } else if (this.selectedEntity == "all") {
if (this.resultsQuickFilter && this.resultsQuickFilter.selected) { if (this.resultsQuickFilter && this.resultsQuickFilter.selected) {
parameterNames.push(this.resultsQuickFilter.filterId); parameterNames.push(this.resultsQuickFilter.filterId);
parameterValues.push('"'+ encodeURIComponent(this.resultsQuickFilter.value)+'"'); parameterValues.push('"' + encodeURIComponent(this.resultsQuickFilter.value) + '"');
} }
} }
if (this.keyword.length > 0) { 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)}); 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, init(getDatasetsLinked = false, getSoftwareLinked = false, getPublications = true, getDatasets = true,
@ -419,7 +434,7 @@ export class HomeComponent implements OnInit, OnDestroy, AfterViewInit{
} }
public get showContentWithNumbers() { 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; return true;
} }
} }

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

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