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

angular-12
parent 9bf87f1f74
commit 11567b2593

@ -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>

@ -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']
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": [
@ -100,10 +100,10 @@ export class HomeComponent implements OnInit, OnDestroy, AfterViewInit{
"logo-orcid.png",
"logo-opendoar.png",
"logo-grid.png",
"logo-fairsharing.png",
"logo-ror.png",
"logo-datacite.png",
"logo-crossref.png"
"logo-fairsharing.png",
"logo-ror.png",
"logo-datacite.png",
"logo-crossref.png"
]
],
"funder": [
@ -136,7 +136,7 @@ export class HomeComponent implements OnInit, OnDestroy, AfterViewInit{
showDataProviders: boolean = false;
showOrganizations: boolean = false;
properties: EnvProperties = properties;
public openaireEntities = OpenaireEntities;
public openaireEntities = OpenaireEntities;
public readMore: boolean = false;
subscriptions: any[] = [];
@ -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"},
@ -172,13 +172,13 @@ export class HomeComponent implements OnInit, OnDestroy, AfterViewInit{
{value: "lcsh:Chemistry", label: "Chemistry"},
{value: "lcsh:Engineering (General). Civil engineering (General)", label: "Civil engineering"},
{value: "lcsh:Technology", label: "Technology"},
/* "Mathematics::Combinatorics",
"lcsh:Medicine",
"lcsh:Science",
"lcsh:Biology (General)",
"lcsh:Chemistry",
"lcsh:Engineering (General). Civil engineering (General)",
"lcsh:Technology"*/
/* "Mathematics::Combinatorics",
"lcsh:Medicine",
"lcsh:Science",
"lcsh:Biology (General)",
"lcsh:Chemistry",
"lcsh:Engineering (General). Civil engineering (General)",
"lcsh:Technology"*/
];
stringUtils = new StringUtils();
disableSelect: boolean = true;
@ -195,7 +195,7 @@ export class HomeComponent implements OnInit, OnDestroy, AfterViewInit{
private location: Location, private _piwikService: PiwikService,
private config: ConfigurationService, private _meta: Meta, private _title: Title, private seoService: SEOService,
private helper: HelperService,
private cdr: ChangeDetectorRef
private cdr: ChangeDetectorRef
) {
let description = "OpenAIRE Explore: Over 100M of research deduplicated, 170K research software, 11M research data. One of the largest open scholarly records collection worldwide.";
let title = "OpenAIRE | Find and Share research";
@ -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});
@ -281,15 +296,14 @@ 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,66 +375,67 @@ 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,
getSoftware = true, getOther = true, getProjects = true, getDataProviders = true, getOrganizations = true, refineValue: string = null) {
this.subscriptions.push(zip(
(getPublications) ? this.searchResearchResultsService.numOfSearchResults('publication', '', this.properties, null) : of(0),
(getDatasets) ? this.searchResearchResultsService.numOfSearchResults('dataset', '', this.properties, null) : of(0),
(getDatasetsLinked) ? this.searchResearchResultsService.numOfSearchResultsLinkedToPub("dataset", this.properties) : of(0),
(getSoftware) ? this.searchResearchResultsService.numOfSearchResults('software', '', this.properties, null) : of(0),
(getSoftwareLinked) ? this.searchResearchResultsService.numOfSearchResultsLinkedToPub("software", this.properties) : of(0),
(getOther) ? this.searchResearchResultsService.numOfSearchResults('other', '', this.properties, null) : of(0),
(getProjects) ? this.refineFieldResultsService.getRefineFieldsResultsByEntityName(['funder'], 'project', this.properties, null) : of(0),
(getDataProviders) ? this.searchDataprovidersService.numOfSearchDataproviders('', this.properties, null) : of(0),
(getOrganizations) ? this.searchOrganizationsService.numOfSearchOrganizations2('', this.properties, null) : of(0)
).subscribe((data: any[]) => {
if (data[0] && data[0] > 0) {
this.numbers.publicationsSize = NumberUtils.roundNumber(data[0]);
}
if (data[1] && data[1] > 0) {
this.numbers.datasetsSize = NumberUtils.roundNumber(data[1]);
}
if (data[2] && data[2] > 0) {
this.numbers.datasetsLinkedSize = NumberUtils.roundNumber(data[2]);
}
if (data[3] && data[3] > 0) {
this.numbers.softwareSize = NumberUtils.roundNumber(data[3]);
}
if (data[4] && data[4] > 0) {
this.numbers.softwareLinkedSize = NumberUtils.roundNumber(data[4]);
}
if (data[5] && data[5] > 0) {
this.numbers.otherSize = NumberUtils.roundNumber(data[5]);
}
if (data[6][0] && data[6][0] > 0) {
this.numbers.projectsSize = NumberUtils.roundNumber(data[6][0]);
}
if (data[6][1] && data[6][1].length > 0 && data[6][1][0].filterId == 'funder' && data[6][1][0].values) {
this.numbers.fundersSize = NumberUtils.roundNumber(data[6][1][0].values.length);
}
if (data[7] && data[7] > 0) {
this.numbers.datasourcesSize = NumberUtils.roundNumber(data[7]);
}
if (data[8] && data[8] > 0) {
this.numbers.organizationsSize = NumberUtils.roundNumber(data[8]);
}
}, err => {
this.handleError('Error getting numbers', err);
}));
}
disableSelectChange(event: boolean) {
this.disableSelect = event;
this.cdr.detectChanges();
}
public get showContentWithNumbers() {
if (this.numbers && this.numbers.publicationsSize && this.numbers.datasetsSize && this.numbers.softwareSize && this.numbers.datasourcesSize && this.numbers.projectsSize && this.numbers.organizationsSize) {
return true;
}
}
init(getDatasetsLinked = false, getSoftwareLinked = false, getPublications = true, getDatasets = true,
getSoftware = true, getOther = true, getProjects = true, getDataProviders = true, getOrganizations = true, refineValue: string = null) {
this.subscriptions.push(zip(
(getPublications) ? this.searchResearchResultsService.numOfSearchResults('publication', '', this.properties, null) : of(0),
(getDatasets) ? this.searchResearchResultsService.numOfSearchResults('dataset', '', this.properties, null) : of(0),
(getDatasetsLinked) ? this.searchResearchResultsService.numOfSearchResultsLinkedToPub("dataset", this.properties) : of(0),
(getSoftware) ? this.searchResearchResultsService.numOfSearchResults('software', '', this.properties, null) : of(0),
(getSoftwareLinked) ? this.searchResearchResultsService.numOfSearchResultsLinkedToPub("software", this.properties) : of(0),
(getOther) ? this.searchResearchResultsService.numOfSearchResults('other', '', this.properties, null) : of(0),
(getProjects) ? this.refineFieldResultsService.getRefineFieldsResultsByEntityName(['funder'], 'project', this.properties, null) : of(0),
(getDataProviders) ? this.searchDataprovidersService.numOfSearchDataproviders('', this.properties, null) : of(0),
(getOrganizations) ? this.searchOrganizationsService.numOfSearchOrganizations2('', this.properties, null) : of(0)
).subscribe((data: any[]) => {
if (data[0] && data[0] > 0) {
this.numbers.publicationsSize = NumberUtils.roundNumber(data[0]);
}
if (data[1] && data[1] > 0) {
this.numbers.datasetsSize = NumberUtils.roundNumber(data[1]);
}
if (data[2] && data[2] > 0) {
this.numbers.datasetsLinkedSize = NumberUtils.roundNumber(data[2]);
}
if (data[3] && data[3] > 0) {
this.numbers.softwareSize = NumberUtils.roundNumber(data[3]);
}
if (data[4] && data[4] > 0) {
this.numbers.softwareLinkedSize = NumberUtils.roundNumber(data[4]);
}
if (data[5] && data[5] > 0) {
this.numbers.otherSize = NumberUtils.roundNumber(data[5]);
}
if (data[6][0] && data[6][0] > 0) {
this.numbers.projectsSize = NumberUtils.roundNumber(data[6][0]);
}
if (data[6][1] && data[6][1].length > 0 && data[6][1][0].filterId == 'funder' && data[6][1][0].values) {
this.numbers.fundersSize = NumberUtils.roundNumber(data[6][1][0].values.length);
}
if (data[7] && data[7] > 0) {
this.numbers.datasourcesSize = NumberUtils.roundNumber(data[7]);
}
if (data[8] && data[8] > 0) {
this.numbers.organizationsSize = NumberUtils.roundNumber(data[8]);
}
}, err => {
this.handleError('Error getting numbers', err);
}));
}
disableSelectChange(event: boolean) {
this.disableSelect = event;
this.cdr.detectChanges();
}
public get showContentWithNumbers() {
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
Loading…
Cancel
Save