mirror of
https://github.com/romancm/gamebrary
synced 2024-11-28 14:10:26 +00:00
restore list sorting (except by release date)
This commit is contained in:
parent
37578f054a
commit
17ea6499d3
2 changed files with 25 additions and 53 deletions
|
@ -32,7 +32,7 @@
|
|||
@start="dragStart"
|
||||
>
|
||||
<component
|
||||
v-for="game in list.games"
|
||||
v-for="game in sortedGames"
|
||||
:is="gameCardComponent"
|
||||
:key="game"
|
||||
:list="list"
|
||||
|
@ -61,7 +61,7 @@ import GameCardGrid from '@/components/GameCards/GameCardGrid';
|
|||
import GameCardCompact from '@/components/GameCards/GameCardCompact';
|
||||
import GameCardText from '@/components/GameCards/GameCardText';
|
||||
import AddGameModal from '@/components/Lists/AddGameModal';
|
||||
// import orderby from 'lodash.orderby';
|
||||
import orderby from 'lodash.orderby';
|
||||
import { mapState } from 'vuex';
|
||||
|
||||
export default {
|
||||
|
@ -119,43 +119,15 @@ export default {
|
|||
return ['sortByName', 'sortByRating', 'sortByReleaseDate', 'sortByProgress'].includes(settings.sortOrder);
|
||||
},
|
||||
|
||||
// sortedGames() {
|
||||
// const { settings } = this.list;
|
||||
//
|
||||
// const sortOrder = settings.sortOrder || 'sortByCustom';
|
||||
//
|
||||
// return gameList;
|
||||
//
|
||||
// // TODO: use lodash to clean things up a bit here
|
||||
//
|
||||
// switch (sortOrder) {
|
||||
// case 'sortByCustom':
|
||||
// return gameList;
|
||||
// case 'sortByProgress':
|
||||
// return orderby(this.list, [(game) => {
|
||||
// const progress = this.games[game]
|
||||
// && this.progresses[this.platform.code][this.games[game].id]
|
||||
// ? Number(this.progresses[this.platform.code][this.games[game].id])
|
||||
// : 0;
|
||||
//
|
||||
// return progress;
|
||||
// }], ['desc']);
|
||||
// case 'sortByRating':
|
||||
// return orderby(this.list, [(game) => {
|
||||
// const rating = this.games[game] && this.games[game].rating
|
||||
// ? this.games[game].rating
|
||||
// : 0;
|
||||
//
|
||||
// return rating;
|
||||
// }], ['desc']);
|
||||
// case 'sortByName':
|
||||
// return orderby(this.list, [(game) => {
|
||||
// const name = this.games[game] && this.games[game].name
|
||||
// ? this.games[game].name.toUpperCase()
|
||||
// : '';
|
||||
//
|
||||
// return name;
|
||||
// }]);
|
||||
sortedGames() {
|
||||
const { settings, games } = this.list;
|
||||
const sortOrder = settings.sortOrder || 'sortByCustom';
|
||||
|
||||
switch (sortOrder) {
|
||||
case 'sortByCustom': return this.list.games;
|
||||
case 'sortByProgress': return orderby(games, [game => this.progresses[game] || 0], ['desc']);
|
||||
case 'sortByRating': return orderby(games, [game => this.games[game].rating || 0], ['desc']);
|
||||
case 'sortByName': return orderby(games, [game => this.games[game].name]);
|
||||
// case 'sortByReleaseDate':
|
||||
// return orderby(this.list, [(game) => {
|
||||
// const releaseDate = this.games[game] && this.games[game].release_dates
|
||||
|
@ -165,10 +137,10 @@ export default {
|
|||
//
|
||||
// return releaseDate && releaseDate.date;
|
||||
// }]);
|
||||
// default:
|
||||
// return gameList;
|
||||
// }
|
||||
// },
|
||||
default:
|
||||
return this.list.games;
|
||||
}
|
||||
},
|
||||
|
||||
isEmpty() {
|
||||
return this.list.games.length === 0;
|
||||
|
|
|
@ -57,7 +57,7 @@ export default {
|
|||
{ text: 'Custom', value: 'sortByCustom' },
|
||||
{ text: 'Name', value: 'sortByName' },
|
||||
{ text: 'Rating', value: 'sortByRating' },
|
||||
{ text: 'Release date', value: 'sortByReleaseDate' },
|
||||
// { text: 'Release date', value: 'sortByReleaseDate' },
|
||||
{ text: 'Progress', value: 'sortByProgress' },
|
||||
],
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue