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">
|
<ng-container *ngVar="(searchOptions$ | async) as config">
|
||||||
<h3>{{ 'search.sidebar.settings.title' | translate}}</h3>
|
<h3>{{ 'search.sidebar.settings.title' | translate}}</h3>
|
||||||
<div *ngIf="config?.sort" class="setting-option result-order-settings mb-3 p-3">
|
<div *ngIf="config?.sort" class="setting-option result-order-settings mb-3 p-3">
|
||||||
|
@@ -10,7 +10,7 @@
|
|||||||
<div id="search-sidebar-content">
|
<div id="search-sidebar-content">
|
||||||
<ds-view-mode-switch [viewModeList]="viewModeList" class="d-none d-md-block"></ds-view-mode-switch>
|
<ds-view-mode-switch [viewModeList]="viewModeList" class="d-none d-md-block"></ds-view-mode-switch>
|
||||||
<div class="sidebar-content">
|
<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-filters [inPlaceSearch]="inPlaceSearch"></ds-search-filters>
|
||||||
<ds-search-settings [inPlaceSearch]="inPlaceSearch"></ds-search-settings>
|
<ds-search-settings [inPlaceSearch]="inPlaceSearch"></ds-search-settings>
|
||||||
</div>
|
</div>
|
||||||
|
@@ -94,7 +94,7 @@ describe('SearchSwitchConfigurationComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should navigate to the route when selecting an option', () => {
|
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;
|
comp.selectedOption = MyDSpaceConfigurationValueType.Workflow;
|
||||||
const navigationExtras: NavigationExtras = {
|
const navigationExtras: NavigationExtras = {
|
||||||
queryParams: {configuration: MyDSpaceConfigurationValueType.Workflow},
|
queryParams: {configuration: MyDSpaceConfigurationValueType.Workflow},
|
||||||
|
@@ -20,6 +20,10 @@ import { SearchService } from '../search-service/search.service';
|
|||||||
*/
|
*/
|
||||||
export class SearchSwitchConfigurationComponent implements OnDestroy, OnInit {
|
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
|
* The list of available configuration options
|
||||||
*/
|
*/
|
||||||
@@ -56,7 +60,7 @@ export class SearchSwitchConfigurationComponent implements OnDestroy, OnInit {
|
|||||||
queryParams: {configuration: this.selectedOption},
|
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();
|
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('/');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -38,7 +38,7 @@
|
|||||||
title="{{ listItem.collection.name }}"
|
title="{{ listItem.collection.name }}"
|
||||||
(click)="onSelect(listItem)">
|
(click)="onSelect(listItem)">
|
||||||
<ul class="list-unstyled mb-0">
|
<ul class="list-unstyled mb-0">
|
||||||
<li class="list-item text-truncate text-secondary" *ngFor="let item of listItem.communities" >
|
<li class="list-item text-truncate text-secondary" *ngFor="let item of listItem.communities">
|
||||||
{{ item.name}} <i class="fa fa-level-down" aria-hidden="true"></i>
|
{{ item.name}} <i class="fa fa-level-down" aria-hidden="true"></i>
|
||||||
</li>
|
</li>
|
||||||
<li class="list-item text-truncate text-primary font-weight-bold">{{ listItem.collection.name}}</li>
|
<li class="list-item text-truncate text-primary font-weight-bold">{{ listItem.collection.name}}</li>
|
||||||
|
@@ -237,7 +237,7 @@ export class SubmissionFormCollectionComponent implements OnChanges, OnInit {
|
|||||||
if (isEmpty(searchTerm)) {
|
if (isEmpty(searchTerm)) {
|
||||||
return listCollection;
|
return listCollection;
|
||||||
} else {
|
} 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