forked from DSpace/dspace-angular
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Created BrowseByPageComponent that uses the new refactored BrowseBySw…
…itcherComponent extending AbstractComponentLoaderComponent - Added the context to the rendersBrowseBy decorator - Created AbstractBrowseByTypeComponent that is extended by all the browse type sections - Fixed a bug in BrowseService where findListByHref was called with null instead of undefined, which prevented its default values from being used
- Loading branch information
1 parent
14d42b0
commit 67ad110
Showing
26 changed files
with
230 additions
and
118 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { Component, Input, OnDestroy } from '@angular/core'; | ||
import { BrowseByDataType } from './browse-by-switcher/browse-by-decorator'; | ||
import { Context } from '../core/shared/context.model'; | ||
import { Subscription } from 'rxjs'; | ||
import { hasValue } from '../shared/empty.util'; | ||
|
||
@Component({ | ||
selector: 'ds-abstract-browse-by-type', | ||
template: '', | ||
}) | ||
export abstract class AbstractBrowseByTypeComponent implements OnDestroy { | ||
|
||
/** | ||
* The optional context | ||
*/ | ||
@Input() context: Context; | ||
|
||
/** | ||
* The {@link BrowseByDataType} of this Component | ||
*/ | ||
@Input() browseByType: BrowseByDataType; | ||
|
||
/** | ||
* List of subscriptions | ||
*/ | ||
subs: Subscription[] = []; | ||
|
||
ngOnDestroy(): void { | ||
this.subs.filter((sub: Subscription) => hasValue(sub)).forEach((sub: Subscription) => sub.unsubscribe()); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
src/app/browse-by/browse-by-page/browse-by-page.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<ds-browse-by-switcher [browseByType]="browseByType$ | async"> | ||
</ds-browse-by-switcher> |
File renamed without changes.
24 changes: 24 additions & 0 deletions
24
src/app/browse-by/browse-by-page/browse-by-page.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
import { BrowseByPageComponent } from './browse-by-page.component'; | ||
|
||
// TODO port old logic from BrowseBySwitcherComponent | ||
fdescribe('BrowseByPageComponent', () => { | ||
let component: BrowseByPageComponent; | ||
let fixture: ComponentFixture<BrowseByPageComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
declarations: [ | ||
BrowseByPageComponent, | ||
], | ||
}).compileComponents(); | ||
|
||
fixture = TestBed.createComponent(BrowseByPageComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
31 changes: 31 additions & 0 deletions
31
src/app/browse-by/browse-by-page/browse-by-page.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { Component, OnInit } from '@angular/core'; | ||
import { map } from 'rxjs/operators'; | ||
import { BrowseDefinition } from '../../core/shared/browse-definition.model'; | ||
import { ActivatedRoute } from '@angular/router'; | ||
import { Observable } from 'rxjs'; | ||
import { BrowseByDataType } from '../browse-by-switcher/browse-by-decorator'; | ||
|
||
@Component({ | ||
selector: 'ds-browse-by-page', | ||
templateUrl: './browse-by-page.component.html', | ||
styleUrls: ['./browse-by-page.component.scss'], | ||
}) | ||
export class BrowseByPageComponent implements OnInit { | ||
|
||
browseByType$: Observable<BrowseByDataType>; | ||
|
||
constructor( | ||
protected route: ActivatedRoute, | ||
) { | ||
} | ||
|
||
/** | ||
* Fetch the correct browse-by component by using the relevant config from the route data | ||
*/ | ||
ngOnInit(): void { | ||
this.browseByType$ = this.route.data.pipe( | ||
map((data: { browseDefinition: BrowseDefinition }) => data.browseDefinition.getRenderType()), | ||
); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
src/app/browse-by/browse-by-switcher/browse-by-switcher.component.html
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.