2020-08-25 04:24:09 +00:00
|
|
|
// TODO: dissolve
|
2020-08-21 06:12:51 +00:00
|
|
|
// import moment from 'moment';
|
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-08-15 00:00:04 +00:00
|
|
|
// TODO: remove getter
|
2020-08-11 23:39:11 +00:00
|
|
|
...mapGetters(['gameTags']),
|
2019-11-08 19:56:03 +00:00
|
|
|
|
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: {
|
|
|
|
openDetails() {
|
2020-08-21 06:12:51 +00:00
|
|
|
const { gameId, list } = this;
|
2020-08-13 06:55:56 +00:00
|
|
|
|
2020-08-21 06:12:51 +00:00
|
|
|
this.$store.commit('SET_GAME_MODAL_DATA', { gameId, list });
|
2020-08-13 06:55:56 +00:00
|
|
|
this.$bvModal.show('game-modal');
|
2019-11-08 19:56:03 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
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-08-18 21:35:32 +00:00
|
|
|
await this.$store.dispatch('SAVE_TAGS_LEGACY', this.tags)
|
2019-12-03 18:26:19 +00:00
|
|
|
.catch(() => {
|
2020-08-13 06:55:56 +00:00
|
|
|
this.$bvToast.toast('Authentication error', { title: 'Error', variant: 'danger' });
|
2019-12-03 18:26:19 +00:00
|
|
|
});
|
|
|
|
|
2020-08-13 06:55:56 +00:00
|
|
|
this.$bvToast.toast('Tags updated', { title: 'Success', variant: 'success' });
|
2019-04-19 05:33:49 +00:00
|
|
|
},
|
2019-11-08 19:56:03 +00:00
|
|
|
},
|
2019-04-19 05:33:49 +00:00
|
|
|
};
|