mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 10:04:11 +00:00
Fixed issue with switch component on mydspace page
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
<script src="../search-switch-configuration/search-switch-configuration.component.ts"></script>
|
||||
<ng-container *ngVar="(searchOptions$ | async) as config">
|
||||
<h3>{{ 'search.sidebar.settings.title' | translate}}</h3>
|
||||
<div *ngIf="config?.sort" class="setting-option result-order-settings mb-3 p-3">
|
||||
|
@@ -10,7 +10,7 @@
|
||||
<div id="search-sidebar-content">
|
||||
<ds-view-mode-switch [viewModeList]="viewModeList" class="d-none d-md-block"></ds-view-mode-switch>
|
||||
<div class="sidebar-content">
|
||||
<ds-search-switch-configuration *ngIf="configurationList" [configurationList]="configurationList"></ds-search-switch-configuration>
|
||||
<ds-search-switch-configuration [inPlaceSearch]="inPlaceSearch" *ngIf="configurationList" [configurationList]="configurationList"></ds-search-switch-configuration>
|
||||
<ds-search-filters [inPlaceSearch]="inPlaceSearch"></ds-search-filters>
|
||||
<ds-search-settings [inPlaceSearch]="inPlaceSearch"></ds-search-settings>
|
||||
</div>
|
||||
|
@@ -94,7 +94,7 @@ describe('SearchSwitchConfigurationComponent', () => {
|
||||
});
|
||||
|
||||
it('should navigate to the route when selecting an option', () => {
|
||||
(comp as any).searchService.getSearchLink.and.returnValue(MYDSPACE_ROUTE);
|
||||
spyOn((comp as any), 'getSearchLinkParts').and.returnValue([MYDSPACE_ROUTE]);
|
||||
comp.selectedOption = MyDSpaceConfigurationValueType.Workflow;
|
||||
const navigationExtras: NavigationExtras = {
|
||||
queryParams: {configuration: MyDSpaceConfigurationValueType.Workflow},
|
||||
|
@@ -20,6 +20,10 @@ import { SearchService } from '../search-service/search.service';
|
||||
*/
|
||||
export class SearchSwitchConfigurationComponent implements OnDestroy, OnInit {
|
||||
|
||||
/**
|
||||
* True when the search component should show results on the current page
|
||||
*/
|
||||
@Input() inPlaceSearch;
|
||||
/**
|
||||
* The list of available configuration options
|
||||
*/
|
||||
@@ -56,7 +60,7 @@ export class SearchSwitchConfigurationComponent implements OnDestroy, OnInit {
|
||||
queryParams: {configuration: this.selectedOption},
|
||||
};
|
||||
|
||||
this.router.navigate([this.searchService.getSearchLink()], navigationExtras);
|
||||
this.router.navigate(this.getSearchLinkParts(), navigationExtras);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -77,4 +81,24 @@ export class SearchSwitchConfigurationComponent implements OnDestroy, OnInit {
|
||||
this.sub.unsubscribe();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {string} The base path to the search page, or the current page when inPlaceSearch is true
|
||||
*/
|
||||
public getSearchLink(): string {
|
||||
if (this.inPlaceSearch) {
|
||||
return './';
|
||||
}
|
||||
return this.searchService.getSearchLink();
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {string[]} The base path to the search page, or the current page when inPlaceSearch is true, split in separate pieces
|
||||
*/
|
||||
public getSearchLinkParts(): string[] {
|
||||
if (this.searchService) {
|
||||
return [];
|
||||
}
|
||||
return this.getSearchLink().split('/');
|
||||
}
|
||||
}
|
||||
|
@@ -237,7 +237,7 @@ export class SubmissionFormCollectionComponent implements OnChanges, OnInit {
|
||||
if (isEmpty(searchTerm)) {
|
||||
return listCollection;
|
||||
} else {
|
||||
return listCollection.filter((v) => v.collection.name.toLowerCase().indexOf(searchTerm.toLowerCase()) > -1).slice(0, 5)
|
||||
return listCollection.filter((v) => v.collection.name.toLowerCase().indexOf(searchTerm.toLowerCase()) > -1).slice(0, 5);
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
Reference in New Issue
Block a user