Merge remote-tracking branch 'origin/develop' into umbrella
This commit is contained in:
commit
6026e6aa82
|
@ -0,0 +1,113 @@
|
|||
import {ChangeDetectorRef, Directive, OnInit} from "@angular/core";
|
||||
import {StakeholderBaseComponent} from "../../monitor-admin/utils/stakeholder-base.component";
|
||||
import {OpenaireEntities} from "../../utils/properties/searchFields";
|
||||
import {StakeholderType} from "../entities/stakeholder";
|
||||
import {Option} from "../../sharedComponents/input/input.component";
|
||||
import {FormBuilder, FormControl} from "@angular/forms";
|
||||
import {LayoutService} from "../../dashboard/sharedComponents/sidebar/layout.service";
|
||||
import {HelperFunctions} from "../../utils/HelperFunctions.class";
|
||||
import {debounceTime, distinctUntilChanged} from "rxjs/operators";
|
||||
|
||||
|
||||
@Directive()
|
||||
export class BrowseStakeholderBaseComponent<T> extends StakeholderBaseComponent implements OnInit {
|
||||
openaireEntities = OpenaireEntities;
|
||||
stakeholderType: StakeholderType;
|
||||
stakeholders: T[] = [];
|
||||
filteredStakeholders: T[] = [];
|
||||
showLoading: boolean = true;
|
||||
isMobile: boolean = false;
|
||||
|
||||
gridView: boolean = true;
|
||||
sortOptions: Option[] = [
|
||||
{value: 'alphAsc', label: 'Alphabetically Asc. (A-Z)'},
|
||||
{value: 'alphDsc', label: 'Alphabetically Dsc. (Z-A)'},
|
||||
];
|
||||
pageOptions: number[] = [10, 20, 30, 40];
|
||||
sortBy: string = null;
|
||||
currentPage: number = 1;
|
||||
pageSize: number = 10;
|
||||
parameters = {};
|
||||
keywordControl: FormControl;
|
||||
hasPublications: boolean = true;
|
||||
|
||||
/* Services */
|
||||
protected layoutService: LayoutService;
|
||||
protected cdr: ChangeDetectorRef;
|
||||
protected fb: FormBuilder;
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.keywordControl = this.fb.control(this._route.snapshot.queryParams.keyword);
|
||||
this.subscriptions.push(this.layoutService.isMobile.subscribe(isMobile => {
|
||||
this.isMobile = isMobile;
|
||||
this.cdr.detectChanges();
|
||||
}));
|
||||
this.stakeholderType = this._route.snapshot.data.type;
|
||||
if (!this.stakeholderType) {
|
||||
this.navigateToError();
|
||||
}
|
||||
this.init();
|
||||
this.subscriptions.push(this.keywordControl.valueChanges.pipe(debounceTime(200), distinctUntilChanged()).subscribe(value => {
|
||||
this.filtering(value);
|
||||
if (value?.length > 0) {
|
||||
this.parameters['keyword'] = value;
|
||||
} else {
|
||||
delete this.parameters['keyword']
|
||||
}
|
||||
this._router.navigate([], {queryParams: this.parameters});
|
||||
}));
|
||||
}
|
||||
|
||||
init() {
|
||||
this.stakeholders = [];
|
||||
this.filteredStakeholders = [];
|
||||
}
|
||||
|
||||
protected filtering(value) {
|
||||
if (!value) {
|
||||
this.filteredStakeholders = this.stakeholders;
|
||||
} else {
|
||||
this.filteredStakeholders = this.stakeholders.filter(item => (item['name'] && item['name'].toLowerCase().includes(value.toLowerCase())) || (item['alias'] && item['alias'].toLowerCase().includes(value.toLowerCase())));
|
||||
}
|
||||
this.afterStakeholdersInitialized();
|
||||
this.currentPage = 1;
|
||||
}
|
||||
|
||||
sortByChanged() {
|
||||
switch (this.sortBy) {
|
||||
case 'alphAsc':
|
||||
this.stakeholders = this.stakeholders.sort((a, b) => a['name'].localeCompare(b['name']));
|
||||
break;
|
||||
case 'alphDsc':
|
||||
this.stakeholders = this.stakeholders.sort((a, b) => b['name'].localeCompare(a['name']));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
sizeChanged($event) {
|
||||
this.pageSize = $event;
|
||||
this.currentPage = 1;
|
||||
this.afterStakeholdersInitialized();
|
||||
}
|
||||
|
||||
updateCurrentPage($event) {
|
||||
this.currentPage = $event.value;
|
||||
HelperFunctions.scrollToId('target');
|
||||
this.afterStakeholdersInitialized();
|
||||
}
|
||||
|
||||
get typeAsLabel() {
|
||||
return this.stakeholderUtils.types.find(type => type.value === this.stakeholderType).label;
|
||||
}
|
||||
|
||||
afterStakeholdersInitialized() {
|
||||
// this is a method that will be overriden from the components extending this base component, if needed
|
||||
this.showLoading = false;
|
||||
}
|
||||
}
|
|
@ -78,7 +78,7 @@ export class SearchResultComponent implements OnInit, OnChanges {
|
|||
// console.debug(i, this.previewResults[i].orcidPutCodes);
|
||||
}
|
||||
}
|
||||
// this.previewResults = JSON.parse(JSON.stringify(this.previewResults, this.replacer), this.reviver);
|
||||
this.previewResults = JSON.parse(JSON.stringify(this.previewResults, this.replacer), this.reviver);
|
||||
}, error => {
|
||||
|
||||
}
|
||||
|
|
|
@ -218,7 +218,7 @@
|
|||
<div *ngIf="result.oaRoutes" class="uk-first-column">
|
||||
<!-- class="metrics uk-text-xsmall uk-width-auto uk-flex uk-flex-middle uk-flex-right uk-text-meta">-->
|
||||
<a class="uk-flex uk-flex-middle uk-link-reset">
|
||||
<span #badge class="access-route-badge" [ngClass]="'dots-' + badge.children.length.toString()">
|
||||
<span #badge class="access-route-badge" [ngClass]="'dots-' + countDots">
|
||||
<span *ngIf="result.oaRoutes.green" class="dot green"></span>
|
||||
<span *ngIf="result.oaRoutes.oaColor" class="dot" [ngClass]="result.oaRoutes.oaColor"></span>
|
||||
<span *ngIf="result.oaRoutes.isInDiamondJournal" class="dot diamond"></span>
|
||||
|
|
|
@ -13,7 +13,7 @@ import {NumberUtils} from '../number-utils.class';
|
|||
selector: 'result-preview',
|
||||
templateUrl: 'result-preview.component.html',
|
||||
styleUrls: ['result-preview.component.less'],
|
||||
// changeDetection: ChangeDetectionStrategy.OnPush
|
||||
changeDetection: ChangeDetectionStrategy.OnPush
|
||||
})
|
||||
export class ResultPreviewComponent implements OnInit, OnChanges {
|
||||
@Input() prevPath: string = "";
|
||||
|
|
Loading…
Reference in New Issue