diff --git a/resources/i18n/en.json b/resources/i18n/en.json index b6a23068d7..d084728fde 100644 --- a/resources/i18n/en.json +++ b/resources/i18n/en.json @@ -22,6 +22,9 @@ }, "sub-collection-list": { "head": "Collections of this Community" + }, + "sub-community-list": { + "head": "Communities of this Community" } }, "item": { @@ -209,6 +212,7 @@ "community": "Loading community...", "collection": "Loading collection...", "sub-collections": "Loading sub-collections...", + "sub-communities": "Loading sub-communities...", "recent-submissions": "Loading recent submissions...", "item": "Loading item...", "objects": "Loading...", @@ -221,6 +225,7 @@ "community": "Error fetching community", "collection": "Error fetching collection", "sub-collections": "Error fetching sub-collections", + "sub-communities": "Error fetching sub-communities", "recent-submissions": "Error fetching recent submissions", "item": "Error fetching item", "objects": "Error fetching objects", diff --git a/src/app/+community-page/community-page.component.html b/src/app/+community-page/community-page.component.html index 637e37af0c..a86a86c3da 100644 --- a/src/app/+community-page/community-page.component.html +++ b/src/app/+community-page/community-page.component.html @@ -24,6 +24,7 @@ [content]="communityPayload.copyrightText" [hasInnerHtml]="true"> + diff --git a/src/app/+community-page/community-page.module.ts b/src/app/+community-page/community-page.module.ts index e00c3910c5..d7f97755c2 100644 --- a/src/app/+community-page/community-page.module.ts +++ b/src/app/+community-page/community-page.module.ts @@ -6,6 +6,7 @@ import { SharedModule } from '../shared/shared.module'; import { CommunityPageComponent } from './community-page.component'; import { CommunityPageSubCollectionListComponent } from './sub-collection-list/community-page-sub-collection-list.component'; import { CommunityPageRoutingModule } from './community-page-routing.module'; +import {CommunityPageSubCommunityListComponent} from './sub-community-list/community-page-sub-community-list.component'; @NgModule({ imports: [ @@ -16,6 +17,7 @@ import { CommunityPageRoutingModule } from './community-page-routing.module'; declarations: [ CommunityPageComponent, CommunityPageSubCollectionListComponent, + CommunityPageSubCommunityListComponent, ] }) export class CommunityPageModule { diff --git a/src/app/+community-page/sub-collection-list/community-page-sub-collection-list.component.html b/src/app/+community-page/sub-collection-list/community-page-sub-collection-list.component.html index 12c2578d9c..9156a99b18 100644 --- a/src/app/+community-page/sub-collection-list/community-page-sub-collection-list.component.html +++ b/src/app/+community-page/sub-collection-list/community-page-sub-collection-list.component.html @@ -1,5 +1,5 @@ - + 0" @fadeIn> {{'community.sub-collection-list.head' | translate}} diff --git a/src/app/+community-page/sub-community-list/community-page-sub-community-list.component.html b/src/app/+community-page/sub-community-list/community-page-sub-community-list.component.html new file mode 100644 index 0000000000..6cd62ba48d --- /dev/null +++ b/src/app/+community-page/sub-community-list/community-page-sub-community-list.component.html @@ -0,0 +1,15 @@ + + 0" @fadeIn> + {{'community.sub-community-list.head' | translate}} + + + + {{community.name}} + {{community.shortDescription}} + + + + + + + diff --git a/src/app/+community-page/sub-community-list/community-page-sub-community-list.component.scss b/src/app/+community-page/sub-community-list/community-page-sub-community-list.component.scss new file mode 100644 index 0000000000..50be6f5ad0 --- /dev/null +++ b/src/app/+community-page/sub-community-list/community-page-sub-community-list.component.scss @@ -0,0 +1 @@ +@import '../../../styles/variables.scss'; diff --git a/src/app/+community-page/sub-community-list/community-page-sub-community-list.component.spec.ts b/src/app/+community-page/sub-community-list/community-page-sub-community-list.component.spec.ts new file mode 100644 index 0000000000..b4203eb11a --- /dev/null +++ b/src/app/+community-page/sub-community-list/community-page-sub-community-list.component.spec.ts @@ -0,0 +1,78 @@ +import {async, ComponentFixture, TestBed} from '@angular/core/testing'; +import {TranslateModule} from '@ngx-translate/core'; +import {NO_ERRORS_SCHEMA} from '@angular/core'; +import {CommunityPageSubCommunityListComponent} from './community-page-sub-community-list.component'; +import {Community} from '../../core/shared/community.model'; +import {Observable} from 'rxjs/Observable'; +import {RemoteData} from '../../core/data/remote-data'; +import {PaginatedList} from '../../core/data/paginated-list'; +import 'rxjs/add/observable/of'; +import {PageInfo} from '../../core/shared/page-info.model'; +import {SharedModule} from '../../shared/shared.module'; +import {RouterTestingModule} from '@angular/router/testing'; +import {NoopAnimationsModule} from '@angular/platform-browser/animations'; +import {By} from '@angular/platform-browser'; + +describe('SubCommunityList Component', () => { + let comp: CommunityPageSubCommunityListComponent; + let fixture: ComponentFixture; + + const subcommunities = [Object.assign(new Community(), { + name: 'SubCommunity 1', + id: '123456789-1', + metadata: [ + { + key: 'dc.title', + language: 'en_US', + value: 'SubCommunity 1' + }] + }), + Object.assign(new Community(), { + name: 'SubCommunity 2', + id: '123456789-2', + metadata: [ + { + key: 'dc.title', + language: 'en_US', + value: 'SubCommunity 2' + }] + }) + ]; + + const mockCommunity = Object.assign(new Community(), { + metadata: [ + { + key: 'dc.title', + language: 'en_US', + value: 'Test title' + }], + subcommunities: Observable.of(new RemoteData(true, true, true, + undefined, new PaginatedList(new PageInfo(), subcommunities))) + }) + ; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + imports: [TranslateModule.forRoot(), SharedModule, + RouterTestingModule.withRoutes([]), + NoopAnimationsModule], + declarations: [CommunityPageSubCommunityListComponent], + schemas: [NO_ERRORS_SCHEMA] + }).compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(CommunityPageSubCommunityListComponent); + comp = fixture.componentInstance; + }); + + it('should display a list of subCommunities', () => { + comp.community = mockCommunity; + fixture.detectChanges(); + + const subComList = fixture.debugElement.queryAll(By.css('li')); + expect(subComList.length).toEqual(2); + expect(subComList[0].nativeElement.textContent).toContain('SubCommunity 1'); + expect(subComList[1].nativeElement.textContent).toContain('SubCommunity 2'); + }); +}); diff --git a/src/app/+community-page/sub-community-list/community-page-sub-community-list.component.ts b/src/app/+community-page/sub-community-list/community-page-sub-community-list.component.ts new file mode 100644 index 0000000000..da6135040c --- /dev/null +++ b/src/app/+community-page/sub-community-list/community-page-sub-community-list.component.ts @@ -0,0 +1,23 @@ +import { Component, Input, OnInit } from '@angular/core'; +import { Observable } from 'rxjs/Observable'; + +import { RemoteData } from '../../core/data/remote-data'; +import { Community } from '../../core/shared/community.model'; + +import { fadeIn } from '../../shared/animations/fade'; +import { PaginatedList } from '../../core/data/paginated-list'; + +@Component({ + selector: 'ds-community-page-sub-community-list', + styleUrls: ['./community-page-sub-community-list.component.scss'], + templateUrl: './community-page-sub-community-list.component.html', + animations:[fadeIn] +}) +export class CommunityPageSubCommunityListComponent implements OnInit { + @Input() community: Community; + subCommunitiesRDObs: Observable>>; + + ngOnInit(): void { + this.subCommunitiesRDObs = this.community.subcommunities; + } +} diff --git a/src/app/core/shared/community.model.ts b/src/app/core/shared/community.model.ts index 20bd50f4a9..d90742fa00 100644 --- a/src/app/core/shared/community.model.ts +++ b/src/app/core/shared/community.model.ts @@ -61,6 +61,6 @@ export class Community extends DSpaceObject { collections: Observable>>; - subcommunities: Observable>>; + subcommunities: Observable>>; }
+ {{community.name}} + {{community.shortDescription}} +