Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/app/category-list/category-list-page.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@ describe('CategoryListPage', () => {
"groupSortBy": [{
"name": {
"order": "asc",
"preference": ['audience', ['subject 1'], ["accountancy"],["subject 1"]]
"preference": ["accountancy",["subject 1"]]
},
}]},
filterPillBy: null
Expand Down
27 changes: 17 additions & 10 deletions src/app/category-list/category-list-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ export class CategoryListPage implements OnInit, OnDestroy {
fromLibrary = false;
sectionCode = '';
primaryFacetFiltersFormGroup: FormGroup;
filterFields: {[k: string]: any} = {};

private readonly searchCriteria: ContentSearchCriteria;
private readonly filterCriteria: ContentSearchCriteria;
Expand Down Expand Up @@ -202,22 +203,28 @@ export class CategoryListPage implements OnInit, OnDestroy {
);
}

private async fetchAndSortData(searchCriteria, isInitialCall: boolean, refreshPillFilter = true, onSelectedFilter?: any) {
private async fetchAndSortData(searchCriteria, isInitialCall: boolean, refreshPillFilter = true, onSelectedFilter?: any, filterKey?) {
this.showSheenAnimation = true;
this.profile = await this.profileService.getActiveSessionProfile({ requiredFields: ProfileConstants.REQUIRED_FIELDS }).toPromise();
if (onSelectedFilter) {
const selectedData = [];
onSelectedFilter.forEach((selectedFilter) => {
selectedData.push(selectedFilter.name);
});
if (filterKey) {
this.filterFields = this.filterFields ? this.filterFields : {};
this.filterFields[filterKey] = selectedData;
}
if (this.formField.aggregate && this.formField.aggregate.groupSortBy && this.formField.aggregate.groupSortBy.length) {
this.formField.aggregate.groupSortBy.forEach((data) => {
if (data.name && data.name.preference && data.name.preference.length) {
data.name.preference.push(selectedData);
} else {
data.name.preference = selectedData;
}
});
let applyFilters = [];
Object.keys(this.filterFields).forEach((e) => {
if (this.filterFields[e].length) {
applyFilters = applyFilters.concat(this.filterFields[e]);
}
});
data.name.preference = applyFilters;
});
}
}

Expand Down Expand Up @@ -503,11 +510,11 @@ export class CategoryListPage implements OnInit, OnDestroy {
onSelectedFilter.push(selectedValue.name);
});

await this.applyFilter(appliedFilterCriteria, true, toApply);
await this.applyFilter(appliedFilterCriteria, true, toApply, primaryFacetFilter.code);
}
}

private async applyFilter(appliedFilterCriteria: ContentSearchCriteria, refreshPillFilter = true, onSelectedFilter?) {
private async applyFilter(appliedFilterCriteria: ContentSearchCriteria, refreshPillFilter = true, onSelectedFilter?, filterKey?) {
const tempSearchCriteria: ContentSearchCriteria = {
...appliedFilterCriteria,
mode: 'hard',
Expand All @@ -521,7 +528,7 @@ export class CategoryListPage implements OnInit, OnDestroy {
}
}
});
await this.fetchAndSortData(tempSearchCriteria, false, refreshPillFilter, onSelectedFilter);
await this.fetchAndSortData(tempSearchCriteria, false, refreshPillFilter, onSelectedFilter, filterKey);
}

async pillFilterHandler(pill){
Expand Down