Skip to content

Commit

Permalink
Merged dspace-cris-7 into DSC-1404-can-not-duplicate-inline-group-whe…
Browse files Browse the repository at this point in the history
…n-mandatory-field-is-empty
  • Loading branch information
atarix83 committed Nov 30, 2023
2 parents 208d5bb + 15ff078 commit d3e9265
Show file tree
Hide file tree
Showing 39 changed files with 488 additions and 286 deletions.
18 changes: 2 additions & 16 deletions src/app/breadcrumbs/breadcrumbs.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,11 @@
</nav>

<ng-template #breadcrumb let-text="text" let-url="url">
<li class="breadcrumb-item" *ngVar="(text | translate) as label">
<div class="breadcrumb-item-limiter">
<a [routerLink]="url" class="text-truncate"
[ngbTooltip]="label | dsBreadcrumbTooltip"
placement="bottom"
>{{label | dsTruncateText}}</a>
</div>
</li>
<li class="breadcrumb-item"><div class="breadcrumb-item-limiter"><a [routerLink]="url" class="text-truncate" [ngbTooltip]="text | translate" placement="bottom" >{{text | translate}}</a></div></li>
</ng-template>

<ng-template #activeBreadcrumb let-text="text">
<li class="breadcrumb-item active" aria-current="page" *ngVar="(text | translate) as label">
<div class="breadcrumb-item-limiter">
<div class="text-truncate"
[ngbTooltip]="label | dsBreadcrumbTooltip"
placement="bottom"
>{{label | dsTruncateText}}</div>
</div>
</li>
<li class="breadcrumb-item active" aria-current="page"><div class="breadcrumb-item-limiter"><div class="text-truncate">{{text | translate}}</div></div></li>
</ng-template>
</ng-container>

47 changes: 5 additions & 42 deletions src/app/breadcrumbs/breadcrumbs.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,22 @@ import { TranslateLoaderMock } from '../shared/testing/translate-loader.mock';
import { RouterTestingModule } from '@angular/router/testing';
import { of as observableOf } from 'rxjs';
import { DebugElement } from '@angular/core';
import { BreadcrumbTooltipPipe } from './breadcrumb/breadcrumb-tooltip.pipe';
import { TruncateBreadcrumbItemCharactersPipe } from './breadcrumb/truncate-breadcrumb-item-characters.pipe';
import { NgbTooltipModule } from '@ng-bootstrap/ng-bootstrap';

