Skip to content

Commit ac68399

Browse files
Merged in UXP-111-carousel-internal-link-porting (pull request DSpace#1570)
UXP-111 carousel internal link porting
2 parents d1d3a22 + 5724c83 commit ac68399

3 files changed

Lines changed: 6 additions & 6 deletions

File tree

src/app/shared/carousel/carousel.component.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<ngb-carousel #carousel [interval]="2000" (slide)="onSlide($event)" class="ds-carousel">
22
<ng-template ngbSlide *ngFor="let item of items; let i = index; let last = last">
33
<ng-container *ngIf="getItemLink(item.indexableObject); let currentLink; else carouselContent">
4-
<a *ngIf="isLinkInternal(currentLink)" [routerLink]="currentLink">
4+
<a *ngIf="internalLinkService.isLinkInternal(currentLink)" [routerLink]="internalLinkService.getRelativePath(currentLink)">
55
<ng-container *ngTemplateOutlet="carouselContent"></ng-container>
66
</a>
7-
<a *ngIf="!isLinkInternal(currentLink)" [href]="currentLink" [target]="carouselOptions.targetBlank ? '_blank' : null">
7+
<a *ngIf="!internalLinkService.isLinkInternal(currentLink)" [href]="currentLink" [target]="carouselOptions.targetBlank ? '_blank' : null">
88
<ng-container *ngTemplateOutlet="carouselContent"></ng-container>
99
</a>
1010
</ng-container>

src/app/shared/carousel/carousel.component.spec.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import { createPaginatedList } from '../testing/utils.test';
3535
import { ItemSearchResult } from '../object-collection/shared/item-search-result.model';
3636
import { BitstreamFormat } from '../../core/shared/bitstream-format.model';
3737
import { CarouselOptions } from './carousel-options.model';
38+
import { InternalLinkService } from 'src/app/core/services/internal-link.service';
3839

3940
describe('CarouselComponent', () => {
4041
let component: CarouselComponent;
@@ -168,6 +169,7 @@ describe('CarouselComponent', () => {
168169
providers: [
169170
CarouselComponent,
170171
{ provide: ObjectCacheService, useValue: {} },
172+
{ provide: InternalLinkService, useValue: {} },
171173
{ provide: UUIDService, useValue: {} },
172174
{ provide: Store, useValue: {} },
173175
{ provide: RemoteDataBuildService, useValue: {} },

src/app/shared/carousel/carousel.component.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {Bitstream} from '../../core/shared/bitstream.model';
88
import {BitstreamDataService} from '../../core/data/bitstream-data.service';
99
import {NativeWindowRef, NativeWindowService} from '../../core/services/window.service';
1010
import {getFirstCompletedRemoteData} from '../../core/shared/operators';
11+
import {InternalLinkService} from '../../core/services/internal-link.service';
1112
import {hasValue} from '../empty.util';
1213
import {ItemSearchResult} from '../object-collection/shared/item-search-result.model';
1314
import {followLink} from '../utils/follow-link-config.model';
@@ -82,6 +83,7 @@ export class CarouselComponent implements OnInit {
8283
isLoading$ = new BehaviorSubject(true);
8384

8485
constructor(
86+
public internalLinkService: InternalLinkService,
8587
protected bitstreamDataService: BitstreamDataService,
8688
@Inject(NativeWindowService) private _window: NativeWindowRef,
8789
) {
@@ -157,10 +159,6 @@ export class CarouselComponent implements OnInit {
157159
return item.firstMetadataValue(this.link);
158160
}
159161

160-
isLinkInternal(link: string) {
161-
return link.startsWith('/');
162-
}
163-
164162
/**
165163
* to open a link of an item
166164
*/

0 commit comments

Comments
 (0)