- {{'browse.empty' | translate}}
+
+
+
+ {{'browse.empty' | translate}}
+
diff --git a/src/app/shared/browse-by/browse-by.component.spec.ts b/src/app/shared/browse-by/browse-by.component.spec.ts
index 806f4bdb6f..875ad02dd2 100644
--- a/src/app/shared/browse-by/browse-by.component.spec.ts
+++ b/src/app/shared/browse-by/browse-by.component.spec.ts
@@ -18,9 +18,10 @@ import { PaginationComponentOptions } from '../pagination/pagination-component-o
import { SortDirection, SortOptions } from '../../core/cache/models/sort-options.model';
import { createSuccessfulRemoteDataObject$ } from '../remote-data.utils';
import { storeModuleConfig } from '../../app.reducer';
-import { FindListOptions } from '../../core/data/request.models';
import { PaginationService } from '../../core/pagination/pagination.service';
import { PaginationServiceStub } from '../testing/pagination-service.stub';
+import { RouteService } from '../../core/services/route.service';
+import { routeServiceStub } from '../testing/route-service.stub';
describe('BrowseByComponent', () => {
let comp: BrowseByComponent;
@@ -75,7 +76,8 @@ describe('BrowseByComponent', () => {
],
declarations: [],
providers: [
- {provide: PaginationService, useValue: paginationService}
+ {provide: PaginationService, useValue: paginationService},
+ {provide: RouteService, useValue: routeServiceStub}
],
schemas: [NO_ERRORS_SCHEMA]
}).compileComponents();
@@ -163,4 +165,18 @@ describe('BrowseByComponent', () => {
});
});
+ describe('reset filters button', () => {
+ it('should not be present when no startsWith or value is present ', () => {
+ const button = fixture.debugElement.query(By.css('reset'));
+ expect(button).toBeNull();
+ });
+ it('should be present when a startsWith or value is present ', () => {
+ comp.shouldDisplayResetButton$ = observableOf(true);
+ fixture.detectChanges();
+
+ const button = fixture.debugElement.query(By.css('reset'));
+ expect(button).toBeDefined();
+ });
+ });
+
});
diff --git a/src/app/shared/browse-by/browse-by.component.ts b/src/app/shared/browse-by/browse-by.component.ts
index 1f05ad2258..9f4350402a 100644
--- a/src/app/shared/browse-by/browse-by.component.ts
+++ b/src/app/shared/browse-by/browse-by.component.ts
@@ -4,10 +4,13 @@ import { PaginatedList } from '../../core/data/paginated-list.model';
import { PaginationComponentOptions } from '../pagination/pagination-component-options.model';
import { SortDirection, SortOptions } from '../../core/cache/models/sort-options.model';
import { fadeIn, fadeInOut } from '../animations/fade';
-import { Observable } from 'rxjs';
+import { combineLatest as observableCombineLatest, Observable } from 'rxjs';
import { ListableObject } from '../object-collection/shared/listable-object.model';
import { getStartsWithComponent, StartsWithType } from '../starts-with/starts-with-decorator';
import { PaginationService } from '../../core/pagination/pagination.service';
+import { RouteService } from '../../core/services/route.service';
+import { map } from 'rxjs/operators';
+import { hasValue } from '../empty.util';
@Component({
selector: 'ds-browse-by',
@@ -97,8 +100,14 @@ export class BrowseByComponent implements OnInit {
*/
public sortDirections = SortDirection;
+ /**
+ * Observable that tracks if the back button should be displayed based on the path parameters
+ */
+ shouldDisplayResetButton$: Observable
;
+
public constructor(private injector: Injector,
protected paginationService: PaginationService,
+ private routeService: RouteService
) {
}
@@ -148,6 +157,14 @@ export class BrowseByComponent implements OnInit {
],
parent: this.injector
});
+
+ const startsWith$ = this.routeService.getQueryParameterValue('startsWith');
+ const value$ = this.routeService.getQueryParameterValue('value');
+
+ this.shouldDisplayResetButton$ = observableCombineLatest([startsWith$, value$]).pipe(
+ map(([startsWith, value]) => hasValue(startsWith) || hasValue(value))
+ );
+
}
}
diff --git a/src/app/shared/starts-with/text/starts-with-text.component.html b/src/app/shared/starts-with/text/starts-with-text.component.html
index 7a93adf7ac..3314d9cc4a 100644
--- a/src/app/shared/starts-with/text/starts-with-text.component.html
+++ b/src/app/shared/starts-with/text/starts-with-text.component.html
@@ -1,24 +1,5 @@