2020-08-14 23:58:55 +00:00
|
|
|
<template lang="html">
|
|
|
|
<b-modal
|
|
|
|
id="game-modal"
|
|
|
|
scrollable
|
|
|
|
size="lg"
|
|
|
|
header-bg-variant="light"
|
|
|
|
footer-bg-variant="light"
|
|
|
|
footer-class="p-2 justify-content-center"
|
2020-08-22 12:21:15 +00:00
|
|
|
:title="game.name"
|
2020-08-21 06:13:45 +00:00
|
|
|
@show="setData"
|
2020-08-14 23:58:55 +00:00
|
|
|
@shown="loadGame"
|
|
|
|
@hidden="reset"
|
|
|
|
>
|
2020-08-22 12:21:15 +00:00
|
|
|
<b-container v-if="game.name">
|
2020-08-14 23:58:55 +00:00
|
|
|
<b-row>
|
|
|
|
<b-col lg="4">
|
|
|
|
<b-img
|
|
|
|
:src="coverUrl"
|
2020-08-22 12:21:15 +00:00
|
|
|
:alt="game.name"
|
2020-08-14 23:58:55 +00:00
|
|
|
rounded
|
|
|
|
fluid
|
|
|
|
/>
|
|
|
|
|
|
|
|
<b-progress
|
|
|
|
v-if="progress"
|
|
|
|
:value="progress"
|
|
|
|
variant="success"
|
|
|
|
height="8px"
|
|
|
|
class="mt-2"
|
|
|
|
/>
|
|
|
|
</b-col>
|
|
|
|
|
|
|
|
<b-col lg="8" md="auto">
|
2020-08-22 12:21:15 +00:00
|
|
|
<h3 class="mb-0">{{ game.name }}</h3>
|
2020-08-14 23:58:55 +00:00
|
|
|
|
2020-08-21 06:13:45 +00:00
|
|
|
<!-- <h6>
|
2020-08-14 23:58:55 +00:00
|
|
|
<b-badge
|
|
|
|
v-if="releaseDate"
|
|
|
|
variant="secondary"
|
|
|
|
>
|
|
|
|
Releases in
|
|
|
|
{{ releaseDate }}
|
|
|
|
</b-badge>
|
2020-08-21 06:13:45 +00:00
|
|
|
</h6> -->
|
2020-08-14 23:58:55 +00:00
|
|
|
|
|
|
|
<b-form-rating
|
|
|
|
v-if="rating"
|
|
|
|
:value="rating"
|
2020-08-22 12:21:15 +00:00
|
|
|
class="p-0 game-rating"
|
|
|
|
inline
|
2020-08-14 23:58:55 +00:00
|
|
|
readonly
|
|
|
|
variant="warning"
|
|
|
|
size="lg"
|
|
|
|
no-border
|
|
|
|
/>
|
|
|
|
|
2020-08-22 12:21:15 +00:00
|
|
|
<b-badge
|
|
|
|
v-for="({ games, hex, tagTextColor }, name) in tags"
|
|
|
|
v-if="games.includes(game.id)"
|
|
|
|
:key="name"
|
|
|
|
pill
|
|
|
|
tag="small"
|
|
|
|
class="mr-1 mb-2"
|
|
|
|
:style="`background-color: ${hex}; color: ${tagTextColor}`"
|
|
|
|
>
|
|
|
|
{{ name }}
|
|
|
|
</b-badge>
|
|
|
|
|
|
|
|
<div v-if="loading" class="my-2">
|
|
|
|
<b-button variant="light">
|
2020-08-14 23:58:55 +00:00
|
|
|
<b-icon-check />
|
|
|
|
</b-button>
|
|
|
|
|
2020-08-22 12:21:15 +00:00
|
|
|
<b-button variant="light">
|
2020-08-14 23:58:55 +00:00
|
|
|
<b-icon-file-earmark-text />
|
|
|
|
</b-button>
|
|
|
|
|
2020-08-22 12:21:15 +00:00
|
|
|
<b-button variant="light">
|
|
|
|
<b-icon-tag />
|
2020-08-14 23:58:55 +00:00
|
|
|
</b-button>
|
|
|
|
|
2020-08-22 12:21:15 +00:00
|
|
|
<b-button variant="light">
|
2020-08-15 06:39:19 +00:00
|
|
|
<b-icon-trash />
|
2020-08-14 23:58:55 +00:00
|
|
|
</b-button>
|
|
|
|
</div>
|
|
|
|
|
2020-08-22 12:21:15 +00:00
|
|
|
<div v-if="!loading" class="my-2">
|
|
|
|
<game-progress :game="game" />
|
|
|
|
<game-notes :game="game" />
|
|
|
|
<game-tags :game="game" />
|
|
|
|
<add-remove-game :game="game" :list="list" />
|
|
|
|
</div>
|
|
|
|
|
2020-08-14 23:58:55 +00:00
|
|
|
<placeholder :lines="3" v-if="loading"/>
|
|
|
|
<p v-else>{{ game.summary }}</p>
|
|
|
|
</b-col>
|
|
|
|
</b-row>
|
|
|
|
|
|
|
|
<game-detail-placeholder v-if="loading" />
|
|
|
|
|
|
|
|
<b-card v-else class="mt-4" no-body>
|
|
|
|
<b-tabs card>
|
2020-08-22 12:21:15 +00:00
|
|
|
<game-details-tab :game="game" />
|
|
|
|
<game-notes-tab :game="game" />
|
|
|
|
<game-websites-tab :game="game" />
|
|
|
|
<game-videos-tab :game="game" />
|
|
|
|
<game-screenshots-tab :game="game" />
|
2020-08-14 23:58:55 +00:00
|
|
|
</b-tabs>
|
|
|
|
</b-card>
|
|
|
|
</b-container>
|
|
|
|
|
|
|
|
<template v-slot:modal-footer>
|
|
|
|
<igdb-logo />
|
|
|
|
</template>
|
|
|
|
</b-modal>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import moment from 'moment';
|
2020-08-22 12:21:15 +00:00
|
|
|
import { mapState } from 'vuex';
|
2020-08-18 18:56:10 +00:00
|
|
|
import GameDetailPlaceholder from '@/components/Game/GameDetailPlaceholder';
|
2020-08-22 12:21:15 +00:00
|
|
|
import GameDetailsTab from '@/components/Game/GameDetailsTab';
|
|
|
|
import GameNotesTab from '@/components/Game/GameNotesTab';
|
|
|
|
import GameScreenshotsTab from '@/components/Game/GameScreenshotsTab';
|
|
|
|
import GameVideosTab from '@/components/Game/GameVideosTab';
|
|
|
|
import GameWebsitesTab from '@/components/Game/GameWebsitesTab';
|
|
|
|
import GameNotes from '@/components/Game/GameNotes';
|
|
|
|
import GameProgress from '@/components/Game/GameProgress';
|
|
|
|
import AddRemoveGame from '@/components/Game/AddRemoveGame';
|
2020-08-18 18:56:10 +00:00
|
|
|
import GameTags from '@/components/Game/GameTags';
|
2020-08-14 23:58:55 +00:00
|
|
|
import IgdbLogo from '@/components/IgdbLogo';
|
|
|
|
import Placeholder from '@/components/Placeholder';
|
|
|
|
|
|
|
|
export default {
|
|
|
|
components: {
|
|
|
|
Placeholder,
|
|
|
|
GameTags,
|
|
|
|
IgdbLogo,
|
|
|
|
GameDetailPlaceholder,
|
2020-08-22 12:21:15 +00:00
|
|
|
GameDetailsTab,
|
|
|
|
GameNotesTab,
|
|
|
|
GameScreenshotsTab,
|
|
|
|
GameVideosTab,
|
|
|
|
GameWebsitesTab,
|
|
|
|
GameNotes,
|
|
|
|
GameProgress,
|
|
|
|
AddRemoveGame,
|
2020-08-14 23:58:55 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
gameId: null,
|
2020-08-22 12:21:15 +00:00
|
|
|
game: {},
|
2020-08-14 23:58:55 +00:00
|
|
|
loading: true,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
computed: {
|
2020-08-21 06:13:45 +00:00
|
|
|
// TODO: rename gameModalData
|
2020-08-22 12:21:15 +00:00
|
|
|
...mapState(['gameModalData', 'games', 'platform', 'progresses', 'tags']),
|
2020-08-14 23:58:55 +00:00
|
|
|
|
|
|
|
releaseDate() {
|
|
|
|
const releaseDate = this.game
|
|
|
|
&& this.game.release_dates
|
|
|
|
&& this.game.release_dates.find(({ platform }) => this.platform.id === platform);
|
|
|
|
|
|
|
|
const formattedDate = releaseDate && releaseDate.date
|
|
|
|
? moment.unix(releaseDate.date)
|
|
|
|
: null;
|
|
|
|
|
|
|
|
return moment(formattedDate).isAfter()
|
|
|
|
? formattedDate.toNow(true)
|
|
|
|
: null;
|
|
|
|
},
|
|
|
|
|
|
|
|
progress() {
|
2020-08-15 20:41:43 +00:00
|
|
|
const { gameId, progresses } = this;
|
2020-08-14 23:58:55 +00:00
|
|
|
|
2020-08-15 20:41:43 +00:00
|
|
|
return progresses[gameId] || null;
|
2020-08-14 23:58:55 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
coverUrl() {
|
|
|
|
return this.game
|
|
|
|
&& this.game.cover
|
|
|
|
&& this.game.cover.image_id
|
|
|
|
? `https://images.igdb.com/igdb/image/upload/t_cover_big_2x/${this.game.cover.image_id}.jpg`
|
|
|
|
: '/static/no-image.jpg';
|
|
|
|
},
|
|
|
|
|
|
|
|
rating() {
|
|
|
|
return this.game && this.game.rating
|
|
|
|
? Math.round((this.game.rating / 20) * 2) / 2
|
|
|
|
: false;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
2020-08-21 06:13:45 +00:00
|
|
|
setData() {
|
|
|
|
const { gameId, list } = this.gameModalData;
|
|
|
|
|
|
|
|
this.gameId = gameId;
|
|
|
|
this.list = list;
|
|
|
|
this.game = this.games[gameId];
|
|
|
|
},
|
|
|
|
|
|
|
|
async loadGame() {
|
|
|
|
this.loading = true;
|
|
|
|
|
|
|
|
const { gameId } = this.gameModalData;
|
|
|
|
|
|
|
|
const game = await this.$store.dispatch('LOAD_GAME', gameId)
|
|
|
|
.catch(() => {
|
|
|
|
this.loading = false;
|
|
|
|
this.$bvToast.toast('Error loading game', { title: 'Error', variant: 'error' });
|
|
|
|
});
|
|
|
|
|
|
|
|
// avoid error when closing modal before game finishes loading
|
|
|
|
if (!this.game) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.game = {
|
|
|
|
...this.game,
|
|
|
|
...game,
|
|
|
|
};
|
|
|
|
|
|
|
|
this.loading = false;
|
|
|
|
|
|
|
|
this.$ga.event({
|
|
|
|
eventCategory: 'game',
|
|
|
|
eventAction: 'view',
|
|
|
|
eventLabel: 'gameViewed',
|
|
|
|
eventValue: `${this.platform.name} - ${this.game.name}`,
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2020-08-14 23:58:55 +00:00
|
|
|
reset() {
|
|
|
|
this.gameId = null;
|
2020-08-22 12:21:15 +00:00
|
|
|
this.loading = true;
|
|
|
|
this.game = {};
|
2020-08-14 23:58:55 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
2020-08-22 12:21:15 +00:00
|
|
|
|
|
|
|
|
|
|
|
<style lang="scss" rel="stylesheet/scss">
|
|
|
|
.b-rating {
|
|
|
|
line-height: normal !important;
|
|
|
|
height: auto !important;
|
|
|
|
}
|
|
|
|
</style>
|