2020-08-25 04:24:09 +00:00
|
|
|
// TODO: dissolve
|
2019-11-21 19:32:41 +00:00
|
|
|
import { mapState, mapGetters } from 'vuex';
|
2019-04-19 05:33:49 +00:00
|
|
|
|
|
|
|
export default {
|
2019-11-08 19:56:03 +00:00
|
|
|
props: {
|
2020-08-21 06:12:51 +00:00
|
|
|
list: {
|
|
|
|
type: Object,
|
|
|
|
default: () => {},
|
|
|
|
},
|
|
|
|
gameId: [String, Number],
|
2019-11-08 19:56:03 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
computed: {
|
2020-08-31 21:38:06 +00:00
|
|
|
...mapState(['settings', 'games', 'tags', 'notes', 'progresses', 'board']),
|
2020-10-14 21:47:02 +00:00
|
|
|
...mapGetters(['gameTags', 'nightMode']),
|
2019-11-08 19:56:03 +00:00
|
|
|
|
2020-12-16 05:33:47 +00:00
|
|
|
highlightCompletedGame() {
|
|
|
|
const { settings } = this.list;
|
|
|
|
|
|
|
|
return settings.highlightCompletedGames
|
|
|
|
&& this.gameProgress
|
|
|
|
&& Number(this.gameProgress) === 100;
|
2020-08-31 22:37:09 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
showGameProgress() {
|
|
|
|
return this.gameProgress && Number(this.gameProgress) < 100;
|
|
|
|
},
|
|
|
|
|
2020-08-11 23:39:11 +00:00
|
|
|
showGameTags() {
|
2020-08-21 06:12:51 +00:00
|
|
|
const { settings } = this.list;
|
|
|
|
|
|
|
|
return settings && settings.showGameTags && this.gameTags;
|
2019-04-19 05:33:49 +00:00
|
|
|
},
|
|
|
|
|
2020-08-11 23:39:11 +00:00
|
|
|
gameRating() {
|
2020-08-21 06:12:51 +00:00
|
|
|
const { settings } = this.list;
|
|
|
|
|
|
|
|
return settings && settings.showGameRatings && this.game.rating
|
2020-08-11 23:39:11 +00:00
|
|
|
? Math.round((this.game.rating / 20) * 2) / 2
|
|
|
|
: false;
|
2020-02-11 17:56:13 +00:00
|
|
|
},
|
|
|
|
|
2019-12-18 05:47:35 +00:00
|
|
|
gameProgress() {
|
2020-08-22 12:23:58 +00:00
|
|
|
const { gameId, progresses, list: { settings } } = this;
|
2020-08-11 23:39:11 +00:00
|
|
|
|
2020-08-22 12:23:58 +00:00
|
|
|
return settings && settings.showGameProgress && gameId && progresses[gameId]
|
2020-08-15 22:39:22 +00:00
|
|
|
? progresses[gameId]
|
|
|
|
: null;
|
2019-12-15 04:32:40 +00:00
|
|
|
},
|
|
|
|
|
2020-08-11 23:39:11 +00:00
|
|
|
gameNotes() {
|
2020-08-21 06:12:51 +00:00
|
|
|
const { settings } = this.list;
|
2019-12-17 05:05:35 +00:00
|
|
|
|
2020-08-21 06:12:51 +00:00
|
|
|
return settings && settings.showGameNotes && this.notes[this.gameId];
|
2019-11-08 19:56:03 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
game() {
|
|
|
|
return this.games[this.gameId];
|
|
|
|
},
|
|
|
|
|
2020-08-25 04:24:09 +00:00
|
|
|
// TODO: move to utils file
|
2019-11-08 19:56:03 +00:00
|
|
|
coverUrl() {
|
|
|
|
const game = this.games[this.gameId];
|
|
|
|
|
2020-08-11 04:16:43 +00:00
|
|
|
return game && game.cover && game.cover.image_id
|
2019-11-08 19:56:03 +00:00
|
|
|
? `https://images.igdb.com/igdb/image/upload/t_cover_small_2x/${game.cover.image_id}.jpg`
|
|
|
|
: '/static/no-image.jpg';
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
removeTag(tagName) {
|
|
|
|
this.$store.commit('REMOVE_GAME_TAG', { tagName, gameId: this.gameId });
|
2019-12-03 18:26:19 +00:00
|
|
|
this.saveTags();
|
|
|
|
},
|
|
|
|
|
|
|
|
async saveTags() {
|
2020-09-09 20:38:52 +00:00
|
|
|
await this.$store.dispatch('SAVE_TAGS', this.tags)
|
2019-12-03 18:26:19 +00:00
|
|
|
.catch(() => {
|
2020-09-23 23:01:39 +00:00
|
|
|
this.$store.commit('SET_SESSION_EXPIRED', true);
|
2019-12-03 18:26:19 +00:00
|
|
|
});
|
|
|
|
|
2020-12-10 05:26:57 +00:00
|
|
|
this.$bvToast.toast('Tags updated');
|
2019-04-19 05:33:49 +00:00
|
|
|
},
|
2019-11-08 19:56:03 +00:00
|
|
|
},
|
2019-04-19 05:33:49 +00:00
|
|
|
};
|