mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 10:04:11 +00:00
110889: Replaced recently added component with search comcol section
This commit is contained in:
@@ -25,7 +25,7 @@ import { DSOEditMenuResolver } from '../shared/dso-page/dso-edit-menu.resolver';
|
|||||||
import { ComcolBrowseByComponent } from '../shared/comcol/sections/comcol-browse-by/comcol-browse-by.component';
|
import { ComcolBrowseByComponent } from '../shared/comcol/sections/comcol-browse-by/comcol-browse-by.component';
|
||||||
import { BrowseByGuard } from '../browse-by/browse-by-guard';
|
import { BrowseByGuard } from '../browse-by/browse-by-guard';
|
||||||
import { BrowseByI18nBreadcrumbResolver } from '../browse-by/browse-by-i18n-breadcrumb.resolver';
|
import { BrowseByI18nBreadcrumbResolver } from '../browse-by/browse-by-i18n-breadcrumb.resolver';
|
||||||
import { CollectionRecentlyAddedComponent } from './sections/recently-added/collection-recently-added.component';
|
import { ComcolSearchSectionComponent } from '../shared/comcol/sections/comcol-search-section/comcol-search-section.component';
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
imports: [
|
imports: [
|
||||||
@@ -73,7 +73,7 @@ import { CollectionRecentlyAddedComponent } from './sections/recently-added/coll
|
|||||||
{
|
{
|
||||||
path: '',
|
path: '',
|
||||||
pathMatch: 'full',
|
pathMatch: 'full',
|
||||||
component: CollectionRecentlyAddedComponent,
|
component: ComcolSearchSectionComponent,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: 'browse/:id',
|
path: 'browse/:id',
|
||||||
|
@@ -19,7 +19,6 @@ 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 { BrowseByPageModule } from '../browse-by/browse-by-page.module';
|
||||||
import { CollectionRecentlyAddedComponent } from './sections/recently-added/collection-recently-added.component';
|
|
||||||
|
|
||||||
const DECLARATIONS = [
|
const DECLARATIONS = [
|
||||||
CollectionPageComponent,
|
CollectionPageComponent,
|
||||||
@@ -29,7 +28,6 @@ const DECLARATIONS = [
|
|||||||
EditItemTemplatePageComponent,
|
EditItemTemplatePageComponent,
|
||||||
ThemedEditItemTemplatePageComponent,
|
ThemedEditItemTemplatePageComponent,
|
||||||
CollectionItemMapperComponent,
|
CollectionItemMapperComponent,
|
||||||
CollectionRecentlyAddedComponent,
|
|
||||||
];
|
];
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
|
@@ -1,18 +0,0 @@
|
|||||||
<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>
|
|
@@ -1,53 +0,0 @@
|
|||||||
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();
|
|
||||||
});
|
|
||||||
});
|
|
@@ -1,82 +0,0 @@
|
|||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@@ -18,6 +18,7 @@ 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 { ComcolBrowseByComponent } from './sections/comcol-browse-by/comcol-browse-by.component';
|
||||||
import { BrowseByModule } from '../../browse-by/browse-by.module';
|
import { BrowseByModule } from '../../browse-by/browse-by.module';
|
||||||
|
import { ComcolSearchSectionComponent } from './sections/comcol-search-section/comcol-search-section.component';
|
||||||
|
|
||||||
const COMPONENTS = [
|
const COMPONENTS = [
|
||||||
ComcolPageContentComponent,
|
ComcolPageContentComponent,
|
||||||
@@ -33,6 +34,7 @@ const COMPONENTS = [
|
|||||||
ComcolRoleComponent,
|
ComcolRoleComponent,
|
||||||
ThemedComcolPageHandleComponent,
|
ThemedComcolPageHandleComponent,
|
||||||
ComcolBrowseByComponent,
|
ComcolBrowseByComponent,
|
||||||
|
ComcolSearchSectionComponent,
|
||||||
];
|
];
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
|
@@ -0,0 +1,23 @@
|
|||||||
|
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
import { ComcolSearchSectionComponent } from './comcol-search-section.component';
|
||||||
|
|
||||||
|
describe('ComcolSearchSectionComponent', () => {
|
||||||
|
let component: ComcolSearchSectionComponent;
|
||||||
|
let fixture: ComponentFixture<ComcolSearchSectionComponent>;
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
await TestBed.configureTestingModule({
|
||||||
|
declarations: [
|
||||||
|
ComcolSearchSectionComponent,
|
||||||
|
],
|
||||||
|
}).compileComponents();
|
||||||
|
|
||||||
|
fixture = TestBed.createComponent(ComcolSearchSectionComponent);
|
||||||
|
component = fixture.componentInstance;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create', () => {
|
||||||
|
expect(component).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
@@ -0,0 +1,9 @@
|
|||||||
|
import { Component } from '@angular/core';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'ds-comcol-search-section',
|
||||||
|
templateUrl: './comcol-search-section.component.html',
|
||||||
|
styleUrls: ['./comcol-search-section.component.scss'],
|
||||||
|
})
|
||||||
|
export class ComcolSearchSectionComponent {
|
||||||
|
}
|
@@ -1074,9 +1074,7 @@
|
|||||||
|
|
||||||
"collection.listelement.badge": "Collection",
|
"collection.listelement.badge": "Collection",
|
||||||
|
|
||||||
"collection.page.browse.recent.head": "Recent Submissions",
|
"collection.page.browse.recent.head": "Search",
|
||||||
|
|
||||||
"collection.page.browse.recent.empty": "No items to show",
|
|
||||||
|
|
||||||
"collection.page.edit": "Edit this collection",
|
"collection.page.edit": "Edit this collection",
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user