-
+
-
+
diff --git a/src/app/+search-page/search-filters/search-filter/search-hierarchy-filter/search-hierarchy-filter.component.scss b/src/app/+search-page/search-filters/search-filter/search-hierarchy-filter/search-hierarchy-filter.component.scss
index 9ec0f61541..d8bb1ff1b3 100644
--- a/src/app/+search-page/search-filters/search-filter/search-hierarchy-filter/search-hierarchy-filter.component.scss
+++ b/src/app/+search-page/search-filters/search-filter/search-hierarchy-filter/search-hierarchy-filter.component.scss
@@ -2,15 +2,6 @@
@import '../../../../../styles/mixins.scss';
.filters {
- a {
- color: $body-color;
- &:hover, &focus {
- text-decoration: none;
- }
- span.badge {
- vertical-align: text-top;
- }
- }
.toggle-more-filters a {
color: $link-color;
text-decoration: underline;
diff --git a/src/app/+search-page/search-filters/search-filter/search-range-filter/search-range-filter.component.html b/src/app/+search-page/search-filters/search-filter/search-range-filter/search-range-filter.component.html
index 9d35cc518a..cad31e7f0f 100644
--- a/src/app/+search-page/search-filters/search-filter/search-range-filter/search-range-filter.component.html
+++ b/src/app/+search-page/search-filters/search-filter/search-range-filter/search-range-filter.component.html
@@ -24,7 +24,7 @@
-
+
diff --git a/src/app/+search-page/search-filters/search-filter/search-range-filter/search-range-filter.component.scss b/src/app/+search-page/search-filters/search-filter/search-range-filter/search-range-filter.component.scss
index c45302b162..caaef5985e 100644
--- a/src/app/+search-page/search-filters/search-filter/search-range-filter/search-range-filter.component.scss
+++ b/src/app/+search-page/search-filters/search-filter/search-range-filter/search-range-filter.component.scss
@@ -3,17 +3,6 @@
.filters {
- a {
- color: $link-color;
- &:hover {
- text-decoration: underline;
- color: $link-hover-color;
-
- }
- span.badge {
- vertical-align: text-top;
- }
- }
.toggle-more-filters a {
color: $link-color;
text-decoration: underline;
diff --git a/src/app/+search-page/search-filters/search-filter/search-range-filter/search-range-filter.component.spec.ts b/src/app/+search-page/search-filters/search-filter/search-range-filter/search-range-filter.component.spec.ts
index 930ea8c9fb..119f3f92a9 100644
--- a/src/app/+search-page/search-filters/search-filter/search-range-filter/search-range-filter.component.spec.ts
+++ b/src/app/+search-page/search-filters/search-filter/search-range-filter/search-range-filter.component.spec.ts
@@ -2,7 +2,7 @@ import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core';
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { TranslateModule } from '@ngx-translate/core';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
-import { FILTER_CONFIG, SearchFilterService } from '../search-filter.service';
+import { FILTER_CONFIG, IN_PLACE_SEARCH, SearchFilterService } from '../search-filter.service';
import { SearchFilterConfig } from '../../../search-service/search-filter-config.model';
import { FilterType } from '../../../search-service/filter-type.model';
import { FacetValue } from '../../../search-service/facet-value.model';
@@ -18,7 +18,8 @@ import { PageInfo } from '../../../../core/shared/page-info.model';
import { SearchRangeFilterComponent } from './search-range-filter.component';
import { RouteService } from '../../../../shared/services/route.service';
import { RemoteDataBuildService } from '../../../../core/cache/builders/remote-data-build.service';
-import { SearchConfigurationService } from '../../../search-service/search-configuration.service';
+import { SEARCH_CONFIG_SERVICE } from '../../../../+my-dspace-page/my-dspace-page.component';
+import { SearchConfigurationServiceStub } from '../../../../shared/testing/search-configuration-service-stub';
describe('SearchRangeFilterComponent', () => {
let comp: SearchRangeFilterComponent;
@@ -41,14 +42,17 @@ describe('SearchRangeFilterComponent', () => {
});
const values: FacetValue[] = [
{
+ label: value1,
value: value1,
count: 52,
search: ''
}, {
+ label: value2,
value: value2,
count: 20,
search: ''
}, {
+ label: value3,
value: value3,
count: 5,
search: ''
@@ -73,9 +77,8 @@ describe('SearchRangeFilterComponent', () => {
{ provide: FILTER_CONFIG, useValue: mockFilterConfig },
{ provide: RemoteDataBuildService, useValue: {aggregate: () => observableOf({})} },
{ provide: RouteService, useValue: {getQueryParameterValue: () => observableOf({})} },
- { provide: SearchConfigurationService, useValue: {
- searchOptions: observableOf({}) }
- },
+ { provide: SEARCH_CONFIG_SERVICE, useValue: new SearchConfigurationServiceStub() },
+ { provide: IN_PLACE_SEARCH, useValue: false },
{
provide: SearchFilterService, useValue: {
getSelectedValuesForFilter: () => selectedValues,
@@ -116,7 +119,7 @@ describe('SearchRangeFilterComponent', () => {
});
it('should call navigate on the router with the right searchlink and parameters', () => {
- expect(router.navigate).toHaveBeenCalledWith([searchUrl], {
+ expect(router.navigate).toHaveBeenCalledWith(searchUrl.split('/'), {
queryParams: {
[mockFilterConfig.paramName + minSuffix]: [1900],
[mockFilterConfig.paramName + maxSuffix]: [1950]
diff --git a/src/app/+search-page/search-filters/search-filter/search-range-filter/search-range-filter.component.ts b/src/app/+search-page/search-filters/search-filter/search-range-filter/search-range-filter.component.ts
index ebdb797500..95d7441184 100644
--- a/src/app/+search-page/search-filters/search-filter/search-range-filter/search-range-filter.component.ts
+++ b/src/app/+search-page/search-filters/search-filter/search-range-filter/search-range-filter.component.ts
@@ -10,13 +10,14 @@ import {
SearchFacetFilterComponent
} from '../search-facet-filter/search-facet-filter.component';
import { SearchFilterConfig } from '../../../search-service/search-filter-config.model';
-import { FILTER_CONFIG, SearchFilterService } from '../search-filter.service';
+import { FILTER_CONFIG, IN_PLACE_SEARCH, SearchFilterService } from '../search-filter.service';
import { SearchService } from '../../../search-service/search.service';
import { Router } from '@angular/router';
import * as moment from 'moment';
import { RouteService } from '../../../../shared/services/route.service';
import { hasValue } from '../../../../shared/empty.util';
import { SearchConfigurationService } from '../../../search-service/search-configuration.service';
+import { SEARCH_CONFIG_SERVICE } from '../../../../+my-dspace-page/my-dspace-page.component';
/**
* The suffix for a range filters' minimum in the frontend URL
@@ -72,13 +73,14 @@ export class SearchRangeFilterComponent extends SearchFacetFilterComponent imple
constructor(protected searchService: SearchService,
protected filterService: SearchFilterService,
- protected searchConfigService: SearchConfigurationService,
protected router: Router,
protected rdbs: RemoteDataBuildService,
+ @Inject(SEARCH_CONFIG_SERVICE) public searchConfigService: SearchConfigurationService,
+ @Inject(IN_PLACE_SEARCH) public inPlaceSearch: boolean,
@Inject(FILTER_CONFIG) public filterConfig: SearchFilterConfig,
@Inject(PLATFORM_ID) private platformId: any,
private route: RouteService) {
- super(searchService, filterService, searchConfigService, rdbs, router, filterConfig);
+ super(searchService, filterService, rdbs, router, searchConfigService, inPlaceSearch, filterConfig);
}
@@ -107,7 +109,7 @@ export class SearchRangeFilterComponent extends SearchFacetFilterComponent imple
onSubmit() {
const newMin = this.range[0] !== this.min ? [this.range[0]] : null;
const newMax = this.range[1] !== this.max ? [this.range[1]] : null;
- this.router.navigate([this.getSearchLink()], {
+ this.router.navigate(this.getSearchLinkParts(), {
queryParams:
{
[this.filterConfig.paramName + RANGE_FILTER_MIN_SUFFIX]: newMin,
diff --git a/src/app/+search-page/search-filters/search-filter/search-text-filter/search-text-filter.component.html b/src/app/+search-page/search-filters/search-filter/search-text-filter/search-text-filter.component.html
index 25ff8e46d3..a4f4fb5ee8 100644
--- a/src/app/+search-page/search-filters/search-filter/search-text-filter/search-text-filter.component.html
+++ b/src/app/+search-page/search-filters/search-filter/search-text-filter/search-text-filter.component.html
@@ -1,9 +1,9 @@
-
+
-
+
diff --git a/src/app/+search-page/search-filters/search-filter/search-text-filter/search-text-filter.component.scss b/src/app/+search-page/search-filters/search-filter/search-text-filter/search-text-filter.component.scss
index 33e354f2d8..d8bb1ff1b3 100644
--- a/src/app/+search-page/search-filters/search-filter/search-text-filter/search-text-filter.component.scss
+++ b/src/app/+search-page/search-filters/search-filter/search-text-filter/search-text-filter.component.scss
@@ -2,15 +2,6 @@
@import '../../../../../styles/mixins.scss';
.filters {
- a {
- color: $body-color;
- &:hover, &focus {
- text-decoration: none;
- }
- span.badge {
- vertical-align: text-top;
- }
- }
.toggle-more-filters a {
color: $link-color;
text-decoration: underline;
diff --git a/src/app/+search-page/search-filters/search-filters.component.html b/src/app/+search-page/search-filters/search-filters.component.html
index 895765f6ac..05f4a693c2 100644
--- a/src/app/+search-page/search-filters/search-filters.component.html
+++ b/src/app/+search-page/search-filters/search-filters.component.html
@@ -1,7 +1,7 @@
{{"search.filters.head" | translate}}
-
{{"search.filters.reset" | translate}}
\ No newline at end of file
+
{{"search.filters.reset" | translate}}
diff --git a/src/app/+search-page/search-filters/search-filters.component.spec.ts b/src/app/+search-page/search-filters/search-filters.component.spec.ts
index db21fc8a69..dc883cd290 100644
--- a/src/app/+search-page/search-filters/search-filters.component.spec.ts
+++ b/src/app/+search-page/search-filters/search-filters.component.spec.ts
@@ -7,13 +7,15 @@ import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import { SearchFilterService } from './search-filter/search-filter.service';
import { SearchFiltersComponent } from './search-filters.component';
import { SearchService } from '../search-service/search.service';
-import { SearchConfigurationService } from '../search-service/search-configuration.service';
import { of as observableOf } from 'rxjs';
+import { SEARCH_CONFIG_SERVICE } from '../../+my-dspace-page/my-dspace-page.component';
+import { SearchConfigurationServiceStub } from '../../shared/testing/search-configuration-service-stub';
describe('SearchFiltersComponent', () => {
let comp: SearchFiltersComponent;
let fixture: ComponentFixture
;
let searchService: SearchService;
+
const searchServiceStub = {
/* tslint:disable:no-empty */
getConfig: () =>
@@ -30,17 +32,13 @@ describe('SearchFiltersComponent', () => {
[]
};
- const searchConfigServiceStub = jasmine.createSpyObj('SearchConfigurationService', {
- getCurrentFrontendFilters: observableOf({})
- });
-
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [TranslateModule.forRoot(), RouterTestingModule.withRoutes([]), NoopAnimationsModule],
declarations: [SearchFiltersComponent],
providers: [
{ provide: SearchService, useValue: searchServiceStub },
- { provide: SearchConfigurationService, useValue: searchConfigServiceStub },
+ { provide: SEARCH_CONFIG_SERVICE, useValue: new SearchConfigurationServiceStub() },
{ provide: SearchFilterService, useValue: searchFiltersStub },
],
diff --git a/src/app/+search-page/search-filters/search-filters.component.ts b/src/app/+search-page/search-filters/search-filters.component.ts
index 1dd747e908..e970647747 100644
--- a/src/app/+search-page/search-filters/search-filters.component.ts
+++ b/src/app/+search-page/search-filters/search-filters.component.ts
@@ -1,13 +1,15 @@
-import { Observable } from 'rxjs';
+import { Component, Inject, Input, OnInit } from '@angular/core';
+
+import { Observable } from 'rxjs';
+import { map, switchMap } from 'rxjs/operators';
-import { map } from 'rxjs/operators';
-import { Component } from '@angular/core';
import { SearchService } from '../search-service/search.service';
import { RemoteData } from '../../core/data/remote-data';
import { SearchFilterConfig } from '../search-service/search-filter-config.model';
import { SearchConfigurationService } from '../search-service/search-configuration.service';
import { SearchFilterService } from './search-filter/search-filter.service';
import { getSucceededRemoteData } from '../../core/shared/operators';
+import { SEARCH_CONFIG_SERVICE } from '../../+my-dspace-page/my-dspace-page.component';
@Component({
selector: 'ds-search-filters',
@@ -18,7 +20,7 @@ import { getSucceededRemoteData } from '../../core/shared/operators';
/**
* This component represents the part of the search sidebar that contains filters.
*/
-export class SearchFiltersComponent {
+export class SearchFiltersComponent implements OnInit {
/**
* An observable containing configuration about which filters are shown and how they are shown
*/
@@ -30,24 +32,43 @@ export class SearchFiltersComponent {
*/
clearParams;
+ /**
+ * True when the search component should show results on the current page
+ */
+ @Input() inPlaceSearch;
+
/**
* Initialize instance variables
* @param {SearchService} searchService
* @param {SearchConfigurationService} searchConfigService
* @param {SearchFilterService} filterService
*/
- constructor(private searchService: SearchService, private searchConfigService: SearchConfigurationService, private filterService: SearchFilterService) {
- this.filters = searchService.getConfig().pipe(getSucceededRemoteData());
- this.clearParams = searchConfigService.getCurrentFrontendFilters().pipe(map((filters) => {
+ constructor(
+ private searchService: SearchService,
+ private filterService: SearchFilterService,
+ @Inject(SEARCH_CONFIG_SERVICE) private searchConfigService: SearchConfigurationService) {
+
+ }
+
+ ngOnInit(): void {
+
+ this.filters = this.searchConfigService.searchOptions.pipe(
+ switchMap((options) => this.searchService.getConfig(options.scope, options.configuration).pipe(getSucceededRemoteData()))
+ );
+
+ this.clearParams = this.searchConfigService.getCurrentFrontendFilters().pipe(map((filters) => {
Object.keys(filters).forEach((f) => filters[f] = null);
return filters;
}));
}
/**
- * @returns {string} The base path to the search page
+ * @returns {string} The base path to the search page, or the current page when inPlaceSearch is true
*/
- getSearchLink() {
+ public getSearchLink(): string {
+ if (this.inPlaceSearch) {
+ return './';
+ }
return this.searchService.getSearchLink();
}
@@ -57,4 +78,5 @@ export class SearchFiltersComponent {
trackUpdate(index, config: SearchFilterConfig) {
return config ? config.name : undefined;
}
+
}
diff --git a/src/app/+search-page/search-labels/search-labels.component.html b/src/app/+search-page/search-labels/search-labels.component.html
index 61a5618dad..cac81e8717 100644
--- a/src/app/+search-page/search-labels/search-labels.component.html
+++ b/src/app/+search-page/search-labels/search-labels.component.html
@@ -2,11 +2,11 @@
diff --git a/src/app/+search-page/search-labels/search-labels.component.spec.ts b/src/app/+search-page/search-labels/search-labels.component.spec.ts
index 81fa5b5df8..d28698764c 100644
--- a/src/app/+search-page/search-labels/search-labels.component.spec.ts
+++ b/src/app/+search-page/search-labels/search-labels.component.spec.ts
@@ -9,7 +9,8 @@ import { SearchServiceStub } from '../../shared/testing/search-service-stub';
import { Observable, of as observableOf } from 'rxjs';
import { Params } from '@angular/router';
import { ObjectKeysPipe } from '../../shared/utils/object-keys-pipe';
-import { SearchConfigurationService } from '../search-service/search-configuration.service';
+import { SEARCH_CONFIG_SERVICE } from '../../+my-dspace-page/my-dspace-page.component';
+import { SearchConfigurationServiceStub } from '../../shared/testing/search-configuration-service-stub';
describe('SearchLabelsComponent', () => {
let comp: SearchLabelsComponent;
@@ -20,8 +21,11 @@ describe('SearchLabelsComponent', () => {
const field1 = 'author';
const field2 = 'subject';
- const value1 = 'TestAuthor';
+ const value1 = 'Test, Author';
+ const normValue1 = 'Test, Author';
const value2 = 'TestSubject';
+ const value3 = 'Test, Authority,authority';
+ const normValue3 = 'Test, Authority';
const filter1 = [field1, value1];
const filter2 = [field2, value2];
const mockFilters = [
@@ -35,7 +39,8 @@ describe('SearchLabelsComponent', () => {
declarations: [SearchLabelsComponent, ObjectKeysPipe],
providers: [
{ provide: SearchService, useValue: new SearchServiceStub(searchLink) },
- { provide: SearchConfigurationService, useValue: {getCurrentFrontendFilters : () => observableOf({})} }
+ { provide: SEARCH_CONFIG_SERVICE, useValue: new SearchConfigurationServiceStub() }
+ // { provide: SearchConfigurationService, useValue: {getCurrentFrontendFilters : () => observableOf({})} }
],
schemas: [NO_ERRORS_SCHEMA]
}).overrideComponent(SearchLabelsComponent, {
@@ -65,4 +70,16 @@ describe('SearchLabelsComponent', () => {
});
})
});
+
+ describe('when normalizeFilterValue is called', () => {
+ it('should return properly filter value', () => {
+ let result: string;
+
+ result = comp.normalizeFilterValue(value1);
+ expect(result).toBe(normValue1);
+
+ result = comp.normalizeFilterValue(value3);
+ expect(result).toBe(normValue3);
+ })
+ });
});
diff --git a/src/app/+search-page/search-labels/search-labels.component.ts b/src/app/+search-page/search-labels/search-labels.component.ts
index 08e07cce3d..104ed5b08b 100644
--- a/src/app/+search-page/search-labels/search-labels.component.ts
+++ b/src/app/+search-page/search-labels/search-labels.component.ts
@@ -1,10 +1,11 @@
-import { Component } from '@angular/core';
+import { Component, Inject, Input } from '@angular/core';
import { SearchService } from '../search-service/search.service';
import { Observable } from 'rxjs';
import { Params } from '@angular/router';
import { map } from 'rxjs/operators';
import { hasValue, isNotEmpty } from '../../shared/empty.util';
import { SearchConfigurationService } from '../search-service/search-configuration.service';
+import { SEARCH_CONFIG_SERVICE } from '../../+my-dspace-page/my-dspace-page.component';
@Component({
selector: 'ds-search-labels',
@@ -21,10 +22,17 @@ export class SearchLabelsComponent {
*/
appliedFilters: Observable;
+ /**
+ * True when the search component should show results on the current page
+ */
+ @Input() inPlaceSearch;
+
/**
* Initialize the instance variable
*/
- constructor(private searchService: SearchService, private searchConfigService: SearchConfigurationService) {
+ constructor(
+ private searchService: SearchService,
+ @Inject(SEARCH_CONFIG_SERVICE) public searchConfigService: SearchConfigurationService) {
this.appliedFilters = this.searchConfigService.getCurrentFrontendFilters();
}
@@ -48,9 +56,25 @@ export class SearchLabelsComponent {
}
/**
- * @returns {string} The base path to the search page
+ * @returns {string} The base path to the search page, or the current page when inPlaceSearch is true
*/
- getSearchLink() {
+ public getSearchLink(): string {
+ if (this.inPlaceSearch) {
+ return './';
+ }
return this.searchService.getSearchLink();
}
+
+ /**
+ * TODO to review after https://github.com/DSpace/dspace-angular/issues/368 is resolved
+ * Strips authority operator from filter value
+ * e.g. 'test ,authority' => 'test'
+ *
+ * @param value
+ */
+ normalizeFilterValue(value: string) {
+ // const pattern = /,[^,]*$/g;
+ const pattern = /,authority*$/g;
+ return value.replace(pattern, '');
+ }
}
diff --git a/src/app/+search-page/search-options.model.ts b/src/app/+search-page/search-options.model.ts
index 69309bed66..2b18854e1e 100644
--- a/src/app/+search-page/search-options.model.ts
+++ b/src/app/+search-page/search-options.model.ts
@@ -9,6 +9,7 @@ import { SetViewMode } from '../shared/view-mode';
* This model class represents all parameters needed to request information about a certain search request
*/
export class SearchOptions {
+ configuration?: string;
view?: SetViewMode = SetViewMode.List;
scope?: string;
query?: string;
@@ -16,7 +17,8 @@ export class SearchOptions {
filters?: any;
fixedFilter?: any;
- constructor(options: {scope?: string, query?: string, dsoType?: DSpaceObjectType, filters?: SearchFilter[], fixedFilter?: any}) {
+ constructor(options: {configuration?: string, scope?: string, query?: string, dsoType?: DSpaceObjectType, filters?: SearchFilter[], fixedFilter?: any}) {
+ this.configuration = options.configuration;
this.scope = options.scope;
this.query = options.query;
this.dsoType = options.dsoType;
@@ -31,6 +33,9 @@ export class SearchOptions {
* @returns {string} URL with all search options and passed arguments as query parameters
*/
toRestUrl(url: string, args: string[] = []): string {
+ if (isNotEmpty(this.configuration)) {
+ args.push(`configuration=${this.configuration}`);
+ }
if (isNotEmpty(this.fixedFilter)) {
args.push(this.fixedFilter);
}
@@ -45,7 +50,10 @@ export class SearchOptions {
}
if (isNotEmpty(this.filters)) {
this.filters.forEach((filter: SearchFilter) => {
- filter.values.forEach((value) => args.push(`${filter.key}=${value},${filter.operator}`));
+ filter.values.forEach((value) => {
+ const filterValue = value.includes(',') ? `${value}` : `${value},${filter.operator}`;
+ args.push(`${filter.key}=${filterValue}`)
+ });
});
}
if (isNotEmpty(args)) {
diff --git a/src/app/+search-page/search-page.component.html b/src/app/+search-page/search-page.component.html
index adab27d8e9..c11e863429 100644
--- a/src/app/+search-page/search-page.component.html
+++ b/src/app/+search-page/search-page.component.html
@@ -2,15 +2,16 @@
+ [resultCount]="(resultsRD$ | async)?.payload.totalElements" [inPlaceSearch]="inPlaceSearch">