Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

N2w buttons #27

Merged
merged 20 commits into from
Aug 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
7ac37a4
Added updateSelectedSeason event
AlexTheMagnus Aug 25, 2020
a201269
Added TvSeries component's events
AlexTheMagnus Aug 25, 2020
2e5ad43
Added updateSelectedSeason event
AlexTheMagnus Aug 25, 2020
f40bfe3
Added TvSeries component's events
AlexTheMagnus Aug 25, 2020
9effcd8
Merge branch 'n2w-episode-info' of https://github.com/Need2Watch/N2W_…
RexusWolf Aug 26, 2020
80cf0ff
Deleted duplicate test
RexusWolf Aug 26, 2020
214085a
Added updateSelectedSeason event
AlexTheMagnus Aug 25, 2020
9811817
Added TvSeries component's events
AlexTheMagnus Aug 25, 2020
e042e42
Added updateSelectedSeason event
AlexTheMagnus Aug 25, 2020
66e8062
Added TvSeries component's events
AlexTheMagnus Aug 25, 2020
2b38c27
Merge branch 'n2w-episode-info' of https://github.com/Need2Watch/N2W_…
RexusWolf Aug 27, 2020
bba6321
Fixed selected episode bug when changing the selected season
AlexTheMagnus Aug 27, 2020
9ce4a6f
Merge branch 'n2w-episode-info' of github.com:Need2Watch/VueFront int…
AlexTheMagnus Aug 27, 2020
a03b20c
Fixed episode and season index bugs
AlexTheMagnus Aug 27, 2020
6a73f0a
Added EpisodeInfo, SeasonsList and EpisodesList tests
AlexTheMagnus Aug 27, 2020
1e69f04
Merge branch 'testing-time' into n2w-episode-info
AlexTheMagnus Aug 27, 2020
b282b09
Added SeasonsList tests
AlexTheMagnus Aug 27, 2020
4c96e6d
Added some tests to TvSeries view's components
AlexTheMagnus Aug 27, 2020
4537bb6
Added watchEpisode and unwatchEpisode events, added some tests
AlexTheMagnus Aug 28, 2020
cf3b99e
Separated follow and watch buttons
AlexTheMagnus Aug 28, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions src/components/buttons/N2wFollowButton.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<template>
<v-btn
v-on:click="followMovie"
v-if="!this.movie.following"
class="primary secondary--text"
>FOLLOW</v-btn>
<v-btn v-on:click="unfollowMovie" v-else class="primary secondary--text">FOLLOWING</v-btn>
</template>
<script>
import axios from 'axios';
import { mapGetters } from 'vuex';

export default {
name: 'N2wFollowButton',
computed: {
...mapGetters({
loggedUser: 'loggedUser/loggedUser',
movie: 'currentMovie/currentMovie',
}),
},
methods: {
followMovie() {
const previousThis = this;
axios
.post('http://127.0.0.1:5000/movies/follow', {
user_id: previousThis.loggedUser.userId,
movie_id: previousThis.movie.movie_id,
})
.then(function () {
previousThis.$store.dispatch('currentMovie/followMovie');
});
},
unfollowMovie() {
const previousThis = this;
axios
.post('http://127.0.0.1:5000/movies/unfollow', {
user_id: previousThis.loggedUser.userId,
movie_id: previousThis.movie.movie_id,
})
.then(function () {
previousThis.$store.dispatch('currentMovie/followMovie');
});
},
},
};
</script>
46 changes: 46 additions & 0 deletions src/components/buttons/N2wWatchButton.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<template>
<v-btn v-on:click="watchMovie" v-if="!this.movie.watched" color="n2wblue">
<v-icon>mdi-eye</v-icon>
</v-btn>
<v-btn v-on:click="unwatchMovie" v-else color="n2wblue">
<v-icon>mdi-eye-off</v-icon>
</v-btn>
</template>
<script>
import axios from 'axios';
import { mapGetters } from 'vuex';

