Skip to content

Commit

Permalink
Make searchTerms and chip filter code more consistent
Browse files Browse the repository at this point in the history
  • Loading branch information
marcellamaki committed Oct 29, 2021
1 parent 163a5e2 commit 3f57dd2
Showing 1 changed file with 14 additions and 15 deletions.
29 changes: 14 additions & 15 deletions kolibri/plugins/learn/assets/src/views/LibraryPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
</div>
<div class="results-header-group">
<div
v-for="item in Object.values(searchTermChipList)"
v-for="(item, key) in searchTermChipList"
:key="item"
class="filter-chip"
>
Expand All @@ -94,7 +94,7 @@
icon="close"
size="mini"
class="filter-chip-button"
@click="removeFilterTag(item)"
@click="removeFilterTag(item, key)"
/>
</span>

Expand Down Expand Up @@ -424,12 +424,11 @@
this.labels = data.labels;
this.searchLoading = false;
});
} else {
ContentNodeResource.fetchCollection({ getParams }).then(data => {
this.labels = data.labels;
});
}
// else {
// ContentNodeResource.fetchCollection({ getParams }).then(data => {
// this.labels = data.labels;
// });
// }
},
searchMore() {
if (this.displayingSearchResults && this.more && !this.moreLoading) {
Expand All @@ -442,16 +441,16 @@
});
}
},
removeFilterTag(value) {
let query = JSON.parse(JSON.stringify(this.$route.query));
const key = Object.keys(query).filter(function(key) {
return query[key] === value;
})[0];
delete query[key];
this.$router.replace({ query: query });
removeFilterTag(value, key) {
const keyObject = this.searchTerms[key];
delete keyObject[value];
this.searchTerms = {
...this.searchTerms,
[key]: keyObject,
};
},
clearSearch() {
this.$router.push(this.$router.getRoute(PageNames.LIBRARY));
this.searchTerms = {};
},
},
$trs: {
Expand Down

0 comments on commit 3f57dd2

Please sign in to comment.