Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use routerLink for counters section #26

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@
</div>
<div *ngFor="let counter of (counterData$ | async)"
class="px-4 py-1 d-flex flex-column" style="flex: 1 0 100px">
<div (click)="goToLink(counter.link)"
[ngStyle]="{'cursor': counter.link? 'pointer' : 'inherit'}"
<div [routerLink]="getLinkSegment(counter.link)" [queryParams]="getLinkQueryParams(counter.link)"
[ngStyle]="{'cursor': counter.link? 'pointer' : 'inherit'}"
class="col d-flex justify-content-center text-center align-items-center">
<i [ngClass]="counter.icon"></i>
</div>
<div (click)="goToLink(counter.link)"
[ngStyle]="{'cursor': counter.link? 'pointer' : 'inherit'}"
<div [routerLink]="getLinkSegment(counter.link)" [queryParams]="getLinkQueryParams(counter.link)"
[ngStyle]="{'cursor': counter.link? 'pointer' : 'inherit'}"
class="col d-flex justify-content-center text-center align-items-center">
{{'explore.counters-section.' + counter.label | translate}}
</div>
<div (click)="goToLink(counter.link)"
[ngStyle]="{'cursor': counter.link? 'pointer' : 'inherit'}"
<div [routerLink]="getLinkSegment(counter.link)" [queryParams]="getLinkQueryParams(counter.link)"
[ngStyle]="{'cursor': counter.link? 'pointer' : 'inherit'}"
class="col d-flex justify-content-center text-center align-items-center">
<b>{{counter.count}}</b>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import { Component, Inject, Input, OnInit } from '@angular/core';
import { Component, Input, OnInit } from '@angular/core';

import { BehaviorSubject, forkJoin, Observable } from 'rxjs';
import { map } from 'rxjs/operators';

import { NativeWindowRef, NativeWindowService } from '../../../../core/services/window.service';
import { DSpaceObject } from '../../../../core/shared/dspace-object.model';
import { SearchObjects } from '../../../search/models/search-objects.model';
import { getFirstSucceededRemoteDataPayload } from '../../../../core/shared/operators';
import { PaginationComponentOptions } from '../../../pagination/pagination-component-options.model';
import { SectionComponent } from '../../../../core/layout/models/section.model';
import { SearchService } from '../../../../core/shared/search/search.service';
import { PaginatedSearchOptions } from '../../../search/models/paginated-search-options.model';
import { Router } from '@angular/router';
import { hasValue } from '../../../empty.util';
import { UUIDService } from '../../../../core/shared/uuid.service';

Expand Down Expand Up @@ -39,7 +39,7 @@ export class CountersSectionComponent implements OnInit {

constructor(private searchService: SearchService,
private uuidService: UUIDService,
@Inject(NativeWindowService) protected _window: NativeWindowRef) {
private router: Router) {

}

Expand All @@ -64,11 +64,17 @@ export class CountersSectionComponent implements OnInit {
this.counterData$.subscribe(() => this.isLoading$.next(false));
}

goToLink(link: string) {
if (hasValue(link)) {
this._window.nativeWindow.location.href = link;
getLinkQueryParams(link: string): any {
return this.router.parseUrl(link).queryParams || null;
}

getLinkSegment(link: string): string {
if (hasValue(link) && link.includes('?')) {
return link.split('?')[0];
}
return link;
}

}


Expand Down