mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 10:04:11 +00:00
removed code repetition
This commit is contained in:
@@ -1,9 +1,4 @@
|
|||||||
<div class="row" *ngIf="showBackButton | async">
|
|
||||||
<div class="col-12">
|
|
||||||
<ds-themed-results-back-button></ds-themed-results-back-button>
|
<ds-themed-results-back-button></ds-themed-results-back-button>
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="d-flex flex-row">
|
<div class="d-flex flex-row">
|
||||||
<ds-item-page-title-field [item]="object" class="mr-auto">
|
<ds-item-page-title-field [item]="object" class="mr-auto">
|
||||||
</ds-item-page-title-field>
|
</ds-item-page-title-field>
|
||||||
|
@@ -1,5 +1,2 @@
|
|||||||
@import '../../../../../styles/variables.scss';
|
@import '../../../../../styles/variables.scss';
|
||||||
|
|
||||||
button.back-btn {
|
|
||||||
margin-bottom: 10px;
|
|
||||||
}
|
|
||||||
|
@@ -1,9 +1,4 @@
|
|||||||
<div class="row" *ngIf="showBackButton | async">
|
|
||||||
<div class="col-12">
|
|
||||||
<ds-themed-results-back-button></ds-themed-results-back-button>
|
<ds-themed-results-back-button></ds-themed-results-back-button>
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="d-flex flex-row">
|
<div class="d-flex flex-row">
|
||||||
<ds-item-page-title-field [item]="object" class="mr-auto">
|
<ds-item-page-title-field [item]="object" class="mr-auto">
|
||||||
</ds-item-page-title-field>
|
</ds-item-page-title-field>
|
||||||
|
@@ -1,5 +1 @@
|
|||||||
@import '../../../../../styles/variables.scss';
|
@import '../../../../../styles/variables.scss';
|
||||||
|
|
||||||
button.back-btn {
|
|
||||||
margin-bottom: 10px;
|
|
||||||
}
|
|
||||||
|
@@ -1,9 +1,4 @@
|
|||||||
<div class="row" *ngIf="showBackButton | async">
|
|
||||||
<div class="col-12">
|
|
||||||
<ds-themed-results-back-button></ds-themed-results-back-button>
|
<ds-themed-results-back-button></ds-themed-results-back-button>
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="d-flex flex-row">
|
<div class="d-flex flex-row">
|
||||||
<ds-item-page-title-field [item]="object" class="mr-auto">
|
<ds-item-page-title-field [item]="object" class="mr-auto">
|
||||||
</ds-item-page-title-field>
|
</ds-item-page-title-field>
|
||||||
|
@@ -1,5 +1 @@
|
|||||||
@import '../../../../../styles/variables.scss';
|
@import '../../../../../styles/variables.scss';
|
||||||
|
|
||||||
button.back-btn {
|
|
||||||
margin-bottom: 10px;
|
|
||||||
}
|
|
||||||
|
@@ -1,9 +1,4 @@
|
|||||||
<div class="row" *ngIf="showBackButton | async">
|
|
||||||
<div class="col-12">
|
|
||||||
<ds-themed-results-back-button></ds-themed-results-back-button>
|
<ds-themed-results-back-button></ds-themed-results-back-button>
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="d-flex flex-row">
|
<div class="d-flex flex-row">
|
||||||
<ds-item-page-title-field [item]="object" class="mr-auto">
|
<ds-item-page-title-field [item]="object" class="mr-auto">
|
||||||
</ds-item-page-title-field>
|
</ds-item-page-title-field>
|
||||||
|
@@ -1,5 +1 @@
|
|||||||
@import '../../../../../styles/variables.scss';
|
@import '../../../../../styles/variables.scss';
|
||||||
|
|
||||||
button.back-btn {
|
|
||||||
margin-bottom: 10px;
|
|
||||||
}
|
|
||||||
|
@@ -1,9 +1,4 @@
|
|||||||
<div class="row" *ngIf="showBackButton | async">
|
|
||||||
<div class="col-12">
|
|
||||||
<ds-themed-results-back-button></ds-themed-results-back-button>
|
<ds-themed-results-back-button></ds-themed-results-back-button>
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="d-flex flex-row">
|
<div class="d-flex flex-row">
|
||||||
<ds-item-page-title-field class="mr-auto" [item]="object">
|
<ds-item-page-title-field class="mr-auto" [item]="object">
|
||||||
</ds-item-page-title-field>
|
</ds-item-page-title-field>
|
||||||
|
@@ -1,5 +1 @@
|
|||||||
@import '../../../../../styles/variables.scss';
|
@import '../../../../../styles/variables.scss';
|
||||||
|
|
||||||
button.back-btn {
|
|
||||||
margin-bottom: 10px;
|
|
||||||
}
|
|
||||||
|
@@ -1,9 +1,4 @@
|
|||||||
<div class="row" *ngIf="showBackButton | async">
|
|
||||||
<div class="col-12">
|
|
||||||
<ds-themed-results-back-button></ds-themed-results-back-button>
|
<ds-themed-results-back-button></ds-themed-results-back-button>
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="d-flex flex-row">
|
<div class="d-flex flex-row">
|
||||||
<ds-item-page-title-field [item]="object" class="mr-auto">
|
<ds-item-page-title-field [item]="object" class="mr-auto">
|
||||||
</ds-item-page-title-field>
|
</ds-item-page-title-field>
|
||||||
|
@@ -1,5 +1 @@
|
|||||||
@import '../../../../../styles/variables.scss';
|
@import '../../../../../styles/variables.scss';
|
||||||
|
|
||||||
button.back-btn {
|
|
||||||
margin-bottom: 10px;
|
|
||||||
}
|
|
||||||
|
@@ -1,9 +1,4 @@
|
|||||||
<div class="row" *ngIf="showBackButton | async">
|
|
||||||
<div class="col-12">
|
|
||||||
<ds-themed-results-back-button></ds-themed-results-back-button>
|
<ds-themed-results-back-button></ds-themed-results-back-button>
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="row" *ngIf="iiifEnabled">
|
<div class="row" *ngIf="iiifEnabled">
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
<ds-mirador-viewer id="iiif-viewer"
|
<ds-mirador-viewer id="iiif-viewer"
|
||||||
|
@@ -1,5 +1,2 @@
|
|||||||
@import '../../../../../styles/variables.scss';
|
@import '../../../../../styles/variables.scss';
|
||||||
|
|
||||||
button.back-btn {
|
|
||||||
margin-bottom: 10px;
|
|
||||||
}
|
|
||||||
|
@@ -38,12 +38,9 @@ import { VersionHistoryDataService } from '../../../../core/data/version-history
|
|||||||
import { RouterTestingModule } from '@angular/router/testing';
|
import { RouterTestingModule } from '@angular/router/testing';
|
||||||
import { AuthorizationDataService } from '../../../../core/data/feature-authorization/authorization-data.service';
|
import { AuthorizationDataService } from '../../../../core/data/feature-authorization/authorization-data.service';
|
||||||
import { ResearcherProfileDataService } from '../../../../core/profile/researcher-profile-data.service';
|
import { ResearcherProfileDataService } from '../../../../core/profile/researcher-profile-data.service';
|
||||||
import { Router } from '@angular/router';
|
|
||||||
|
|
||||||
import { buildPaginatedList } from '../../../../core/data/paginated-list.model';
|
import { buildPaginatedList } from '../../../../core/data/paginated-list.model';
|
||||||
import { PageInfo } from '../../../../core/shared/page-info.model';
|
import { PageInfo } from '../../../../core/shared/page-info.model';
|
||||||
import { ItemComponent } from './item.component';
|
|
||||||
import { ItemVersionsSharedService } from '../../../../shared/item/item-versions/item-versions-shared.service';
|
|
||||||
|
|
||||||
export function getIIIFSearchEnabled(enabled: boolean): MetadataValue {
|
export function getIIIFSearchEnabled(enabled: boolean): MetadataValue {
|
||||||
return Object.assign(new MetadataValue(), {
|
return Object.assign(new MetadataValue(), {
|
||||||
@@ -404,79 +401,4 @@ describe('ItemComponent', () => {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('back to results', () => {
|
|
||||||
let comp: ItemComponent;
|
|
||||||
let fixture: ComponentFixture<any>;
|
|
||||||
let router: Router;
|
|
||||||
|
|
||||||
const searchUrl = '/search?query=test&spc.page=2';
|
|
||||||
const browseUrl = '/browse/title?scope=0cc&bbm.page=3';
|
|
||||||
const recentSubmissionsUrl = '/collections/be7b8430-77a5-4016-91c9-90863e50583a?cp.page=3';
|
|
||||||
|
|
||||||
beforeEach(waitForAsync(() => {
|
|
||||||
TestBed.configureTestingModule({
|
|
||||||
imports: [
|
|
||||||
TranslateModule.forRoot({
|
|
||||||
loader: {
|
|
||||||
provide: TranslateLoader,
|
|
||||||
useClass: TranslateLoaderMock
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
RouterTestingModule,
|
|
||||||
],
|
|
||||||
declarations: [ItemComponent, GenericItemPageFieldComponent, TruncatePipe ],
|
|
||||||
providers: [
|
|
||||||
{ provide: ItemDataService, useValue: {} },
|
|
||||||
{ provide: TruncatableService, useValue: {} },
|
|
||||||
{ provide: RelationshipDataService, useValue: {} },
|
|
||||||
{ provide: ObjectCacheService, useValue: {} },
|
|
||||||
{ provide: UUIDService, useValue: {} },
|
|
||||||
{ provide: Store, useValue: {} },
|
|
||||||
{ provide: RemoteDataBuildService, useValue: {} },
|
|
||||||
{ provide: CommunityDataService, useValue: {} },
|
|
||||||
{ provide: HALEndpointService, useValue: {} },
|
|
||||||
{ provide: NotificationsService, useValue: {} },
|
|
||||||
{ provide: HttpClient, useValue: {} },
|
|
||||||
{ provide: DSOChangeAnalyzer, useValue: {} },
|
|
||||||
{ provide: DefaultChangeAnalyzer, useValue: {} },
|
|
||||||
{ provide: VersionHistoryDataService, useValue: {} },
|
|
||||||
{ provide: VersionDataService, useValue: {} },
|
|
||||||
{ provide: BitstreamDataService, useValue: {} },
|
|
||||||
{ provide: WorkspaceitemDataService, useValue: {} },
|
|
||||||
{ provide: SearchService, useValue: {} },
|
|
||||||
{ provide: ItemDataService, useValue: {} },
|
|
||||||
{ provide: ItemVersionsSharedService, useValue: {} },
|
|
||||||
{ provide: RouteService, useValue: mockRouteService }
|
|
||||||
],
|
|
||||||
schemas: [NO_ERRORS_SCHEMA]
|
|
||||||
}).overrideComponent(ItemComponent, {
|
|
||||||
set: {changeDetection: ChangeDetectionStrategy.Default}
|
|
||||||
});
|
|
||||||
}));
|
|
||||||
|
|
||||||
beforeEach(waitForAsync(() => {
|
|
||||||
router = TestBed.inject(Router);
|
|
||||||
spyOn(router, 'navigateByUrl');
|
|
||||||
TestBed.compileComponents();
|
|
||||||
fixture = TestBed.createComponent(ItemComponent);
|
|
||||||
comp = fixture.componentInstance;
|
|
||||||
comp.object = mockItem;
|
|
||||||
fixture.detectChanges();
|
|
||||||
}));
|
|
||||||
|
|
||||||
it('should hide back button',() => {
|
|
||||||
spyOn(mockRouteService, 'getPreviousUrl').and.returnValue(observableOf(''));
|
|
||||||
comp.showBackButton.subscribe((val) => {
|
|
||||||
expect(val).toBeFalse();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
it('should show back button', () => {
|
|
||||||
spyOn(mockRouteService, 'getPreviousUrl').and.returnValue(observableOf(searchUrl));
|
|
||||||
comp.ngOnInit();
|
|
||||||
comp.showBackButton.subscribe((val) => {
|
|
||||||
expect(val).toBeTrue();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@@ -5,7 +5,6 @@ import { getItemPageRoute } from '../../../item-page-routing-paths';
|
|||||||
import { RouteService } from '../../../../core/services/route.service';
|
import { RouteService } from '../../../../core/services/route.service';
|
||||||
import { Observable } from 'rxjs';
|
import { Observable } from 'rxjs';
|
||||||
import { getDSpaceQuery, isIiifEnabled, isIiifSearchEnabled } from './item-iiif-utils';
|
import { getDSpaceQuery, isIiifEnabled, isIiifSearchEnabled } from './item-iiif-utils';
|
||||||
import { filter, map, take } from 'rxjs/operators';
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'ds-item',
|
selector: 'ds-item',
|
||||||
@@ -55,12 +54,5 @@ export class ItemComponent implements OnInit {
|
|||||||
if (this.iiifSearchEnabled) {
|
if (this.iiifSearchEnabled) {
|
||||||
this.iiifQuery$ = getDSpaceQuery(this.object, this.routeService);
|
this.iiifQuery$ = getDSpaceQuery(this.object, this.routeService);
|
||||||
}
|
}
|
||||||
// Show the back to results button when the previous context was search, browse,
|
|
||||||
// or recent submissions pagination.
|
|
||||||
this.showBackButton = this.routeService.getPreviousUrl().pipe(
|
|
||||||
filter(url => /^(\/search|\/browse|\/collections|\/admin\/search|\/mydspace)/.test(url)),
|
|
||||||
take(1),
|
|
||||||
map(() => true)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,9 +1,4 @@
|
|||||||
<div class="row" *ngIf="showBackButton | async">
|
|
||||||
<div class="col-12">
|
|
||||||
<ds-themed-results-back-button></ds-themed-results-back-button>
|
<ds-themed-results-back-button></ds-themed-results-back-button>
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="row" *ngIf="iiifEnabled">
|
<div class="row" *ngIf="iiifEnabled">
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
<ds-mirador-viewer id="iiif-viewer"
|
<ds-mirador-viewer id="iiif-viewer"
|
||||||
|
@@ -1,4 +1,2 @@
|
|||||||
@import '../../../../../styles/variables.scss';
|
@import '../../../../../styles/variables.scss';
|
||||||
button.back-btn {
|
|
||||||
margin-bottom: 10px;
|
|
||||||
}
|
|
||||||
|
@@ -3,7 +3,7 @@
|
|||||||
<ng-container *ngComponentOutlet="getStartsWithComponent(); injector: objectInjector;"></ng-container>
|
<ng-container *ngComponentOutlet="getStartsWithComponent(); injector: objectInjector;"></ng-container>
|
||||||
<div *ngIf="objects?.hasSucceeded && !objects?.isLoading && objects?.payload?.page.length > 0" @fadeIn>
|
<div *ngIf="objects?.hasSucceeded && !objects?.isLoading && objects?.payload?.page.length > 0" @fadeIn>
|
||||||
<div *ngIf="shouldDisplayResetButton$ |async" class="mb-2 reset">
|
<div *ngIf="shouldDisplayResetButton$ |async" class="mb-2 reset">
|
||||||
<ds-results-back-button [paginationConfig]="paginationConfig" [previousPage$]="previousPage$"></ds-results-back-button>
|
<ds-themed-results-back-button [paginationConfig]="paginationConfig" [previousPage$]="previousPage$"></ds-themed-results-back-button>
|
||||||
</div>
|
</div>
|
||||||
<ds-viewable-collection
|
<ds-viewable-collection
|
||||||
[config]="paginationConfig"
|
[config]="paginationConfig"
|
||||||
@@ -18,7 +18,7 @@
|
|||||||
<ds-error *ngIf="objects?.hasFailed" message="{{'error.browse-by' | translate}}"></ds-error>
|
<ds-error *ngIf="objects?.hasFailed" message="{{'error.browse-by' | translate}}"></ds-error>
|
||||||
<div *ngIf="!objects?.isLoading && objects?.payload?.page.length === 0">
|
<div *ngIf="!objects?.isLoading && objects?.payload?.page.length === 0">
|
||||||
<div *ngIf="shouldDisplayResetButton$ |async" class="d-inline-block mb-4 reset">
|
<div *ngIf="shouldDisplayResetButton$ |async" class="d-inline-block mb-4 reset">
|
||||||
<ds-results-back-button [paginationConfig]="paginationConfig" [previousPage$]="previousPage$" ></ds-results-back-button>
|
<ds-themed-results-back-button [paginationConfig]="paginationConfig" [previousPage$]="previousPage$" ></ds-themed-results-back-button>
|
||||||
</div>
|
</div>
|
||||||
<div class="alert alert-info w-100" role="alert">
|
<div class="alert alert-info w-100" role="alert">
|
||||||
{{'browse.empty' | translate}}
|
{{'browse.empty' | translate}}
|
||||||
|
@@ -1,4 +1,5 @@
|
|||||||
<button class="btn btn-secondary btn-sm back-btn ng-tns-c242-28" (click)="back()">
|
<button *ngIf="showBackButton | async" class="btn btn-secondary btn-sm mb-2 ng-tns-c242-28" (click)="back()">
|
||||||
<i _ngcontent-dspace-angular-c242="" class="fas fa-arrow-left ng-tns-c242-3"></i>
|
<i _ngcontent-dspace-angular-c242="" class="fas fa-arrow-left ng-tns-c242-3"></i>
|
||||||
{{this.buttonLabel | async}}
|
{{this.buttonLabel | async}}
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
|
@@ -1,4 +0,0 @@
|
|||||||
|
|
||||||
button.back-btn {
|
|
||||||
margin-bottom: 10px;
|
|
||||||
}
|
|
||||||
|
@@ -9,6 +9,7 @@ import { Router } from '@angular/router';
|
|||||||
import { PaginationComponentOptions } from '../pagination/pagination-component-options.model';
|
import { PaginationComponentOptions } from '../pagination/pagination-component-options.model';
|
||||||
import { PaginationService } from '../../core/pagination/pagination.service';
|
import { PaginationService } from '../../core/pagination/pagination.service';
|
||||||
import { PaginationServiceStub } from '../testing/pagination-service.stub';
|
import { PaginationServiceStub } from '../testing/pagination-service.stub';
|
||||||
|
import { By } from '@angular/platform-browser';
|
||||||
|
|
||||||
describe('ResultsBackButtonComponent', () => {
|
describe('ResultsBackButtonComponent', () => {
|
||||||
|
|
||||||
@@ -23,12 +24,15 @@ describe('ResultsBackButtonComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const searchUrl = '/search?query=test&spc.page=2';
|
const searchUrl = '/search?query=test&spc.page=2';
|
||||||
|
const nonSearchUrl = '/item';
|
||||||
|
|
||||||
const mockRouteService = {
|
function getMockRouteService(url) {
|
||||||
|
return {
|
||||||
getPreviousUrl(): Observable < string > {
|
getPreviousUrl(): Observable < string > {
|
||||||
return of(searchUrl);
|
return of(url);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
router = jasmine.createSpyObj('router', {
|
router = jasmine.createSpyObj('router', {
|
||||||
navigateByUrl: jasmine.createSpy('navigateByUrl')
|
navigateByUrl: jasmine.createSpy('navigateByUrl')
|
||||||
@@ -40,6 +44,8 @@ describe('ResultsBackButtonComponent', () => {
|
|||||||
|
|
||||||
describe('back to results', () => {
|
describe('back to results', () => {
|
||||||
|
|
||||||
|
const mockRouteService = getMockRouteService(searchUrl);
|
||||||
|
|
||||||
beforeEach(waitForAsync(() => {
|
beforeEach(waitForAsync(() => {
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
declarations: [ResultsBackButtonComponent],
|
declarations: [ResultsBackButtonComponent],
|
||||||
@@ -73,7 +79,7 @@ describe('ResultsBackButtonComponent', () => {
|
|||||||
|
|
||||||
it('should navigate to previous pagination', () => {
|
it('should navigate to previous pagination', () => {
|
||||||
component.back();
|
component.back();
|
||||||
expect(mockRouteService.getPreviousUrl).not.toHaveBeenCalled();
|
expect(mockRouteService.getPreviousUrl).toHaveBeenCalled();
|
||||||
expect(paginationService.updateRoute).toHaveBeenCalled();
|
expect(paginationService.updateRoute).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -97,7 +103,44 @@ describe('ResultsBackButtonComponent', () => {
|
|||||||
expect(router.navigateByUrl).toHaveBeenCalledWith(searchUrl);
|
expect(router.navigateByUrl).toHaveBeenCalledWith(searchUrl);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('back to results', () => {
|
||||||
|
|
||||||
|
const mockRouteService = getMockRouteService(nonSearchUrl);
|
||||||
|
|
||||||
|
beforeEach(waitForAsync(() => {
|
||||||
|
TestBed.configureTestingModule({
|
||||||
|
declarations: [ResultsBackButtonComponent],
|
||||||
|
imports: [TranslateModule.forRoot(),
|
||||||
|
RouterTestingModule.withRoutes([])
|
||||||
|
],
|
||||||
|
providers: [
|
||||||
|
{provide: RouteService, useValue: mockRouteService},
|
||||||
|
{provide: PaginationService, useValue: paginationService},
|
||||||
|
{provide: Router, useValue: router},
|
||||||
|
{provide: TranslateService, useValue: translate}
|
||||||
|
],
|
||||||
|
schemas: [NO_ERRORS_SCHEMA]
|
||||||
|
}).compileComponents();
|
||||||
|
spyOn(mockRouteService, 'getPreviousUrl').and.callThrough();
|
||||||
|
}));
|
||||||
|
|
||||||
|
describe('previous route not search or browse list', () => {
|
||||||
|
beforeEach(waitForAsync(() => {
|
||||||
|
fixture = TestBed.createComponent(ResultsBackButtonComponent);
|
||||||
|
component = fixture.componentInstance;
|
||||||
|
component.ngOnInit();
|
||||||
|
fixture.detectChanges();
|
||||||
|
}));
|
||||||
|
|
||||||
|
it('should hide back button', () => {
|
||||||
|
let button = fixture.debugElement.query(By.css('button'));
|
||||||
|
expect(button).toBeNull();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
import { ChangeDetectionStrategy, Component, Input } from '@angular/core';
|
import { ChangeDetectionStrategy, Component, Input } from '@angular/core';
|
||||||
import { take } from 'rxjs/operators';
|
import { filter, map, take } from 'rxjs/operators';
|
||||||
import { RouteService } from '../../core/services/route.service';
|
import { RouteService } from '../../core/services/route.service';
|
||||||
import { Router } from '@angular/router';
|
import { Router } from '@angular/router';
|
||||||
import { PaginationService } from '../../core/pagination/pagination.service';
|
import { PaginationService } from '../../core/pagination/pagination.service';
|
||||||
@@ -29,6 +29,11 @@ export class ResultsBackButtonComponent {
|
|||||||
*/
|
*/
|
||||||
@Input() paginationConfig?: PaginationComponentOptions;
|
@Input() paginationConfig?: PaginationComponentOptions;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to configure search in mirador.
|
||||||
|
*/
|
||||||
|
showBackButton: Observable<boolean>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The button text
|
* The button text
|
||||||
*/
|
*/
|
||||||
@@ -47,13 +52,18 @@ export class ResultsBackButtonComponent {
|
|||||||
} else {
|
} else {
|
||||||
this.buttonLabel = this.translateService.get('search.browse.item-back');
|
this.buttonLabel = this.translateService.get('search.browse.item-back');
|
||||||
}
|
}
|
||||||
|
// Show the back to results button when the previous context was a search or browse list.
|
||||||
|
this.showBackButton = this.routeService.getPreviousUrl().pipe(
|
||||||
|
filter(url => /^(\/search|\/browse|\/collections|\/admin\/search|\/mydspace)/.test(url)),
|
||||||
|
take(1),
|
||||||
|
map(() => true)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Navigate back from the item to the previous pagination list.
|
* Navigate back from the item to the previous pagination list.
|
||||||
*/
|
*/
|
||||||
public back() {
|
public back() {
|
||||||
|
|
||||||
if (isNotEmpty(this.paginationConfig) && isNotEmpty(this.previousPage$)) {
|
if (isNotEmpty(this.paginationConfig) && isNotEmpty(this.previousPage$)) {
|
||||||
// if pagination configuration is provided use it to update the route to the previous browse page.
|
// if pagination configuration is provided use it to update the route to the previous browse page.
|
||||||
const page = +this.previousPage$.value > 1 ? +this.previousPage$.value : 1;
|
const page = +this.previousPage$.value > 1 ? +this.previousPage$.value : 1;
|
||||||
|
@@ -1,6 +1,8 @@
|
|||||||
import { Component } from '@angular/core';
|
import { Component, Input } from '@angular/core';
|
||||||
import { ThemedComponent } from '../theme-support/themed.component';
|
import { ThemedComponent } from '../theme-support/themed.component';
|
||||||
import { ResultsBackButtonComponent } from './results-back-button.component';
|
import { ResultsBackButtonComponent } from './results-back-button.component';
|
||||||
|
import { PaginationComponentOptions } from '../pagination/pagination-component-options.model';
|
||||||
|
import { BehaviorSubject } from 'rxjs';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'ds-themed-results-back-button',
|
selector: 'ds-themed-results-back-button',
|
||||||
@@ -8,6 +10,11 @@ import { ResultsBackButtonComponent } from './results-back-button.component';
|
|||||||
templateUrl: '../theme-support/themed.component.html',
|
templateUrl: '../theme-support/themed.component.html',
|
||||||
})
|
})
|
||||||
export class ThemedResultsBackButtonComponent extends ThemedComponent<ResultsBackButtonComponent> {
|
export class ThemedResultsBackButtonComponent extends ThemedComponent<ResultsBackButtonComponent> {
|
||||||
|
|
||||||
|
@Input() previousPage$?: BehaviorSubject<string>;
|
||||||
|
|
||||||
|
@Input() paginationConfig?: PaginationComponentOptions;
|
||||||
|
|
||||||
protected getComponentName(): string {
|
protected getComponentName(): string {
|
||||||
return 'ResultsBackButtonComponent';
|
return 'ResultsBackButtonComponent';
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user