mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 10:04:11 +00:00
added support for Object.entries, removed a console.log and fixed an issue where the page wouldn't reset after selecting a new filter
This commit is contained in:
@@ -124,14 +124,14 @@ describe('SearchFacetFilterComponent', () => {
|
|||||||
describe('when the getAddParams method is called wih a value', () => {
|
describe('when the getAddParams method is called wih a value', () => {
|
||||||
it('should return the selectedValue list with the new parameter value', () => {
|
it('should return the selectedValue list with the new parameter value', () => {
|
||||||
const result = comp.getAddParams(value3);
|
const result = comp.getAddParams(value3);
|
||||||
expect(result).toEqual({ [mockFilterConfig.paramName]: [value1, value2, value3] });
|
expect(result[mockFilterConfig.paramName]).toEqual([value1, value2, value3]);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('when the getRemoveParams method is called wih a value', () => {
|
describe('when the getRemoveParams method is called wih a value', () => {
|
||||||
it('should return the selectedValue list with the parameter value left out', () => {
|
it('should return the selectedValue list with the parameter value left out', () => {
|
||||||
const result = comp.getRemoveParams(value1);
|
const result = comp.getRemoveParams(value1);
|
||||||
expect(result).toEqual({ [mockFilterConfig.paramName]: [value2] });
|
expect(result[mockFilterConfig.paramName]).toEqual([value2]);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -100,11 +100,17 @@ export class SearchFacetFilterComponent implements OnInit, OnDestroy {
|
|||||||
return hasValue(o);
|
return hasValue(o);
|
||||||
}
|
}
|
||||||
getRemoveParams(value: string) {
|
getRemoveParams(value: string) {
|
||||||
return { [this.filterConfig.paramName]: this.selectedValues.filter((v) => v !== value) };
|
return {
|
||||||
|
[this.filterConfig.paramName]: this.selectedValues.filter((v) => v !== value),
|
||||||
|
page: 1
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
getAddParams(value: string) {
|
getAddParams(value: string) {
|
||||||
return { [this.filterConfig.paramName]: [...this.selectedValues, value] };
|
return {
|
||||||
|
[this.filterConfig.paramName]: [...this.selectedValues, value],
|
||||||
|
page: 1
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnDestroy(): void {
|
ngOnDestroy(): void {
|
||||||
|
@@ -23,8 +23,6 @@ export class SearchFiltersComponent {
|
|||||||
constructor(private searchService: SearchService, private filterService: SearchFilterService) {
|
constructor(private searchService: SearchService, private filterService: SearchFilterService) {
|
||||||
this.filters = searchService.getConfig();
|
this.filters = searchService.getConfig();
|
||||||
this.clearParams = filterService.getCurrentFilters().map((filters) => {Object.keys(filters).forEach((f) => filters[f] = null); return filters;});
|
this.clearParams = filterService.getCurrentFilters().map((filters) => {Object.keys(filters).forEach((f) => filters[f] = null); return filters;});
|
||||||
|
|
||||||
this.filters.subscribe((v) => console.log('this.filters', v));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getSearchLink() {
|
getSearchLink() {
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
import { isNotEmpty } from '../shared/empty.util';
|
import { isNotEmpty } from '../shared/empty.util';
|
||||||
import { URLCombiner } from '../core/url-combiner/url-combiner';
|
import { URLCombiner } from '../core/url-combiner/url-combiner';
|
||||||
|
import 'core-js/fn/object/entries';
|
||||||
|
|
||||||
export enum ViewMode {
|
export enum ViewMode {
|
||||||
List = 'list',
|
List = 'list',
|
||||||
|
@@ -26,7 +26,8 @@
|
|||||||
"es6",
|
"es6",
|
||||||
"es2015",
|
"es2015",
|
||||||
"es2016",
|
"es2016",
|
||||||
"es2017"
|
"es2017",
|
||||||
|
"es2017.object"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"exclude": [
|
"exclude": [
|
||||||
|
Reference in New Issue
Block a user