Skip to content

Commit bb0b66f

Browse files
108588: Moved sub communities & collections from community page to new component
1 parent 0483612 commit bb0b66f

6 files changed

Lines changed: 80 additions & 2 deletions

File tree

src/app/community-page/community-page-routing.module.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { LinkMenuItemModel } from '../shared/menu/menu-item/models/link.model';
1515
import { ThemedCommunityPageComponent } from './themed-community-page.component';
1616
import { MenuItemType } from '../shared/menu/menu-item-type.model';
1717
import { DSOEditMenuResolver } from '../shared/dso-page/dso-edit-menu.resolver';
18+
import { SubComColSectionComponent } from './sections/sub-com-col-section/sub-com-col-section.component';
1819

1920
@NgModule({
2021
imports: [
@@ -46,9 +47,15 @@ import { DSOEditMenuResolver } from '../shared/dso-page/dso-edit-menu.resolver';
4647
canActivate: [AuthenticatedGuard],
4748
},
4849
{
49-
path: '',
50+
path: '**',
5051
component: ThemedCommunityPageComponent,
5152
pathMatch: 'full',
53+
children: [
54+
{
55+
path: '',
56+
component: SubComColSectionComponent,
57+
},
58+
],
5259
}
5360
],
5461
data: {

src/app/community-page/community-page.module.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import {
2020
ThemedCollectionPageSubCollectionListComponent
2121
} from './sections/sub-com-col-section/sub-collection-list/themed-community-page-sub-collection-list.component';
2222
import { DsoPageModule } from '../shared/dso-page/dso-page.module';
23+
import { SubComColSectionComponent } from './sections/sub-com-col-section/sub-com-col-section.component';
2324

2425
const DECLARATIONS = [CommunityPageComponent,
2526
ThemedCommunityPageComponent,
@@ -28,7 +29,9 @@ const DECLARATIONS = [CommunityPageComponent,
2829
ThemedCollectionPageSubCollectionListComponent,
2930
CommunityPageSubCommunityListComponent,
3031
CreateCommunityPageComponent,
31-
DeleteCommunityPageComponent];
32+
DeleteCommunityPageComponent,
33+
SubComColSectionComponent,
34+
];
3235

3336
@NgModule({
3437
imports: [
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<ng-container *ngIf="(community$ | async) as community">
2+
<ds-themed-community-page-sub-community-list
3+
[community]="community">
4+
</ds-themed-community-page-sub-community-list>
5+
<ds-themed-community-page-sub-collection-list
6+
[community]="community">
7+
</ds-themed-community-page-sub-collection-list>
8+
</ng-container>

src/app/community-page/sections/sub-com-col-section/sub-com-col-section.component.scss

Whitespace-only changes.
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import { ComponentFixture, TestBed } from '@angular/core/testing';
2+
import { SubComColSectionComponent } from './sub-com-col-section.component';
3+
import { ActivatedRoute } from '@angular/router';
4+
import { ActivatedRouteStub } from '../../../shared/testing/active-router.stub';
5+
6+
describe('SubComColSectionComponent', () => {
7+
let component: SubComColSectionComponent;
8+
let fixture: ComponentFixture<SubComColSectionComponent>;
9+
10+
let activatedRoute: ActivatedRouteStub;
11+
12+
beforeEach(async () => {
13+
activatedRoute = new ActivatedRouteStub();
14+
15+
await TestBed.configureTestingModule({
16+
declarations: [
17+
SubComColSectionComponent,
18+
],
19+
providers: [
20+
{ provide: ActivatedRoute, useValue: activatedRoute },
21+
],
22+
}).compileComponents();
23+
24+
fixture = TestBed.createComponent(SubComColSectionComponent);
25+
component = fixture.componentInstance;
26+
fixture.detectChanges();
27+
});
28+
29+
it('should create', () => {
30+
expect(component).toBeTruthy();
31+
});
32+
});
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { Component, OnInit } from '@angular/core';
2+
import { Observable } from 'rxjs';
3+
import { RemoteData } from '../../../core/data/remote-data';
4+
import { Community } from '../../../core/shared/community.model';
5+
import { ActivatedRoute, Data } from '@angular/router';
6+
import { map } from 'rxjs/operators';
7+
8+
@Component({
9+
selector: 'ds-sub-com-col-section',
10+
templateUrl: './sub-com-col-section.component.html',
11+
styleUrls: ['./sub-com-col-section.component.scss'],
12+
})
13+
export class SubComColSectionComponent implements OnInit {
14+
15+
community$: Observable<Community>;
16+
17+
constructor(
18+
private route: ActivatedRoute,
19+
) {
20+
}
21+
22+
ngOnInit(): void {
23+
this.community$ = this.route.data.pipe(
24+
map((data: Data) => (data.dso as RemoteData<Community>).payload),
25+
);
26+
}
27+
28+
}

0 commit comments

Comments
 (0)