Skip to content
This repository has been archived by the owner on Jul 9, 2024. It is now read-only.

Commit

Permalink
fix(paging): set pg to 1 when facet added/removed
Browse files Browse the repository at this point in the history
Closes #1129
  • Loading branch information
Christine Yu committed Aug 4, 2015
1 parent b29ef33 commit 60c233b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
1 change: 1 addition & 0 deletions app/scripts/components/facets/facets.services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ module ngApp.components.facets.services {

addTerm(facet: string, term: string, op: string = 'in') {
var filters = this.ensurePath(this.LocationService.filters());

// TODO - not like this
var found = false;
var cs = filters["content"];
Expand Down
15 changes: 12 additions & 3 deletions app/scripts/components/location/location.services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,15 @@ module ngApp.components.location.services {
} else {
delete search.filters;
}

//move the user back to pg1
var paging = this.pagination();
if (paging) {
_.each(paging, (page) => {
page.from = 0;
});
search['pagination'] = paging;
}
return this.setSearch(search);
}

Expand All @@ -60,13 +69,13 @@ module ngApp.components.location.services {
}

pagination(): any {
var f = this.search()["pagination"];
return f ? angular.fromJson(f) : {};
var f = _.get(this.search(), "pagination", "{}");
return angular.fromJson(f);
}

setPaging(pagination: {[key: string]: string}): ng.ILocationService {
var search: ISearch = this.search();

if (pagination) {
search.pagination = angular.toJson(pagination);
} else if (_.isEmpty(search.pagination)) {
Expand Down

0 comments on commit 60c233b

Please sign in to comment.