mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 01:54:15 +00:00
Merge branch 'refactor-comcol-pages_contribute-7.6' into refactor-comcol-pages_contribute-main
This commit is contained in:
@@ -5,9 +5,9 @@ describe('Browse By Author', () => {
|
|||||||
cy.visit('/browse/author');
|
cy.visit('/browse/author');
|
||||||
|
|
||||||
// Wait for <ds-browse-by-metadata-page> to be visible
|
// Wait for <ds-browse-by-metadata-page> to be visible
|
||||||
cy.get('ds-browse-by-metadata-page').should('be.visible');
|
cy.get('ds-browse-by-metadata').should('be.visible');
|
||||||
|
|
||||||
// Analyze <ds-browse-by-metadata-page> for accessibility
|
// Analyze <ds-browse-by-metadata-page> for accessibility
|
||||||
testA11y('ds-browse-by-metadata-page');
|
testA11y('ds-browse-by-metadata');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -5,9 +5,9 @@ describe('Browse By Date Issued', () => {
|
|||||||
cy.visit('/browse/dateissued');
|
cy.visit('/browse/dateissued');
|
||||||
|
|
||||||
// Wait for <ds-browse-by-date-page> to be visible
|
// Wait for <ds-browse-by-date-page> to be visible
|
||||||
cy.get('ds-browse-by-date-page').should('be.visible');
|
cy.get('ds-browse-by-date').should('be.visible');
|
||||||
|
|
||||||
// Analyze <ds-browse-by-date-page> for accessibility
|
// Analyze <ds-browse-by-date-page> for accessibility
|
||||||
testA11y('ds-browse-by-date-page');
|
testA11y('ds-browse-by-date');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -5,9 +5,9 @@ describe('Browse By Subject', () => {
|
|||||||
cy.visit('/browse/subject');
|
cy.visit('/browse/subject');
|
||||||
|
|
||||||
// Wait for <ds-browse-by-metadata-page> to be visible
|
// Wait for <ds-browse-by-metadata-page> to be visible
|
||||||
cy.get('ds-browse-by-metadata-page').should('be.visible');
|
cy.get('ds-browse-by-metadata').should('be.visible');
|
||||||
|
|
||||||
// Analyze <ds-browse-by-metadata-page> for accessibility
|
// Analyze <ds-browse-by-metadata-page> for accessibility
|
||||||
testA11y('ds-browse-by-metadata-page');
|
testA11y('ds-browse-by-metadata');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -5,9 +5,9 @@ describe('Browse By Title', () => {
|
|||||||
cy.visit('/browse/title');
|
cy.visit('/browse/title');
|
||||||
|
|
||||||
// Wait for <ds-browse-by-title-page> to be visible
|
// Wait for <ds-browse-by-title-page> to be visible
|
||||||
cy.get('ds-browse-by-title-page').should('be.visible');
|
cy.get('ds-browse-by-title').should('be.visible');
|
||||||
|
|
||||||
// Analyze <ds-browse-by-title-page> for accessibility
|
// Analyze <ds-browse-by-title-page> for accessibility
|
||||||
testA11y('ds-browse-by-title-page');
|
testA11y('ds-browse-by-title');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
import { BrowseByDatePageComponent } from './browse-by-date-page.component';
|
import { BrowseByDateComponent } from './browse-by-date.component';
|
||||||
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
|
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
|
||||||
import { CommonModule } from '@angular/common';
|
import { CommonModule } from '@angular/common';
|
||||||
import { RouterTestingModule } from '@angular/router/testing';
|
import { RouterTestingModule } from '@angular/router/testing';
|
||||||
@@ -15,7 +15,7 @@ import { ActivatedRouteStub } from '../../shared/testing/active-router.stub';
|
|||||||
import { Community } from '../../core/shared/community.model';
|
import { Community } from '../../core/shared/community.model';
|
||||||
import { Item } from '../../core/shared/item.model';
|
import { Item } from '../../core/shared/item.model';
|
||||||
import { BrowseEntrySearchOptions } from '../../core/browse/browse-entry-search-options.model';
|
import { BrowseEntrySearchOptions } from '../../core/browse/browse-entry-search-options.model';
|
||||||
import { toRemoteData } from '../browse-by-metadata-page/browse-by-metadata-page.component.spec';
|
import { toRemoteData } from '../browse-by-metadata/browse-by-metadata.component.spec';
|
||||||
import { VarDirective } from '../../shared/utils/var.directive';
|
import { VarDirective } from '../../shared/utils/var.directive';
|
||||||
import { createSuccessfulRemoteDataObject$ } from '../../shared/remote-data.utils';
|
import { createSuccessfulRemoteDataObject$ } from '../../shared/remote-data.utils';
|
||||||
import { PaginationService } from '../../core/pagination/pagination.service';
|
import { PaginationService } from '../../core/pagination/pagination.service';
|
||||||
@@ -23,10 +23,11 @@ import { PaginationServiceStub } from '../../shared/testing/pagination-service.s
|
|||||||
import { APP_CONFIG } from '../../../config/app-config.interface';
|
import { APP_CONFIG } from '../../../config/app-config.interface';
|
||||||
import { environment } from '../../../environments/environment';
|
import { environment } from '../../../environments/environment';
|
||||||
import { SortDirection } from '../../core/cache/models/sort-options.model';
|
import { SortDirection } from '../../core/cache/models/sort-options.model';
|
||||||
|
import { cold } from 'jasmine-marbles';
|
||||||
|
|
||||||
describe('BrowseByDatePageComponent', () => {
|
describe('BrowseByDateComponent', () => {
|
||||||
let comp: BrowseByDatePageComponent;
|
let comp: BrowseByDateComponent;
|
||||||
let fixture: ComponentFixture<BrowseByDatePageComponent>;
|
let fixture: ComponentFixture<BrowseByDateComponent>;
|
||||||
let route: ActivatedRoute;
|
let route: ActivatedRoute;
|
||||||
let paginationService;
|
let paginationService;
|
||||||
|
|
||||||
@@ -86,7 +87,7 @@ describe('BrowseByDatePageComponent', () => {
|
|||||||
beforeEach(waitForAsync(() => {
|
beforeEach(waitForAsync(() => {
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
imports: [CommonModule, RouterTestingModule.withRoutes([]), TranslateModule.forRoot(), NgbModule],
|
imports: [CommonModule, RouterTestingModule.withRoutes([]), TranslateModule.forRoot(), NgbModule],
|
||||||
declarations: [BrowseByDatePageComponent, EnumKeysPipe, VarDirective],
|
declarations: [BrowseByDateComponent, EnumKeysPipe, VarDirective],
|
||||||
providers: [
|
providers: [
|
||||||
{ provide: ActivatedRoute, useValue: activatedRouteStub },
|
{ provide: ActivatedRoute, useValue: activatedRouteStub },
|
||||||
{ provide: BrowseService, useValue: mockBrowseService },
|
{ provide: BrowseService, useValue: mockBrowseService },
|
||||||
@@ -101,7 +102,7 @@ describe('BrowseByDatePageComponent', () => {
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
fixture = TestBed.createComponent(BrowseByDatePageComponent);
|
fixture = TestBed.createComponent(BrowseByDateComponent);
|
||||||
const browseService = fixture.debugElement.injector.get(BrowseService);
|
const browseService = fixture.debugElement.injector.get(BrowseService);
|
||||||
spyOn(browseService, 'getFirstItemFor')
|
spyOn(browseService, 'getFirstItemFor')
|
||||||
// ok to expect the default browse as first param since we just need the mock items obtained via sort direction.
|
// ok to expect the default browse as first param since we just need the mock items obtained via sort direction.
|
||||||
@@ -112,9 +113,13 @@ describe('BrowseByDatePageComponent', () => {
|
|||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should initialize the list of items', () => {
|
it('should initialize the list of items', (done: DoneFn) => {
|
||||||
|
expect(comp.loading$).toBeObservable(cold('(a|)', {
|
||||||
|
a: false,
|
||||||
|
}));
|
||||||
comp.items$.subscribe((result) => {
|
comp.items$.subscribe((result) => {
|
||||||
expect(result.payload.page).toEqual([firstItem]);
|
expect(result.payload.page).toEqual([firstItem]);
|
||||||
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
@@ -1,10 +1,6 @@
|
|||||||
import { ChangeDetectorRef, Component, Inject, OnInit } from '@angular/core';
|
import { ChangeDetectorRef, Component, Inject, OnInit } from '@angular/core';
|
||||||
import {
|
import { BrowseByMetadataComponent, browseParamsToOptions, getBrowseSearchOptions } from '../browse-by-metadata/browse-by-metadata.component';
|
||||||
BrowseByMetadataPageComponent,
|
import { combineLatest as observableCombineLatest, Observable } from 'rxjs';
|
||||||
browseParamsToOptions,
|
|
||||||
getBrowseSearchOptions
|
|
||||||
} from '../browse-by-metadata-page/browse-by-metadata-page.component';
|
|
||||||
import { combineLatest as observableCombineLatest } from 'rxjs';
|
|
||||||
import { hasValue, isNotEmpty } from '../../shared/empty.util';
|
import { hasValue, isNotEmpty } from '../../shared/empty.util';
|
||||||
import { ActivatedRoute, Params, Router } from '@angular/router';
|
import { ActivatedRoute, Params, Router } from '@angular/router';
|
||||||
import { BrowseService } from '../../core/browse/browse.service';
|
import { BrowseService } from '../../core/browse/browse.service';
|
||||||
@@ -23,9 +19,9 @@ import { rendersBrowseBy } from '../browse-by-switcher/browse-by-decorator';
|
|||||||
import { BrowseByDataType } from '../browse-by-switcher/browse-by-data-type';
|
import { BrowseByDataType } from '../browse-by-switcher/browse-by-data-type';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'ds-browse-by-date-page',
|
selector: 'ds-browse-by-date',
|
||||||
styleUrls: ['../browse-by-metadata-page/browse-by-metadata-page.component.scss'],
|
styleUrls: ['../browse-by-metadata/browse-by-metadata.component.scss'],
|
||||||
templateUrl: '../browse-by-metadata-page/browse-by-metadata-page.component.html'
|
templateUrl: '../browse-by-metadata/browse-by-metadata.component.html',
|
||||||
})
|
})
|
||||||
/**
|
/**
|
||||||
* Component for browsing items by metadata definition of type 'date'
|
* Component for browsing items by metadata definition of type 'date'
|
||||||
@@ -33,21 +29,22 @@ import { BrowseByDataType } from '../browse-by-switcher/browse-by-data-type';
|
|||||||
* An example would be 'dateissued' for 'dc.date.issued'
|
* An example would be 'dateissued' for 'dc.date.issued'
|
||||||
*/
|
*/
|
||||||
@rendersBrowseBy(BrowseByDataType.Date)
|
@rendersBrowseBy(BrowseByDataType.Date)
|
||||||
export class BrowseByDatePageComponent extends BrowseByMetadataPageComponent implements OnInit {
|
export class BrowseByDateComponent extends BrowseByMetadataComponent implements OnInit {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The default metadata keys to use for determining the lower limit of the StartsWith dropdown options
|
* The default metadata keys to use for determining the lower limit of the StartsWith dropdown options
|
||||||
*/
|
*/
|
||||||
defaultMetadataKeys = ['dc.date.issued'];
|
defaultMetadataKeys = ['dc.date.issued'];
|
||||||
|
|
||||||
public constructor(protected route: ActivatedRoute,
|
public constructor(
|
||||||
protected browseService: BrowseService,
|
protected route: ActivatedRoute,
|
||||||
protected dsoService: DSpaceObjectDataService,
|
protected browseService: BrowseService,
|
||||||
protected router: Router,
|
protected dsoService: DSpaceObjectDataService,
|
||||||
protected paginationService: PaginationService,
|
protected paginationService: PaginationService,
|
||||||
protected cdRef: ChangeDetectorRef,
|
protected router: Router,
|
||||||
@Inject(APP_CONFIG) public appConfig: AppConfig,
|
@Inject(APP_CONFIG) public appConfig: AppConfig,
|
||||||
public dsoNameService: DSONameService,
|
public dsoNameService: DSONameService,
|
||||||
|
protected cdRef: ChangeDetectorRef,
|
||||||
) {
|
) {
|
||||||
super(route, browseService, dsoService, paginationService, router, appConfig, dsoNameService);
|
super(route, browseService, dsoService, paginationService, router, appConfig, dsoNameService);
|
||||||
}
|
}
|
||||||
@@ -60,19 +57,17 @@ export class BrowseByDatePageComponent extends BrowseByMetadataPageComponent imp
|
|||||||
this.currentPagination$ = this.paginationService.getCurrentPagination(this.paginationConfig.id, this.paginationConfig);
|
this.currentPagination$ = this.paginationService.getCurrentPagination(this.paginationConfig.id, this.paginationConfig);
|
||||||
this.currentSort$ = this.paginationService.getCurrentSort(this.paginationConfig.id, sortConfig);
|
this.currentSort$ = this.paginationService.getCurrentSort(this.paginationConfig.id, sortConfig);
|
||||||
this.subs.push(
|
this.subs.push(
|
||||||
observableCombineLatest([this.route.params, this.route.queryParams, this.route.data,
|
observableCombineLatest([this.route.params, this.route.queryParams, this.scope$, this.route.data,
|
||||||
this.currentPagination$, this.currentSort$]).pipe(
|
this.currentPagination$, this.currentSort$]).pipe(
|
||||||
map(([routeParams, queryParams, data, currentPage, currentSort]) => {
|
map(([routeParams, queryParams, scope, data, currentPage, currentSort]) => {
|
||||||
return [Object.assign({}, routeParams, queryParams, data), currentPage, currentSort];
|
return [Object.assign({}, routeParams, queryParams, data), scope, currentPage, currentSort];
|
||||||
})
|
})
|
||||||
).subscribe(([params, currentPage, currentSort]: [Params, PaginationComponentOptions, SortOptions]) => {
|
).subscribe(([params, scope, currentPage, currentSort]: [Params, string, PaginationComponentOptions, SortOptions]) => {
|
||||||
const metadataKeys = params.browseDefinition ? params.browseDefinition.metadataKeys : this.defaultMetadataKeys;
|
const metadataKeys = params.browseDefinition ? params.browseDefinition.metadataKeys : this.defaultMetadataKeys;
|
||||||
this.browseId = params.id || this.defaultBrowseId;
|
this.browseId = params.id || this.defaultBrowseId;
|
||||||
this.startsWith = +params.startsWith || params.startsWith;
|
this.startsWith = +params.startsWith || params.startsWith;
|
||||||
const searchOptions = browseParamsToOptions(params, currentPage, currentSort, this.browseId, this.fetchThumbnails);
|
const searchOptions = browseParamsToOptions(params, scope, currentPage, currentSort, this.browseId, this.fetchThumbnails);
|
||||||
this.updatePageWithItems(searchOptions, this.value, undefined);
|
this.updatePageWithItems(searchOptions, this.value, undefined);
|
||||||
this.updateParent(params.scope);
|
|
||||||
this.updateLogo();
|
|
||||||
this.updateStartsWithOptions(this.browseId, metadataKeys, params.scope);
|
this.updateStartsWithOptions(this.browseId, metadataKeys, params.scope);
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
@@ -88,12 +83,21 @@ export class BrowseByDatePageComponent extends BrowseByMetadataPageComponent imp
|
|||||||
* @param scope The scope under which to fetch the earliest item for
|
* @param scope The scope under which to fetch the earliest item for
|
||||||
*/
|
*/
|
||||||
updateStartsWithOptions(definition: string, metadataKeys: string[], scope?: string) {
|
updateStartsWithOptions(definition: string, metadataKeys: string[], scope?: string) {
|
||||||
const firstItemRD = this.browseService.getFirstItemFor(definition, scope, SortDirection.ASC);
|
const firstItemRD$: Observable<RemoteData<Item>> = this.browseService.getFirstItemFor(definition, scope, SortDirection.ASC);
|
||||||
const lastItemRD = this.browseService.getFirstItemFor(definition, scope, SortDirection.DESC);
|
const lastItemRD$: Observable<RemoteData<Item>> = this.browseService.getFirstItemFor(definition, scope, SortDirection.DESC);
|
||||||
|
this.loading$ = observableCombineLatest([
|
||||||
|
firstItemRD$,
|
||||||
|
lastItemRD$,
|
||||||
|
]).pipe(
|
||||||
|
map(([firstItemRD, lastItemRD]: [RemoteData<Item>, RemoteData<Item>]) => firstItemRD.isLoading || lastItemRD.isLoading)
|
||||||
|
);
|
||||||
this.subs.push(
|
this.subs.push(
|
||||||
observableCombineLatest([firstItemRD, lastItemRD]).subscribe(([firstItem, lastItem]) => {
|
observableCombineLatest([
|
||||||
let lowerLimit: number = this.getLimit(firstItem, metadataKeys, this.appConfig.browseBy.defaultLowerLimit);
|
firstItemRD$,
|
||||||
let upperLimit: number = this.getLimit(lastItem, metadataKeys, new Date().getUTCFullYear());
|
lastItemRD$,
|
||||||
|
]).subscribe(([firstItemRD, lastItemRD]: [RemoteData<Item>, RemoteData<Item>]) => {
|
||||||
|
let lowerLimit: number = this.getLimit(firstItemRD, metadataKeys, this.appConfig.browseBy.defaultLowerLimit);
|
||||||
|
let upperLimit: number = this.getLimit(lastItemRD, metadataKeys, new Date().getUTCFullYear());
|
||||||
const options: number[] = [];
|
const options: number[] = [];
|
||||||
const oneYearBreak: number = Math.floor((upperLimit - this.appConfig.browseBy.oneYearLimit) / 5) * 5;
|
const oneYearBreak: number = Math.floor((upperLimit - this.appConfig.browseBy.oneYearLimit) / 5) * 5;
|
||||||
const fiveYearBreak: number = Math.floor((upperLimit - this.appConfig.browseBy.fiveYearLimit) / 10) * 10;
|
const fiveYearBreak: number = Math.floor((upperLimit - this.appConfig.browseBy.fiveYearLimit) / 10) * 10;
|
@@ -1,17 +1,13 @@
|
|||||||
import { first } from 'rxjs/operators';
|
import { first } from 'rxjs/operators';
|
||||||
import { BrowseByGuard } from './browse-by-guard';
|
import { BrowseByGuard } from './browse-by-guard';
|
||||||
import { of as observableOf } from 'rxjs';
|
|
||||||
import { createFailedRemoteDataObject$, createSuccessfulRemoteDataObject$ } from '../shared/remote-data.utils';
|
import { createFailedRemoteDataObject$, createSuccessfulRemoteDataObject$ } from '../shared/remote-data.utils';
|
||||||
import { BrowseByDataType } from './browse-by-switcher/browse-by-data-type';
|
import { BrowseByDataType } from './browse-by-switcher/browse-by-data-type';
|
||||||
import { ValueListBrowseDefinition } from '../core/shared/value-list-browse-definition.model';
|
import { ValueListBrowseDefinition } from '../core/shared/value-list-browse-definition.model';
|
||||||
import { DSONameServiceMock } from '../shared/mocks/dso-name.service.mock';
|
|
||||||
import { DSONameService } from '../core/breadcrumbs/dso-name.service';
|
|
||||||
import { RouterStub } from '../shared/testing/router.stub';
|
import { RouterStub } from '../shared/testing/router.stub';
|
||||||
|
|
||||||
describe('BrowseByGuard', () => {
|
describe('BrowseByGuard', () => {
|
||||||
describe('canActivate', () => {
|
describe('canActivate', () => {
|
||||||
let guard: BrowseByGuard;
|
let guard: BrowseByGuard;
|
||||||
let dsoService: any;
|
|
||||||
let translateService: any;
|
let translateService: any;
|
||||||
let browseDefinitionService: any;
|
let browseDefinitionService: any;
|
||||||
let router: any;
|
let router: any;
|
||||||
@@ -25,10 +21,6 @@ describe('BrowseByGuard', () => {
|
|||||||
const browseDefinition = Object.assign(new ValueListBrowseDefinition(), { type: BrowseByDataType.Metadata, metadataKeys: ['dc.contributor'] });
|
const browseDefinition = Object.assign(new ValueListBrowseDefinition(), { type: BrowseByDataType.Metadata, metadataKeys: ['dc.contributor'] });
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
dsoService = {
|
|
||||||
findById: (dsoId: string) => observableOf({ payload: { name: name }, hasSucceeded: true })
|
|
||||||
};
|
|
||||||
|
|
||||||
translateService = {
|
translateService = {
|
||||||
instant: () => field
|
instant: () => field
|
||||||
};
|
};
|
||||||
@@ -39,7 +31,7 @@ describe('BrowseByGuard', () => {
|
|||||||
|
|
||||||
router = new RouterStub() as any;
|
router = new RouterStub() as any;
|
||||||
|
|
||||||
guard = new BrowseByGuard(dsoService, translateService, browseDefinitionService, new DSONameServiceMock() as DSONameService, router);
|
guard = new BrowseByGuard(translateService, browseDefinitionService, router);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return true, and sets up the data correctly, with a scope and value', () => {
|
it('should return true, and sets up the data correctly, with a scope and value', () => {
|
||||||
@@ -48,6 +40,7 @@ describe('BrowseByGuard', () => {
|
|||||||
title: field,
|
title: field,
|
||||||
browseDefinition,
|
browseDefinition,
|
||||||
},
|
},
|
||||||
|
parent: null,
|
||||||
params: {
|
params: {
|
||||||
id,
|
id,
|
||||||
},
|
},
|
||||||
@@ -64,7 +57,7 @@ describe('BrowseByGuard', () => {
|
|||||||
title,
|
title,
|
||||||
id,
|
id,
|
||||||
browseDefinition,
|
browseDefinition,
|
||||||
collection: name,
|
scope,
|
||||||
field,
|
field,
|
||||||
value: '"' + value + '"'
|
value: '"' + value + '"'
|
||||||
};
|
};
|
||||||
@@ -97,7 +90,7 @@ describe('BrowseByGuard', () => {
|
|||||||
title,
|
title,
|
||||||
id,
|
id,
|
||||||
browseDefinition,
|
browseDefinition,
|
||||||
collection: name,
|
scope,
|
||||||
field,
|
field,
|
||||||
value: ''
|
value: ''
|
||||||
};
|
};
|
||||||
@@ -108,12 +101,48 @@ describe('BrowseByGuard', () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should return true, and sets up the data correctly using the community/collection page id, with a scope and without value', () => {
|
||||||
|
const scopedNoValueRoute = {
|
||||||
|
data: {
|
||||||
|
title: field,
|
||||||
|
browseDefinition,
|
||||||
|
},
|
||||||
|
parent: {
|
||||||
|
params: {
|
||||||
|
id: scope,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
params: {
|
||||||
|
id,
|
||||||
|
},
|
||||||
|
queryParams: {
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
guard.canActivate(scopedNoValueRoute as any, undefined).pipe(
|
||||||
|
first(),
|
||||||
|
).subscribe((canActivate) => {
|
||||||
|
const result = {
|
||||||
|
title,
|
||||||
|
id,
|
||||||
|
browseDefinition,
|
||||||
|
scope,
|
||||||
|
field,
|
||||||
|
value: '',
|
||||||
|
};
|
||||||
|
expect(scopedNoValueRoute.data).toEqual(result);
|
||||||
|
expect(router.navigate).not.toHaveBeenCalled();
|
||||||
|
expect(canActivate).toEqual(true);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it('should return true, and sets up the data correctly, without a scope and with a value', () => {
|
it('should return true, and sets up the data correctly, without a scope and with a value', () => {
|
||||||
const route = {
|
const route = {
|
||||||
data: {
|
data: {
|
||||||
title: field,
|
title: field,
|
||||||
browseDefinition,
|
browseDefinition,
|
||||||
},
|
},
|
||||||
|
parent: null,
|
||||||
params: {
|
params: {
|
||||||
id,
|
id,
|
||||||
},
|
},
|
||||||
@@ -129,7 +158,7 @@ describe('BrowseByGuard', () => {
|
|||||||
title,
|
title,
|
||||||
id,
|
id,
|
||||||
browseDefinition,
|
browseDefinition,
|
||||||
collection: '',
|
scope: undefined,
|
||||||
field,
|
field,
|
||||||
value: '"' + value + '"'
|
value: '"' + value + '"'
|
||||||
};
|
};
|
||||||
@@ -147,6 +176,7 @@ describe('BrowseByGuard', () => {
|
|||||||
data: {
|
data: {
|
||||||
title: field,
|
title: field,
|
||||||
},
|
},
|
||||||
|
parent: null,
|
||||||
params: {
|
params: {
|
||||||
id,
|
id,
|
||||||
},
|
},
|
||||||
|
@@ -1,15 +1,12 @@
|
|||||||
import { ActivatedRouteSnapshot, CanActivate, Router, RouterStateSnapshot } from '@angular/router';
|
import { ActivatedRouteSnapshot, CanActivate, Router, RouterStateSnapshot, Data } from '@angular/router';
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { DSpaceObjectDataService } from '../core/data/dspace-object-data.service';
|
|
||||||
import { hasNoValue, hasValue } from '../shared/empty.util';
|
import { hasNoValue, hasValue } from '../shared/empty.util';
|
||||||
import { map, switchMap } from 'rxjs/operators';
|
import { map, switchMap } from 'rxjs/operators';
|
||||||
import { getFirstCompletedRemoteData, getFirstSucceededRemoteDataPayload } from '../core/shared/operators';
|
import { getFirstCompletedRemoteData } from '../core/shared/operators';
|
||||||
import { TranslateService } from '@ngx-translate/core';
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
import { Observable, of as observableOf } from 'rxjs';
|
import { Observable, of as observableOf } from 'rxjs';
|
||||||
import { BrowseDefinitionDataService } from '../core/browse/browse-definition-data.service';
|
import { BrowseDefinitionDataService } from '../core/browse/browse-definition-data.service';
|
||||||
import { BrowseDefinition } from '../core/shared/browse-definition.model';
|
import { BrowseDefinition } from '../core/shared/browse-definition.model';
|
||||||
import { DSONameService } from '../core/breadcrumbs/dso-name.service';
|
|
||||||
import { DSpaceObject } from '../core/shared/dspace-object.model';
|
|
||||||
import { RemoteData } from '../core/data/remote-data';
|
import { RemoteData } from '../core/data/remote-data';
|
||||||
import { PAGE_NOT_FOUND_PATH } from '../app-routing-paths';
|
import { PAGE_NOT_FOUND_PATH } from '../app-routing-paths';
|
||||||
|
|
||||||
@@ -19,11 +16,10 @@ import { PAGE_NOT_FOUND_PATH } from '../app-routing-paths';
|
|||||||
*/
|
*/
|
||||||
export class BrowseByGuard implements CanActivate {
|
export class BrowseByGuard implements CanActivate {
|
||||||
|
|
||||||
constructor(protected dsoService: DSpaceObjectDataService,
|
constructor(
|
||||||
protected translate: TranslateService,
|
protected translate: TranslateService,
|
||||||
protected browseDefinitionService: BrowseDefinitionDataService,
|
protected browseDefinitionService: BrowseDefinitionDataService,
|
||||||
protected dsoNameService: DSONameService,
|
protected router: Router,
|
||||||
protected router: Router,
|
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -39,25 +35,14 @@ export class BrowseByGuard implements CanActivate {
|
|||||||
} else {
|
} else {
|
||||||
browseDefinition$ = observableOf(route.data.browseDefinition);
|
browseDefinition$ = observableOf(route.data.browseDefinition);
|
||||||
}
|
}
|
||||||
const scope = route.queryParams.scope;
|
const scope = route.queryParams.scope ?? route.parent?.params.id;
|
||||||
const value = route.queryParams.value;
|
const value = route.queryParams.value;
|
||||||
const metadataTranslated = this.translate.instant(`browse.metadata.${id}`);
|
const metadataTranslated = this.translate.instant(`browse.metadata.${id}`);
|
||||||
return browseDefinition$.pipe(
|
return browseDefinition$.pipe(
|
||||||
switchMap((browseDefinition: BrowseDefinition | undefined) => {
|
switchMap((browseDefinition: BrowseDefinition | undefined) => {
|
||||||
if (hasValue(browseDefinition)) {
|
if (hasValue(browseDefinition)) {
|
||||||
if (hasValue(scope)) {
|
route.data = this.createData(title, id, browseDefinition, metadataTranslated, value, route, scope);
|
||||||
const dso$: Observable<DSpaceObject> = this.dsoService.findById(scope).pipe(getFirstSucceededRemoteDataPayload());
|
return observableOf(true);
|
||||||
return dso$.pipe(
|
|
||||||
map((dso: DSpaceObject) => {
|
|
||||||
const name = this.dsoNameService.getName(dso);
|
|
||||||
route.data = this.createData(title, id, browseDefinition, name, metadataTranslated, value, route);
|
|
||||||
return true;
|
|
||||||
})
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
route.data = this.createData(title, id, browseDefinition, '', metadataTranslated, value, route);
|
|
||||||
return observableOf(true);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
void this.router.navigate([PAGE_NOT_FOUND_PATH]);
|
void this.router.navigate([PAGE_NOT_FOUND_PATH]);
|
||||||
return observableOf(false);
|
return observableOf(false);
|
||||||
@@ -66,14 +51,14 @@ export class BrowseByGuard implements CanActivate {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private createData(title, id, browseDefinition, collection, field, value, route) {
|
private createData(title: string, id: string, browseDefinition: BrowseDefinition, field: string, value: string, route: ActivatedRouteSnapshot, scope: string): Data {
|
||||||
return Object.assign({}, route.data, {
|
return Object.assign({}, route.data, {
|
||||||
title: title,
|
title: title,
|
||||||
id: id,
|
id: id,
|
||||||
browseDefinition: browseDefinition,
|
browseDefinition: browseDefinition,
|
||||||
collection: collection,
|
|
||||||
field: field,
|
field: field,
|
||||||
value: hasValue(value) ? `"${value}"` : ''
|
value: hasValue(value) ? `"${value}"` : '',
|
||||||
|
scope: scope,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,67 +0,0 @@
|
|||||||
<div class="container">
|
|
||||||
<ng-container *ngVar="(parent$ | async) as parent">
|
|
||||||
<ng-container *ngIf="parent?.payload as parentContext">
|
|
||||||
<div class="d-flex flex-row border-bottom mb-4 pb-4">
|
|
||||||
|
|
||||||
<header class="comcol-header mr-auto">
|
|
||||||
<!-- Parent Name -->
|
|
||||||
<ds-comcol-page-header [name]="dsoNameService.getName(parentContext)">
|
|
||||||
</ds-comcol-page-header>
|
|
||||||
<!-- Collection logo -->
|
|
||||||
<ds-comcol-page-logo *ngIf="logo$"
|
|
||||||
[logo]="(logo$ | async)?.payload"
|
|
||||||
[alternateText]="'Community or Collection Logo'">
|
|
||||||
</ds-comcol-page-logo>
|
|
||||||
<!-- Handle -->
|
|
||||||
<ds-themed-comcol-page-handle
|
|
||||||
[content]="parentContext.handle"
|
|
||||||
[title]="parentContext.type+'.page.handle'" >
|
|
||||||
</ds-themed-comcol-page-handle>
|
|
||||||
<!-- Introductory text -->
|
|
||||||
<ds-comcol-page-content [content]="parentContext.introductoryText" [hasInnerHtml]="true">
|
|
||||||
</ds-comcol-page-content>
|
|
||||||
<!-- News -->
|
|
||||||
<ds-comcol-page-content [content]="parentContext.sidebarText" [hasInnerHtml]="true" [title]="'community.page.news'">
|
|
||||||
</ds-comcol-page-content>
|
|
||||||
</header>
|
|
||||||
<ds-dso-edit-menu></ds-dso-edit-menu>
|
|
||||||
</div>
|
|
||||||
<!-- Browse-By Links -->
|
|
||||||
<ds-themed-comcol-page-browse-by [id]="parentContext.id" [contentType]="parentContext.type"></ds-themed-comcol-page-browse-by>
|
|
||||||
</ng-container></ng-container>
|
|
||||||
|
|
||||||
<section class="comcol-page-browse-section">
|
|
||||||
<div class="browse-by-metadata w-100">
|
|
||||||
<ds-themed-browse-by *ngIf="startsWithOptions" class="col-xs-12 w-100"
|
|
||||||
title="{{'browse.title' | translate:
|
|
||||||
{
|
|
||||||
collection: dsoNameService.getName((parent$ | async)?.payload),
|
|
||||||
field: 'browse.metadata.' + browseId | translate,
|
|
||||||
startsWith: (startsWith)? ('browse.startsWith' | translate: { startsWith: '"' + startsWith + '"' }) : '',
|
|
||||||
value: (value)? '"' + value + '"': ''
|
|
||||||
} }}"
|
|
||||||
parentname="{{dsoNameService.getName((parent$ | async)?.payload)}}"
|
|
||||||
[objects$]="(items$ !== undefined)? items$ : browseEntries$"
|
|
||||||
[paginationConfig]="(currentPagination$ |async)"
|
|
||||||
[sortConfig]="(currentSort$ |async)"
|
|
||||||
[type]="startsWithType"
|
|
||||||
[startsWithOptions]="startsWithOptions"
|
|
||||||
(prev)="goPrev()"
|
|
||||||
(next)="goNext()">
|
|
||||||
</ds-themed-browse-by>
|
|
||||||
<ds-themed-loading *ngIf="!startsWithOptions" message="{{'loading.browse-by-page' | translate}}"></ds-themed-loading>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
<ng-container *ngVar="(parent$ | async) as parent">
|
|
||||||
<ng-container *ngIf="parent?.payload as parentContext">
|
|
||||||
<footer *ngIf="parentContext.copyrightText" class="border-top my-5 pt-4">
|
|
||||||
<div >
|
|
||||||
|
|
||||||
<!-- Copyright -->
|
|
||||||
<ds-comcol-page-content [content]="parentContext.copyrightText" [hasInnerHtml]="true">
|
|
||||||
</ds-comcol-page-content>
|
|
||||||
</div>
|
|
||||||
</footer>
|
|
||||||
</ng-container>
|
|
||||||
</ng-container>
|
|
||||||
</div>
|
|
@@ -0,0 +1,21 @@
|
|||||||
|
<section class="comcol-page-browse-section">
|
||||||
|
<div class="browse-by-metadata w-100">
|
||||||
|
<ds-themed-browse-by *ngIf="!(loading$ | async)" class="col-xs-12 w-100"
|
||||||
|
title="{{'browse.title' | translate:{
|
||||||
|
field: 'browse.metadata.' + browseId | translate,
|
||||||
|
startsWith: (startsWith)? ('browse.startsWith' | translate: { startsWith: '"' + startsWith + '"' }) : '',
|
||||||
|
value: (value)? '"' + value + '"': ''
|
||||||
|
} }}"
|
||||||
|
[displayTitle]="displayTitle"
|
||||||
|
[objects$]="(items$ !== undefined)? items$ : browseEntries$"
|
||||||
|
[paginationConfig]="(currentPagination$ |async)"
|
||||||
|
[sortConfig]="(currentSort$ |async)"
|
||||||
|
[type]="startsWithType"
|
||||||
|
[startsWithOptions]="startsWithOptions"
|
||||||
|
(prev)="goPrev()"
|
||||||
|
(next)="goNext()">
|
||||||
|
</ds-themed-browse-by>
|
||||||
|
<ds-themed-loading *ngIf="loading$ | async"
|
||||||
|
message="{{'loading.browse-by-page' | translate}}"></ds-themed-loading>
|
||||||
|
</div>
|
||||||
|
</section>
|
@@ -1,8 +1,8 @@
|
|||||||
import {
|
import {
|
||||||
BrowseByMetadataPageComponent,
|
BrowseByMetadataComponent,
|
||||||
browseParamsToOptions,
|
browseParamsToOptions,
|
||||||
getBrowseSearchOptions
|
getBrowseSearchOptions
|
||||||
} from './browse-by-metadata-page.component';
|
} from './browse-by-metadata.component';
|
||||||
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
|
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
|
||||||
import { BrowseService } from '../../core/browse/browse.service';
|
import { BrowseService } from '../../core/browse/browse.service';
|
||||||
import { CommonModule } from '@angular/common';
|
import { CommonModule } from '@angular/common';
|
||||||
@@ -30,10 +30,11 @@ import { PaginationService } from '../../core/pagination/pagination.service';
|
|||||||
import { PaginationComponentOptions } from '../../shared/pagination/pagination-component-options.model';
|
import { PaginationComponentOptions } from '../../shared/pagination/pagination-component-options.model';
|
||||||
import { PaginationServiceStub } from '../../shared/testing/pagination-service.stub';
|
import { PaginationServiceStub } from '../../shared/testing/pagination-service.stub';
|
||||||
import { APP_CONFIG } from '../../../config/app-config.interface';
|
import { APP_CONFIG } from '../../../config/app-config.interface';
|
||||||
|
import { cold } from 'jasmine-marbles';
|
||||||
|
|
||||||
describe('BrowseByMetadataPageComponent', () => {
|
describe('BrowseByMetadataComponent', () => {
|
||||||
let comp: BrowseByMetadataPageComponent;
|
let comp: BrowseByMetadataComponent;
|
||||||
let fixture: ComponentFixture<BrowseByMetadataPageComponent>;
|
let fixture: ComponentFixture<BrowseByMetadataComponent>;
|
||||||
let browseService: BrowseService;
|
let browseService: BrowseService;
|
||||||
let route: ActivatedRoute;
|
let route: ActivatedRoute;
|
||||||
let paginationService;
|
let paginationService;
|
||||||
@@ -103,7 +104,7 @@ describe('BrowseByMetadataPageComponent', () => {
|
|||||||
beforeEach(waitForAsync(() => {
|
beforeEach(waitForAsync(() => {
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
imports: [CommonModule, RouterTestingModule.withRoutes([]), TranslateModule.forRoot(), NgbModule],
|
imports: [CommonModule, RouterTestingModule.withRoutes([]), TranslateModule.forRoot(), NgbModule],
|
||||||
declarations: [BrowseByMetadataPageComponent, EnumKeysPipe, VarDirective],
|
declarations: [BrowseByMetadataComponent, EnumKeysPipe, VarDirective],
|
||||||
providers: [
|
providers: [
|
||||||
{ provide: ActivatedRoute, useValue: activatedRouteStub },
|
{ provide: ActivatedRoute, useValue: activatedRouteStub },
|
||||||
{ provide: BrowseService, useValue: mockBrowseService },
|
{ provide: BrowseService, useValue: mockBrowseService },
|
||||||
@@ -117,7 +118,7 @@ describe('BrowseByMetadataPageComponent', () => {
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
fixture = TestBed.createComponent(BrowseByMetadataPageComponent);
|
fixture = TestBed.createComponent(BrowseByMetadataComponent);
|
||||||
comp = fixture.componentInstance;
|
comp = fixture.componentInstance;
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
browseService = (comp as any).browseService;
|
browseService = (comp as any).browseService;
|
||||||
@@ -144,20 +145,18 @@ describe('BrowseByMetadataPageComponent', () => {
|
|||||||
|
|
||||||
route.params = observableOf(paramsWithValue);
|
route.params = observableOf(paramsWithValue);
|
||||||
comp.ngOnInit();
|
comp.ngOnInit();
|
||||||
comp.updateParent('fake-scope');
|
|
||||||
comp.updateLogo();
|
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should fetch items', () => {
|
it('should fetch items', (done: DoneFn) => {
|
||||||
|
expect(comp.loading$).toBeObservable(cold('(a|)', {
|
||||||
|
a: false,
|
||||||
|
}));
|
||||||
comp.items$.subscribe((result) => {
|
comp.items$.subscribe((result) => {
|
||||||
expect(result.payload.page).toEqual(mockItems);
|
expect(result.payload.page).toEqual(mockItems);
|
||||||
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should fetch the logo', () => {
|
|
||||||
expect(comp.logo$).toBeTruthy();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('when calling browseParamsToOptions', () => {
|
describe('when calling browseParamsToOptions', () => {
|
||||||
@@ -176,7 +175,7 @@ describe('BrowseByMetadataPageComponent', () => {
|
|||||||
field: 'fake-field',
|
field: 'fake-field',
|
||||||
};
|
};
|
||||||
|
|
||||||
result = browseParamsToOptions(paramsScope, paginationOptions, sortOptions, 'author', comp.fetchThumbnails);
|
result = browseParamsToOptions(paramsScope, 'fake-scope', paginationOptions, sortOptions, 'author', comp.fetchThumbnails);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return BrowseEntrySearchOptions with the correct properties', () => {
|
it('should return BrowseEntrySearchOptions with the correct properties', () => {
|
@@ -1,5 +1,5 @@
|
|||||||
import { combineLatest as observableCombineLatest, Observable, Subscription } from 'rxjs';
|
import { BehaviorSubject, combineLatest as observableCombineLatest, Observable, Subscription, of as observableOf } from 'rxjs';
|
||||||
import { Component, Inject, OnInit, OnDestroy, Input } from '@angular/core';
|
import { Component, Inject, OnInit, OnDestroy, Input, OnChanges } from '@angular/core';
|
||||||
import { RemoteData } from '../../core/data/remote-data';
|
import { RemoteData } from '../../core/data/remote-data';
|
||||||
import { PaginatedList } from '../../core/data/paginated-list.model';
|
import { PaginatedList } from '../../core/data/paginated-list.model';
|
||||||
import { PaginationComponentOptions } from '../../shared/pagination/pagination-component-options.model';
|
import { PaginationComponentOptions } from '../../shared/pagination/pagination-component-options.model';
|
||||||
@@ -12,14 +12,9 @@ import { Item } from '../../core/shared/item.model';
|
|||||||
import { BrowseEntrySearchOptions } from '../../core/browse/browse-entry-search-options.model';
|
import { BrowseEntrySearchOptions } from '../../core/browse/browse-entry-search-options.model';
|
||||||
import { getFirstSucceededRemoteData } from '../../core/shared/operators';
|
import { getFirstSucceededRemoteData } from '../../core/shared/operators';
|
||||||
import { DSpaceObjectDataService } from '../../core/data/dspace-object-data.service';
|
import { DSpaceObjectDataService } from '../../core/data/dspace-object-data.service';
|
||||||
import { DSpaceObject } from '../../core/shared/dspace-object.model';
|
|
||||||
import { StartsWithType } from '../../shared/starts-with/starts-with-decorator';
|
import { StartsWithType } from '../../shared/starts-with/starts-with-decorator';
|
||||||
import { PaginationService } from '../../core/pagination/pagination.service';
|
import { PaginationService } from '../../core/pagination/pagination.service';
|
||||||
import { filter, map, mergeMap } from 'rxjs/operators';
|
import { map } from 'rxjs/operators';
|
||||||
import { followLink, FollowLinkConfig } from '../../shared/utils/follow-link-config.model';
|
|
||||||
import { Bitstream } from '../../core/shared/bitstream.model';
|
|
||||||
import { Collection } from '../../core/shared/collection.model';
|
|
||||||
import { Community } from '../../core/shared/community.model';
|
|
||||||
import { APP_CONFIG, AppConfig } from '../../../config/app-config.interface';
|
import { APP_CONFIG, AppConfig } from '../../../config/app-config.interface';
|
||||||
import { DSONameService } from '../../core/breadcrumbs/dso-name.service';
|
import { DSONameService } from '../../core/breadcrumbs/dso-name.service';
|
||||||
import { rendersBrowseBy } from '../browse-by-switcher/browse-by-decorator';
|
import { rendersBrowseBy } from '../browse-by-switcher/browse-by-decorator';
|
||||||
@@ -29,9 +24,9 @@ import { Context } from '../../core/shared/context.model';
|
|||||||
export const BBM_PAGINATION_ID = 'bbm';
|
export const BBM_PAGINATION_ID = 'bbm';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'ds-browse-by-metadata-page',
|
selector: 'ds-browse-by-metadata',
|
||||||
styleUrls: ['./browse-by-metadata-page.component.scss'],
|
styleUrls: ['./browse-by-metadata.component.scss'],
|
||||||
templateUrl: './browse-by-metadata-page.component.html'
|
templateUrl: './browse-by-metadata.component.html',
|
||||||
})
|
})
|
||||||
/**
|
/**
|
||||||
* Component for browsing (items) by metadata definition.
|
* Component for browsing (items) by metadata definition.
|
||||||
@@ -40,7 +35,7 @@ export const BBM_PAGINATION_ID = 'bbm';
|
|||||||
* 'dc.contributor.*'
|
* 'dc.contributor.*'
|
||||||
*/
|
*/
|
||||||
@rendersBrowseBy(BrowseByDataType.Metadata)
|
@rendersBrowseBy(BrowseByDataType.Metadata)
|
||||||
export class BrowseByMetadataPageComponent implements OnInit, OnDestroy {
|
export class BrowseByMetadataComponent implements OnInit, OnChanges, OnDestroy {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The optional context
|
* The optional context
|
||||||
@@ -52,6 +47,18 @@ export class BrowseByMetadataPageComponent implements OnInit, OnDestroy {
|
|||||||
*/
|
*/
|
||||||
@Input() browseByType: BrowseByDataType;
|
@Input() browseByType: BrowseByDataType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The ID of the {@link Community} or {@link Collection} of the scope to display
|
||||||
|
*/
|
||||||
|
@Input() scope: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display the h1 title in the section
|
||||||
|
*/
|
||||||
|
@Input() displayTitle = true;
|
||||||
|
|
||||||
|
scope$: BehaviorSubject<string> = new BehaviorSubject(undefined);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The list of browse-entries to display
|
* The list of browse-entries to display
|
||||||
*/
|
*/
|
||||||
@@ -62,16 +69,6 @@ export class BrowseByMetadataPageComponent implements OnInit, OnDestroy {
|
|||||||
*/
|
*/
|
||||||
items$: Observable<RemoteData<PaginatedList<Item>>>;
|
items$: Observable<RemoteData<PaginatedList<Item>>>;
|
||||||
|
|
||||||
/**
|
|
||||||
* The current Community or Collection we're browsing metadata/items in
|
|
||||||
*/
|
|
||||||
parent$: Observable<RemoteData<DSpaceObject>>;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The logo of the current Community or Collection
|
|
||||||
*/
|
|
||||||
logo$: Observable<RemoteData<Bitstream>>;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The pagination config used to display the values
|
* The pagination config used to display the values
|
||||||
*/
|
*/
|
||||||
@@ -112,7 +109,7 @@ export class BrowseByMetadataPageComponent implements OnInit, OnDestroy {
|
|||||||
* The list of StartsWith options
|
* The list of StartsWith options
|
||||||
* Should be defined after ngOnInit is called!
|
* Should be defined after ngOnInit is called!
|
||||||
*/
|
*/
|
||||||
startsWithOptions;
|
startsWithOptions: (string | number)[];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The value we're browsing items for
|
* The value we're browsing items for
|
||||||
@@ -136,6 +133,11 @@ export class BrowseByMetadataPageComponent implements OnInit, OnDestroy {
|
|||||||
*/
|
*/
|
||||||
fetchThumbnails: boolean;
|
fetchThumbnails: boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Observable determining if the loading animation needs to be shown
|
||||||
|
*/
|
||||||
|
loading$ = observableOf(true);
|
||||||
|
|
||||||
public constructor(protected route: ActivatedRoute,
|
public constructor(protected route: ActivatedRoute,
|
||||||
protected browseService: BrowseService,
|
protected browseService: BrowseService,
|
||||||
protected dsoService: DSpaceObjectDataService,
|
protected dsoService: DSpaceObjectDataService,
|
||||||
@@ -160,12 +162,12 @@ export class BrowseByMetadataPageComponent implements OnInit, OnDestroy {
|
|||||||
this.currentPagination$ = this.paginationService.getCurrentPagination(this.paginationConfig.id, this.paginationConfig);
|
this.currentPagination$ = this.paginationService.getCurrentPagination(this.paginationConfig.id, this.paginationConfig);
|
||||||
this.currentSort$ = this.paginationService.getCurrentSort(this.paginationConfig.id, sortConfig);
|
this.currentSort$ = this.paginationService.getCurrentSort(this.paginationConfig.id, sortConfig);
|
||||||
this.subs.push(
|
this.subs.push(
|
||||||
observableCombineLatest([this.route.params, this.route.queryParams, this.currentPagination$, this.currentSort$]).pipe(
|
observableCombineLatest([this.route.params, this.route.queryParams, this.scope$, this.currentPagination$, this.currentSort$]).pipe(
|
||||||
map(([routeParams, queryParams, currentPage, currentSort]) => {
|
map(([routeParams, queryParams, scope, currentPage, currentSort]) => {
|
||||||
return [Object.assign({}, routeParams, queryParams),currentPage,currentSort];
|
return [Object.assign({}, routeParams, queryParams), scope, currentPage, currentSort];
|
||||||
})
|
})
|
||||||
).subscribe(([params, currentPage, currentSort]: [Params, PaginationComponentOptions, SortOptions]) => {
|
).subscribe(([params, scope, currentPage, currentSort]: [Params, string, PaginationComponentOptions, SortOptions]) => {
|
||||||
this.browseId = params.id || this.defaultBrowseId;
|
this.browseId = params.id || this.defaultBrowseId;
|
||||||
this.authority = params.authority;
|
this.authority = params.authority;
|
||||||
|
|
||||||
if (typeof params.value === 'string'){
|
if (typeof params.value === 'string'){
|
||||||
@@ -183,18 +185,19 @@ export class BrowseByMetadataPageComponent implements OnInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (isNotEmpty(this.value)) {
|
if (isNotEmpty(this.value)) {
|
||||||
this.updatePageWithItems(
|
this.updatePageWithItems(browseParamsToOptions(params, scope, currentPage, currentSort, this.browseId, this.fetchThumbnails), this.value, this.authority);
|
||||||
browseParamsToOptions(params, currentPage, currentSort, this.browseId, this.fetchThumbnails), this.value, this.authority);
|
|
||||||
} else {
|
} else {
|
||||||
this.updatePage(browseParamsToOptions(params, currentPage, currentSort, this.browseId, false));
|
this.updatePage(browseParamsToOptions(params, scope, currentPage, currentSort, this.browseId, false));
|
||||||
}
|
}
|
||||||
this.updateParent(params.scope);
|
|
||||||
this.updateLogo();
|
|
||||||
}));
|
}));
|
||||||
this.updateStartsWithTextOptions();
|
this.updateStartsWithTextOptions();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ngOnChanges(): void {
|
||||||
|
this.scope$.next(this.scope);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update the StartsWith options with text values
|
* Update the StartsWith options with text values
|
||||||
* It adds the value "0-9" as well as all letters from A to Z
|
* It adds the value "0-9" as well as all letters from A to Z
|
||||||
@@ -213,6 +216,9 @@ export class BrowseByMetadataPageComponent implements OnInit, OnDestroy {
|
|||||||
*/
|
*/
|
||||||
updatePage(searchOptions: BrowseEntrySearchOptions) {
|
updatePage(searchOptions: BrowseEntrySearchOptions) {
|
||||||
this.browseEntries$ = this.browseService.getBrowseEntriesFor(searchOptions);
|
this.browseEntries$ = this.browseService.getBrowseEntriesFor(searchOptions);
|
||||||
|
this.loading$ = this.browseEntries$.pipe(
|
||||||
|
map((browseEntriesRD: RemoteData<PaginatedList<BrowseEntry>>) => browseEntriesRD.isLoading),
|
||||||
|
);
|
||||||
this.items$ = undefined;
|
this.items$ = undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -227,37 +233,9 @@ export class BrowseByMetadataPageComponent implements OnInit, OnDestroy {
|
|||||||
*/
|
*/
|
||||||
updatePageWithItems(searchOptions: BrowseEntrySearchOptions, value: string, authority: string) {
|
updatePageWithItems(searchOptions: BrowseEntrySearchOptions, value: string, authority: string) {
|
||||||
this.items$ = this.browseService.getBrowseItemsFor(value, authority, searchOptions);
|
this.items$ = this.browseService.getBrowseItemsFor(value, authority, searchOptions);
|
||||||
}
|
this.loading$ = this.items$.pipe(
|
||||||
|
map((itemsRD: RemoteData<PaginatedList<Item>>) => itemsRD.isLoading),
|
||||||
/**
|
);
|
||||||
* Update the parent Community or Collection using their scope
|
|
||||||
* @param scope The UUID of the Community or Collection to fetch
|
|
||||||
*/
|
|
||||||
updateParent(scope: string) {
|
|
||||||
if (hasValue(scope)) {
|
|
||||||
const linksToFollow = () => {
|
|
||||||
return [followLink('logo')];
|
|
||||||
};
|
|
||||||
this.parent$ = this.dsoService.findById(scope,
|
|
||||||
true,
|
|
||||||
true,
|
|
||||||
...linksToFollow() as FollowLinkConfig<DSpaceObject>[]).pipe(
|
|
||||||
getFirstSucceededRemoteData()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Update the parent Community or Collection logo
|
|
||||||
*/
|
|
||||||
updateLogo() {
|
|
||||||
if (hasValue(this.parent$)) {
|
|
||||||
this.logo$ = this.parent$.pipe(
|
|
||||||
map((rd: RemoteData<Collection | Community>) => rd.payload),
|
|
||||||
filter((collectionOrCommunity: Collection | Community) => hasValue(collectionOrCommunity.logo)),
|
|
||||||
mergeMap((collectionOrCommunity: Collection | Community) => collectionOrCommunity.logo)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -320,12 +298,14 @@ export function getBrowseSearchOptions(defaultBrowseId: string,
|
|||||||
/**
|
/**
|
||||||
* Function to transform query and url parameters into searchOptions used to fetch browse entries or items
|
* Function to transform query and url parameters into searchOptions used to fetch browse entries or items
|
||||||
* @param params URL and query parameters
|
* @param params URL and query parameters
|
||||||
|
* @param scope The scope to show the results
|
||||||
* @param paginationConfig Pagination configuration
|
* @param paginationConfig Pagination configuration
|
||||||
* @param sortConfig Sorting configuration
|
* @param sortConfig Sorting configuration
|
||||||
* @param metadata Optional metadata definition to fetch browse entries/items for
|
* @param metadata Optional metadata definition to fetch browse entries/items for
|
||||||
* @param fetchThumbnail Optional parameter for requesting thumbnail images
|
* @param fetchThumbnail Optional parameter for requesting thumbnail images
|
||||||
*/
|
*/
|
||||||
export function browseParamsToOptions(params: any,
|
export function browseParamsToOptions(params: any,
|
||||||
|
scope: string,
|
||||||
paginationConfig: PaginationComponentOptions,
|
paginationConfig: PaginationComponentOptions,
|
||||||
sortConfig: SortOptions,
|
sortConfig: SortOptions,
|
||||||
metadata?: string,
|
metadata?: string,
|
||||||
@@ -335,7 +315,7 @@ export function browseParamsToOptions(params: any,
|
|||||||
paginationConfig,
|
paginationConfig,
|
||||||
sortConfig,
|
sortConfig,
|
||||||
params.startsWith,
|
params.startsWith,
|
||||||
params.scope,
|
scope,
|
||||||
fetchThumbnail
|
fetchThumbnail
|
||||||
);
|
);
|
||||||
}
|
}
|
@@ -1,2 +1,4 @@
|
|||||||
<ds-browse-by-switcher [browseByType]="browseByType$ | async">
|
<div class="container">
|
||||||
</ds-browse-by-switcher>
|
<ds-browse-by-switcher [browseByType]="browseByType$ | async">
|
||||||
|
</ds-browse-by-switcher>
|
||||||
|
</div>
|
||||||
|
@@ -15,6 +15,10 @@ export class BrowseBySwitcherComponent extends AbstractComponentLoaderComponent<
|
|||||||
|
|
||||||
@Input() browseByType: BrowseByDataType;
|
@Input() browseByType: BrowseByDataType;
|
||||||
|
|
||||||
|
@Input() displayTitle: boolean;
|
||||||
|
|
||||||
|
@Input() scope: string;
|
||||||
|
|
||||||
protected inputNamesDependentForComponent: (keyof this & string)[] = [
|
protected inputNamesDependentForComponent: (keyof this & string)[] = [
|
||||||
'context',
|
'context',
|
||||||
'browseByType',
|
'browseByType',
|
||||||
@@ -23,6 +27,8 @@ export class BrowseBySwitcherComponent extends AbstractComponentLoaderComponent<
|
|||||||
protected inputNames: (keyof this & string)[] = [
|
protected inputNames: (keyof this & string)[] = [
|
||||||
'context',
|
'context',
|
||||||
'browseByType',
|
'browseByType',
|
||||||
|
'displayTitle',
|
||||||
|
'scope',
|
||||||
];
|
];
|
||||||
|
|
||||||
public getComponent(): GenericConstructor<Component> {
|
public getComponent(): GenericConstructor<Component> {
|
||||||
|
@@ -0,0 +1,16 @@
|
|||||||
|
import { Directive, ViewContainerRef } from '@angular/core';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Directive used as a hook to know where to inject the dynamic loaded component
|
||||||
|
*/
|
||||||
|
@Directive({
|
||||||
|
selector: '[dsDynamicComponentLoader]'
|
||||||
|
})
|
||||||
|
export class DynamicComponentLoaderDirective {
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
public viewContainerRef: ViewContainerRef,
|
||||||
|
) {
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@@ -1,5 +1,11 @@
|
|||||||
<div class="container">
|
<section>
|
||||||
<h1>{{ ('browse.taxonomy_' + vocabularyName + '.title') | translate }}</h1>
|
<h1 *ngIf="displayTitle">
|
||||||
|
{{ ('browse.title') | translate:{
|
||||||
|
field: 'browse.metadata.' + vocabularyName | translate,
|
||||||
|
startsWith: '',
|
||||||
|
value: '',
|
||||||
|
} }}
|
||||||
|
</h1>
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<ds-vocabulary-treeview [vocabularyOptions]=vocabularyOptions
|
<ds-vocabulary-treeview [vocabularyOptions]=vocabularyOptions
|
||||||
[multiSelect]="true"
|
[multiSelect]="true"
|
||||||
@@ -12,4 +18,4 @@
|
|||||||
[queryParams]="queryParams"
|
[queryParams]="queryParams"
|
||||||
[queryParamsHandling]="'merge'">
|
[queryParamsHandling]="'merge'">
|
||||||
{{ 'browse.taxonomy.button' | translate }}</a>
|
{{ 'browse.taxonomy.button' | translate }}</a>
|
||||||
</div>
|
</section>
|
@@ -1,6 +1,5 @@
|
|||||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
import { BrowseByTaxonomyComponent } from './browse-by-taxonomy.component';
|
||||||
import { BrowseByTaxonomyPageComponent } from './browse-by-taxonomy-page.component';
|
|
||||||
import { VocabularyEntryDetail } from '../../core/submission/vocabularies/models/vocabulary-entry-detail.model';
|
import { VocabularyEntryDetail } from '../../core/submission/vocabularies/models/vocabulary-entry-detail.model';
|
||||||
import { TranslateModule } from '@ngx-translate/core';
|
import { TranslateModule } from '@ngx-translate/core';
|
||||||
import { NO_ERRORS_SCHEMA } from '@angular/core';
|
import { NO_ERRORS_SCHEMA } from '@angular/core';
|
||||||
@@ -10,9 +9,9 @@ import { createDataWithBrowseDefinition } from '../browse-by-switcher/browse-by-
|
|||||||
import { HierarchicalBrowseDefinition } from '../../core/shared/hierarchical-browse-definition.model';
|
import { HierarchicalBrowseDefinition } from '../../core/shared/hierarchical-browse-definition.model';
|
||||||
import { ThemeService } from '../../shared/theme-support/theme.service';
|
import { ThemeService } from '../../shared/theme-support/theme.service';
|
||||||
|
|
||||||
describe('BrowseByTaxonomyPageComponent', () => {
|
describe('BrowseByTaxonomyComponent', () => {
|
||||||
let component: BrowseByTaxonomyPageComponent;
|
let component: BrowseByTaxonomyComponent;
|
||||||
let fixture: ComponentFixture<BrowseByTaxonomyPageComponent>;
|
let fixture: ComponentFixture<BrowseByTaxonomyComponent>;
|
||||||
let themeService: ThemeService;
|
let themeService: ThemeService;
|
||||||
let detail1: VocabularyEntryDetail;
|
let detail1: VocabularyEntryDetail;
|
||||||
let detail2: VocabularyEntryDetail;
|
let detail2: VocabularyEntryDetail;
|
||||||
@@ -29,7 +28,9 @@ describe('BrowseByTaxonomyPageComponent', () => {
|
|||||||
|
|
||||||
await TestBed.configureTestingModule({
|
await TestBed.configureTestingModule({
|
||||||
imports: [ TranslateModule.forRoot() ],
|
imports: [ TranslateModule.forRoot() ],
|
||||||
declarations: [ BrowseByTaxonomyPageComponent ],
|
declarations: [
|
||||||
|
BrowseByTaxonomyComponent,
|
||||||
|
],
|
||||||
providers: [
|
providers: [
|
||||||
{ provide: ActivatedRoute, useValue: activatedRouteStub },
|
{ provide: ActivatedRoute, useValue: activatedRouteStub },
|
||||||
{ provide: ThemeService, useValue: themeService },
|
{ provide: ThemeService, useValue: themeService },
|
||||||
@@ -40,8 +41,9 @@ describe('BrowseByTaxonomyPageComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
fixture = TestBed.createComponent(BrowseByTaxonomyPageComponent);
|
fixture = TestBed.createComponent(BrowseByTaxonomyComponent);
|
||||||
component = fixture.componentInstance;
|
component = fixture.componentInstance;
|
||||||
|
spyOn(component, 'updateQueryParams').and.callThrough();
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
detail1 = new VocabularyEntryDetail();
|
detail1 = new VocabularyEntryDetail();
|
||||||
detail2 = new VocabularyEntryDetail();
|
detail2 = new VocabularyEntryDetail();
|
||||||
@@ -61,6 +63,7 @@ describe('BrowseByTaxonomyPageComponent', () => {
|
|||||||
expect(component.selectedItems).toContain(detail1);
|
expect(component.selectedItems).toContain(detail1);
|
||||||
expect(component.selectedItems.length).toBe(1);
|
expect(component.selectedItems.length).toBe(1);
|
||||||
expect(component.filterValues).toEqual(['HUMANITIES and RELIGION,equals'] );
|
expect(component.filterValues).toEqual(['HUMANITIES and RELIGION,equals'] );
|
||||||
|
expect(component.updateQueryParams).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should handle select event with multiple selected items', () => {
|
it('should handle select event with multiple selected items', () => {
|
||||||
@@ -70,6 +73,7 @@ describe('BrowseByTaxonomyPageComponent', () => {
|
|||||||
expect(component.selectedItems).toContain(detail1, detail2);
|
expect(component.selectedItems).toContain(detail1, detail2);
|
||||||
expect(component.selectedItems.length).toBe(2);
|
expect(component.selectedItems.length).toBe(2);
|
||||||
expect(component.filterValues).toEqual(['HUMANITIES and RELIGION,equals', 'TECHNOLOGY,equals'] );
|
expect(component.filterValues).toEqual(['HUMANITIES and RELIGION,equals', 'TECHNOLOGY,equals'] );
|
||||||
|
expect(component.updateQueryParams).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should handle deselect event', () => {
|
it('should handle deselect event', () => {
|
||||||
@@ -82,6 +86,33 @@ describe('BrowseByTaxonomyPageComponent', () => {
|
|||||||
expect(component.selectedItems).toContain(detail2);
|
expect(component.selectedItems).toContain(detail2);
|
||||||
expect(component.selectedItems.length).toBe(1);
|
expect(component.selectedItems.length).toBe(1);
|
||||||
expect(component.filterValues).toEqual(['TECHNOLOGY,equals'] );
|
expect(component.filterValues).toEqual(['TECHNOLOGY,equals'] );
|
||||||
|
expect(component.updateQueryParams).toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('updateQueryParams', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
component.facetType = 'subject';
|
||||||
|
component.filterValues = ['HUMANITIES and RELIGION,equals', 'TECHNOLOGY,equals'];
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should update the queryParams with the selected filterValues', () => {
|
||||||
|
component.updateQueryParams();
|
||||||
|
|
||||||
|
expect(component.queryParams).toEqual({
|
||||||
|
'f.subject': ['HUMANITIES and RELIGION,equals', 'TECHNOLOGY,equals'],
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should include the scope if present', () => {
|
||||||
|
component.scope = '67f849f1-2499-4872-8c61-9e2b47d71068';
|
||||||
|
|
||||||
|
component.updateQueryParams();
|
||||||
|
|
||||||
|
expect(component.queryParams).toEqual({
|
||||||
|
'f.subject': ['HUMANITIES and RELIGION,equals', 'TECHNOLOGY,equals'],
|
||||||
|
'scope': '67f849f1-2499-4872-8c61-9e2b47d71068',
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
@@ -1,25 +1,26 @@
|
|||||||
import { Component, OnInit, OnDestroy, Input } from '@angular/core';
|
import { Component, OnInit, OnChanges, OnDestroy, Input } from '@angular/core';
|
||||||
import { VocabularyOptions } from '../../core/submission/vocabularies/models/vocabulary-options.model';
|
import { VocabularyOptions } from '../../core/submission/vocabularies/models/vocabulary-options.model';
|
||||||
import { VocabularyEntryDetail } from '../../core/submission/vocabularies/models/vocabulary-entry-detail.model';
|
import { VocabularyEntryDetail } from '../../core/submission/vocabularies/models/vocabulary-entry-detail.model';
|
||||||
import { ActivatedRoute } from '@angular/router';
|
import { ActivatedRoute, Params } from '@angular/router';
|
||||||
import { Observable, Subscription } from 'rxjs';
|
import { BehaviorSubject, Observable, Subscription } from 'rxjs';
|
||||||
import { BrowseDefinition } from '../../core/shared/browse-definition.model';
|
import { BrowseDefinition } from '../../core/shared/browse-definition.model';
|
||||||
import { rendersBrowseBy } from '../browse-by-switcher/browse-by-decorator';
|
import { rendersBrowseBy } from '../browse-by-switcher/browse-by-decorator';
|
||||||
import { map } from 'rxjs/operators';
|
import { map } from 'rxjs/operators';
|
||||||
import { HierarchicalBrowseDefinition } from '../../core/shared/hierarchical-browse-definition.model';
|
import { HierarchicalBrowseDefinition } from '../../core/shared/hierarchical-browse-definition.model';
|
||||||
import { BrowseByDataType } from '../browse-by-switcher/browse-by-data-type';
|
import { BrowseByDataType } from '../browse-by-switcher/browse-by-data-type';
|
||||||
import { Context } from '../../core/shared/context.model';
|
import { Context } from '../../core/shared/context.model';
|
||||||
|
import { hasValue } from '../../shared/empty.util';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'ds-browse-by-taxonomy-page',
|
selector: 'ds-browse-by-taxonomy',
|
||||||
templateUrl: './browse-by-taxonomy-page.component.html',
|
templateUrl: './browse-by-taxonomy.component.html',
|
||||||
styleUrls: ['./browse-by-taxonomy-page.component.scss']
|
styleUrls: ['./browse-by-taxonomy.component.scss'],
|
||||||
})
|
})
|
||||||
/**
|
/**
|
||||||
* Component for browsing items by metadata in a hierarchical controlled vocabulary
|
* Component for browsing items by metadata in a hierarchical controlled vocabulary
|
||||||
*/
|
*/
|
||||||
@rendersBrowseBy(BrowseByDataType.Hierarchy)
|
@rendersBrowseBy(BrowseByDataType.Hierarchy)
|
||||||
export class BrowseByTaxonomyPageComponent implements OnInit, OnDestroy {
|
export class BrowseByTaxonomyComponent implements OnInit, OnChanges, OnDestroy {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The optional context
|
* The optional context
|
||||||
@@ -31,6 +32,18 @@ export class BrowseByTaxonomyPageComponent implements OnInit, OnDestroy {
|
|||||||
*/
|
*/
|
||||||
@Input() browseByType: BrowseByDataType;
|
@Input() browseByType: BrowseByDataType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The ID of the {@link Community} or {@link Collection} of the scope to display
|
||||||
|
*/
|
||||||
|
@Input() scope: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display the h1 title in the section
|
||||||
|
*/
|
||||||
|
@Input() displayTitle = true;
|
||||||
|
|
||||||
|
scope$: BehaviorSubject<string> = new BehaviorSubject(undefined);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The {@link VocabularyOptions} object
|
* The {@link VocabularyOptions} object
|
||||||
*/
|
*/
|
||||||
@@ -59,7 +72,7 @@ export class BrowseByTaxonomyPageComponent implements OnInit, OnDestroy {
|
|||||||
/**
|
/**
|
||||||
* The parameters used in the URL
|
* The parameters used in the URL
|
||||||
*/
|
*/
|
||||||
queryParams: any;
|
queryParams: Params;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resolved browse-by definition
|
* Resolved browse-by definition
|
||||||
@@ -87,6 +100,13 @@ export class BrowseByTaxonomyPageComponent implements OnInit, OnDestroy {
|
|||||||
this.vocabularyName = browseDefinition.vocabulary;
|
this.vocabularyName = browseDefinition.vocabulary;
|
||||||
this.vocabularyOptions = { name: this.vocabularyName, closed: true };
|
this.vocabularyOptions = { name: this.vocabularyName, closed: true };
|
||||||
}));
|
}));
|
||||||
|
this.subs.push(this.scope$.subscribe(() => {
|
||||||
|
this.updateQueryParams();
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
ngOnChanges(): void {
|
||||||
|
this.scope$.next(this.scope);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -96,9 +116,9 @@ export class BrowseByTaxonomyPageComponent implements OnInit, OnDestroy {
|
|||||||
* @param detail VocabularyEntryDetail to be added
|
* @param detail VocabularyEntryDetail to be added
|
||||||
*/
|
*/
|
||||||
onSelect(detail: VocabularyEntryDetail): void {
|
onSelect(detail: VocabularyEntryDetail): void {
|
||||||
this.selectedItems.push(detail);
|
this.selectedItems.push(detail);
|
||||||
this.filterValues = this.selectedItems
|
this.filterValues = this.selectedItems
|
||||||
.map((item: VocabularyEntryDetail) => `${item.value},equals`);
|
.map((item: VocabularyEntryDetail) => `${item.value},equals`);
|
||||||
this.updateQueryParams();
|
this.updateQueryParams();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -108,18 +128,25 @@ export class BrowseByTaxonomyPageComponent implements OnInit, OnDestroy {
|
|||||||
* @param detail VocabularyEntryDetail to be removed
|
* @param detail VocabularyEntryDetail to be removed
|
||||||
*/
|
*/
|
||||||
onDeselect(detail: VocabularyEntryDetail): void {
|
onDeselect(detail: VocabularyEntryDetail): void {
|
||||||
this.selectedItems = this.selectedItems.filter((entry: VocabularyEntryDetail) => { return entry.id !== detail.id; });
|
this.selectedItems = this.selectedItems.filter((entry: VocabularyEntryDetail) => {
|
||||||
this.filterValues = this.filterValues.filter((value: string) => { return value !== `${detail.value},equals`; });
|
return entry.id !== detail.id;
|
||||||
|
});
|
||||||
|
this.filterValues = this.filterValues.filter((value: string) => {
|
||||||
|
return value !== `${detail.value},equals`;
|
||||||
|
});
|
||||||
this.updateQueryParams();
|
this.updateQueryParams();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates queryParams based on the current facetType and filterValues.
|
* Updates queryParams based on the current facetType and filterValues.
|
||||||
*/
|
*/
|
||||||
private updateQueryParams(): void {
|
updateQueryParams(): void {
|
||||||
this.queryParams = {
|
this.queryParams = {
|
||||||
['f.' + this.facetType]: this.filterValues
|
['f.' + this.facetType]: this.filterValues
|
||||||
};
|
};
|
||||||
|
if (hasValue(this.scope)) {
|
||||||
|
this.queryParams.scope = this.scope;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnDestroy(): void {
|
ngOnDestroy(): void {
|
@@ -1,62 +0,0 @@
|
|||||||
import { combineLatest as observableCombineLatest } from 'rxjs';
|
|
||||||
import { Component, Inject, OnInit } from '@angular/core';
|
|
||||||
import { ActivatedRoute, Params, Router } from '@angular/router';
|
|
||||||
import {
|
|
||||||
BrowseByMetadataPageComponent,
|
|
||||||
browseParamsToOptions, getBrowseSearchOptions
|
|
||||||
} from '../browse-by-metadata-page/browse-by-metadata-page.component';
|
|
||||||
import { DSpaceObjectDataService } from '../../core/data/dspace-object-data.service';
|
|
||||||
import { BrowseService } from '../../core/browse/browse.service';
|
|
||||||
import { SortDirection, SortOptions } from '../../core/cache/models/sort-options.model';
|
|
||||||
import { PaginationService } from '../../core/pagination/pagination.service';
|
|
||||||
import { map } from 'rxjs/operators';
|
|
||||||
import { PaginationComponentOptions } from '../../shared/pagination/pagination-component-options.model';
|
|
||||||
import { AppConfig, APP_CONFIG } from '../../../config/app-config.interface';
|
|
||||||
import { DSONameService } from '../../core/breadcrumbs/dso-name.service';
|
|
||||||
import { rendersBrowseBy } from '../browse-by-switcher/browse-by-decorator';
|
|
||||||
import { BrowseByDataType } from '../browse-by-switcher/browse-by-data-type';
|
|
||||||
|
|
||||||
@Component({
|
|
||||||
selector: 'ds-browse-by-title-page',
|
|
||||||
styleUrls: ['../browse-by-metadata-page/browse-by-metadata-page.component.scss'],
|
|
||||||
templateUrl: '../browse-by-metadata-page/browse-by-metadata-page.component.html'
|
|
||||||
})
|
|
||||||
/**
|
|
||||||
* Component for browsing items by title (dc.title)
|
|
||||||
*/
|
|
||||||
@rendersBrowseBy(BrowseByDataType.Title)
|
|
||||||
export class BrowseByTitlePageComponent extends BrowseByMetadataPageComponent implements OnInit {
|
|
||||||
|
|
||||||
public constructor(protected route: ActivatedRoute,
|
|
||||||
protected browseService: BrowseService,
|
|
||||||
protected dsoService: DSpaceObjectDataService,
|
|
||||||
protected paginationService: PaginationService,
|
|
||||||
protected router: Router,
|
|
||||||
@Inject(APP_CONFIG) public appConfig: AppConfig,
|
|
||||||
public dsoNameService: DSONameService,
|
|
||||||
) {
|
|
||||||
super(route, browseService, dsoService, paginationService, router, appConfig, dsoNameService);
|
|
||||||
}
|
|
||||||
|
|
||||||
ngOnInit(): void {
|
|
||||||
const sortConfig = new SortOptions('dc.title', SortDirection.ASC);
|
|
||||||
// include the thumbnail configuration in browse search options
|
|
||||||
this.updatePage(getBrowseSearchOptions(this.defaultBrowseId, this.paginationConfig, sortConfig, this.fetchThumbnails));
|
|
||||||
this.currentPagination$ = this.paginationService.getCurrentPagination(this.paginationConfig.id, this.paginationConfig);
|
|
||||||
this.currentSort$ = this.paginationService.getCurrentSort(this.paginationConfig.id, sortConfig);
|
|
||||||
this.subs.push(
|
|
||||||
observableCombineLatest([this.route.params, this.route.queryParams, this.currentPagination$, this.currentSort$]).pipe(
|
|
||||||
map(([routeParams, queryParams, currentPage, currentSort]) => {
|
|
||||||
return [Object.assign({}, routeParams, queryParams),currentPage,currentSort];
|
|
||||||
})
|
|
||||||
).subscribe(([params, currentPage, currentSort]: [Params, PaginationComponentOptions, SortOptions]) => {
|
|
||||||
this.startsWith = +params.startsWith || params.startsWith;
|
|
||||||
this.browseId = params.id || this.defaultBrowseId;
|
|
||||||
this.updatePageWithItems(browseParamsToOptions(params, currentPage, currentSort, this.browseId, this.fetchThumbnails), undefined, undefined);
|
|
||||||
this.updateParent(params.scope);
|
|
||||||
this.updateLogo();
|
|
||||||
}));
|
|
||||||
this.updateStartsWithTextOptions();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@@ -9,8 +9,8 @@ import { TranslateModule } from '@ngx-translate/core';
|
|||||||
import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
|
import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
|
||||||
import { EnumKeysPipe } from '../../shared/utils/enum-keys-pipe';
|
import { EnumKeysPipe } from '../../shared/utils/enum-keys-pipe';
|
||||||
import { NO_ERRORS_SCHEMA } from '@angular/core';
|
import { NO_ERRORS_SCHEMA } from '@angular/core';
|
||||||
import { toRemoteData } from '../browse-by-metadata-page/browse-by-metadata-page.component.spec';
|
import { toRemoteData } from '../browse-by-metadata/browse-by-metadata.component.spec';
|
||||||
import { BrowseByTitlePageComponent } from './browse-by-title-page.component';
|
import { BrowseByTitleComponent } from './browse-by-title.component';
|
||||||
import { ItemDataService } from '../../core/data/item-data.service';
|
import { ItemDataService } from '../../core/data/item-data.service';
|
||||||
import { Community } from '../../core/shared/community.model';
|
import { Community } from '../../core/shared/community.model';
|
||||||
import { DSpaceObjectDataService } from '../../core/data/dspace-object-data.service';
|
import { DSpaceObjectDataService } from '../../core/data/dspace-object-data.service';
|
||||||
@@ -24,9 +24,9 @@ import { APP_CONFIG } from '../../../config/app-config.interface';
|
|||||||
import { environment } from '../../../environments/environment';
|
import { environment } from '../../../environments/environment';
|
||||||
|
|
||||||
|
|
||||||
describe('BrowseByTitlePageComponent', () => {
|
describe('BrowseByTitleComponent', () => {
|
||||||
let comp: BrowseByTitlePageComponent;
|
let comp: BrowseByTitleComponent;
|
||||||
let fixture: ComponentFixture<BrowseByTitlePageComponent>;
|
let fixture: ComponentFixture<BrowseByTitleComponent>;
|
||||||
let itemDataService: ItemDataService;
|
let itemDataService: ItemDataService;
|
||||||
let route: ActivatedRoute;
|
let route: ActivatedRoute;
|
||||||
|
|
||||||
@@ -71,7 +71,7 @@ describe('BrowseByTitlePageComponent', () => {
|
|||||||
beforeEach(waitForAsync(() => {
|
beforeEach(waitForAsync(() => {
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
imports: [CommonModule, RouterTestingModule.withRoutes([]), TranslateModule.forRoot(), NgbModule],
|
imports: [CommonModule, RouterTestingModule.withRoutes([]), TranslateModule.forRoot(), NgbModule],
|
||||||
declarations: [BrowseByTitlePageComponent, EnumKeysPipe, VarDirective],
|
declarations: [BrowseByTitleComponent, EnumKeysPipe, VarDirective],
|
||||||
providers: [
|
providers: [
|
||||||
{ provide: ActivatedRoute, useValue: activatedRouteStub },
|
{ provide: ActivatedRoute, useValue: activatedRouteStub },
|
||||||
{ provide: BrowseService, useValue: mockBrowseService },
|
{ provide: BrowseService, useValue: mockBrowseService },
|
||||||
@@ -85,7 +85,7 @@ describe('BrowseByTitlePageComponent', () => {
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
fixture = TestBed.createComponent(BrowseByTitlePageComponent);
|
fixture = TestBed.createComponent(BrowseByTitleComponent);
|
||||||
comp = fixture.componentInstance;
|
comp = fixture.componentInstance;
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
itemDataService = (comp as any).itemDataService;
|
itemDataService = (comp as any).itemDataService;
|
@@ -0,0 +1,44 @@
|
|||||||
|
import { combineLatest as observableCombineLatest } from 'rxjs';
|
||||||
|
import { Component, OnInit } from '@angular/core';
|
||||||
|
import { Params } from '@angular/router';
|
||||||
|
import {
|
||||||
|
BrowseByMetadataComponent,
|
||||||
|
browseParamsToOptions, getBrowseSearchOptions
|
||||||
|
} from '../browse-by-metadata/browse-by-metadata.component';
|
||||||
|
import { SortDirection, SortOptions } from '../../core/cache/models/sort-options.model';
|
||||||
|
import { map } from 'rxjs/operators';
|
||||||
|
import { PaginationComponentOptions } from '../../shared/pagination/pagination-component-options.model';
|
||||||
|
import { rendersBrowseBy } from '../browse-by-switcher/browse-by-decorator';
|
||||||
|
import { BrowseByDataType } from '../browse-by-switcher/browse-by-data-type';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'ds-browse-by-title',
|
||||||
|
styleUrls: ['../browse-by-metadata/browse-by-metadata.component.scss'],
|
||||||
|
templateUrl: '../browse-by-metadata/browse-by-metadata.component.html'
|
||||||
|
})
|
||||||
|
/**
|
||||||
|
* Component for browsing items by title (dc.title)
|
||||||
|
*/
|
||||||
|
@rendersBrowseBy(BrowseByDataType.Title)
|
||||||
|
export class BrowseByTitleComponent extends BrowseByMetadataComponent implements OnInit {
|
||||||
|
|
||||||
|
ngOnInit(): void {
|
||||||
|
const sortConfig = new SortOptions('dc.title', SortDirection.ASC);
|
||||||
|
// include the thumbnail configuration in browse search options
|
||||||
|
this.updatePage(getBrowseSearchOptions(this.defaultBrowseId, this.paginationConfig, sortConfig, this.fetchThumbnails));
|
||||||
|
this.currentPagination$ = this.paginationService.getCurrentPagination(this.paginationConfig.id, this.paginationConfig);
|
||||||
|
this.currentSort$ = this.paginationService.getCurrentSort(this.paginationConfig.id, sortConfig);
|
||||||
|
this.subs.push(
|
||||||
|
observableCombineLatest([this.route.params, this.route.queryParams, this.scope$, this.currentPagination$, this.currentSort$]).pipe(
|
||||||
|
map(([routeParams, queryParams, scope, currentPage, currentSort]) => {
|
||||||
|
return [Object.assign({}, routeParams, queryParams), scope, currentPage, currentSort];
|
||||||
|
})
|
||||||
|
).subscribe(([params, scope, currentPage, currentSort]: [Params, string, PaginationComponentOptions, SortOptions]) => {
|
||||||
|
this.startsWith = +params.startsWith || params.startsWith;
|
||||||
|
this.browseId = params.id || this.defaultBrowseId;
|
||||||
|
this.updatePageWithItems(browseParamsToOptions(params, scope, currentPage, currentSort, this.browseId, this.fetchThumbnails), undefined, undefined);
|
||||||
|
}));
|
||||||
|
this.updateStartsWithTextOptions();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@@ -1,11 +1,10 @@
|
|||||||
import { NgModule } from '@angular/core';
|
import { NgModule } from '@angular/core';
|
||||||
import { CommonModule } from '@angular/common';
|
import { CommonModule } from '@angular/common';
|
||||||
import { BrowseByTitlePageComponent } from './browse-by-title-page/browse-by-title-page.component';
|
import { BrowseByTitleComponent } from './browse-by-title/browse-by-title.component';
|
||||||
import { BrowseByMetadataPageComponent } from './browse-by-metadata-page/browse-by-metadata-page.component';
|
import { BrowseByMetadataComponent } from './browse-by-metadata/browse-by-metadata.component';
|
||||||
import { BrowseByDatePageComponent } from './browse-by-date-page/browse-by-date-page.component';
|
import { BrowseByDateComponent } from './browse-by-date/browse-by-date.component';
|
||||||
import { BrowseBySwitcherComponent } from './browse-by-switcher/browse-by-switcher.component';
|
import { BrowseBySwitcherComponent } from './browse-by-switcher/browse-by-switcher.component';
|
||||||
import { BrowseByTaxonomyPageComponent } from './browse-by-taxonomy-page/browse-by-taxonomy-page.component';
|
import { BrowseByTaxonomyComponent } from './browse-by-taxonomy/browse-by-taxonomy.component';
|
||||||
import { ComcolModule } from '../shared/comcol/comcol.module';
|
|
||||||
import { SharedBrowseByModule } from '../shared/browse-by/shared-browse-by.module';
|
import { SharedBrowseByModule } from '../shared/browse-by/shared-browse-by.module';
|
||||||
import { DsoPageModule } from '../shared/dso-page/dso-page.module';
|
import { DsoPageModule } from '../shared/dso-page/dso-page.module';
|
||||||
import { FormModule } from '../shared/form/form.module';
|
import { FormModule } from '../shared/form/form.module';
|
||||||
@@ -17,17 +16,16 @@ const DECLARATIONS = [
|
|||||||
|
|
||||||
const ENTRY_COMPONENTS = [
|
const ENTRY_COMPONENTS = [
|
||||||
// put only entry components that use custom decorator
|
// put only entry components that use custom decorator
|
||||||
BrowseByTitlePageComponent,
|
BrowseByTitleComponent,
|
||||||
BrowseByMetadataPageComponent,
|
BrowseByMetadataComponent,
|
||||||
BrowseByDatePageComponent,
|
BrowseByDateComponent,
|
||||||
BrowseByTaxonomyPageComponent,
|
BrowseByTaxonomyComponent,
|
||||||
];
|
];
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
imports: [
|
imports: [
|
||||||
SharedBrowseByModule,
|
SharedBrowseByModule,
|
||||||
CommonModule,
|
CommonModule,
|
||||||
ComcolModule,
|
|
||||||
DsoPageModule,
|
DsoPageModule,
|
||||||
FormModule,
|
FormModule,
|
||||||
SharedModule,
|
SharedModule,
|
||||||
|
@@ -22,6 +22,10 @@ import { LinkMenuItemModel } from '../shared/menu/menu-item/models/link.model';
|
|||||||
import { ThemedCollectionPageComponent } from './themed-collection-page.component';
|
import { ThemedCollectionPageComponent } from './themed-collection-page.component';
|
||||||
import { MenuItemType } from '../shared/menu/menu-item-type.model';
|
import { MenuItemType } from '../shared/menu/menu-item-type.model';
|
||||||
import { DSOEditMenuResolver } from '../shared/dso-page/dso-edit-menu.resolver';
|
import { DSOEditMenuResolver } from '../shared/dso-page/dso-edit-menu.resolver';
|
||||||
|
import { ComcolBrowseByComponent } from '../shared/comcol/sections/comcol-browse-by/comcol-browse-by.component';
|
||||||
|
import { BrowseByGuard } from '../browse-by/browse-by-guard';
|
||||||
|
import { BrowseByI18nBreadcrumbResolver } from '../browse-by/browse-by-i18n-breadcrumb.resolver';
|
||||||
|
import { CollectionRecentlyAddedComponent } from './sections/recently-added/collection-recently-added.component';
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
imports: [
|
imports: [
|
||||||
@@ -65,7 +69,23 @@ import { DSOEditMenuResolver } from '../shared/dso-page/dso-edit-menu.resolver';
|
|||||||
{
|
{
|
||||||
path: '',
|
path: '',
|
||||||
component: ThemedCollectionPageComponent,
|
component: ThemedCollectionPageComponent,
|
||||||
pathMatch: 'full',
|
children: [
|
||||||
|
{
|
||||||
|
path: '',
|
||||||
|
pathMatch: 'full',
|
||||||
|
component: CollectionRecentlyAddedComponent,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: 'browse/:id',
|
||||||
|
pathMatch: 'full',
|
||||||
|
component: ComcolBrowseByComponent,
|
||||||
|
canActivate: [BrowseByGuard],
|
||||||
|
resolve: {
|
||||||
|
breadcrumb: BrowseByI18nBreadcrumbResolver,
|
||||||
|
},
|
||||||
|
data: { breadcrumbKey: 'browse.metadata' },
|
||||||
|
},
|
||||||
|
],
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
data: {
|
data: {
|
||||||
|
@@ -1,78 +1,61 @@
|
|||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="collection-page"
|
<div class="collection-page"
|
||||||
*ngVar="(collectionRD$ | async) as collectionRD">
|
*ngVar="(collectionRD$ | async) as collectionRD">
|
||||||
<div *ngIf="collectionRD?.hasSucceeded" @fadeInOut>
|
<div *ngIf="collectionRD?.hasSucceeded" @fadeInOut>
|
||||||
<div *ngIf="collectionRD?.payload as collection">
|
<div *ngIf="collectionRD?.payload as collection">
|
||||||
<ds-view-tracker [object]="collection"></ds-view-tracker>
|
<ds-view-tracker [object]="collection"></ds-view-tracker>
|
||||||
<div class="d-flex flex-row border-bottom mb-4 pb-4">
|
<div class="d-flex flex-row border-bottom mb-4 pb-4">
|
||||||
<header class="comcol-header mr-auto">
|
<header class="comcol-header mr-auto">
|
||||||
<!-- Collection Name -->
|
<!-- Collection Name -->
|
||||||
<ds-comcol-page-header
|
<ds-comcol-page-header
|
||||||
[name]="dsoNameService.getName(collection)">
|
[name]="dsoNameService.getName(collection)">
|
||||||
</ds-comcol-page-header>
|
</ds-comcol-page-header>
|
||||||
<!-- Collection logo -->
|
<!-- Collection logo -->
|
||||||
<ds-comcol-page-logo *ngIf="logoRD$"
|
<ds-comcol-page-logo *ngIf="logoRD$"
|
||||||
[logo]="(logoRD$ | async)?.payload"
|
[logo]="(logoRD$ | async)?.payload"
|
||||||
[alternateText]="'collection.logo' | translate">
|
[alternateText]="'collection.logo' | translate">
|
||||||
</ds-comcol-page-logo>
|
</ds-comcol-page-logo>
|
||||||
|
|
||||||
<!-- Handle -->
|
<!-- Handle -->
|
||||||
<ds-themed-comcol-page-handle
|
<ds-themed-comcol-page-handle
|
||||||
[content]="collection.handle"
|
[content]="collection.handle"
|
||||||
[title]="'collection.page.handle'" >
|
[title]="'collection.page.handle'">
|
||||||
</ds-themed-comcol-page-handle>
|
</ds-themed-comcol-page-handle>
|
||||||
<!-- Introductory text -->
|
<!-- Introductory text -->
|
||||||
<ds-comcol-page-content
|
<ds-comcol-page-content
|
||||||
[content]="collection.introductoryText"
|
[content]="collection.introductoryText"
|
||||||
[hasInnerHtml]="true">
|
[hasInnerHtml]="true">
|
||||||
</ds-comcol-page-content>
|
</ds-comcol-page-content>
|
||||||
<!-- News -->
|
<!-- News -->
|
||||||
<ds-comcol-page-content
|
<ds-comcol-page-content
|
||||||
[content]="collection.sidebarText"
|
[content]="collection.sidebarText"
|
||||||
[hasInnerHtml]="true"
|
[hasInnerHtml]="true"
|
||||||
[title]="'collection.page.news'">
|
[title]="'collection.page.news'">
|
||||||
</ds-comcol-page-content>
|
</ds-comcol-page-content>
|
||||||
</header>
|
</header>
|
||||||
<ds-dso-edit-menu></ds-dso-edit-menu>
|
<ds-dso-edit-menu></ds-dso-edit-menu>
|
||||||
</div>
|
</div>
|
||||||
<section class="comcol-page-browse-section">
|
<section class="comcol-page-browse-section">
|
||||||
<!-- Browse-By Links -->
|
<!-- Browse-By Links -->
|
||||||
<ds-themed-comcol-page-browse-by
|
<ds-themed-comcol-page-browse-by
|
||||||
[id]="collection.id"
|
[id]="collection.id"
|
||||||
[contentType]="collection.type">
|
[contentType]="collection.type">
|
||||||
</ds-themed-comcol-page-browse-by>
|
</ds-themed-comcol-page-browse-by>
|
||||||
|
|
||||||
<ng-container *ngVar="(itemRD$ | async) as itemRD">
|
<router-outlet></router-outlet>
|
||||||
<div class="mt-4" *ngIf="itemRD?.hasSucceeded" @fadeIn>
|
</section>
|
||||||
<h3 class="sr-only">{{'collection.page.browse.recent.head' | translate}}</h3>
|
<footer *ngIf="collection.copyrightText" class="border-top my-5 pt-4">
|
||||||
<ds-viewable-collection
|
|
||||||
[config]="paginationConfig"
|
|
||||||
[sortConfig]="sortConfig"
|
|
||||||
[objects]="itemRD"
|
|
||||||
[hideGear]="true">
|
|
||||||
</ds-viewable-collection>
|
|
||||||
</div>
|
|
||||||
<ds-error *ngIf="itemRD?.hasFailed"
|
|
||||||
message="{{'error.recent-submissions' | translate}}"></ds-error>
|
|
||||||
<ds-themed-loading *ngIf="!itemRD || itemRD.isLoading"
|
|
||||||
message="{{'loading.recent-submissions' | translate}}"></ds-themed-loading>
|
|
||||||
<div *ngIf="!itemRD?.isLoading && itemRD?.payload?.page.length === 0" class="alert alert-info w-100" role="alert">
|
|
||||||
{{'collection.page.browse.recent.empty' | translate}}
|
|
||||||
</div>
|
|
||||||
</ng-container>
|
|
||||||
</section>
|
|
||||||
<footer *ngIf="collection.copyrightText" class="border-top my-5 pt-4">
|
|
||||||
<!-- Copyright -->
|
<!-- Copyright -->
|
||||||
<ds-comcol-page-content
|
<ds-comcol-page-content
|
||||||
[content]="collection.copyrightText"
|
[content]="collection.copyrightText"
|
||||||
[hasInnerHtml]="true">
|
[hasInnerHtml]="true">
|
||||||
</ds-comcol-page-content>
|
</ds-comcol-page-content>
|
||||||
</footer>
|
</footer>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<ds-error *ngIf="collectionRD?.hasFailed"
|
<ds-error *ngIf="collectionRD?.hasFailed"
|
||||||
message="{{'error.collection' | translate}}"></ds-error>
|
message="{{'error.collection' | translate}}"></ds-error>
|
||||||
<ds-themed-loading *ngIf="collectionRD?.isLoading"
|
<ds-themed-loading *ngIf="collectionRD?.isLoading"
|
||||||
message="{{'loading.collection' | translate}}"></ds-themed-loading>
|
message="{{'loading.collection' | translate}}"></ds-themed-loading>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@@ -1,36 +1,21 @@
|
|||||||
import { ChangeDetectionStrategy, Component, OnInit, Inject } from '@angular/core';
|
import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core';
|
||||||
import { ActivatedRoute, Router } from '@angular/router';
|
import { ActivatedRoute, Router } from '@angular/router';
|
||||||
import { BehaviorSubject, combineLatest as observableCombineLatest, Observable, Subject } from 'rxjs';
|
import { Observable } from 'rxjs';
|
||||||
import { filter, map, mergeMap, startWith, switchMap, take } from 'rxjs/operators';
|
import { filter, map, mergeMap, take } from 'rxjs/operators';
|
||||||
import { PaginatedSearchOptions } from '../shared/search/models/paginated-search-options.model';
|
import { SortOptions } from '../core/cache/models/sort-options.model';
|
||||||
import { SearchService } from '../core/shared/search/search.service';
|
|
||||||
import { SortDirection, SortOptions } from '../core/cache/models/sort-options.model';
|
|
||||||
import { CollectionDataService } from '../core/data/collection-data.service';
|
|
||||||
import { PaginatedList } from '../core/data/paginated-list.model';
|
|
||||||
import { RemoteData } from '../core/data/remote-data';
|
import { RemoteData } from '../core/data/remote-data';
|
||||||
import { Bitstream } from '../core/shared/bitstream.model';
|
import { Bitstream } from '../core/shared/bitstream.model';
|
||||||
|
|
||||||
import { Collection } from '../core/shared/collection.model';
|
import { Collection } from '../core/shared/collection.model';
|
||||||
import { DSpaceObjectType } from '../core/shared/dspace-object-type.model';
|
import { getAllSucceededRemoteDataPayload } from '../core/shared/operators';
|
||||||
import { Item } from '../core/shared/item.model';
|
|
||||||
import {
|
|
||||||
getAllSucceededRemoteDataPayload,
|
|
||||||
getFirstSucceededRemoteData,
|
|
||||||
toDSpaceObjectListRD
|
|
||||||
} from '../core/shared/operators';
|
|
||||||
|
|
||||||
import { fadeIn, fadeInOut } from '../shared/animations/fade';
|
import { fadeIn, fadeInOut } from '../shared/animations/fade';
|
||||||
import { hasValue, isNotEmpty } from '../shared/empty.util';
|
import { hasValue, isNotEmpty } from '../shared/empty.util';
|
||||||
import { PaginationComponentOptions } from '../shared/pagination/pagination-component-options.model';
|
import { PaginationComponentOptions } from '../shared/pagination/pagination-component-options.model';
|
||||||
import { AuthService } from '../core/auth/auth.service';
|
import { AuthService } from '../core/auth/auth.service';
|
||||||
import { PaginationService } from '../core/pagination/pagination.service';
|
|
||||||
import { AuthorizationDataService } from '../core/data/feature-authorization/authorization-data.service';
|
import { AuthorizationDataService } from '../core/data/feature-authorization/authorization-data.service';
|
||||||
import { FeatureID } from '../core/data/feature-authorization/feature-id';
|
import { FeatureID } from '../core/data/feature-authorization/feature-id';
|
||||||
import { getCollectionPageRoute } from './collection-page-routing-paths';
|
import { getCollectionPageRoute } from './collection-page-routing-paths';
|
||||||
import { redirectOn4xx } from '../core/shared/authorized.operators';
|
import { redirectOn4xx } from '../core/shared/authorized.operators';
|
||||||
import { BROWSE_LINKS_TO_FOLLOW } from '../core/browse/browse.service';
|
|
||||||
import { DSONameService } from '../core/breadcrumbs/dso-name.service';
|
import { DSONameService } from '../core/breadcrumbs/dso-name.service';
|
||||||
import { APP_CONFIG, AppConfig } from '../../../src/config/app-config.interface';
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'ds-collection-page',
|
selector: 'ds-collection-page',
|
||||||
@@ -44,14 +29,9 @@ import { APP_CONFIG, AppConfig } from '../../../src/config/app-config.interface'
|
|||||||
})
|
})
|
||||||
export class CollectionPageComponent implements OnInit {
|
export class CollectionPageComponent implements OnInit {
|
||||||
collectionRD$: Observable<RemoteData<Collection>>;
|
collectionRD$: Observable<RemoteData<Collection>>;
|
||||||
itemRD$: Observable<RemoteData<PaginatedList<Item>>>;
|
|
||||||
logoRD$: Observable<RemoteData<Bitstream>>;
|
logoRD$: Observable<RemoteData<Bitstream>>;
|
||||||
paginationConfig: PaginationComponentOptions;
|
paginationConfig: PaginationComponentOptions;
|
||||||
sortConfig: SortOptions;
|
sortConfig: SortOptions;
|
||||||
private paginationChanges$: Subject<{
|
|
||||||
paginationConfig: PaginationComponentOptions,
|
|
||||||
sortConfig: SortOptions
|
|
||||||
}>;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether the current user is a Community admin
|
* Whether the current user is a Community admin
|
||||||
@@ -64,23 +44,12 @@ export class CollectionPageComponent implements OnInit {
|
|||||||
collectionPageRoute$: Observable<string>;
|
collectionPageRoute$: Observable<string>;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private collectionDataService: CollectionDataService,
|
protected route: ActivatedRoute,
|
||||||
private searchService: SearchService,
|
protected router: Router,
|
||||||
private route: ActivatedRoute,
|
protected authService: AuthService,
|
||||||
private router: Router,
|
protected authorizationDataService: AuthorizationDataService,
|
||||||
private authService: AuthService,
|
|
||||||
private paginationService: PaginationService,
|
|
||||||
private authorizationDataService: AuthorizationDataService,
|
|
||||||
public dsoNameService: DSONameService,
|
public dsoNameService: DSONameService,
|
||||||
@Inject(APP_CONFIG) public appConfig: AppConfig,
|
|
||||||
) {
|
) {
|
||||||
this.paginationConfig = Object.assign(new PaginationComponentOptions(), {
|
|
||||||
id: 'cp',
|
|
||||||
currentPage: 1,
|
|
||||||
pageSize: this.appConfig.browseBy.pageSize,
|
|
||||||
});
|
|
||||||
|
|
||||||
this.sortConfig = new SortOptions('dc.date.accessioned', SortDirection.DESC);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
@@ -96,33 +65,6 @@ export class CollectionPageComponent implements OnInit {
|
|||||||
);
|
);
|
||||||
this.isCollectionAdmin$ = this.authorizationDataService.isAuthorized(FeatureID.IsCollectionAdmin);
|
this.isCollectionAdmin$ = this.authorizationDataService.isAuthorized(FeatureID.IsCollectionAdmin);
|
||||||
|
|
||||||
this.paginationChanges$ = new BehaviorSubject({
|
|
||||||
paginationConfig: this.paginationConfig,
|
|
||||||
sortConfig: this.sortConfig
|
|
||||||
});
|
|
||||||
|
|
||||||
const currentPagination$ = this.paginationService.getCurrentPagination(this.paginationConfig.id, this.paginationConfig);
|
|
||||||
const currentSort$ = this.paginationService.getCurrentSort(this.paginationConfig.id, this.sortConfig);
|
|
||||||
|
|
||||||
this.itemRD$ = observableCombineLatest([currentPagination$, currentSort$]).pipe(
|
|
||||||
switchMap(([currentPagination, currentSort]) => this.collectionRD$.pipe(
|
|
||||||
getFirstSucceededRemoteData(),
|
|
||||||
map((rd) => rd.payload.id),
|
|
||||||
switchMap((id: string) => {
|
|
||||||
return this.searchService.search<Item>(
|
|
||||||
new PaginatedSearchOptions({
|
|
||||||
scope: id,
|
|
||||||
pagination: currentPagination,
|
|
||||||
sort: currentSort,
|
|
||||||
dsoTypes: [DSpaceObjectType.ITEM]
|
|
||||||
}), null, true, true, ...BROWSE_LINKS_TO_FOLLOW)
|
|
||||||
.pipe(toDSpaceObjectListRD()) as Observable<RemoteData<PaginatedList<Item>>>;
|
|
||||||
}),
|
|
||||||
startWith(undefined) // Make sure switching pages shows loading component
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
this.collectionPageRoute$ = this.collectionRD$.pipe(
|
this.collectionPageRoute$ = this.collectionRD$.pipe(
|
||||||
getAllSucceededRemoteDataPayload(),
|
getAllSucceededRemoteDataPayload(),
|
||||||
map((collection) => getCollectionPageRoute(collection.id))
|
map((collection) => getCollectionPageRoute(collection.id))
|
||||||
@@ -133,9 +75,5 @@ export class CollectionPageComponent implements OnInit {
|
|||||||
return isNotEmpty(object);
|
return isNotEmpty(object);
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnDestroy(): void {
|
|
||||||
this.paginationService.clearPagination(this.paginationConfig.id);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -18,6 +18,19 @@ import { ThemedCollectionPageComponent } from './themed-collection-page.componen
|
|||||||
import { ComcolModule } from '../shared/comcol/comcol.module';
|
import { ComcolModule } from '../shared/comcol/comcol.module';
|
||||||
import { DsoSharedModule } from '../dso-shared/dso-shared.module';
|
import { DsoSharedModule } from '../dso-shared/dso-shared.module';
|
||||||
import { DsoPageModule } from '../shared/dso-page/dso-page.module';
|
import { DsoPageModule } from '../shared/dso-page/dso-page.module';
|
||||||
|
import { BrowseByPageModule } from '../browse-by/browse-by-page.module';
|
||||||
|
import { CollectionRecentlyAddedComponent } from './sections/recently-added/collection-recently-added.component';
|
||||||
|
|
||||||
|
const DECLARATIONS = [
|
||||||
|
CollectionPageComponent,
|
||||||
|
ThemedCollectionPageComponent,
|
||||||
|
CreateCollectionPageComponent,
|
||||||
|
DeleteCollectionPageComponent,
|
||||||
|
EditItemTemplatePageComponent,
|
||||||
|
ThemedEditItemTemplatePageComponent,
|
||||||
|
CollectionItemMapperComponent,
|
||||||
|
CollectionRecentlyAddedComponent,
|
||||||
|
];
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
imports: [
|
imports: [
|
||||||
@@ -30,15 +43,10 @@ import { DsoPageModule } from '../shared/dso-page/dso-page.module';
|
|||||||
ComcolModule,
|
ComcolModule,
|
||||||
DsoSharedModule,
|
DsoSharedModule,
|
||||||
DsoPageModule,
|
DsoPageModule,
|
||||||
|
BrowseByPageModule,
|
||||||
],
|
],
|
||||||
declarations: [
|
declarations: [
|
||||||
CollectionPageComponent,
|
...DECLARATIONS,
|
||||||
ThemedCollectionPageComponent,
|
|
||||||
CreateCollectionPageComponent,
|
|
||||||
DeleteCollectionPageComponent,
|
|
||||||
EditItemTemplatePageComponent,
|
|
||||||
ThemedEditItemTemplatePageComponent,
|
|
||||||
CollectionItemMapperComponent
|
|
||||||
],
|
],
|
||||||
providers: [
|
providers: [
|
||||||
SearchService,
|
SearchService,
|
||||||
|
@@ -0,0 +1,18 @@
|
|||||||
|
<ng-container *ngVar="(itemRD$ | async) as itemRD">
|
||||||
|
<div class="mt-4" *ngIf="itemRD?.hasSucceeded" @fadeIn>
|
||||||
|
<h3 class="sr-only">{{'collection.page.browse.recent.head' | translate}}</h3>
|
||||||
|
<ds-viewable-collection
|
||||||
|
[config]="paginationConfig"
|
||||||
|
[sortConfig]="sortConfig"
|
||||||
|
[objects]="itemRD"
|
||||||
|
[hideGear]="true">
|
||||||
|
</ds-viewable-collection>
|
||||||
|
</div>
|
||||||
|
<ds-error *ngIf="itemRD?.hasFailed"
|
||||||
|
message="{{'error.recent-submissions' | translate}}"></ds-error>
|
||||||
|
<ds-themed-loading *ngIf="!itemRD || itemRD.isLoading"
|
||||||
|
message="{{'loading.recent-submissions' | translate}}"></ds-themed-loading>
|
||||||
|
<div *ngIf="!itemRD?.isLoading && itemRD?.payload?.page.length === 0" class="alert alert-info w-100" role="alert">
|
||||||
|
{{'collection.page.browse.recent.empty' | translate}}
|
||||||
|
</div>
|
||||||
|
</ng-container>
|
@@ -0,0 +1,53 @@
|
|||||||
|
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
import { CollectionRecentlyAddedComponent } from './collection-recently-added.component';
|
||||||
|
import { APP_CONFIG } from '../../../../config/app-config.interface';
|
||||||
|
import { environment } from '../../../../environments/environment.test';
|
||||||
|
import { ActivatedRoute } from '@angular/router';
|
||||||
|
import { ActivatedRouteStub } from '../../../shared/testing/active-router.stub';
|
||||||
|
import { PaginationService } from '../../../core/pagination/pagination.service';
|
||||||
|
import { PaginationServiceStub } from '../../../shared/testing/pagination-service.stub';
|
||||||
|
import { SearchServiceStub } from '../../../shared/testing/search-service.stub';
|
||||||
|
import { SearchService } from '../../../core/shared/search/search.service';
|
||||||
|
import { VarDirective } from '../../../shared/utils/var.directive';
|
||||||
|
import { TranslateModule } from '@ngx-translate/core';
|
||||||
|
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
|
||||||
|
|
||||||
|
describe('CollectionRecentlyAddedComponent', () => {
|
||||||
|
let component: CollectionRecentlyAddedComponent;
|
||||||
|
let fixture: ComponentFixture<CollectionRecentlyAddedComponent>;
|
||||||
|
|
||||||
|
let activatedRoute: ActivatedRouteStub;
|
||||||
|
let paginationService: PaginationServiceStub;
|
||||||
|
let searchService: SearchServiceStub;
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
activatedRoute = new ActivatedRouteStub();
|
||||||
|
paginationService = new PaginationServiceStub();
|
||||||
|
searchService = new SearchServiceStub();
|
||||||
|
|
||||||
|
await TestBed.configureTestingModule({
|
||||||
|
declarations: [
|
||||||
|
CollectionRecentlyAddedComponent,
|
||||||
|
VarDirective,
|
||||||
|
],
|
||||||
|
imports: [
|
||||||
|
TranslateModule.forRoot(),
|
||||||
|
],
|
||||||
|
providers: [
|
||||||
|
{ provide: ActivatedRoute, useValue: activatedRoute },
|
||||||
|
{ provide: APP_CONFIG, useValue: environment },
|
||||||
|
{ provide: PaginationService, useValue: paginationService },
|
||||||
|
{ provide: SearchService, useValue: SearchServiceStub },
|
||||||
|
],
|
||||||
|
schemas: [CUSTOM_ELEMENTS_SCHEMA],
|
||||||
|
}).compileComponents();
|
||||||
|
|
||||||
|
fixture = TestBed.createComponent(CollectionRecentlyAddedComponent);
|
||||||
|
component = fixture.componentInstance;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create', () => {
|
||||||
|
expect(component).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
@@ -0,0 +1,82 @@
|
|||||||
|
import { Component, OnInit, Inject, OnDestroy } from '@angular/core';
|
||||||
|
import { Observable, combineLatest as observableCombineLatest } from 'rxjs';
|
||||||
|
import { RemoteData } from '../../../core/data/remote-data';
|
||||||
|
import { PaginatedList } from '../../../core/data/paginated-list.model';
|
||||||
|
import { Item } from '../../../core/shared/item.model';
|
||||||
|
import { switchMap, map, startWith, take } from 'rxjs/operators';
|
||||||
|
import { getFirstSucceededRemoteData, toDSpaceObjectListRD } from '../../../core/shared/operators';
|
||||||
|
import { PaginatedSearchOptions } from '../../../shared/search/models/paginated-search-options.model';
|
||||||
|
import { DSpaceObjectType } from '../../../core/shared/dspace-object-type.model';
|
||||||
|
import { BROWSE_LINKS_TO_FOLLOW } from '../../../core/browse/browse.service';
|
||||||
|
import { PaginationService } from '../../../core/pagination/pagination.service';
|
||||||
|
import { PaginationComponentOptions } from '../../../shared/pagination/pagination-component-options.model';
|
||||||
|
import { SortOptions, SortDirection } from '../../../core/cache/models/sort-options.model';
|
||||||
|
import { APP_CONFIG, AppConfig } from '../../../../config/app-config.interface';
|
||||||
|
import { SearchService } from '../../../core/shared/search/search.service';
|
||||||
|
import { Collection } from '../../../core/shared/collection.model';
|
||||||
|
import { ActivatedRoute, Data } from '@angular/router';
|
||||||
|
import { fadeIn } from '../../../shared/animations/fade';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'ds-collection-recently-added',
|
||||||
|
templateUrl: './collection-recently-added.component.html',
|
||||||
|
styleUrls: ['./collection-recently-added.component.scss'],
|
||||||
|
animations: [fadeIn],
|
||||||
|
})
|
||||||
|
export class CollectionRecentlyAddedComponent implements OnInit, OnDestroy {
|
||||||
|
|
||||||
|
paginationConfig: PaginationComponentOptions;
|
||||||
|
|
||||||
|
sortConfig: SortOptions;
|
||||||
|
|
||||||
|
collectionRD$: Observable<RemoteData<Collection>>;
|
||||||
|
|
||||||
|
itemRD$: Observable<RemoteData<PaginatedList<Item>>>;
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
@Inject(APP_CONFIG) protected appConfig: AppConfig,
|
||||||
|
protected paginationService: PaginationService,
|
||||||
|
protected route: ActivatedRoute,
|
||||||
|
protected searchService: SearchService,
|
||||||
|
) {
|
||||||
|
this.paginationConfig = Object.assign(new PaginationComponentOptions(), {
|
||||||
|
id: 'cp',
|
||||||
|
currentPage: 1,
|
||||||
|
pageSize: this.appConfig.browseBy.pageSize,
|
||||||
|
});
|
||||||
|
|
||||||
|
this.sortConfig = new SortOptions('dc.date.accessioned', SortDirection.DESC);
|
||||||
|
}
|
||||||
|
|
||||||
|
ngOnInit(): void {
|
||||||
|
this.collectionRD$ = this.route.data.pipe(
|
||||||
|
map((data: Data) => data.dso as RemoteData<Collection>),
|
||||||
|
take(1),
|
||||||
|
);
|
||||||
|
|
||||||
|
this.itemRD$ = observableCombineLatest([
|
||||||
|
this.paginationService.getCurrentPagination(this.paginationConfig.id, this.paginationConfig),
|
||||||
|
this.paginationService.getCurrentSort(this.paginationConfig.id, this.sortConfig),
|
||||||
|
]).pipe(
|
||||||
|
switchMap(([currentPagination, currentSort]: [PaginationComponentOptions, SortOptions]) => this.collectionRD$.pipe(
|
||||||
|
getFirstSucceededRemoteData(),
|
||||||
|
map((rd: RemoteData<Collection>) => rd.payload.id),
|
||||||
|
switchMap((id: string) => this.searchService.search<Item>(
|
||||||
|
new PaginatedSearchOptions({
|
||||||
|
scope: id,
|
||||||
|
pagination: currentPagination,
|
||||||
|
sort: currentSort,
|
||||||
|
dsoTypes: [DSpaceObjectType.ITEM]
|
||||||
|
}), null, true, true, ...BROWSE_LINKS_TO_FOLLOW).pipe(
|
||||||
|
toDSpaceObjectListRD()
|
||||||
|
) as Observable<RemoteData<PaginatedList<Item>>>),
|
||||||
|
startWith(undefined), // Make sure switching pages shows loading component
|
||||||
|
)),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
ngOnDestroy(): void {
|
||||||
|
this.paginationService.clearPagination(this.paginationConfig.id);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@@ -15,6 +15,10 @@ import { LinkMenuItemModel } from '../shared/menu/menu-item/models/link.model';
|
|||||||
import { ThemedCommunityPageComponent } from './themed-community-page.component';
|
import { ThemedCommunityPageComponent } from './themed-community-page.component';
|
||||||
import { MenuItemType } from '../shared/menu/menu-item-type.model';
|
import { MenuItemType } from '../shared/menu/menu-item-type.model';
|
||||||
import { DSOEditMenuResolver } from '../shared/dso-page/dso-edit-menu.resolver';
|
import { DSOEditMenuResolver } from '../shared/dso-page/dso-edit-menu.resolver';
|
||||||
|
import { SubComColSectionComponent } from './sections/sub-com-col-section/sub-com-col-section.component';
|
||||||
|
import { BrowseByI18nBreadcrumbResolver } from '../browse-by/browse-by-i18n-breadcrumb.resolver';
|
||||||
|
import { BrowseByGuard } from '../browse-by/browse-by-guard';
|
||||||
|
import { ComcolBrowseByComponent } from '../shared/comcol/sections/comcol-browse-by/comcol-browse-by.component';
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
imports: [
|
imports: [
|
||||||
@@ -48,7 +52,23 @@ import { DSOEditMenuResolver } from '../shared/dso-page/dso-edit-menu.resolver';
|
|||||||
{
|
{
|
||||||
path: '',
|
path: '',
|
||||||
component: ThemedCommunityPageComponent,
|
component: ThemedCommunityPageComponent,
|
||||||
pathMatch: 'full',
|
children: [
|
||||||
|
{
|
||||||
|
path: '',
|
||||||
|
pathMatch: 'full',
|
||||||
|
component: SubComColSectionComponent,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: 'browse/:id',
|
||||||
|
pathMatch: 'full',
|
||||||
|
component: ComcolBrowseByComponent,
|
||||||
|
canActivate: [BrowseByGuard],
|
||||||
|
resolve: {
|
||||||
|
breadcrumb: BrowseByI18nBreadcrumbResolver,
|
||||||
|
},
|
||||||
|
data: { breadcrumbKey: 'browse.metadata' },
|
||||||
|
},
|
||||||
|
],
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
data: {
|
data: {
|
||||||
|
@@ -17,7 +17,7 @@
|
|||||||
</ds-comcol-page-content>
|
</ds-comcol-page-content>
|
||||||
<!-- News -->
|
<!-- News -->
|
||||||
<ds-comcol-page-content [content]="communityPayload.sidebarText" [hasInnerHtml]="true"
|
<ds-comcol-page-content [content]="communityPayload.sidebarText" [hasInnerHtml]="true"
|
||||||
[title]="'community.page.news'">
|
[title]="'community.page.news'">
|
||||||
</ds-comcol-page-content>
|
</ds-comcol-page-content>
|
||||||
</header>
|
</header>
|
||||||
<ds-dso-edit-menu></ds-dso-edit-menu>
|
<ds-dso-edit-menu></ds-dso-edit-menu>
|
||||||
@@ -28,10 +28,9 @@
|
|||||||
<ds-themed-comcol-page-browse-by [id]="communityPayload.id" [contentType]="communityPayload.type">
|
<ds-themed-comcol-page-browse-by [id]="communityPayload.id" [contentType]="communityPayload.type">
|
||||||
</ds-themed-comcol-page-browse-by>
|
</ds-themed-comcol-page-browse-by>
|
||||||
|
|
||||||
<ds-themed-community-page-sub-community-list [community]="communityPayload"></ds-themed-community-page-sub-community-list>
|
<router-outlet></router-outlet>
|
||||||
<ds-themed-community-page-sub-collection-list [community]="communityPayload"></ds-themed-community-page-sub-collection-list>
|
|
||||||
</section>
|
</section>
|
||||||
<footer *ngIf="communityPayload.copyrightText" class="border-top my-5 pt-4">
|
<footer *ngIf="communityPayload.copyrightText" class="border-top my-5 pt-4">
|
||||||
<!-- Copyright -->
|
<!-- Copyright -->
|
||||||
<ds-comcol-page-content [content]="communityPayload.copyrightText" [hasInnerHtml]="true">
|
<ds-comcol-page-content [content]="communityPayload.copyrightText" [hasInnerHtml]="true">
|
||||||
</ds-comcol-page-content>
|
</ds-comcol-page-content>
|
||||||
|
@@ -1,16 +1,10 @@
|
|||||||
import { mergeMap, filter, map } from 'rxjs/operators';
|
import { mergeMap, filter, map } from 'rxjs/operators';
|
||||||
import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core';
|
import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core';
|
||||||
import { ActivatedRoute, Router } from '@angular/router';
|
import { ActivatedRoute, Router } from '@angular/router';
|
||||||
|
|
||||||
import { Observable } from 'rxjs';
|
import { Observable } from 'rxjs';
|
||||||
import { CommunityDataService } from '../core/data/community-data.service';
|
|
||||||
import { RemoteData } from '../core/data/remote-data';
|
import { RemoteData } from '../core/data/remote-data';
|
||||||
import { Bitstream } from '../core/shared/bitstream.model';
|
import { Bitstream } from '../core/shared/bitstream.model';
|
||||||
|
|
||||||
import { Community } from '../core/shared/community.model';
|
import { Community } from '../core/shared/community.model';
|
||||||
|
|
||||||
import { MetadataService } from '../core/metadata/metadata.service';
|
|
||||||
|
|
||||||
import { fadeInOut } from '../shared/animations/fade';
|
import { fadeInOut } from '../shared/animations/fade';
|
||||||
import { hasValue } from '../shared/empty.util';
|
import { hasValue } from '../shared/empty.util';
|
||||||
import { getAllSucceededRemoteDataPayload} from '../core/shared/operators';
|
import { getAllSucceededRemoteDataPayload} from '../core/shared/operators';
|
||||||
@@ -53,8 +47,6 @@ export class CommunityPageComponent implements OnInit {
|
|||||||
communityPageRoute$: Observable<string>;
|
communityPageRoute$: Observable<string>;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private communityDataService: CommunityDataService,
|
|
||||||
private metadata: MetadataService,
|
|
||||||
private route: ActivatedRoute,
|
private route: ActivatedRoute,
|
||||||
private router: Router,
|
private router: Router,
|
||||||
private authService: AuthService,
|
private authService: AuthService,
|
||||||
|
@@ -4,9 +4,9 @@ import { CommonModule } from '@angular/common';
|
|||||||
import { SharedModule } from '../shared/shared.module';
|
import { SharedModule } from '../shared/shared.module';
|
||||||
|
|
||||||
import { CommunityPageComponent } from './community-page.component';
|
import { CommunityPageComponent } from './community-page.component';
|
||||||
import { CommunityPageSubCollectionListComponent } from './sub-collection-list/community-page-sub-collection-list.component';
|
import { CommunityPageSubCollectionListComponent } from './sections/sub-com-col-section/sub-collection-list/community-page-sub-collection-list.component';
|
||||||
import { CommunityPageRoutingModule } from './community-page-routing.module';
|
import { CommunityPageRoutingModule } from './community-page-routing.module';
|
||||||
import { CommunityPageSubCommunityListComponent } from './sub-community-list/community-page-sub-community-list.component';
|
import { CommunityPageSubCommunityListComponent } from './sections/sub-com-col-section/sub-community-list/community-page-sub-community-list.component';
|
||||||
import { CreateCommunityPageComponent } from './create-community-page/create-community-page.component';
|
import { CreateCommunityPageComponent } from './create-community-page/create-community-page.component';
|
||||||
import { DeleteCommunityPageComponent } from './delete-community-page/delete-community-page.component';
|
import { DeleteCommunityPageComponent } from './delete-community-page/delete-community-page.component';
|
||||||
import { StatisticsModule } from '../statistics/statistics.module';
|
import { StatisticsModule } from '../statistics/statistics.module';
|
||||||
@@ -15,20 +15,25 @@ import { ThemedCommunityPageComponent } from './themed-community-page.component'
|
|||||||
import { ComcolModule } from '../shared/comcol/comcol.module';
|
import { ComcolModule } from '../shared/comcol/comcol.module';
|
||||||
import {
|
import {
|
||||||
ThemedCommunityPageSubCommunityListComponent
|
ThemedCommunityPageSubCommunityListComponent
|
||||||
} from './sub-community-list/themed-community-page-sub-community-list.component';
|
} from './sections/sub-com-col-section/sub-community-list/themed-community-page-sub-community-list.component';
|
||||||
import {
|
import {
|
||||||
ThemedCollectionPageSubCollectionListComponent
|
ThemedCollectionPageSubCollectionListComponent
|
||||||
} from './sub-collection-list/themed-community-page-sub-collection-list.component';
|
} from './sections/sub-com-col-section/sub-collection-list/themed-community-page-sub-collection-list.component';
|
||||||
import { DsoPageModule } from '../shared/dso-page/dso-page.module';
|
import { DsoPageModule } from '../shared/dso-page/dso-page.module';
|
||||||
|
import { SubComColSectionComponent } from './sections/sub-com-col-section/sub-com-col-section.component';
|
||||||
|
import { BrowseByPageModule } from '../browse-by/browse-by-page.module';
|
||||||
|
|
||||||
const DECLARATIONS = [CommunityPageComponent,
|
const DECLARATIONS = [
|
||||||
|
CommunityPageComponent,
|
||||||
ThemedCommunityPageComponent,
|
ThemedCommunityPageComponent,
|
||||||
ThemedCommunityPageSubCommunityListComponent,
|
ThemedCommunityPageSubCommunityListComponent,
|
||||||
CommunityPageSubCollectionListComponent,
|
CommunityPageSubCollectionListComponent,
|
||||||
ThemedCollectionPageSubCollectionListComponent,
|
ThemedCollectionPageSubCollectionListComponent,
|
||||||
CommunityPageSubCommunityListComponent,
|
CommunityPageSubCommunityListComponent,
|
||||||
CreateCommunityPageComponent,
|
CreateCommunityPageComponent,
|
||||||
DeleteCommunityPageComponent];
|
DeleteCommunityPageComponent,
|
||||||
|
SubComColSectionComponent,
|
||||||
|
];
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
imports: [
|
imports: [
|
||||||
@@ -39,6 +44,7 @@ const DECLARATIONS = [CommunityPageComponent,
|
|||||||
CommunityFormModule,
|
CommunityFormModule,
|
||||||
ComcolModule,
|
ComcolModule,
|
||||||
DsoPageModule,
|
DsoPageModule,
|
||||||
|
BrowseByPageModule,
|
||||||
],
|
],
|
||||||
declarations: [
|
declarations: [
|
||||||
...DECLARATIONS
|
...DECLARATIONS
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
<ng-container *ngVar="(subCollectionsRDObs | async) as subCollectionsRD">
|
<ng-container *ngVar="(subCollectionsRDObs | async) as subCollectionsRD">
|
||||||
<div *ngIf="subCollectionsRD?.hasSucceeded && subCollectionsRD?.payload.totalElements > 0" @fadeIn>
|
<div *ngIf="subCollectionsRD?.hasSucceeded && subCollectionsRD?.payload.totalElements > 0" @fadeIn>
|
||||||
<h2>{{'community.sub-collection-list.head' | translate}}</h2>
|
<h3>{{'community.sub-collection-list.head' | translate}}</h3>
|
||||||
<ds-viewable-collection
|
<ds-viewable-collection
|
||||||
[config]="config"
|
[config]="config"
|
||||||
[sortConfig]="sortConfig"
|
[sortConfig]="sortConfig"
|
@@ -8,27 +8,27 @@ import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
|||||||
import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
|
import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
|
||||||
|
|
||||||
import { CommunityPageSubCollectionListComponent } from './community-page-sub-collection-list.component';
|
import { CommunityPageSubCollectionListComponent } from './community-page-sub-collection-list.component';
|
||||||
import { Community } from '../../core/shared/community.model';
|
import { Community } from '../../../../core/shared/community.model';
|
||||||
import { SharedModule } from '../../shared/shared.module';
|
import { SharedModule } from '../../../../shared/shared.module';
|
||||||
import { CollectionDataService } from '../../core/data/collection-data.service';
|
import { CollectionDataService } from '../../../../core/data/collection-data.service';
|
||||||
import { createSuccessfulRemoteDataObject$ } from '../../shared/remote-data.utils';
|
import { createSuccessfulRemoteDataObject$ } from '../../../../shared/remote-data.utils';
|
||||||
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 { HostWindowService } from '../../shared/host-window.service';
|
import { HostWindowService } from '../../../../shared/host-window.service';
|
||||||
import { HostWindowServiceStub } from '../../shared/testing/host-window-service.stub';
|
import { HostWindowServiceStub } from '../../../../shared/testing/host-window-service.stub';
|
||||||
import { SelectableListService } from '../../shared/object-list/selectable-list/selectable-list.service';
|
import { SelectableListService } from '../../../../shared/object-list/selectable-list/selectable-list.service';
|
||||||
import { PaginationService } from '../../core/pagination/pagination.service';
|
import { PaginationService } from '../../../../core/pagination/pagination.service';
|
||||||
import { getMockThemeService } from '../../shared/mocks/theme-service.mock';
|
import { getMockThemeService } from '../../../../shared/mocks/theme-service.mock';
|
||||||
import { ThemeService } from '../../shared/theme-support/theme.service';
|
import { ThemeService } from '../../../../shared/theme-support/theme.service';
|
||||||
import { PaginationServiceStub } from '../../shared/testing/pagination-service.stub';
|
import { PaginationServiceStub } from '../../../../shared/testing/pagination-service.stub';
|
||||||
import { FindListOptions } from '../../core/data/find-list-options.model';
|
import { FindListOptions } from '../../../../core/data/find-list-options.model';
|
||||||
import { GroupDataService } from '../../core/eperson/group-data.service';
|
import { GroupDataService } from '../../../../core/eperson/group-data.service';
|
||||||
import { LinkHeadService } from '../../core/services/link-head.service';
|
import { LinkHeadService } from '../../../../core/services/link-head.service';
|
||||||
import { ConfigurationDataService } from '../../core/data/configuration-data.service';
|
import { ConfigurationDataService } from '../../../../core/data/configuration-data.service';
|
||||||
import { SearchConfigurationService } from '../../core/shared/search/search-configuration.service';
|
import { SearchConfigurationService } from '../../../../core/shared/search/search-configuration.service';
|
||||||
import { ConfigurationProperty } from '../../core/shared/configuration-property.model';
|
import { ConfigurationProperty } from '../../../../core/shared/configuration-property.model';
|
||||||
import { createPaginatedList } from '../../shared/testing/utils.test';
|
import { createPaginatedList } from '../../../../shared/testing/utils.test';
|
||||||
import { SearchConfigurationServiceStub } from '../../shared/testing/search-configuration-service.stub';
|
import { SearchConfigurationServiceStub } from '../../../../shared/testing/search-configuration-service.stub';
|
||||||
|
|
||||||
describe('CommunityPageSubCollectionList Component', () => {
|
describe('CommunityPageSubCollectionList Component', () => {
|
||||||
let comp: CommunityPageSubCollectionListComponent;
|
let comp: CommunityPageSubCollectionListComponent;
|
@@ -1,19 +1,17 @@
|
|||||||
import { Component, Input, OnDestroy, OnInit } from '@angular/core';
|
import { Component, Input, OnDestroy, OnInit } from '@angular/core';
|
||||||
import { ActivatedRoute } from '@angular/router';
|
import { ActivatedRoute } from '@angular/router';
|
||||||
|
|
||||||
import { BehaviorSubject, combineLatest as observableCombineLatest, Subscription } from 'rxjs';
|
import { BehaviorSubject, combineLatest as observableCombineLatest, Subscription } from 'rxjs';
|
||||||
|
import { RemoteData } from '../../../../core/data/remote-data';
|
||||||
import { RemoteData } from '../../core/data/remote-data';
|
import { Collection } from '../../../../core/shared/collection.model';
|
||||||
import { Collection } from '../../core/shared/collection.model';
|
import { Community } from '../../../../core/shared/community.model';
|
||||||
import { Community } from '../../core/shared/community.model';
|
import { fadeIn } from '../../../../shared/animations/fade';
|
||||||
import { fadeIn } from '../../shared/animations/fade';
|
import { PaginatedList } from '../../../../core/data/paginated-list.model';
|
||||||
import { PaginatedList } from '../../core/data/paginated-list.model';
|
import { PaginationComponentOptions } from '../../../../shared/pagination/pagination-component-options.model';
|
||||||
import { PaginationComponentOptions } from '../../shared/pagination/pagination-component-options.model';
|
import { SortDirection, SortOptions } from '../../../../core/cache/models/sort-options.model';
|
||||||
import { SortDirection, SortOptions } from '../../core/cache/models/sort-options.model';
|
import { CollectionDataService } from '../../../../core/data/collection-data.service';
|
||||||
import { CollectionDataService } from '../../core/data/collection-data.service';
|
import { PaginationService } from '../../../../core/pagination/pagination.service';
|
||||||
import { PaginationService } from '../../core/pagination/pagination.service';
|
|
||||||
import { switchMap } from 'rxjs/operators';
|
import { switchMap } from 'rxjs/operators';
|
||||||
import { hasValue } from '../../shared/empty.util';
|
import { hasValue } from '../../../../shared/empty.util';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'ds-community-page-sub-collection-list',
|
selector: 'ds-community-page-sub-collection-list',
|
@@ -1,12 +1,12 @@
|
|||||||
import { ThemedComponent } from '../../shared/theme-support/themed.component';
|
import { ThemedComponent } from '../../../../shared/theme-support/themed.component';
|
||||||
import { CommunityPageSubCollectionListComponent } from './community-page-sub-collection-list.component';
|
import { CommunityPageSubCollectionListComponent } from './community-page-sub-collection-list.component';
|
||||||
import { Component, Input } from '@angular/core';
|
import { Component, Input } from '@angular/core';
|
||||||
import { Community } from '../../core/shared/community.model';
|
import { Community } from '../../../../core/shared/community.model';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'ds-themed-community-page-sub-collection-list',
|
selector: 'ds-themed-community-page-sub-collection-list',
|
||||||
styleUrls: [],
|
styleUrls: [],
|
||||||
templateUrl: '../../shared/theme-support/themed.component.html',
|
templateUrl: '../../../../shared/theme-support/themed.component.html',
|
||||||
})
|
})
|
||||||
export class ThemedCollectionPageSubCollectionListComponent extends ThemedComponent<CommunityPageSubCollectionListComponent> {
|
export class ThemedCollectionPageSubCollectionListComponent extends ThemedComponent<CommunityPageSubCollectionListComponent> {
|
||||||
@Input() community: Community;
|
@Input() community: Community;
|
||||||
@@ -18,7 +18,7 @@ export class ThemedCollectionPageSubCollectionListComponent extends ThemedCompon
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected importThemedComponent(themeName: string): Promise<any> {
|
protected importThemedComponent(themeName: string): Promise<any> {
|
||||||
return import(`../../../themes/${themeName}/app/community-page/sub-collection-list/community-page-sub-collection-list.component`);
|
return import(`../../../../../themes/${themeName}/app/community-page/sections/sub-com-col-section/sub-collection-list/community-page-sub-collection-list.component`);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected importUnthemedComponent(): Promise<any> {
|
protected importUnthemedComponent(): Promise<any> {
|
@@ -0,0 +1,8 @@
|
|||||||
|
<ng-container *ngIf="(community$ | async) as community">
|
||||||
|
<ds-themed-community-page-sub-community-list
|
||||||
|
[community]="community">
|
||||||
|
</ds-themed-community-page-sub-community-list>
|
||||||
|
<ds-themed-community-page-sub-collection-list
|
||||||
|
[community]="community">
|
||||||
|
</ds-themed-community-page-sub-collection-list>
|
||||||
|
</ng-container>
|
@@ -0,0 +1,32 @@
|
|||||||
|
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
import { SubComColSectionComponent } from './sub-com-col-section.component';
|
||||||
|
import { ActivatedRoute } from '@angular/router';
|
||||||
|
import { ActivatedRouteStub } from '../../../shared/testing/active-router.stub';
|
||||||
|
|
||||||
|
describe('SubComColSectionComponent', () => {
|
||||||
|
let component: SubComColSectionComponent;
|
||||||
|
let fixture: ComponentFixture<SubComColSectionComponent>;
|
||||||
|
|
||||||
|
let activatedRoute: ActivatedRouteStub;
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
activatedRoute = new ActivatedRouteStub();
|
||||||
|
|
||||||
|
await TestBed.configureTestingModule({
|
||||||
|
declarations: [
|
||||||
|
SubComColSectionComponent,
|
||||||
|
],
|
||||||
|
providers: [
|
||||||
|
{ provide: ActivatedRoute, useValue: activatedRoute },
|
||||||
|
],
|
||||||
|
}).compileComponents();
|
||||||
|
|
||||||
|
fixture = TestBed.createComponent(SubComColSectionComponent);
|
||||||
|
component = fixture.componentInstance;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create', () => {
|
||||||
|
expect(component).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
@@ -0,0 +1,28 @@
|
|||||||
|
import { Component, OnInit } from '@angular/core';
|
||||||
|
import { Observable } from 'rxjs';
|
||||||
|
import { RemoteData } from '../../../core/data/remote-data';
|
||||||
|
import { Community } from '../../../core/shared/community.model';
|
||||||
|
import { ActivatedRoute, Data } from '@angular/router';
|
||||||
|
import { map } from 'rxjs/operators';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'ds-sub-com-col-section',
|
||||||
|
templateUrl: './sub-com-col-section.component.html',
|
||||||
|
styleUrls: ['./sub-com-col-section.component.scss'],
|
||||||
|
})
|
||||||
|
export class SubComColSectionComponent implements OnInit {
|
||||||
|
|
||||||
|
community$: Observable<Community>;
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
private route: ActivatedRoute,
|
||||||
|
) {
|
||||||
|
}
|
||||||
|
|
||||||
|
ngOnInit(): void {
|
||||||
|
this.community$ = this.route.data.pipe(
|
||||||
|
map((data: Data) => (data.dso as RemoteData<Community>).payload),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@@ -1,6 +1,6 @@
|
|||||||
<ng-container *ngVar="(subCommunitiesRDObs | async) as subCommunitiesRD">
|
<ng-container *ngVar="(subCommunitiesRDObs | async) as subCommunitiesRD">
|
||||||
<div *ngIf="subCommunitiesRD?.hasSucceeded && subCommunitiesRD?.payload.totalElements > 0" @fadeIn>
|
<div *ngIf="subCommunitiesRD?.hasSucceeded && subCommunitiesRD?.payload.totalElements > 0" @fadeIn>
|
||||||
<h2>{{'community.sub-community-list.head' | translate}}</h2>
|
<h3>{{'community.sub-community-list.head' | translate}}</h3>
|
||||||
<ds-viewable-collection
|
<ds-viewable-collection
|
||||||
[config]="config"
|
[config]="config"
|
||||||
[sortConfig]="sortConfig"
|
[sortConfig]="sortConfig"
|
@@ -8,27 +8,27 @@ import { By } from '@angular/platform-browser';
|
|||||||
import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
|
import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
|
||||||
|
|
||||||
import { CommunityPageSubCommunityListComponent } from './community-page-sub-community-list.component';
|
import { CommunityPageSubCommunityListComponent } from './community-page-sub-community-list.component';
|
||||||
import { Community } from '../../core/shared/community.model';
|
import { Community } from '../../../../core/shared/community.model';
|
||||||
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 { SharedModule } from '../../shared/shared.module';
|
import { SharedModule } from '../../../../shared/shared.module';
|
||||||
import { createSuccessfulRemoteDataObject$ } from '../../shared/remote-data.utils';
|
import { createSuccessfulRemoteDataObject$ } from '../../../../shared/remote-data.utils';
|
||||||
import { HostWindowService } from '../../shared/host-window.service';
|
import { HostWindowService } from '../../../../shared/host-window.service';
|
||||||
import { HostWindowServiceStub } from '../../shared/testing/host-window-service.stub';
|
import { HostWindowServiceStub } from '../../../../shared/testing/host-window-service.stub';
|
||||||
import { CommunityDataService } from '../../core/data/community-data.service';
|
import { CommunityDataService } from '../../../../core/data/community-data.service';
|
||||||
import { SelectableListService } from '../../shared/object-list/selectable-list/selectable-list.service';
|
import { SelectableListService } from '../../../../shared/object-list/selectable-list/selectable-list.service';
|
||||||
import { PaginationService } from '../../core/pagination/pagination.service';
|
import { PaginationService } from '../../../../core/pagination/pagination.service';
|
||||||
import { getMockThemeService } from '../../shared/mocks/theme-service.mock';
|
import { getMockThemeService } from '../../../../shared/mocks/theme-service.mock';
|
||||||
import { ThemeService } from '../../shared/theme-support/theme.service';
|
import { ThemeService } from '../../../../shared/theme-support/theme.service';
|
||||||
import { PaginationServiceStub } from '../../shared/testing/pagination-service.stub';
|
import { PaginationServiceStub } from '../../../../shared/testing/pagination-service.stub';
|
||||||
import { FindListOptions } from '../../core/data/find-list-options.model';
|
import { FindListOptions } from '../../../../core/data/find-list-options.model';
|
||||||
import { GroupDataService } from '../../core/eperson/group-data.service';
|
import { GroupDataService } from '../../../../core/eperson/group-data.service';
|
||||||
import { LinkHeadService } from '../../core/services/link-head.service';
|
import { LinkHeadService } from '../../../../core/services/link-head.service';
|
||||||
import { ConfigurationDataService } from '../../core/data/configuration-data.service';
|
import { ConfigurationDataService } from '../../../../core/data/configuration-data.service';
|
||||||
import { SearchConfigurationService } from '../../core/shared/search/search-configuration.service';
|
import { SearchConfigurationService } from '../../../../core/shared/search/search-configuration.service';
|
||||||
import { SearchConfigurationServiceStub } from '../../shared/testing/search-configuration-service.stub';
|
import { SearchConfigurationServiceStub } from '../../../../shared/testing/search-configuration-service.stub';
|
||||||
import { ConfigurationProperty } from '../../core/shared/configuration-property.model';
|
import { ConfigurationProperty } from '../../../../core/shared/configuration-property.model';
|
||||||
import { createPaginatedList } from '../../shared/testing/utils.test';
|
import { createPaginatedList } from '../../../../shared/testing/utils.test';
|
||||||
|
|
||||||
describe('CommunityPageSubCommunityListComponent Component', () => {
|
describe('CommunityPageSubCommunityListComponent Component', () => {
|
||||||
let comp: CommunityPageSubCommunityListComponent;
|
let comp: CommunityPageSubCommunityListComponent;
|
@@ -3,16 +3,16 @@ import { ActivatedRoute } from '@angular/router';
|
|||||||
|
|
||||||
import { BehaviorSubject, combineLatest as observableCombineLatest, Subscription } from 'rxjs';
|
import { BehaviorSubject, combineLatest as observableCombineLatest, Subscription } from 'rxjs';
|
||||||
|
|
||||||
import { RemoteData } from '../../core/data/remote-data';
|
import { RemoteData } from '../../../../core/data/remote-data';
|
||||||
import { Community } from '../../core/shared/community.model';
|
import { Community } from '../../../../core/shared/community.model';
|
||||||
import { fadeIn } from '../../shared/animations/fade';
|
import { fadeIn } from '../../../../shared/animations/fade';
|
||||||
import { PaginatedList } from '../../core/data/paginated-list.model';
|
import { PaginatedList } from '../../../../core/data/paginated-list.model';
|
||||||
import { PaginationComponentOptions } from '../../shared/pagination/pagination-component-options.model';
|
import { PaginationComponentOptions } from '../../../../shared/pagination/pagination-component-options.model';
|
||||||
import { SortDirection, SortOptions } from '../../core/cache/models/sort-options.model';
|
import { SortDirection, SortOptions } from '../../../../core/cache/models/sort-options.model';
|
||||||
import { CommunityDataService } from '../../core/data/community-data.service';
|
import { CommunityDataService } from '../../../../core/data/community-data.service';
|
||||||
import { switchMap } from 'rxjs/operators';
|
import { switchMap } from 'rxjs/operators';
|
||||||
import { PaginationService } from '../../core/pagination/pagination.service';
|
import { PaginationService } from '../../../../core/pagination/pagination.service';
|
||||||
import { hasValue } from '../../shared/empty.util';
|
import { hasValue } from '../../../../shared/empty.util';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'ds-community-page-sub-community-list',
|
selector: 'ds-community-page-sub-community-list',
|
@@ -1,12 +1,12 @@
|
|||||||
import { ThemedComponent } from '../../shared/theme-support/themed.component';
|
import { ThemedComponent } from '../../../../shared/theme-support/themed.component';
|
||||||
import { CommunityPageSubCommunityListComponent } from './community-page-sub-community-list.component';
|
import { CommunityPageSubCommunityListComponent } from './community-page-sub-community-list.component';
|
||||||
import { Component, Input } from '@angular/core';
|
import { Component, Input } from '@angular/core';
|
||||||
import { Community } from '../../core/shared/community.model';
|
import { Community } from '../../../../core/shared/community.model';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'ds-themed-community-page-sub-community-list',
|
selector: 'ds-themed-community-page-sub-community-list',
|
||||||
styleUrls: [],
|
styleUrls: [],
|
||||||
templateUrl: '../../shared/theme-support/themed.component.html',
|
templateUrl: '../../../../shared/theme-support/themed.component.html',
|
||||||
})
|
})
|
||||||
export class ThemedCommunityPageSubCommunityListComponent extends ThemedComponent<CommunityPageSubCommunityListComponent> {
|
export class ThemedCommunityPageSubCommunityListComponent extends ThemedComponent<CommunityPageSubCommunityListComponent> {
|
||||||
|
|
||||||
@@ -19,7 +19,7 @@ export class ThemedCommunityPageSubCommunityListComponent extends ThemedComponen
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected importThemedComponent(themeName: string): Promise<any> {
|
protected importThemedComponent(themeName: string): Promise<any> {
|
||||||
return import(`../../../themes/${themeName}/app/community-page/sub-community-list/community-page-sub-community-list.component`);
|
return import(`../../../../../themes/${themeName}/app/community-page/sections/sub-com-col-section/sub-community-list/community-page-sub-community-list.component`);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected importUnthemedComponent(): Promise<any> {
|
protected importUnthemedComponent(): Promise<any> {
|
@@ -1,6 +1,7 @@
|
|||||||
<ng-container *ngVar="(objects$ | async) as objects">
|
<ng-container *ngVar="(objects$ | async) as objects">
|
||||||
<h1 [ngClass]="{'sr-only': parentname }">{{title | translate}}</h1>
|
<h1 *ngIf="displayTitle">{{title | translate}}</h1>
|
||||||
<ng-container *ngComponentOutlet="getStartsWithComponent(); injector: objectInjector;"></ng-container>
|
<ds-starts-with-loader [paginationId]="paginationConfig?.id" [startsWithOptions]="startsWithOptions" [type]="type">
|
||||||
|
</ds-starts-with-loader>
|
||||||
<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-themed-results-back-button [back]="back" [buttonLabel]="buttonLabel"></ds-themed-results-back-button>
|
<ds-themed-results-back-button [back]="back" [buttonLabel]="buttonLabel"></ds-themed-results-back-button>
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
import { Component, EventEmitter, Injector, Input, OnDestroy, OnInit, Output } from '@angular/core';
|
import { Component, EventEmitter, Injector, Input, OnDestroy, OnInit, Output, OnChanges } from '@angular/core';
|
||||||
import { RemoteData } from '../../core/data/remote-data';
|
import { RemoteData } from '../../core/data/remote-data';
|
||||||
import { PaginatedList } from '../../core/data/paginated-list.model';
|
import { PaginatedList } from '../../core/data/paginated-list.model';
|
||||||
import { PaginationComponentOptions } from '../pagination/pagination-component-options.model';
|
import { PaginationComponentOptions } from '../pagination/pagination-component-options.model';
|
||||||
@@ -6,7 +6,7 @@ import { SortDirection, SortOptions } from '../../core/cache/models/sort-options
|
|||||||
import { fadeIn, fadeInOut } from '../animations/fade';
|
import { fadeIn, fadeInOut } from '../animations/fade';
|
||||||
import { BehaviorSubject, combineLatest as observableCombineLatest, Observable, Subscription } from 'rxjs';
|
import { BehaviorSubject, combineLatest as observableCombineLatest, Observable, Subscription } from 'rxjs';
|
||||||
import { ListableObject } from '../object-collection/shared/listable-object.model';
|
import { ListableObject } from '../object-collection/shared/listable-object.model';
|
||||||
import { getStartsWithComponent, StartsWithType } from '../starts-with/starts-with-decorator';
|
import { StartsWithType } from '../starts-with/starts-with-decorator';
|
||||||
import { PaginationService } from '../../core/pagination/pagination.service';
|
import { PaginationService } from '../../core/pagination/pagination.service';
|
||||||
import { ViewMode } from '../../core/shared/view-mode.model';
|
import { ViewMode } from '../../core/shared/view-mode.model';
|
||||||
import { RouteService } from '../../core/services/route.service';
|
import { RouteService } from '../../core/services/route.service';
|
||||||
@@ -26,7 +26,7 @@ import { TranslateService } from '@ngx-translate/core';
|
|||||||
/**
|
/**
|
||||||
* Component to display a browse-by page for any ListableObject
|
* Component to display a browse-by page for any ListableObject
|
||||||
*/
|
*/
|
||||||
export class BrowseByComponent implements OnInit, OnDestroy {
|
export class BrowseByComponent implements OnInit, OnChanges, OnDestroy {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ViewMode that should be passed to {@link ListableObjectComponentLoaderComponent}.
|
* ViewMode that should be passed to {@link ListableObjectComponentLoaderComponent}.
|
||||||
@@ -39,9 +39,10 @@ export class BrowseByComponent implements OnInit, OnDestroy {
|
|||||||
@Input() title: string;
|
@Input() title: string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The parent name
|
* Whether the title should be displayed
|
||||||
*/
|
*/
|
||||||
@Input() parentname: string;
|
@Input() displayTitle = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The list of objects to display
|
* The list of objects to display
|
||||||
*/
|
*/
|
||||||
@@ -66,7 +67,7 @@ export class BrowseByComponent implements OnInit, OnDestroy {
|
|||||||
/**
|
/**
|
||||||
* The list of options to render for the StartsWith component
|
* The list of options to render for the StartsWith component
|
||||||
*/
|
*/
|
||||||
@Input() startsWithOptions = [];
|
@Input() startsWithOptions: (string | number)[] = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether or not the pagination should be rendered as simple previous and next buttons instead of the normal pagination
|
* Whether or not the pagination should be rendered as simple previous and next buttons instead of the normal pagination
|
||||||
@@ -98,16 +99,6 @@ export class BrowseByComponent implements OnInit, OnDestroy {
|
|||||||
*/
|
*/
|
||||||
@Output() sortDirectionChange = new EventEmitter<SortDirection>();
|
@Output() sortDirectionChange = new EventEmitter<SortDirection>();
|
||||||
|
|
||||||
/**
|
|
||||||
* An object injector used to inject the startsWithOptions to the switchable StartsWith component
|
|
||||||
*/
|
|
||||||
objectInjector: Injector;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Declare SortDirection enumeration to use it in the template
|
|
||||||
*/
|
|
||||||
public sortDirections = SortDirection;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Observable that tracks if the back button should be displayed based on the path parameters
|
* Observable that tracks if the back button should be displayed based on the path parameters
|
||||||
*/
|
*/
|
||||||
@@ -141,7 +132,7 @@ export class BrowseByComponent implements OnInit, OnDestroy {
|
|||||||
*/
|
*/
|
||||||
back = () => {
|
back = () => {
|
||||||
const page = +this.previousPage$.value > 1 ? +this.previousPage$.value : 1;
|
const page = +this.previousPage$.value > 1 ? +this.previousPage$.value : 1;
|
||||||
this.paginationService.updateRoute(this.paginationConfig.id, {page: page}, {[this.paginationConfig.id + '.return']: null, value: null, startsWith: null});
|
this.paginationService.updateRoute(this.paginationConfig.id, { page: page }, { [this.paginationConfig.id + '.return']: null, value: null, startsWith: null });
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -158,44 +149,19 @@ export class BrowseByComponent implements OnInit, OnDestroy {
|
|||||||
this.next.emit(true);
|
this.next.emit(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Change the page size
|
|
||||||
* @param size
|
|
||||||
*/
|
|
||||||
doPageSizeChange(size) {
|
|
||||||
this.paginationService.updateRoute(this.paginationConfig.id,{pageSize: size});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Change the sort direction
|
|
||||||
* @param direction
|
|
||||||
*/
|
|
||||||
doSortDirectionChange(direction) {
|
|
||||||
this.paginationService.updateRoute(this.paginationConfig.id,{sortDirection: direction});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the switchable StartsWith component dependant on the type
|
|
||||||
*/
|
|
||||||
getStartsWithComponent() {
|
|
||||||
return getStartsWithComponent(this.type);
|
|
||||||
}
|
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
this.objectInjector = Injector.create({
|
|
||||||
providers: [
|
|
||||||
{ provide: 'startsWithOptions', useFactory: () => (this.startsWithOptions), deps:[] },
|
|
||||||
{ provide: 'paginationId', useFactory: () => (this.paginationConfig?.id), deps:[] }
|
|
||||||
],
|
|
||||||
parent: this.injector
|
|
||||||
});
|
|
||||||
|
|
||||||
const startsWith$ = this.routeService.getQueryParameterValue('startsWith');
|
const startsWith$ = this.routeService.getQueryParameterValue('startsWith');
|
||||||
const value$ = this.routeService.getQueryParameterValue('value');
|
const value$ = this.routeService.getQueryParameterValue('value');
|
||||||
|
|
||||||
this.shouldDisplayResetButton$ = observableCombineLatest([startsWith$, value$]).pipe(
|
this.shouldDisplayResetButton$ = observableCombineLatest([startsWith$, value$]).pipe(
|
||||||
map(([startsWith, value]) => hasValue(startsWith) || hasValue(value))
|
map(([startsWith, value]) => hasValue(startsWith) || hasValue(value))
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
ngOnChanges(): void {
|
||||||
|
if (this.sub) {
|
||||||
|
this.sub.unsubscribe();
|
||||||
|
}
|
||||||
this.sub = this.routeService.getQueryParameterValue(this.paginationConfig.id + '.return').subscribe(this.previousPage$);
|
this.sub = this.routeService.getQueryParameterValue(this.paginationConfig.id + '.return').subscribe(this.previousPage$);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -21,7 +21,7 @@ export class ThemedBrowseByComponent extends ThemedComponent<BrowseByComponent>
|
|||||||
|
|
||||||
@Input() title: string;
|
@Input() title: string;
|
||||||
|
|
||||||
@Input() parentname: string;
|
@Input() displayTitle: boolean;
|
||||||
|
|
||||||
@Input() objects$: Observable<RemoteData<PaginatedList<ListableObject>>>;
|
@Input() objects$: Observable<RemoteData<PaginatedList<ListableObject>>>;
|
||||||
|
|
||||||
@@ -31,7 +31,7 @@ export class ThemedBrowseByComponent extends ThemedComponent<BrowseByComponent>
|
|||||||
|
|
||||||
@Input() type: StartsWithType;
|
@Input() type: StartsWithType;
|
||||||
|
|
||||||
@Input() startsWithOptions: number[];
|
@Input() startsWithOptions: (string | number)[];
|
||||||
|
|
||||||
@Input() showPaginator: boolean;
|
@Input() showPaginator: boolean;
|
||||||
|
|
||||||
@@ -47,7 +47,7 @@ export class ThemedBrowseByComponent extends ThemedComponent<BrowseByComponent>
|
|||||||
|
|
||||||
protected inAndOutputNames: (keyof BrowseByComponent & keyof this)[] = [
|
protected inAndOutputNames: (keyof BrowseByComponent & keyof this)[] = [
|
||||||
'title',
|
'title',
|
||||||
'parentname',
|
'displayTitle',
|
||||||
'objects$',
|
'objects$',
|
||||||
'paginationConfig',
|
'paginationConfig',
|
||||||
'sortConfig',
|
'sortConfig',
|
||||||
|
@@ -1,13 +1,17 @@
|
|||||||
<h2 class="comcol-browse-label h5">{{'browse.comcol.head' | translate}}</h2>
|
<h2 class="comcol-browse-label">{{'browse.comcol.head' | translate}}</h2>
|
||||||
<nav class="comcol-browse mb-4" aria-label="Browse Community or Collection">
|
<nav *ngIf="(allOptions$ | async) as allOptions" class="comcol-browse mb-4" aria-label="Browse Community or Collection">
|
||||||
<div class="d-none d-sm-block">
|
<div class="d-none d-sm-block">
|
||||||
|
|
||||||
<div class="list-group list-group-horizontal">
|
<div class="list-group list-group-horizontal" role="tablist">
|
||||||
<a *ngFor="let option of allOptions"
|
<a *ngFor="let option of allOptions"
|
||||||
|
[attr.aria-current]="(currentOption$ | async)?.id === option.id"
|
||||||
class="list-group-item"
|
class="list-group-item"
|
||||||
|
role="tab"
|
||||||
[routerLink]="option.routerLink"
|
[routerLink]="option.routerLink"
|
||||||
[queryParams]="option.params"
|
[queryParams]="option.params"
|
||||||
routerLinkActive="active">{{ option.label | translate }}</a>
|
[class.active]="(currentOption$ | async)?.id === option.id">
|
||||||
|
{{ option.label | translate }}
|
||||||
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -15,10 +19,12 @@
|
|||||||
<select name="browse-type"
|
<select name="browse-type"
|
||||||
class="form-control"
|
class="form-control"
|
||||||
aria-label="Browse Community or Collection"
|
aria-label="Browse Community or Collection"
|
||||||
(ngModelChange)="onSelectChange($event)" [ngModel]="currentOptionId$ | async">
|
(change)="onSelectChange($event)">
|
||||||
<option *ngFor="let option of allOptions"
|
<option *ngFor="let option of allOptions"
|
||||||
[ngValue]="option.id"
|
[value]="option.id"
|
||||||
[attr.selected]="(currentOptionId$ | async) === option.id ? 'selected' : null">{{ option.label | translate }}</option>
|
[attr.selected]="(currentOption$ | async)?.id === option.id ? 'selected' : null">
|
||||||
|
{{ option.label | translate }}
|
||||||
|
</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
import { Component, Input, OnInit } from '@angular/core';
|
import { Component, Input, OnInit, OnDestroy } from '@angular/core';
|
||||||
import { Observable } from 'rxjs';
|
import { BehaviorSubject, combineLatest, Observable, Subscription } from 'rxjs';
|
||||||
import { map } from 'rxjs/operators';
|
import { map, take } from 'rxjs/operators';
|
||||||
import { ActivatedRoute, Params, Router } from '@angular/router';
|
import { Router, EventType, Scroll } from '@angular/router';
|
||||||
import { getCommunityPageRoute } from '../../../community-page/community-page-routing-paths';
|
import { getCommunityPageRoute } from '../../../community-page/community-page-routing-paths';
|
||||||
import { getCollectionPageRoute } from '../../../collection-page/collection-page-routing-paths';
|
import { getCollectionPageRoute } from '../../../collection-page/collection-page-routing-paths';
|
||||||
import { getFirstCompletedRemoteData } from '../../../core/shared/operators';
|
import { getFirstCompletedRemoteData } from '../../../core/shared/operators';
|
||||||
@@ -26,62 +26,87 @@ export interface ComColPageNavOption {
|
|||||||
styleUrls: ['./comcol-page-browse-by.component.scss'],
|
styleUrls: ['./comcol-page-browse-by.component.scss'],
|
||||||
templateUrl: './comcol-page-browse-by.component.html'
|
templateUrl: './comcol-page-browse-by.component.html'
|
||||||
})
|
})
|
||||||
export class ComcolPageBrowseByComponent implements OnInit {
|
export class ComcolPageBrowseByComponent implements OnDestroy, OnInit {
|
||||||
/**
|
/**
|
||||||
* The ID of the Community or Collection
|
* The ID of the Community or Collection
|
||||||
*/
|
*/
|
||||||
@Input() id: string;
|
@Input() id: string;
|
||||||
@Input() contentType: string;
|
@Input() contentType: string;
|
||||||
|
|
||||||
allOptions: ComColPageNavOption[];
|
allOptions$: Observable<ComColPageNavOption[]>;
|
||||||
|
|
||||||
currentOptionId$: Observable<string>;
|
currentOption$: BehaviorSubject<ComColPageNavOption> = new BehaviorSubject(undefined);
|
||||||
|
|
||||||
|
subs: Subscription[] = [];
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private route: ActivatedRoute,
|
public router: Router,
|
||||||
private router: Router,
|
|
||||||
private browseService: BrowseService
|
private browseService: BrowseService
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
this.browseService.getBrowseDefinitions()
|
this.allOptions$ = this.browseService.getBrowseDefinitions().pipe(
|
||||||
.pipe(getFirstCompletedRemoteData<PaginatedList<BrowseDefinition>>())
|
getFirstCompletedRemoteData(),
|
||||||
.subscribe((browseDefListRD: RemoteData<PaginatedList<BrowseDefinition>>) => {
|
map((browseDefListRD: RemoteData<PaginatedList<BrowseDefinition>>) => {
|
||||||
|
const allOptions: ComColPageNavOption[] = [];
|
||||||
if (browseDefListRD.hasSucceeded) {
|
if (browseDefListRD.hasSucceeded) {
|
||||||
this.allOptions = browseDefListRD.payload.page
|
let comColRoute: string;
|
||||||
.map((config: BrowseDefinition) => ({
|
|
||||||
id: config.id,
|
|
||||||
label: `browse.comcol.by.${config.id}`,
|
|
||||||
routerLink: `/browse/${config.id}`,
|
|
||||||
params: { scope: this.id }
|
|
||||||
}));
|
|
||||||
|
|
||||||
if (this.contentType === 'collection') {
|
if (this.contentType === 'collection') {
|
||||||
this.allOptions = [{
|
comColRoute = getCollectionPageRoute(this.id);
|
||||||
id: this.id,
|
allOptions.push({
|
||||||
|
id: 'recent_submissions',
|
||||||
label: 'collection.page.browse.recent.head',
|
label: 'collection.page.browse.recent.head',
|
||||||
routerLink: getCollectionPageRoute(this.id)
|
routerLink: comColRoute,
|
||||||
}, ...this.allOptions];
|
});
|
||||||
} else if (this.contentType === 'community') {
|
} else if (this.contentType === 'community') {
|
||||||
this.allOptions = [{
|
comColRoute = getCommunityPageRoute(this.id);
|
||||||
id: this.id,
|
allOptions.push({
|
||||||
|
id: 'comcols',
|
||||||
label: 'community.all-lists.head',
|
label: 'community.all-lists.head',
|
||||||
routerLink: getCommunityPageRoute(this.id)
|
routerLink: comColRoute,
|
||||||
}, ...this.allOptions];
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
allOptions.push(...browseDefListRD.payload.page.map((config: BrowseDefinition) => ({
|
||||||
|
id: `browse_${config.id}`,
|
||||||
|
label: `browse.comcol.by.${config.id}`,
|
||||||
|
routerLink: `${comColRoute}/browse/${config.id}`,
|
||||||
|
})));
|
||||||
|
}
|
||||||
|
return allOptions;
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
|
this.subs.push(combineLatest([
|
||||||
|
this.allOptions$,
|
||||||
|
this.router.events,
|
||||||
|
]).subscribe(([navOptions, scrollEvent]: [ComColPageNavOption[], Scroll]) => {
|
||||||
|
if (scrollEvent.type === EventType.Scroll) {
|
||||||
|
for (let option of navOptions) {
|
||||||
|
if (option.routerLink === scrollEvent.routerEvent.urlAfterRedirects.split('?')[0]) {
|
||||||
|
this.currentOption$.next(option);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
}));
|
||||||
this.currentOptionId$ = this.route.params.pipe(
|
|
||||||
map((params: Params) => params.id)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onSelectChange(newId: string) {
|
ngOnDestroy(): void {
|
||||||
const selectedOption = this.allOptions
|
this.subs.forEach((sub: Subscription) => sub.unsubscribe());
|
||||||
.find((option: ComColPageNavOption) => option.id === newId);
|
}
|
||||||
|
|
||||||
this.router.navigate([selectedOption.routerLink], { queryParams: selectedOption.params });
|
onSelectChange(event: any): void {
|
||||||
|
this.allOptions$.pipe(
|
||||||
|
take(1),
|
||||||
|
).subscribe((allOptions: ComColPageNavOption[]) => {
|
||||||
|
for (let option of allOptions) {
|
||||||
|
if (option.id === event.target.value) {
|
||||||
|
this.currentOption$.next(option[0]);
|
||||||
|
void this.router.navigate([option.routerLink], { queryParams: option.params });
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -16,6 +16,8 @@ import { ComcolRoleComponent } from './comcol-forms/edit-comcol-page/comcol-role
|
|||||||
import { SharedModule } from '../shared.module';
|
import { SharedModule } from '../shared.module';
|
||||||
import { FormModule } from '../form/form.module';
|
import { FormModule } from '../form/form.module';
|
||||||
import { UploadModule } from '../upload/upload.module';
|
import { UploadModule } from '../upload/upload.module';
|
||||||
|
import { ComcolBrowseByComponent } from './sections/comcol-browse-by/comcol-browse-by.component';
|
||||||
|
import { BrowseByModule } from '../../browse-by/browse-by.module';
|
||||||
|
|
||||||
const COMPONENTS = [
|
const COMPONENTS = [
|
||||||
ComcolPageContentComponent,
|
ComcolPageContentComponent,
|
||||||
@@ -29,7 +31,8 @@ const COMPONENTS = [
|
|||||||
ComcolPageBrowseByComponent,
|
ComcolPageBrowseByComponent,
|
||||||
ThemedComcolPageBrowseByComponent,
|
ThemedComcolPageBrowseByComponent,
|
||||||
ComcolRoleComponent,
|
ComcolRoleComponent,
|
||||||
ThemedComcolPageHandleComponent
|
ThemedComcolPageHandleComponent,
|
||||||
|
ComcolBrowseByComponent,
|
||||||
];
|
];
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
@@ -41,6 +44,7 @@ const COMPONENTS = [
|
|||||||
FormModule,
|
FormModule,
|
||||||
SharedModule,
|
SharedModule,
|
||||||
UploadModule,
|
UploadModule,
|
||||||
|
BrowseByModule,
|
||||||
],
|
],
|
||||||
exports: [
|
exports: [
|
||||||
...COMPONENTS,
|
...COMPONENTS,
|
||||||
|
@@ -0,0 +1,4 @@
|
|||||||
|
<ds-browse-by-switcher [browseByType]="browseByType$ | async"
|
||||||
|
[displayTitle]="false"
|
||||||
|
[scope]="scope$ | async">
|
||||||
|
</ds-browse-by-switcher>
|
@@ -0,0 +1,69 @@
|
|||||||
|
// eslint-disable-next-line max-classes-per-file
|
||||||
|
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
import { ComcolBrowseByComponent } from './comcol-browse-by.component';
|
||||||
|
import { rendersBrowseBy } from '../../../../browse-by/browse-by-switcher/browse-by-decorator';
|
||||||
|
import { BrowseByDataType } from '../../../../browse-by/browse-by-switcher/browse-by-data-type';
|
||||||
|
import { Component } from '@angular/core';
|
||||||
|
import { BrowseDefinition } from '../../../../core/shared/browse-definition.model';
|
||||||
|
import { ActivatedRouteStub } from '../../../testing/active-router.stub';
|
||||||
|
import { ThemeService } from '../../../theme-support/theme.service';
|
||||||
|
import { getMockThemeService } from '../../../mocks/theme-service.mock';
|
||||||
|
import { BrowseBySwitcherComponent } from '../../../../browse-by/browse-by-switcher/browse-by-switcher.component';
|
||||||
|
import { DynamicComponentLoaderDirective } from '../../../abstract-component-loader/dynamic-component-loader.directive';
|
||||||
|
import { ActivatedRoute } from '@angular/router';
|
||||||
|
import { By } from '@angular/platform-browser';
|
||||||
|
|
||||||
|
@rendersBrowseBy('ComcolBrowseByComponent' as BrowseByDataType)
|
||||||
|
@Component({
|
||||||
|
// eslint-disable-next-line @angular-eslint/component-selector
|
||||||
|
selector: '',
|
||||||
|
template: '<span id="ComcolBrowseByComponent"></span>',
|
||||||
|
})
|
||||||
|
class BrowseByTestComponent {
|
||||||
|
}
|
||||||
|
|
||||||
|
class TestBrowseByPageBrowseDefinition extends BrowseDefinition {
|
||||||
|
getRenderType(): BrowseByDataType {
|
||||||
|
return 'ComcolBrowseByComponent' as BrowseByDataType;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
describe('ComcolBrowseByComponent', () => {
|
||||||
|
let component: ComcolBrowseByComponent;
|
||||||
|
let fixture: ComponentFixture<ComcolBrowseByComponent>;
|
||||||
|
|
||||||
|
let activatedRoute: ActivatedRouteStub;
|
||||||
|
let themeService: ThemeService;
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
activatedRoute = new ActivatedRouteStub();
|
||||||
|
themeService = getMockThemeService();
|
||||||
|
|
||||||
|
await TestBed.configureTestingModule({
|
||||||
|
declarations: [
|
||||||
|
ComcolBrowseByComponent,
|
||||||
|
BrowseBySwitcherComponent,
|
||||||
|
DynamicComponentLoaderDirective,
|
||||||
|
],
|
||||||
|
providers: [
|
||||||
|
BrowseByTestComponent,
|
||||||
|
{ provide: ActivatedRoute, useValue: activatedRoute },
|
||||||
|
{ provide: ThemeService, useValue: themeService },
|
||||||
|
],
|
||||||
|
}).compileComponents();
|
||||||
|
|
||||||
|
fixture = TestBed.createComponent(ComcolBrowseByComponent);
|
||||||
|
component = fixture.componentInstance;
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create the correct browse section based on the route browseDefinition', () => {
|
||||||
|
activatedRoute.testData = {
|
||||||
|
browseDefinition: new TestBrowseByPageBrowseDefinition(),
|
||||||
|
};
|
||||||
|
|
||||||
|
fixture.detectChanges();
|
||||||
|
|
||||||
|
expect(component).toBeTruthy();
|
||||||
|
expect(fixture.debugElement.query(By.css('#ComcolBrowseByComponent'))).not.toBeNull();
|
||||||
|
});
|
||||||
|
});
|
@@ -0,0 +1,36 @@
|
|||||||
|
import { Component, OnInit } from '@angular/core';
|
||||||
|
import { Observable } from 'rxjs';
|
||||||
|
import { BrowseByDataType } from '../../../../browse-by/browse-by-switcher/browse-by-data-type';
|
||||||
|
import { ActivatedRoute, Data } from '@angular/router';
|
||||||
|
import { map } from 'rxjs/operators';
|
||||||
|
import { BrowseDefinition } from '../../../../core/shared/browse-definition.model';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'ds-comcol-browse-by',
|
||||||
|
templateUrl: './comcol-browse-by.component.html',
|
||||||
|
styleUrls: ['./comcol-browse-by.component.scss'],
|
||||||
|
})
|
||||||
|
export class ComcolBrowseByComponent implements OnInit {
|
||||||
|
|
||||||
|
browseByType$: Observable<BrowseByDataType>;
|
||||||
|
|
||||||
|
scope$: Observable<string>;
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
protected route: ActivatedRoute,
|
||||||
|
) {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fetch the correct browse-by component by using the relevant config from the route data
|
||||||
|
*/
|
||||||
|
ngOnInit(): void {
|
||||||
|
this.browseByType$ = this.route.data.pipe(
|
||||||
|
map((data: { browseDefinition: BrowseDefinition }) => data.browseDefinition.getRenderType()),
|
||||||
|
);
|
||||||
|
this.scope$ = this.route.data.pipe(
|
||||||
|
map((data: Data) => data.scope),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@@ -6,7 +6,7 @@ import { ViewMode } from '../../../core/shared/view-mode.model';
|
|||||||
import { listableObjectComponent } from '../../object-collection/shared/listable-object/listable-object.decorator';
|
import { listableObjectComponent } from '../../object-collection/shared/listable-object/listable-object.decorator';
|
||||||
import { PaginationService } from '../../../core/pagination/pagination.service';
|
import { PaginationService } from '../../../core/pagination/pagination.service';
|
||||||
import { Params } from '@angular/router';
|
import { Params } from '@angular/router';
|
||||||
import { BBM_PAGINATION_ID } from '../../../browse-by/browse-by-metadata-page/browse-by-metadata-page.component';
|
import { BBM_PAGINATION_ID } from '../../../browse-by/browse-by-metadata/browse-by-metadata.component';
|
||||||
import { RouteService } from 'src/app/core/services/route.service';
|
import { RouteService } from 'src/app/core/services/route.service';
|
||||||
import { Observable } from 'rxjs';
|
import { Observable } from 'rxjs';
|
||||||
import { map } from 'rxjs/operators';
|
import { map } from 'rxjs/operators';
|
||||||
|
@@ -282,6 +282,7 @@ import { NgxPaginationModule } from 'ngx-pagination';
|
|||||||
import { ThemedUserMenuComponent } from './auth-nav-menu/user-menu/themed-user-menu.component';
|
import { ThemedUserMenuComponent } from './auth-nav-menu/user-menu/themed-user-menu.component';
|
||||||
import { ThemedLangSwitchComponent } from './lang-switch/themed-lang-switch.component';
|
import { ThemedLangSwitchComponent } from './lang-switch/themed-lang-switch.component';
|
||||||
import { DynamicComponentLoaderDirective } from './abstract-component-loader/dynamic-component-loader.directive';
|
import { DynamicComponentLoaderDirective } from './abstract-component-loader/dynamic-component-loader.directive';
|
||||||
|
import { StartsWithLoaderComponent } from './starts-with/starts-with-loader.component';
|
||||||
|
|
||||||
const MODULES = [
|
const MODULES = [
|
||||||
CommonModule,
|
CommonModule,
|
||||||
@@ -377,7 +378,7 @@ const COMPONENTS = [
|
|||||||
ThemedStatusBadgeComponent,
|
ThemedStatusBadgeComponent,
|
||||||
BadgesComponent,
|
BadgesComponent,
|
||||||
ThemedBadgesComponent,
|
ThemedBadgesComponent,
|
||||||
|
StartsWithLoaderComponent,
|
||||||
ItemSelectComponent,
|
ItemSelectComponent,
|
||||||
CollectionSelectComponent,
|
CollectionSelectComponent,
|
||||||
MetadataRepresentationLoaderComponent,
|
MetadataRepresentationLoaderComponent,
|
||||||
|
@@ -3,9 +3,8 @@ import { CommonModule } from '@angular/common';
|
|||||||
import { RouterTestingModule } from '@angular/router/testing';
|
import { RouterTestingModule } from '@angular/router/testing';
|
||||||
import { TranslateModule } from '@ngx-translate/core';
|
import { TranslateModule } from '@ngx-translate/core';
|
||||||
import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
|
import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
|
||||||
import { ActivatedRoute, NavigationExtras, Router } from '@angular/router';
|
import { ActivatedRoute, Router } from '@angular/router';
|
||||||
import { NO_ERRORS_SCHEMA } from '@angular/core';
|
import { NO_ERRORS_SCHEMA } from '@angular/core';
|
||||||
import { of as observableOf } from 'rxjs';
|
|
||||||
import { By } from '@angular/platform-browser';
|
import { By } from '@angular/platform-browser';
|
||||||
import { StartsWithDateComponent } from './starts-with-date.component';
|
import { StartsWithDateComponent } from './starts-with-date.component';
|
||||||
import { ActivatedRouteStub } from '../../testing/active-router.stub';
|
import { ActivatedRouteStub } from '../../testing/active-router.stub';
|
||||||
@@ -17,29 +16,25 @@ import { PaginationServiceStub } from '../../testing/pagination-service.stub';
|
|||||||
describe('StartsWithDateComponent', () => {
|
describe('StartsWithDateComponent', () => {
|
||||||
let comp: StartsWithDateComponent;
|
let comp: StartsWithDateComponent;
|
||||||
let fixture: ComponentFixture<StartsWithDateComponent>;
|
let fixture: ComponentFixture<StartsWithDateComponent>;
|
||||||
let route: ActivatedRoute;
|
|
||||||
let router: Router;
|
let route: ActivatedRouteStub;
|
||||||
let paginationService;
|
let paginationService: PaginationServiceStub;
|
||||||
|
let router: RouterStub;
|
||||||
|
|
||||||
const options = [2019, 2018, 2017, 2016, 2015];
|
const options = [2019, 2018, 2017, 2016, 2015];
|
||||||
|
|
||||||
const activatedRouteStub = Object.assign(new ActivatedRouteStub(), {
|
beforeEach(waitForAsync(async () => {
|
||||||
params: observableOf({}),
|
route = new ActivatedRouteStub();
|
||||||
queryParams: observableOf({})
|
router = new RouterStub();
|
||||||
});
|
paginationService = new PaginationServiceStub();
|
||||||
|
|
||||||
paginationService = new PaginationServiceStub();
|
await TestBed.configureTestingModule({
|
||||||
|
|
||||||
beforeEach(waitForAsync(() => {
|
|
||||||
TestBed.configureTestingModule({
|
|
||||||
imports: [CommonModule, RouterTestingModule.withRoutes([]), TranslateModule.forRoot(), NgbModule],
|
imports: [CommonModule, RouterTestingModule.withRoutes([]), TranslateModule.forRoot(), NgbModule],
|
||||||
declarations: [StartsWithDateComponent, EnumKeysPipe],
|
declarations: [StartsWithDateComponent, EnumKeysPipe],
|
||||||
providers: [
|
providers: [
|
||||||
{ provide: 'startsWithOptions', useValue: options },
|
{ provide: ActivatedRoute, useValue: route },
|
||||||
{ provide: 'paginationId', useValue: 'page-id' },
|
|
||||||
{ provide: ActivatedRoute, useValue: activatedRouteStub },
|
|
||||||
{ provide: PaginationService, useValue: paginationService },
|
{ provide: PaginationService, useValue: paginationService },
|
||||||
{ provide: Router, useValue: new RouterStub() }
|
{ provide: Router, useValue: router },
|
||||||
],
|
],
|
||||||
schemas: [NO_ERRORS_SCHEMA]
|
schemas: [NO_ERRORS_SCHEMA]
|
||||||
}).compileComponents();
|
}).compileComponents();
|
||||||
@@ -48,9 +43,9 @@ describe('StartsWithDateComponent', () => {
|
|||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
fixture = TestBed.createComponent(StartsWithDateComponent);
|
fixture = TestBed.createComponent(StartsWithDateComponent);
|
||||||
comp = fixture.componentInstance;
|
comp = fixture.componentInstance;
|
||||||
|
comp.paginationId = 'page-id';
|
||||||
|
comp.startsWithOptions = options;
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
route = (comp as any).route;
|
|
||||||
router = (comp as any).router;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should create a FormGroup containing a startsWith FormControl', () => {
|
it('should create a FormGroup containing a startsWith FormControl', () => {
|
||||||
@@ -156,10 +151,6 @@ describe('StartsWithDateComponent', () => {
|
|||||||
describe('when filling in the input form', () => {
|
describe('when filling in the input form', () => {
|
||||||
let form;
|
let form;
|
||||||
const expectedValue = '2015';
|
const expectedValue = '2015';
|
||||||
const extras: NavigationExtras = {
|
|
||||||
queryParams: Object.assign({ startsWith: expectedValue }),
|
|
||||||
queryParamsHandling: 'merge'
|
|
||||||
};
|
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
form = fixture.debugElement.query(By.css('form'));
|
form = fixture.debugElement.query(By.css('form'));
|
||||||
|
@@ -1,10 +1,7 @@
|
|||||||
import { Component, Inject } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
import { ActivatedRoute, Router } from '@angular/router';
|
|
||||||
|
|
||||||
import { renderStartsWithFor, StartsWithType } from '../starts-with-decorator';
|
import { renderStartsWithFor, StartsWithType } from '../starts-with-decorator';
|
||||||
import { StartsWithAbstractComponent } from '../starts-with-abstract.component';
|
import { StartsWithAbstractComponent } from '../starts-with-abstract.component';
|
||||||
import { hasValue } from '../../empty.util';
|
import { hasValue } from '../../empty.util';
|
||||||
import { PaginationService } from '../../../core/pagination/pagination.service';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A switchable component rendering StartsWith options for the type "Date".
|
* A switchable component rendering StartsWith options for the type "Date".
|
||||||
@@ -16,7 +13,7 @@ import { PaginationService } from '../../../core/pagination/pagination.service';
|
|||||||
templateUrl: './starts-with-date.component.html'
|
templateUrl: './starts-with-date.component.html'
|
||||||
})
|
})
|
||||||
@renderStartsWithFor(StartsWithType.date)
|
@renderStartsWithFor(StartsWithType.date)
|
||||||
export class StartsWithDateComponent extends StartsWithAbstractComponent {
|
export class StartsWithDateComponent extends StartsWithAbstractComponent implements OnInit {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A list of options for months to select from
|
* A list of options for months to select from
|
||||||
@@ -33,14 +30,6 @@ export class StartsWithDateComponent extends StartsWithAbstractComponent {
|
|||||||
*/
|
*/
|
||||||
startsWithYear: number;
|
startsWithYear: number;
|
||||||
|
|
||||||
public constructor(@Inject('startsWithOptions') public startsWithOptions: any[],
|
|
||||||
@Inject('paginationId') public paginationId: string,
|
|
||||||
protected paginationService: PaginationService,
|
|
||||||
protected route: ActivatedRoute,
|
|
||||||
protected router: Router) {
|
|
||||||
super(startsWithOptions, paginationId, paginationService, route, router);
|
|
||||||
}
|
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.monthOptions = [
|
this.monthOptions = [
|
||||||
'none',
|
'none',
|
||||||
@@ -133,13 +122,6 @@ export class StartsWithDateComponent extends StartsWithAbstractComponent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get startsWithYear as a number;
|
|
||||||
*/
|
|
||||||
getStartsWithYear() {
|
|
||||||
return this.startsWithYear;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get startsWithMonth as a number;
|
* Get startsWithMonth as a number;
|
||||||
*/
|
*/
|
||||||
|
@@ -1,9 +1,10 @@
|
|||||||
import { Component, Inject, OnDestroy, OnInit } from '@angular/core';
|
import { Component, OnDestroy, OnInit, Input } from '@angular/core';
|
||||||
import { ActivatedRoute, Router } from '@angular/router';
|
import { ActivatedRoute, Router } from '@angular/router';
|
||||||
import { Subscription } from 'rxjs';
|
import { Subscription } from 'rxjs';
|
||||||
import { UntypedFormControl, UntypedFormGroup } from '@angular/forms';
|
import { UntypedFormControl, UntypedFormGroup } from '@angular/forms';
|
||||||
import { hasValue } from '../empty.util';
|
import { hasValue } from '../empty.util';
|
||||||
import { PaginationService } from '../../core/pagination/pagination.service';
|
import { PaginationService } from '../../core/pagination/pagination.service';
|
||||||
|
import { StartsWithType } from './starts-with-decorator';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An abstract component to render StartsWith options
|
* An abstract component to render StartsWith options
|
||||||
@@ -13,6 +14,13 @@ import { PaginationService } from '../../core/pagination/pagination.service';
|
|||||||
template: ''
|
template: ''
|
||||||
})
|
})
|
||||||
export abstract class StartsWithAbstractComponent implements OnInit, OnDestroy {
|
export abstract class StartsWithAbstractComponent implements OnInit, OnDestroy {
|
||||||
|
|
||||||
|
@Input() paginationId: string;
|
||||||
|
|
||||||
|
@Input() startsWithOptions: (string | number)[];
|
||||||
|
|
||||||
|
@Input() type: StartsWithType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The currently selected startsWith in string format
|
* The currently selected startsWith in string format
|
||||||
*/
|
*/
|
||||||
@@ -28,11 +36,11 @@ export abstract class StartsWithAbstractComponent implements OnInit, OnDestroy {
|
|||||||
*/
|
*/
|
||||||
subs: Subscription[] = [];
|
subs: Subscription[] = [];
|
||||||
|
|
||||||
public constructor(@Inject('startsWithOptions') public startsWithOptions: any[],
|
public constructor(
|
||||||
@Inject('paginationId') public paginationId: string,
|
protected paginationService: PaginationService,
|
||||||
protected paginationService: PaginationService,
|
protected route: ActivatedRoute,
|
||||||
protected route: ActivatedRoute,
|
protected router: Router,
|
||||||
protected router: Router) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
@@ -55,15 +63,6 @@ export abstract class StartsWithAbstractComponent implements OnInit, OnDestroy {
|
|||||||
return this.startsWith;
|
return this.startsWith;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the startsWith by event
|
|
||||||
* @param event
|
|
||||||
*/
|
|
||||||
setStartsWithEvent(event: Event) {
|
|
||||||
this.startsWith = (event.target as HTMLInputElement).value;
|
|
||||||
this.setStartsWithParam();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the startsWith by string
|
* Set the startsWith by string
|
||||||
* @param startsWith
|
* @param startsWith
|
||||||
@@ -82,7 +81,7 @@ export abstract class StartsWithAbstractComponent implements OnInit, OnDestroy {
|
|||||||
if (resetPage) {
|
if (resetPage) {
|
||||||
this.paginationService.updateRoute(this.paginationId, {page: 1}, { startsWith: this.startsWith });
|
this.paginationService.updateRoute(this.paginationId, {page: 1}, { startsWith: this.startsWith });
|
||||||
} else {
|
} else {
|
||||||
this.router.navigate([], {
|
void this.router.navigate([], {
|
||||||
queryParams: Object.assign({ startsWith: this.startsWith }),
|
queryParams: Object.assign({ startsWith: this.startsWith }),
|
||||||
queryParamsHandling: 'merge'
|
queryParamsHandling: 'merge'
|
||||||
});
|
});
|
||||||
|
@@ -0,0 +1,71 @@
|
|||||||
|
import { StartsWithLoaderComponent } from './starts-with-loader.component';
|
||||||
|
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
|
||||||
|
import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core';
|
||||||
|
import { DynamicComponentLoaderDirective } from '../abstract-component-loader/dynamic-component-loader.directive';
|
||||||
|
import { TranslateModule } from '@ngx-translate/core';
|
||||||
|
import { StartsWithTextComponent } from './text/starts-with-text.component';
|
||||||
|
import { Router, ActivatedRoute } from '@angular/router';
|
||||||
|
import { RouterStub } from '../testing/router.stub';
|
||||||
|
import { ThemeService } from '../theme-support/theme.service';
|
||||||
|
import { getMockThemeService } from '../mocks/theme-service.mock';
|
||||||
|
import { StartsWithType } from './starts-with-decorator';
|
||||||
|
import { ActivatedRouteStub } from '../testing/active-router.stub';
|
||||||
|
import { PaginationService } from '../../core/pagination/pagination.service';
|
||||||
|
import { PaginationServiceStub } from '../testing/pagination-service.stub';
|
||||||
|
|
||||||
|
describe('StartsWithLoaderComponent', () => {
|
||||||
|
let comp: StartsWithLoaderComponent;
|
||||||
|
let fixture: ComponentFixture<StartsWithLoaderComponent>;
|
||||||
|
|
||||||
|
let paginationService: PaginationServiceStub;
|
||||||
|
let route: ActivatedRouteStub;
|
||||||
|
let themeService: ThemeService;
|
||||||
|
|
||||||
|
const type: StartsWithType = StartsWithType.text;
|
||||||
|
|
||||||
|
beforeEach(waitForAsync(() => {
|
||||||
|
paginationService = new PaginationServiceStub();
|
||||||
|
route = new ActivatedRouteStub();
|
||||||
|
themeService = getMockThemeService('dspace');
|
||||||
|
|
||||||
|
void TestBed.configureTestingModule({
|
||||||
|
imports: [
|
||||||
|
TranslateModule.forRoot(),
|
||||||
|
],
|
||||||
|
declarations: [
|
||||||
|
StartsWithLoaderComponent,
|
||||||
|
StartsWithTextComponent,
|
||||||
|
DynamicComponentLoaderDirective,
|
||||||
|
],
|
||||||
|
providers: [
|
||||||
|
{ provide: PaginationService, useValue: paginationService },
|
||||||
|
{ provide: ActivatedRoute, useValue: route },
|
||||||
|
{ provide: Router, useValue: new RouterStub() },
|
||||||
|
{ provide: ThemeService, useValue: themeService },
|
||||||
|
],
|
||||||
|
schemas: [NO_ERRORS_SCHEMA],
|
||||||
|
}).overrideComponent(StartsWithLoaderComponent, {
|
||||||
|
set: {
|
||||||
|
changeDetection: ChangeDetectionStrategy.Default,
|
||||||
|
entryComponents: [StartsWithTextComponent],
|
||||||
|
}
|
||||||
|
}).compileComponents();
|
||||||
|
}));
|
||||||
|
|
||||||
|
beforeEach(waitForAsync(() => {
|
||||||
|
fixture = TestBed.createComponent(StartsWithLoaderComponent);
|
||||||
|
comp = fixture.componentInstance;
|
||||||
|
comp.type = type;
|
||||||
|
comp.paginationId = 'bbm';
|
||||||
|
comp.startsWithOptions = [];
|
||||||
|
spyOn(comp, 'getComponent').and.returnValue(StartsWithTextComponent);
|
||||||
|
|
||||||
|
fixture.detectChanges();
|
||||||
|
}));
|
||||||
|
|
||||||
|
describe('When the component is rendered', () => {
|
||||||
|
it('should call the getComponent function', () => {
|
||||||
|
expect(comp.getComponent).toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
33
src/app/shared/starts-with/starts-with-loader.component.ts
Normal file
33
src/app/shared/starts-with/starts-with-loader.component.ts
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
import { Component, Input, } from '@angular/core';
|
||||||
|
import { AbstractComponentLoaderComponent } from '../abstract-component-loader/abstract-component-loader.component';
|
||||||
|
import { GenericConstructor } from '../../core/shared/generic-constructor';
|
||||||
|
import { getStartsWithComponent, StartsWithType } from './starts-with-decorator';
|
||||||
|
import { StartsWithAbstractComponent } from './starts-with-abstract.component';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Component for loading a {@link StartsWithAbstractComponent} depending on the "type" input
|
||||||
|
*/
|
||||||
|
@Component({
|
||||||
|
selector: 'ds-starts-with-loader',
|
||||||
|
templateUrl: '../abstract-component-loader/abstract-component-loader.component.html',
|
||||||
|
})
|
||||||
|
export class StartsWithLoaderComponent extends AbstractComponentLoaderComponent<StartsWithAbstractComponent> {
|
||||||
|
|
||||||
|
@Input() paginationId: string;
|
||||||
|
|
||||||
|
@Input() startsWithOptions: (string | number)[];
|
||||||
|
|
||||||
|
@Input() type: StartsWithType;
|
||||||
|
|
||||||
|
protected inputNames: (keyof this & string)[] = [
|
||||||
|
...this.inputNames,
|
||||||
|
'paginationId',
|
||||||
|
'startsWithOptions',
|
||||||
|
'type',
|
||||||
|
];
|
||||||
|
|
||||||
|
public getComponent(): GenericConstructor<StartsWithAbstractComponent> {
|
||||||
|
return getStartsWithComponent(this.type);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@@ -10,25 +10,31 @@ import { By } from '@angular/platform-browser';
|
|||||||
import { StartsWithTextComponent } from './starts-with-text.component';
|
import { StartsWithTextComponent } from './starts-with-text.component';
|
||||||
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 { ActivatedRouteStub } from '../../testing/active-router.stub';
|
||||||
|
import { RouterStub } from '../../testing/router.stub';
|
||||||
|
|
||||||
describe('StartsWithTextComponent', () => {
|
describe('StartsWithTextComponent', () => {
|
||||||
let comp: StartsWithTextComponent;
|
let comp: StartsWithTextComponent;
|
||||||
let fixture: ComponentFixture<StartsWithTextComponent>;
|
let fixture: ComponentFixture<StartsWithTextComponent>;
|
||||||
let route: ActivatedRoute;
|
|
||||||
let router: Router;
|
let paginationService: PaginationServiceStub;
|
||||||
|
let route: ActivatedRouteStub;
|
||||||
|
let router: RouterStub;
|
||||||
|
|
||||||
const options = ['0-9', 'A', 'B', 'C'];
|
const options = ['0-9', 'A', 'B', 'C'];
|
||||||
|
|
||||||
const paginationService = new PaginationServiceStub();
|
beforeEach(waitForAsync(async () => {
|
||||||
|
paginationService = new PaginationServiceStub();
|
||||||
|
route = new ActivatedRouteStub();
|
||||||
|
router = new RouterStub();
|
||||||
|
|
||||||
beforeEach(waitForAsync(() => {
|
await TestBed.configureTestingModule({
|
||||||
TestBed.configureTestingModule({
|
|
||||||
imports: [CommonModule, RouterTestingModule.withRoutes([]), TranslateModule.forRoot(), NgbModule],
|
imports: [CommonModule, RouterTestingModule.withRoutes([]), TranslateModule.forRoot(), NgbModule],
|
||||||
declarations: [StartsWithTextComponent, EnumKeysPipe],
|
declarations: [StartsWithTextComponent, EnumKeysPipe],
|
||||||
providers: [
|
providers: [
|
||||||
{ provide: 'startsWithOptions', useValue: options },
|
{ provide: PaginationService, useValue: paginationService },
|
||||||
{ provide: 'paginationId', useValue: 'page-id' },
|
{ provide: ActivatedRoute, useValue: route },
|
||||||
{ provide: PaginationService, useValue: paginationService }
|
{ provide: Router, useValue: router },
|
||||||
],
|
],
|
||||||
schemas: [NO_ERRORS_SCHEMA]
|
schemas: [NO_ERRORS_SCHEMA]
|
||||||
}).compileComponents();
|
}).compileComponents();
|
||||||
@@ -37,10 +43,9 @@ describe('StartsWithTextComponent', () => {
|
|||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
fixture = TestBed.createComponent(StartsWithTextComponent);
|
fixture = TestBed.createComponent(StartsWithTextComponent);
|
||||||
comp = fixture.componentInstance;
|
comp = fixture.componentInstance;
|
||||||
|
comp.paginationId = 'page-id';
|
||||||
|
comp.startsWithOptions = options;
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
route = (comp as any).route;
|
|
||||||
router = (comp as any).router;
|
|
||||||
spyOn(router, 'navigate');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should create a FormGroup containing a startsWith FormControl', () => {
|
it('should create a FormGroup containing a startsWith FormControl', () => {
|
||||||
|
@@ -35,15 +35,4 @@ export class StartsWithTextComponent extends StartsWithAbstractComponent {
|
|||||||
super.setStartsWithParam(resetPage);
|
super.setStartsWithParam(resetPage);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks whether the provided option is equal to the current startsWith
|
|
||||||
* @param option
|
|
||||||
*/
|
|
||||||
isSelectedOption(option: string): boolean {
|
|
||||||
if (this.startsWith === '0' && option === '0-9') {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return option === this.startsWith;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -824,6 +824,8 @@
|
|||||||
|
|
||||||
"browse.metadata.title": "Title",
|
"browse.metadata.title": "Title",
|
||||||
|
|
||||||
|
"browse.metadata.srsc": "Subject Category",
|
||||||
|
|
||||||
"browse.metadata.author.breadcrumbs": "Browse by Author",
|
"browse.metadata.author.breadcrumbs": "Browse by Author",
|
||||||
|
|
||||||
"browse.metadata.dateissued.breadcrumbs": "Browse by Date",
|
"browse.metadata.dateissued.breadcrumbs": "Browse by Date",
|
||||||
@@ -890,13 +892,11 @@
|
|||||||
|
|
||||||
"browse.startsWith.input": "Filter",
|
"browse.startsWith.input": "Filter",
|
||||||
|
|
||||||
"browse.taxonomy_srsc.title": "Browsing by Subject Category",
|
|
||||||
|
|
||||||
"browse.taxonomy.button": "Browse",
|
"browse.taxonomy.button": "Browse",
|
||||||
|
|
||||||
"browse.title": "Browsing {{ collection }} by {{ field }}{{ startsWith }} {{ value }}",
|
"browse.title": "Browsing by {{ field }}{{ startsWith }} {{ value }}",
|
||||||
|
|
||||||
"browse.title.page": "Browsing {{ collection }} by {{ field }} {{ value }}",
|
"browse.title.page": "Browsing by {{ field }} {{ value }}",
|
||||||
|
|
||||||
"search.browse.item-back": "Back to Results",
|
"search.browse.item-back": "Back to Results",
|
||||||
|
|
||||||
|
@@ -1,16 +0,0 @@
|
|||||||
import { Component } from '@angular/core';
|
|
||||||
import { BrowseByDatePageComponent as BaseComponent } from '../../../../../app/browse-by/browse-by-date-page/browse-by-date-page.component';
|
|
||||||
import { BrowseByDataType } from '../../../../../app/browse-by/browse-by-switcher/browse-by-data-type';
|
|
||||||
import { rendersBrowseBy } from '../../../../../app/browse-by/browse-by-switcher/browse-by-decorator';
|
|
||||||
import { Context } from '../../../../../app/core/shared/context.model';
|
|
||||||
|
|
||||||
@Component({
|
|
||||||
selector: 'ds-browse-by-date-page',
|
|
||||||
// styleUrls: ['./browse-by-date-page.component.scss'],
|
|
||||||
styleUrls: ['../../../../../app/browse-by/browse-by-metadata-page/browse-by-metadata-page.component.scss'],
|
|
||||||
// templateUrl: './browse-by-date-page.component.html'
|
|
||||||
templateUrl: '../../../../../app/browse-by/browse-by-metadata-page/browse-by-metadata-page.component.html'
|
|
||||||
})
|
|
||||||
@rendersBrowseBy(BrowseByDataType.Date, Context.Any, 'custom')
|
|
||||||
export class BrowseByDatePageComponent extends BaseComponent {
|
|
||||||
}
|
|
@@ -0,0 +1,16 @@
|
|||||||
|
import { Component } from '@angular/core';
|
||||||
|
import { BrowseByDateComponent as BaseComponent } from '../../../../../app/browse-by/browse-by-date/browse-by-date.component';
|
||||||
|
import { BrowseByDataType } from '../../../../../app/browse-by/browse-by-switcher/browse-by-data-type';
|
||||||
|
import { rendersBrowseBy } from '../../../../../app/browse-by/browse-by-switcher/browse-by-decorator';
|
||||||
|
import { Context } from '../../../../../app/core/shared/context.model';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'ds-browse-by-date',
|
||||||
|
// styleUrls: ['./browse-by-date.component.scss'],
|
||||||
|
styleUrls: ['../../../../../app/browse-by/browse-by-metadata/browse-by-metadata.component.scss'],
|
||||||
|
// templateUrl: './browse-by-date.component.html',
|
||||||
|
templateUrl: '../../../../../app/browse-by/browse-by-metadata/browse-by-metadata.component.html',
|
||||||
|
})
|
||||||
|
@rendersBrowseBy(BrowseByDataType.Date, Context.Any, 'custom')
|
||||||
|
export class BrowseByDateComponent extends BaseComponent {
|
||||||
|
}
|
@@ -1,16 +0,0 @@
|
|||||||
import { Component } from '@angular/core';
|
|
||||||
import { BrowseByMetadataPageComponent as BaseComponent } from '../../../../../app/browse-by/browse-by-metadata-page/browse-by-metadata-page.component';
|
|
||||||
import { BrowseByDataType } from '../../../../../app/browse-by/browse-by-switcher/browse-by-data-type';
|
|
||||||
import { rendersBrowseBy } from '../../../../../app/browse-by/browse-by-switcher/browse-by-decorator';
|
|
||||||
import { Context } from '../../../../../app/core/shared/context.model';
|
|
||||||
|
|
||||||
@Component({
|
|
||||||
selector: 'ds-browse-by-metadata-page',
|
|
||||||
// styleUrls: ['./browse-by-metadata-page.component.scss'],
|
|
||||||
styleUrls: ['../../../../../app/browse-by/browse-by-metadata-page/browse-by-metadata-page.component.scss'],
|
|
||||||
// templateUrl: './browse-by-metadata-page.component.html'
|
|
||||||
templateUrl: '../../../../../app/browse-by/browse-by-metadata-page/browse-by-metadata-page.component.html'
|
|
||||||
})
|
|
||||||
@rendersBrowseBy(BrowseByDataType.Metadata, Context.Any, 'custom')
|
|
||||||
export class BrowseByMetadataPageComponent extends BaseComponent {
|
|
||||||
}
|
|
@@ -0,0 +1,16 @@
|
|||||||
|
import { Component } from '@angular/core';
|
||||||
|
import { BrowseByMetadataComponent as BaseComponent } from '../../../../../app/browse-by/browse-by-metadata/browse-by-metadata.component';
|
||||||
|
import { BrowseByDataType } from '../../../../../app/browse-by/browse-by-switcher/browse-by-data-type';
|
||||||
|
import { rendersBrowseBy } from '../../../../../app/browse-by/browse-by-switcher/browse-by-decorator';
|
||||||
|
import { Context } from '../../../../../app/core/shared/context.model';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'ds-browse-by-metadata',
|
||||||
|
// styleUrls: ['./browse-by-metadata.component.scss'],
|
||||||
|
styleUrls: ['../../../../../app/browse-by/browse-by-metadata/browse-by-metadata.component.scss'],
|
||||||
|
// templateUrl: './browse-by-metadata.component.html',
|
||||||
|
templateUrl: '../../../../../app/browse-by/browse-by-metadata/browse-by-metadata.component.html',
|
||||||
|
})
|
||||||
|
@rendersBrowseBy(BrowseByDataType.Metadata, Context.Any, 'custom')
|
||||||
|
export class BrowseByMetadataComponent extends BaseComponent {
|
||||||
|
}
|
@@ -1,16 +0,0 @@
|
|||||||
import { Component } from '@angular/core';
|
|
||||||
import { BrowseByTaxonomyPageComponent as BaseComponent } from '../../../../../app/browse-by/browse-by-taxonomy-page/browse-by-taxonomy-page.component';
|
|
||||||
import { BrowseByDataType } from '../../../../../app/browse-by/browse-by-switcher/browse-by-data-type';
|
|
||||||
import { rendersBrowseBy } from '../../../../../app/browse-by/browse-by-switcher/browse-by-decorator';
|
|
||||||
import { Context } from '../../../../../app/core/shared/context.model';
|
|
||||||
|
|
||||||
@Component({
|
|
||||||
selector: 'ds-browse-by-taxonomy-page',
|
|
||||||
// templateUrl: './browse-by-taxonomy-page.component.html',
|
|
||||||
templateUrl: '../../../../../app/browse-by/browse-by-taxonomy-page/browse-by-taxonomy-page.component.html',
|
|
||||||
// styleUrls: ['./browse-by-taxonomy-page.component.scss'],
|
|
||||||
styleUrls: ['../../../../../app/browse-by/browse-by-taxonomy-page/browse-by-taxonomy-page.component.scss'],
|
|
||||||
})
|
|
||||||
@rendersBrowseBy(BrowseByDataType.Hierarchy, Context.Any, 'custom')
|
|
||||||
export class BrowseByTaxonomyPageComponent extends BaseComponent {
|
|
||||||
}
|
|
@@ -0,0 +1,16 @@
|
|||||||
|
import { Component } from '@angular/core';
|
||||||
|
import { BrowseByTaxonomyComponent as BaseComponent } from '../../../../../app/browse-by/browse-by-taxonomy/browse-by-taxonomy.component';
|
||||||
|
import { BrowseByDataType } from '../../../../../app/browse-by/browse-by-switcher/browse-by-data-type';
|
||||||
|
import { rendersBrowseBy } from '../../../../../app/browse-by/browse-by-switcher/browse-by-decorator';
|
||||||
|
import { Context } from '../../../../../app/core/shared/context.model';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'ds-browse-by-taxonomy',
|
||||||
|
// templateUrl: './browse-by-taxonomy.component.html',
|
||||||
|
templateUrl: '../../../../../app/browse-by/browse-by-taxonomy/browse-by-taxonomy.component.html',
|
||||||
|
// styleUrls: ['./browse-by-taxonomy.component.scss'],
|
||||||
|
styleUrls: ['../../../../../app/browse-by/browse-by-taxonomy/browse-by-taxonomy.component.scss'],
|
||||||
|
})
|
||||||
|
@rendersBrowseBy(BrowseByDataType.Hierarchy, Context.Any, 'custom')
|
||||||
|
export class BrowseByTaxonomyComponent extends BaseComponent {
|
||||||
|
}
|
@@ -1,16 +0,0 @@
|
|||||||
import { Component } from '@angular/core';
|
|
||||||
import { BrowseByTitlePageComponent as BaseComponent } from '../../../../../app/browse-by/browse-by-title-page/browse-by-title-page.component';
|
|
||||||
import { BrowseByDataType } from '../../../../../app/browse-by/browse-by-switcher/browse-by-data-type';
|
|
||||||
import { rendersBrowseBy } from '../../../../../app/browse-by/browse-by-switcher/browse-by-decorator';
|
|
||||||
import { Context } from '../../../../../app/core/shared/context.model';
|
|
||||||
|
|
||||||
@Component({
|
|
||||||
selector: 'ds-browse-by-title-page',
|
|
||||||
// styleUrls: ['./browse-by-title-page.component.scss'],
|
|
||||||
styleUrls: ['../../../../../app/browse-by/browse-by-metadata-page/browse-by-metadata-page.component.scss'],
|
|
||||||
// templateUrl: './browse-by-title-page.component.html'
|
|
||||||
templateUrl: '../../../../../app/browse-by/browse-by-metadata-page/browse-by-metadata-page.component.html'
|
|
||||||
})
|
|
||||||
@rendersBrowseBy(BrowseByDataType.Title, Context.Any, 'custom')
|
|
||||||
export class BrowseByTitlePageComponent extends BaseComponent {
|
|
||||||
}
|
|
@@ -0,0 +1,16 @@
|
|||||||
|
import { Component } from '@angular/core';
|
||||||
|
import { BrowseByTitleComponent as BaseComponent } from '../../../../../app/browse-by/browse-by-title/browse-by-title.component';
|
||||||
|
import { BrowseByDataType } from '../../../../../app/browse-by/browse-by-switcher/browse-by-data-type';
|
||||||
|
import { rendersBrowseBy } from '../../../../../app/browse-by/browse-by-switcher/browse-by-decorator';
|
||||||
|
import { Context } from '../../../../../app/core/shared/context.model';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'ds-browse-by-title',
|
||||||
|
// styleUrls: ['./browse-by-title.component.scss'],
|
||||||
|
styleUrls: ['../../../../../app/browse-by/browse-by-metadata/browse-by-metadata.component.scss'],
|
||||||
|
// templateUrl: './browse-by-title.component.html',
|
||||||
|
templateUrl: '../../../../../app/browse-by/browse-by-metadata/browse-by-metadata.component.html',
|
||||||
|
})
|
||||||
|
@rendersBrowseBy(BrowseByDataType.Title, Context.Any, 'custom')
|
||||||
|
export class BrowseByTitleComponent extends BaseComponent {
|
||||||
|
}
|
@@ -0,0 +1,12 @@
|
|||||||
|
import { Component } from '@angular/core';
|
||||||
|
import { CommunityPageSubCollectionListComponent as BaseComponent } from '../../../../../../../app/community-page/sections/sub-com-col-section/sub-collection-list/community-page-sub-collection-list.component';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'ds-community-page-sub-collection-list',
|
||||||
|
// styleUrls: ['./community-page-sub-collection-list.component.scss'],
|
||||||
|
styleUrls: ['../../../../../app/community-page/sections/sub-com-col-section/sub-collection-list/community-page-sub-collection-list.component.scss'],
|
||||||
|
// templateUrl: './community-page-sub-collection-list.component.html',
|
||||||
|
templateUrl: '../../../../../app/community-page/sections/sub-com-col-section/sub-collection-list/community-page-sub-collection-list.component.html',
|
||||||
|
})
|
||||||
|
export class CommunityPageSubCollectionListComponent extends BaseComponent {
|
||||||
|
}
|
@@ -0,0 +1,12 @@
|
|||||||
|
import { Component } from '@angular/core';
|
||||||
|
import { CommunityPageSubCommunityListComponent as BaseComponent } from '../../../../../../../app/community-page/sections/sub-com-col-section/sub-community-list/community-page-sub-community-list.component';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'ds-community-page-sub-community-list',
|
||||||
|
// styleUrls: ['./community-page-sub-community-list.component.scss'],
|
||||||
|
styleUrls: ['../../../../../../../app/community-page/sections/sub-com-col-section/sub-community-list/community-page-sub-community-list.component.scss'],
|
||||||
|
// templateUrl: './community-page-sub-community-list.component.html',
|
||||||
|
templateUrl: '../../../../../../../app/community-page/sections/sub-com-col-section/sub-community-list/community-page-sub-community-list.component.html',
|
||||||
|
})
|
||||||
|
export class CommunityPageSubCommunityListComponent extends BaseComponent {
|
||||||
|
}
|
@@ -1,12 +0,0 @@
|
|||||||
import { Component } from '@angular/core';
|
|
||||||
import { CommunityPageSubCollectionListComponent as BaseComponent }
|
|
||||||
from '../../../../../app/community-page/sub-collection-list/community-page-sub-collection-list.component';
|
|
||||||
|
|
||||||
@Component({
|
|
||||||
selector: 'ds-community-page-sub-collection-list',
|
|
||||||
// styleUrls: ['./community-page-sub-collection-list.component.scss'],
|
|
||||||
styleUrls: ['../../../../../app/community-page/sub-collection-list/community-page-sub-collection-list.component.scss'],
|
|
||||||
// templateUrl: './community-page-sub-collection-list.component.html',
|
|
||||||
templateUrl: '../../../../../app/community-page/sub-collection-list/community-page-sub-collection-list.component.html'
|
|
||||||
})
|
|
||||||
export class CommunityPageSubCollectionListComponent extends BaseComponent {}
|
|
@@ -1,12 +0,0 @@
|
|||||||
import { Component } from '@angular/core';
|
|
||||||
import { CommunityPageSubCommunityListComponent as BaseComponent }
|
|
||||||
from '../../../../../app/community-page/sub-community-list/community-page-sub-community-list.component';
|
|
||||||
|
|
||||||
@Component({
|
|
||||||
selector: 'ds-community-page-sub-community-list',
|
|
||||||
// styleUrls: ['./community-page-sub-community-list.component.scss'],
|
|
||||||
styleUrls: ['../../../../../app/community-page/sub-community-list/community-page-sub-community-list.component.scss'],
|
|
||||||
// templateUrl: './community-page-sub-community-list.component.html',
|
|
||||||
templateUrl: '../../../../../app/community-page/sub-community-list/community-page-sub-community-list.component.html'
|
|
||||||
})
|
|
||||||
export class CommunityPageSubCommunityListComponent extends BaseComponent {}
|
|
@@ -93,14 +93,14 @@ import { SearchResultsComponent } from './app/shared/search/search-results/searc
|
|||||||
import { AdminSidebarComponent } from './app/admin/admin-sidebar/admin-sidebar.component';
|
import { AdminSidebarComponent } from './app/admin/admin-sidebar/admin-sidebar.component';
|
||||||
import { ComcolPageBrowseByComponent } from './app/shared/comcol-page-browse-by/comcol-page-browse-by.component';
|
import { ComcolPageBrowseByComponent } from './app/shared/comcol-page-browse-by/comcol-page-browse-by.component';
|
||||||
import { SearchSettingsComponent } from './app/shared/search/search-settings/search-settings.component';
|
import { SearchSettingsComponent } from './app/shared/search/search-settings/search-settings.component';
|
||||||
import { CommunityPageSubCommunityListComponent } from './app/community-page/sub-community-list/community-page-sub-community-list.component';
|
import { CommunityPageSubCommunityListComponent } from './app/community-page/sections/sub-com-col-section/sub-community-list/community-page-sub-community-list.component';
|
||||||
import { CommunityPageSubCollectionListComponent } from './app/community-page/sub-collection-list/community-page-sub-collection-list.component';
|
import { CommunityPageSubCollectionListComponent } from './app/community-page/sections/sub-com-col-section/sub-collection-list/community-page-sub-collection-list.component';
|
||||||
import { ObjectListComponent } from './app/shared/object-list/object-list.component';
|
import { ObjectListComponent } from './app/shared/object-list/object-list.component';
|
||||||
|
|
||||||
import { BrowseByMetadataPageComponent } from './app/browse-by/browse-by-metadata-page/browse-by-metadata-page.component';
|
import { BrowseByMetadataComponent } from './app/browse-by/browse-by-metadata/browse-by-metadata.component';
|
||||||
import { BrowseByDatePageComponent } from './app/browse-by/browse-by-date-page/browse-by-date-page.component';
|
import { BrowseByDateComponent } from './app/browse-by/browse-by-date/browse-by-date.component';
|
||||||
import { BrowseByTitlePageComponent } from './app/browse-by/browse-by-title-page/browse-by-title-page.component';
|
import { BrowseByTitleComponent } from './app/browse-by/browse-by-title/browse-by-title.component';
|
||||||
import { BrowseByTaxonomyPageComponent } from './app/browse-by/browse-by-taxonomy-page/browse-by-taxonomy-page.component';
|
import { BrowseByTaxonomyComponent } from './app/browse-by/browse-by-taxonomy/browse-by-taxonomy.component';
|
||||||
import {
|
import {
|
||||||
ExternalSourceEntryImportModalComponent
|
ExternalSourceEntryImportModalComponent
|
||||||
} from './app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/external-source-tab/external-source-entry-import-modal/external-source-entry-import-modal.component';
|
} from './app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/external-source-tab/external-source-entry-import-modal/external-source-entry-import-modal.component';
|
||||||
@@ -209,10 +209,10 @@ const DECLARATIONS = [
|
|||||||
SearchSettingsComponent,
|
SearchSettingsComponent,
|
||||||
ComcolPageBrowseByComponent,
|
ComcolPageBrowseByComponent,
|
||||||
ObjectListComponent,
|
ObjectListComponent,
|
||||||
BrowseByMetadataPageComponent,
|
BrowseByMetadataComponent,
|
||||||
BrowseByDatePageComponent,
|
BrowseByDateComponent,
|
||||||
BrowseByTitlePageComponent,
|
BrowseByTitleComponent,
|
||||||
BrowseByTaxonomyPageComponent,
|
BrowseByTaxonomyComponent,
|
||||||
ExternalSourceEntryImportModalComponent,
|
ExternalSourceEntryImportModalComponent,
|
||||||
SearchFiltersComponent,
|
SearchFiltersComponent,
|
||||||
SearchSidebarComponent,
|
SearchSidebarComponent,
|
||||||
@@ -305,9 +305,6 @@ const DECLARATIONS = [
|
|||||||
RequestCopyModule,
|
RequestCopyModule,
|
||||||
],
|
],
|
||||||
declarations: DECLARATIONS,
|
declarations: DECLARATIONS,
|
||||||
exports: [
|
|
||||||
CommunityPageSubCollectionListComponent
|
|
||||||
]
|
|
||||||
})
|
})
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user