-
Notifications
You must be signed in to change notification settings - Fork 384
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
148 additions
and
62 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
...ge/simple/related-entities/related-entities-search/related-entities-search.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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
<ds-filtered-search-page | ||
[fixedFilterQuery]="fixedFilter" | ||
[fixedFilter$]="fixedFilter$" | ||
[configuration$]="configuration$" | ||
[searchEnabled]="searchEnabled" | ||
[sideBarWidth]="sideBarWidth"> | ||
</ds-filtered-search-page> |
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
21 changes: 21 additions & 0 deletions
21
src/app/+search-page/configuration-search-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,21 @@ | ||
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; | ||
import { configureSearchComponentTestingModule } from './search-page.component.spec'; | ||
import { SearchConfigurationService } from './search-service/search-configuration.service'; | ||
import { ConfigurationSearchPageComponent } from './configuration-search-page.component'; | ||
|
||
describe('ConfigurationSearchPageComponent', () => { | ||
let comp: ConfigurationSearchPageComponent; | ||
let fixture: ComponentFixture<ConfigurationSearchPageComponent>; | ||
let searchConfigService: SearchConfigurationService; | ||
|
||
beforeEach(async(() => { | ||
configureSearchComponentTestingModule(ConfigurationSearchPageComponent); | ||
})); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(ConfigurationSearchPageComponent); | ||
comp = fixture.componentInstance; | ||
searchConfigService = (comp as any).searchConfigService; | ||
fixture.detectChanges(); | ||
}); | ||
}); |
71 changes: 71 additions & 0 deletions
71
src/app/+search-page/configuration-search-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,71 @@ | ||
import { HostWindowService } from '../shared/host-window.service'; | ||
import { SearchService } from './search-service/search.service'; | ||
import { SearchSidebarService } from './search-sidebar/search-sidebar.service'; | ||
import { SearchPageComponent } from './search-page.component'; | ||
import { ChangeDetectionStrategy, Component, Inject, Input, OnInit } from '@angular/core'; | ||
import { pushInOut } from '../shared/animations/push'; | ||
import { RouteService } from '../shared/services/route.service'; | ||
import { SearchConfigurationService } from './search-service/search-configuration.service'; | ||
import { Observable } from 'rxjs'; | ||
import { PaginatedSearchOptions } from './paginated-search-options.model'; | ||
import { SEARCH_CONFIG_SERVICE } from '../+my-dspace-page/my-dspace-page.component'; | ||
import { map } from 'rxjs/operators'; | ||
|
||
/** | ||
* This component renders a search page using a configuration as input. | ||
*/ | ||
@Component({ | ||
selector: 'ds-configuration-search-page', | ||
styleUrls: ['./search-page.component.scss'], | ||
templateUrl: './search-page.component.html', | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
animations: [pushInOut], | ||
providers: [ | ||
{ | ||
provide: SEARCH_CONFIG_SERVICE, | ||
useClass: SearchConfigurationService | ||
} | ||
] | ||
}) | ||
|
||
export class ConfigurationSearchPageComponent extends SearchPageComponent implements OnInit { | ||
/** | ||
* The configuration to use for the search options | ||
* If empty, the configuration will be determined by the route parameter called 'configuration' | ||
*/ | ||
@Input() configuration: string; | ||
|
||
constructor(protected service: SearchService, | ||
protected sidebarService: SearchSidebarService, | ||
protected windowService: HostWindowService, | ||
@Inject(SEARCH_CONFIG_SERVICE) public searchConfigService: SearchConfigurationService, | ||
protected routeService: RouteService) { | ||
super(service, sidebarService, windowService, searchConfigService, routeService); | ||
} | ||
|
||
/** | ||
* Listening to changes in the paginated search options | ||
* If something changes, update the search results | ||
* | ||
* Listen to changes in the scope | ||
* If something changes, update the list of scopes for the dropdown | ||
*/ | ||
ngOnInit(): void { | ||
super.ngOnInit(); | ||
} | ||
|
||
/** | ||
* Get the current paginated search options after updating the configuration using the configuration input | ||
* This is to make sure the configuration is included in the paginated search options, as it is not part of any | ||
* query or route parameters | ||
* @returns {Observable<PaginatedSearchOptions>} | ||
*/ | ||
protected getSearchOptions(): Observable<PaginatedSearchOptions> { | ||
return this.searchConfigService.paginatedSearchOptions.pipe( | ||
map((options: PaginatedSearchOptions) => { | ||
const config = this.configuration || options.configuration; | ||
return Object.assign(options, { configuration: config }); | ||
}) | ||
); | ||
} | ||
} |
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,22 @@ | ||
import { Injectable } from '@angular/core'; | ||
import { CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router'; | ||
import { Observable } from 'rxjs'; | ||
|
||
@Injectable() | ||
/** | ||
* Assemble the correct i18n key for the configuration search page's title depending on the current route's configuration parameter. | ||
* The format of the key will be "{configuration}.search.title" with: | ||
* - configuration: The current configuration stored in route.params | ||
*/ | ||
export class ConfigurationSearchPageGuard implements CanActivate { | ||
canActivate( | ||
route: ActivatedRouteSnapshot, | ||
state: RouterStateSnapshot): Observable<boolean> | Promise<boolean> | boolean { | ||
const configuration = route.params.configuration; | ||
|
||
const newTitle = configuration + '.search.title'; | ||
|
||
route.data = { title: newTitle }; | ||
return true; | ||
} | ||
} |
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
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
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: 1 addition & 1 deletion
2
src/app/+search-page/search-results/search-results.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
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
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