export default {
name: 'N2wWatchButton',
computed: {
...mapGetters({
loggedUser: 'loggedUser/loggedUser',
movie: 'currentMovie/currentMovie',
}),
},
methods: {
watchMovie() {
const previousThis = this;
axios
.post('http://127.0.0.1:5000/movies/watch', {
user_id: previousThis.loggedUser.userId,
movie_id: previousThis.movie.movie_id,
})
.then(function () {
previousThis.$store.dispatch('currentMovie/watchMovie');
});
},
unwatchMovie() {
const previousThis = this;
axios
.post('http://127.0.0.1:5000/movies/unwatch', {
user_id: previousThis.loggedUser.userId,
movie_id: previousThis.movie.movie_id,
})
.then(function () {
previousThis.$store.dispatch('currentMovie/watchMovie');
});
},
},
};
</script>
26 changes: 0 additions & 26 deletions src/components/mainView/__tests__/N2wCalendar.spec.ts

This file was deleted.

66 changes: 8 additions & 58 deletions src/components/moviesView/N2wMovieCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,27 +19,19 @@
</v-card-subtitle>
<v-card-text class="headline mb-10">{{this.movie.overview}}</v-card-text>
<v-card-actions v-if="this.loggedUser.userId" class="movieCardActions">
<v-btn
v-on:click="followMovie"
v-if="!this.movie.following"
class="primary secondary--text"
>FOLLOW</v-btn>
<v-btn v-on:click="unfollowMovie" v-else class="primary secondary--text">FOLLOWING</v-btn>
<v-btn v-on:click="watchMovie" v-if="!this.movie.watched" color="n2wblue">
<v-icon>mdi-eye</v-icon>
</v-btn>
<v-btn v-on:click="unwatchMovie" v-else color="n2wblue">
<v-icon>mdi-eye-off</v-icon>
</v-btn>
<n2w-follow-button />
<n2w-watch-button />
</v-card-actions>
</v-col>
</v-row>
</v-card>
</template>
<script>
import axios from 'axios';
import { mapGetters } from 'vuex';

import N2wFollowButton from '../buttons/N2wFollowButton.vue';
import N2wWatchButton from '../buttons/N2wWatchButton.vue';