describe('BreadcrumbsComponent', () => {
let component: BreadcrumbsComponent;
let fixture: ComponentFixture<BreadcrumbsComponent>;
let breadcrumbsServiceMock: BreadcrumbsService;
let truncateTextPipe: TruncateBreadcrumbItemCharactersPipe;

const expectBreadcrumb = (listItem: DebugElement, text: string, url: string) => {
const anchor = listItem.query(By.css('a'));
const truncatedText = truncateTextPipe.transform(text);

if (url == null) {
expect(anchor).toBeNull();
// remove leading whitespace characters
const textWithoutSpaces = listItem.nativeElement.innerHTML.trimStart().replace(/^\s+/, '');
expect(textWithoutSpaces).toEqual(truncatedText);
expect(listItem.nativeElement.innerHTML).toEqual(text);
} else {
expect(anchor).toBeInstanceOf(DebugElement);
expect(anchor.attributes.href).toEqual(url);
// remove leading whitespace characters
const textWithoutSpaces = anchor.nativeElement.innerHTML.trimStart().replace(/^\s+/, '');
expect(textWithoutSpaces).toEqual(truncatedText);
expect(anchor.nativeElement.innerHTML).toEqual(text);
}
};

Expand All @@ -43,7 +35,6 @@ describe('BreadcrumbsComponent', () => {
// NOTE: a root breadcrumb is automatically rendered
new Breadcrumb('bc 1', 'example.com'),
new Breadcrumb('bc 2', 'another.com'),
new Breadcrumb('breadcrumb to be truncated', 'truncated.com'),
]),
showBreadcrumbs$: observableOf(true),
} as BreadcrumbsService;
Expand All @@ -52,11 +43,8 @@ describe('BreadcrumbsComponent', () => {
declarations: [
BreadcrumbsComponent,
VarDirective,
BreadcrumbTooltipPipe,
TruncateBreadcrumbItemCharactersPipe,
],
imports: [
NgbTooltipModule,
RouterTestingModule.withRoutes([]),
TranslateModule.forRoot({
loader: {
Expand All @@ -67,12 +55,10 @@ describe('BreadcrumbsComponent', () => {
],
providers: [
{ provide: BreadcrumbsService, useValue: breadcrumbsServiceMock },
{ provide: TruncateBreadcrumbItemCharactersPipe, useClass: TruncateBreadcrumbItemCharactersPipe },
],
}).compileComponents();

fixture = TestBed.createComponent(BreadcrumbsComponent);
truncateTextPipe = TestBed.inject(TruncateBreadcrumbItemCharactersPipe);
component = fixture.componentInstance;
fixture.detectChanges();
}));
Expand All @@ -81,35 +67,12 @@ describe('BreadcrumbsComponent', () => {
expect(component).toBeTruthy();
});

it('should render the breadcrumbs accordingly', () => {
it('should render the breadcrumbs', () => {
const breadcrumbs = fixture.debugElement.queryAll(By.css('.breadcrumb-item'));
expect(breadcrumbs.length).toBe(4);
expect(breadcrumbs.length).toBe(3);
expectBreadcrumb(breadcrumbs[0], 'home.breadcrumbs', '/');
expectBreadcrumb(breadcrumbs[1], 'bc 1', '/example.com');
expectBreadcrumb(breadcrumbs[2].query(By.css('.text-truncate')), 'bc 2', null);
expectBreadcrumb(breadcrumbs[3].query(By.css('.text-truncate')), 'breadcrumb...', null);
});

it('should show tooltip only for truncated text', () => {
const breadcrumbs = fixture.debugElement.queryAll(By.css('.breadcrumb-item .text-truncate'));
expect(breadcrumbs.length).toBe(4);

const truncatable = breadcrumbs[3];
truncatable.triggerEventHandler('mouseenter', null);
fixture.detectChanges();
let tooltip = truncatable.parent.query(By.css('div.tooltip-inner'));
expect(tooltip).not.toBeNull();
expect(tooltip.nativeElement.innerText).toBe('breadcrumb to be truncated');
truncatable.triggerEventHandler('mouseleave', null);
fixture.detectChanges();

const notTruncatable = breadcrumbs[2];
notTruncatable.triggerEventHandler('mouseenter', null);
fixture.detectChanges();
const tooltip2 = notTruncatable.parent.query(By.css('div.tooltip-inner'));
expect(tooltip2).toBeNull();
notTruncatable.triggerEventHandler('mouseleave', null);
fixture.detectChanges();
});

});
2 changes: 1 addition & 1 deletion src/app/collection-page/collection-page.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ <h3 class="sr-only">{{'collection.page.browse.recent.head' | translate}}</h3>
</div>
<ds-error *ngIf="collectionRD?.hasFailed"
message="{{'error.collection' | translate}}"></ds-error>
<ds-themed-loading *ngIf="collectionRD?.isLoading"
<ds-themed-loading *ngIf="!collectionRD || collectionRD?.isLoading"
message="{{'loading.collection' | translate}}"></ds-themed-loading>
</div>
</div>
8 changes: 7 additions & 1 deletion src/app/collection-page/collection-page.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ChangeDetectionStrategy, Component, OnInit, Inject } from '@angular/core';
import { ChangeDetectionStrategy, Component, OnInit, Inject, PLATFORM_ID } from '@angular/core';
import { isPlatformServer } from '@angular/common';
import { ActivatedRoute, Router } from '@angular/router';
import { BehaviorSubject, combineLatest as observableCombineLatest, Observable, Subject } from 'rxjs';
import { filter, map, mergeMap, startWith, switchMap, take } from 'rxjs/operators';
Expand Down Expand Up @@ -62,6 +63,7 @@ export class CollectionPageComponent implements OnInit {
collectionPageRoute$: Observable<string>;

constructor(
@Inject(PLATFORM_ID) private platformId: Object,
private collectionDataService: CollectionDataService,
private searchService: SearchService,
private route: ActivatedRoute,
Expand All @@ -82,6 +84,10 @@ export class CollectionPageComponent implements OnInit {
}

ngOnInit(): void {
if (isPlatformServer(this.platformId)) {
return;
}

this.collectionRD$ = this.route.data.pipe(
map((data) => data.dso as RemoteData<Collection>),
redirectOn4xx(this.router, this.authService),
Expand Down
68 changes: 0 additions & 68 deletions src/app/cris-item-page/cris-item-page-routing.module.ts

This file was deleted.

2 changes: 0 additions & 2 deletions src/app/cris-item-page/cris-item-page.module.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { CrisItemPageRoutingModule } from './cris-item-page-routing.module';
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { SharedModule } from '../shared/shared.module';
Expand All @@ -17,7 +16,6 @@ import { ItemSharedModule } from '../item-page/item-shared.module';
SharedModule,
CrisLayoutModule,
StatisticsModule,
CrisItemPageRoutingModule,
ItemSharedModule
],
exports: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,13 @@ export abstract class CrisLayoutTabsComponent {
abstract emitSelected(selectedTab): void;

setActiveTab(tab) {
const itemPageRoute = getItemPageRoute(this.item);
this.activeTab$.next(tab);
this.emitSelected(tab);
if (isNotNull(this.route.snapshot.paramMap.get('tab'))) {
this.location.replaceState(getItemPageRoute(this.item) + '/' + tab.shortname);
if (this.tabs[0].shortname === tab.shortname) {
this.location.replaceState(itemPageRoute);
} else {
this.location.replaceState(itemPageRoute + '/' + tab.shortname);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<ds-configuration-search-page *ngIf="configuration" class="w-100"
[fixedFilterQuery]="searchFilter"
[configuration]="configuration"
[renderOnServerSide]="false"
[searchEnabled]="searchEnabled"
[showCharts]="true"
[showScopeSelector]="false"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { ChangeDetectionStrategy, Component, ElementRef, Inject, OnInit, PLATFORM_ID } from '@angular/core';
import { isPlatformServer } from '@angular/common';

import { PaginatedSearchOptions } from '../../shared/search/models/paginated-search-options.model';
import { fadeIn, fadeInOut } from '../../shared/animations/fade';
import { RemoteData } from '../../core/data/remote-data';
Expand Down Expand Up @@ -62,6 +64,10 @@ export class RecentItemListComponent implements OnInit {
this.sortConfig = new SortOptions(environment.homePage.recentSubmissions.sortField, SortDirection.DESC);
}
ngOnInit(): void {
if (isPlatformServer(this.platformId)) {
return;
}

const linksToFollow: FollowLinkConfig<Item>[] = [];
if (this.appConfig.browseBy.showThumbnails) {
linksToFollow.push(followLink('thumbnail'));
Expand Down
Loading

0 comments on commit d3e9265

Please sign in to comment.