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