export default {
name: 'N2wMovieCard',
computed: {
Expand All @@ -57,51 +49,9 @@ export default {
},
},

methods: {
followMovie() {
const previousThis = this;
axios
.post('http://127.0.0.1:5000/movies/follow', {
user_id: previousThis.loggedUser.userId,
movie_id: previousThis.movie.movie_id,
})
.then(function () {
previousThis.$store.dispatch('currentMovie/followMovie');
});
},
watchMovie() {
const previousThis = this;
axios
.post('http://127.0.0.1:5000/movies/watch', {
user_id: previousThis.loggedUser.userId,
movie_id: previousThis.movie.movie_id,
})
.then(function () {
previousThis.$store.dispatch('currentMovie/watchMovie');
});
},
unfollowMovie() {
const previousThis = this;
axios
.post('http://127.0.0.1:5000/movies/unfollow', {
user_id: previousThis.loggedUser.userId,
movie_id: previousThis.movie.movie_id,
})
.then(function () {
previousThis.$store.dispatch('currentMovie/followMovie');
});
},
unwatchMovie() {
const previousThis = this;
axios
.post('http://127.0.0.1:5000/movies/unwatch', {
user_id: previousThis.loggedUser.userId,
movie_id: previousThis.movie.movie_id,
})
.then(function () {
previousThis.$store.dispatch('currentMovie/watchMovie');
});
},
components: {
N2wFollowButton,
N2wWatchButton,
},
};
</script>
Expand Down
2 changes: 1 addition & 1 deletion src/components/tvSeriesView/N2wEpisodeInfo.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<v-container class="secondary" fill-height>
<v-container data-testid="episode-info" class="secondary" fill-height>
<v-row class="fill-height">
<v-col>
<v-card-title>{{this.title}}</v-card-title>
Expand Down
16 changes: 14 additions & 2 deletions src/components/tvSeriesView/N2wEpisodesList.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,24 @@ export default {
excludeStories: /.*Data$/,
};

const N2wEpisodesListTemplate = `<N2wEpisodesList />`;
export const episodes = [
{ title: 'Rose', seen: true },
{ title: 'The End of the world', seen: true },
{ title: 'The Unquiet Dead', seen: true },
{ title: 'Aliens on London', seen: true },
{ title: 'World War Three', seen: false },
{ title: 'Dalek', seen: false },
{ title: 'The Long Game', seen: false },
];

const N2wEpisodesListTemplate = `<N2wEpisodesList :episodes=episodes></N2wEpisodesList>`;

// default task state
export const Default = () => ({
components: { N2wEpisodesList },
template: N2wEpisodesListTemplate,
props: {},
props: {
episodes: Array,
},
methods: {},
});
91 changes: 51 additions & 40 deletions src/components/tvSeriesView/N2wEpisodesList.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<v-container class="secondary" fill-height fluid>
<v-container data-testid="episodes-list" class="secondary" fill-height fluid>
<v-row align="center">
<v-col>
<p class="font-weight-black">Episodes</p>
Expand All @@ -13,16 +13,20 @@
</v-row>
<v-col cols="12">
<v-list color="transparent">
<v-list-item v-for="(item, index) in episodes" :key="item.title" @click="{}">
<v-list-item
v-for="(item, index) in episodes"
:key="item.title"
@click="updateSelectedEpisode(index)"
>
<v-list-item-content>
<v-list-item-title>{{index}}. {{item.title}}</v-list-item-title>
<v-list-item-title>{{ index }}. {{ item.title }}</v-list-item-title>
</v-list-item-content>

<v-list-item-action>
<v-btn v-if="item.seen" icon>
<v-btn v-on:click="watchEpisode" v-if="item.seen" icon>
<v-icon>mdi-eye</v-icon>
</v-btn>
<v-btn v-if="!item.seen" icon>
<v-btn v-on:click="unwatchEpisode" v-if="!item.seen" icon>
<v-icon>mdi-eye-off</v-icon>
</v-btn>
</v-list-item-action>
Expand All @@ -33,42 +37,49 @@
</template>

<script>
//import axios from 'axios';

export default {
name: 'N2wEpisodesList',
data: () => ({
episodes: [
{
title: 'Rose',
seen: true,
},
{
title: 'The End of the world',
seen: true,
},
{
title: 'The Unquiet Dead',
seen: true,
},
{
title: 'Aliens on London',
seen: true,
},
{
title: 'World War Three',
seen: false,
},
{
title: 'Dalek',
seen: false,
},
{
title: 'The Long Game',
seen: false,
},
],
}),
methods: {},
props: {
episodes: {
type: Array,
required: true,
},
},
methods: {
watchEpisode() {
/* Back part isn't ready

const previousThis = this;
axios
.post('http://127.0.0.1:5000/tvseries/watch', {
user_id: previousThis.loggedUser.userId,
tvSerie_id: previousThis.serie.serie_id,
})
.then(function () {
previousThis.$store.dispatch('currentTvSerie/watchTvSerie');
});
*/
},
unwatchEpisode() {
/* Back part isn't ready

const previousThis = this;
axios
.post('http://127.0.0.1:5000/tvseries/unwatch', {
user_id: previousThis.loggedUser.userId,
tvSerie_id: previousThis.serie.serie_id,
})
.then(function () {
previousThis.$store.dispatch('currentTvSerie/watchTvSerie');
});
*/
},
updateSelectedEpisode(episode) {
this.$emit('clickedEpisode', episode);
},
},
};
</script>
<style scoped>
</style>
<style scoped></style>
2 changes: 1 addition & 1 deletion src/components/tvSeriesView/N2wSeasonsList.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default {
excludeStories: /.*Data$/,
};

const N2wSeasonsListTemplate = `<N2wSeasonsList seasons=14></N2wSeasonsList>`;
const N2wSeasonsListTemplate = `<N2wSeasonsList :seasons=14></N2wSeasonsList>`;

// default task state
export const Default = () => ({
Expand Down
Loading