mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 01:54:15 +00:00
110889: Added search form to the community & collection pages
This commit is contained in:
@@ -19,6 +19,8 @@ import { SubComColSectionComponent } from './sections/sub-com-col-section/sub-co
|
||||
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';
|
||||
import { ComcolSearchSectionComponent } from '../shared/comcol/sections/comcol-search-section/comcol-search-section.component';
|
||||
import { I18nBreadcrumbResolver } from '../core/breadcrumbs/i18n-breadcrumb.resolver';
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
@@ -56,7 +58,16 @@ import { ComcolBrowseByComponent } from '../shared/comcol/sections/comcol-browse
|
||||
{
|
||||
path: '',
|
||||
pathMatch: 'full',
|
||||
component: ComcolSearchSectionComponent,
|
||||
},
|
||||
{
|
||||
path: 'subcoms-cols',
|
||||
pathMatch: 'full',
|
||||
component: SubComColSectionComponent,
|
||||
resolve: {
|
||||
breadcrumb: I18nBreadcrumbResolver,
|
||||
},
|
||||
data: { breadcrumbKey: 'community.subcoms-cols' },
|
||||
},
|
||||
{
|
||||
path: 'browse/:id',
|
||||
|
@@ -11,6 +11,7 @@ describe('SubComColSectionComponent', () => {
|
||||
|
||||
beforeEach(async () => {
|
||||
activatedRoute = new ActivatedRouteStub();
|
||||
activatedRoute.parent = new ActivatedRouteStub();
|
||||
|
||||
await TestBed.configureTestingModule({
|
||||
declarations: [
|
||||
|
@@ -20,7 +20,7 @@ export class SubComColSectionComponent implements OnInit {
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.community$ = this.route.data.pipe(
|
||||
this.community$ = this.route.parent.data.pipe(
|
||||
map((data: Data) => (data.dso as RemoteData<Community>).payload),
|
||||
);
|
||||
}
|
||||
|
@@ -55,16 +55,21 @@ export class ComcolPageBrowseByComponent implements OnDestroy, OnInit {
|
||||
if (this.contentType === 'collection') {
|
||||
comColRoute = getCollectionPageRoute(this.id);
|
||||
allOptions.push({
|
||||
id: 'recent_submissions',
|
||||
label: 'collection.page.browse.recent.head',
|
||||
id: 'search',
|
||||
label: 'collection.page.browse.search.head',
|
||||
routerLink: comColRoute,
|
||||
});
|
||||
} else if (this.contentType === 'community') {
|
||||
comColRoute = getCommunityPageRoute(this.id);
|
||||
allOptions.push({
|
||||
id: 'search',
|
||||
label: 'collection.page.browse.search.head',
|
||||
routerLink: comColRoute,
|
||||
});
|
||||
allOptions.push({
|
||||
id: 'comcols',
|
||||
label: 'community.all-lists.head',
|
||||
routerLink: comColRoute,
|
||||
routerLink: `${comColRoute}/subcoms-cols`,
|
||||
});
|
||||
}
|
||||
|
||||
|
@@ -18,6 +18,7 @@ import { FormModule } from '../form/form.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';
|
||||
import { SearchModule } from '../search/search.module';
|
||||
import { ComcolSearchSectionComponent } from './sections/comcol-search-section/comcol-search-section.component';
|
||||
|
||||
const COMPONENTS = [
|
||||
@@ -47,6 +48,7 @@ const COMPONENTS = [
|
||||
SharedModule,
|
||||
UploadModule,
|
||||
BrowseByModule,
|
||||
SearchModule,
|
||||
],
|
||||
exports: [
|
||||
...COMPONENTS,
|
||||
|
@@ -0,0 +1,4 @@
|
||||
<ds-themed-search
|
||||
[showScopeSelector]="false"
|
||||
[scope]="(comcol$ | async)?.id">
|
||||
</ds-themed-search>
|
||||
|
@@ -1,15 +1,24 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { ComcolSearchSectionComponent } from './comcol-search-section.component';
|
||||
import { ActivatedRoute } from '@angular/router';
|
||||
import { ActivatedRouteStub } from '../../../testing/active-router.stub';
|
||||
|
||||
describe('ComcolSearchSectionComponent', () => {
|
||||
let component: ComcolSearchSectionComponent;
|
||||
let fixture: ComponentFixture<ComcolSearchSectionComponent>;
|
||||
|
||||
let route: ActivatedRouteStub;
|
||||
|
||||
beforeEach(async () => {
|
||||
route = new ActivatedRouteStub();
|
||||
|
||||
await TestBed.configureTestingModule({
|
||||
declarations: [
|
||||
ComcolSearchSectionComponent,
|
||||
],
|
||||
providers: [
|
||||
{ provide: ActivatedRoute, useValue: route },
|
||||
],
|
||||
}).compileComponents();
|
||||
|
||||
fixture = TestBed.createComponent(ComcolSearchSectionComponent);
|
||||
|
@@ -1,9 +1,37 @@
|
||||
import { Component } from '@angular/core';
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { Observable } from 'rxjs';
|
||||
import { ActivatedRoute, Data } from '@angular/router';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { SEARCH_CONFIG_SERVICE } from '../../../../my-dspace-page/my-dspace-page.component';
|
||||
import { SearchConfigurationService } from '../../../../core/shared/search/search-configuration.service';
|
||||
import { RemoteData } from '../../../../core/data/remote-data';
|
||||
import { Community } from '../../../../core/shared/community.model';
|
||||
import { Collection } from '../../../../core/shared/collection.model';
|
||||
|
||||
@Component({
|
||||
selector: 'ds-comcol-search-section',
|
||||
templateUrl: './comcol-search-section.component.html',
|
||||
styleUrls: ['./comcol-search-section.component.scss'],
|
||||
providers: [
|
||||
{
|
||||
provide: SEARCH_CONFIG_SERVICE,
|
||||
useClass: SearchConfigurationService,
|
||||
},
|
||||
],
|
||||
})
|
||||
export class ComcolSearchSectionComponent {
|
||||
export class ComcolSearchSectionComponent implements OnInit {
|
||||
|
||||
comcol$: Observable<Community | Collection>;
|
||||
|
||||
constructor(
|
||||
protected route: ActivatedRoute,
|
||||
) {
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.comcol$ = this.route.data.pipe(
|
||||
map((data: Data) => (data.dso as RemoteData<Community | Collection>).payload),
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,19 +1,19 @@
|
||||
import { map } from 'rxjs/operators';
|
||||
import { convertToParamMap, Params } from '@angular/router';
|
||||
|
||||
import { ActivatedRoute, convertToParamMap, Data, Params } from '@angular/router';
|
||||
import { BehaviorSubject } from 'rxjs';
|
||||
|
||||
export class ActivatedRouteStub {
|
||||
|
||||
private _testParams?: any;
|
||||
private _testData?: any;
|
||||
private _testParams?: Params;
|
||||
private _testData?: Data;
|
||||
// ActivatedRoute.params is Observable
|
||||
private subject?: BehaviorSubject<any> = new BehaviorSubject(this.testParams);
|
||||
private dataSubject?: BehaviorSubject<any> = new BehaviorSubject(this.testData);
|
||||
private subject?: BehaviorSubject<Params> = new BehaviorSubject(this.testParams);
|
||||
private dataSubject?: BehaviorSubject<Data> = new BehaviorSubject(this.testData);
|
||||
|
||||
params = this.subject.asObservable();
|
||||
queryParams = this.subject.asObservable();
|
||||
paramMap = this.subject.asObservable().pipe(map((params: Params) => convertToParamMap(params)));
|
||||
parent: ActivatedRoute | ActivatedRouteStub;
|
||||
queryParamMap = this.subject.asObservable().pipe(map((params: Params) => convertToParamMap(params)));
|
||||
data = this.dataSubject.asObservable();
|
||||
|
||||
@@ -35,17 +35,17 @@ export class ActivatedRouteStub {
|
||||
return this._testParams;
|
||||
}
|
||||
|
||||
set testParams(params: {}) {
|
||||
set testParams(params: Params) {
|
||||
this._testParams = params;
|
||||
this.subject.next(params);
|
||||
}
|
||||
|
||||
// Test data
|
||||
get testData() {
|
||||
return this._testParams;
|
||||
return this._testData;
|
||||
}
|
||||
|
||||
set testData(data: {}) {
|
||||
set testData(data: Data) {
|
||||
this._testData = data;
|
||||
this.dataSubject.next(data);
|
||||
}
|
||||
|
@@ -1074,7 +1074,7 @@
|
||||
|
||||
"collection.listelement.badge": "Collection",
|
||||
|
||||
"collection.page.browse.recent.head": "Search",
|
||||
"collection.page.browse.search.head": "Search",
|
||||
|
||||
"collection.page.edit": "Edit this collection",
|
||||
|
||||
@@ -1148,6 +1148,8 @@
|
||||
|
||||
"communityList.showMore": "Show More",
|
||||
|
||||
"community.subcoms-cols.breadcrumbs": "Subcommunities and Collections",
|
||||
|
||||
"community.create.head": "Create a Community",
|
||||
|
||||
"community.create.notifications.success": "Successfully created the Community",
|
||||
|
Reference in New Issue
Block a user