Skip to content

Commit

Permalink
Fixed #31 - Sorting is taken over by search order…
Browse files Browse the repository at this point in the history
  • Loading branch information
joonaspaakko committed Mar 29, 2021
1 parent a69b2f1 commit 8bac243
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,6 @@ export default {
const wrapper = {};
wrapper.el = gridView;
wrapper.width = wrapper.el.getBoundingClientRect().width;
console.log( target.width, wrapper.width )
const info = {};
info.cols = Math.floor(wrapper.width / target.width) || 1;
Expand Down
23 changes: 15 additions & 8 deletions src/output-page/_components/alePages/aleGallery/aleSearch.vue
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export default {
if ( this.$route.query.search ) {
const searchQuery = decodeURIComponent(this.$route.query.search);
this.$store.commit("prop", { key: "searchQuery", value: searchQuery });
this.fuseOptions.shouldSort = false
this.fuseOptions.shouldSort = false;
this.search();
}
Expand Down Expand Up @@ -138,20 +138,27 @@ export default {
scope: function() {
this.$root.$emit("book-clicked", { book: null });
if (this.$store.getters.searchIsActive ) this.search();
// No need to shuffle anything when there's no active search
if ( this.$store.getters.searchIsActive ) {
this.$store.commit("prop", { key: 'mutatingCollection', value: this.sortBooks( this.filterBooks( _.get(this.$store.state, this.collectionSource) ) ) });
// this.$nextTick(function() {
this.fuseOptions.shouldSort = false;
this.search();
// });
}
},
filter: function() {
this.$root.$emit("book-clicked", { book: null });
// scroll({ top: 0 });
this.$store.commit("prop", { key: 'mutatingCollection', value: this.sortBooks( this.filterBooks( _.get(this.$store.state, this.collectionSource) ) ) });
if ( this.$store.getters.searchIsActive ) {
this.$store.commit("prop", { key: 'mutatingCollection', value: this.filterBooks( _.get(this.$store.state, this.collectionSource) ) });
this.search();
// this.$nextTick(function() {
this.fuseOptions.shouldSort = false;
this.search();
// });
}
else {
this.$store.commit("prop", { key: 'mutatingCollection', value: this.sortBooks( this.filterBooks( _.get(this.$store.state, this.collectionSource) ) ) });
}
},
sort: function() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<div class="search-opts-arrow" :style="css.arrow"></div>

<ul v-if="listName === 'filter' && $store.getters.filterKeys" class="regular-filters" :style="css.filter">
<ul v-if="listName === 'filter' && $store.getters.regularFilters" class="regular-filters" :style="css.filter">
<li class="search-option"
v-for="(item, index) in optionsList" :key="item.key"
v-if="item.type === 'filter'"
Expand Down
4 changes: 0 additions & 4 deletions src/output-page/_components/alePages/aleSeries.vue
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,6 @@ export default {
// { active: false, type: 'filterExtras', label: 'Books > 20', key: 'series-20', group: 'radioHead', condition: function( series ) { return series.books.length > 20; }},
// { active: false, type: 'filterExtras', label: 'Books > 30', key: 'series-30', group: 'radioHead', condition: function( series ) { return series.books.length > 30; }},
// FIXME: series page not showing up initially.........?? only after you meddle with the filters...
{ active: true, type: 'filterExtras', label: 'Books in series', key: 'inSeries', range: [1, (function() {
let series = _.get(vue.$store.state, vue.collectionSource);
let max = _.maxBy( series, function( series ){
Expand Down
4 changes: 2 additions & 2 deletions src/output-page/_components/snippets/sorter.vue
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ export default {
if ( this.item.key === "sortValues" ) this.$root.$emit("book-clicked", { book: null });
if (this.listName === "scope") {
if ( this.listName === "scope" ) {
this.$root.$emit("start-scope");
}
else if (
Expand All @@ -219,7 +219,7 @@ export default {
) {
this.$store.commit("prop", { 'key': 'searchSort', value: false });
this.$root.$emit("start-sort");
} else if (this.listName === "filter") {
} else if ( this.listName === "filter" ) {
this.$root.$emit("start-filter", range ? value : null);
}
Expand Down
3 changes: 3 additions & 0 deletions src/output-page/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ export default new Vuex.Store({
sortBy: function( state ) {
return _.find( state.listRenderingOpts.sort, 'current').key;
},
regularFilters: function( state ) {
return _.filter( state.listRenderingOpts.filter, { type: 'filter' }).length > 0;
},
filterKeys: function( state ) {
return _.map(_.filter( state.listRenderingOpts.filter, { type: 'filter', active: true }), function( o ) {
return o.key;
Expand Down

0 comments on commit 8bac243

Please sign in to comment.