Skip to content
This repository was archived by the owner on Oct 27, 2022. It is now read-only.

Commit 689e82f

Browse files
committed
Merge branch 'develop' into #73-add-to-home-message
2 parents 581f09f + 00e6bca commit 689e82f

File tree

8 files changed

+169
-112
lines changed

8 files changed

+169
-112
lines changed

src/components/cards/AssignButton.vue

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
></b-button>
1515
<b-button
1616
pill
17-
v-if="isAssigned && canBeChecked"
17+
v-if="isAssigned && isCheckable"
1818
@click="addPoints"
1919
id="button2"
2020
class="d-flex assign-button"
@@ -29,30 +29,28 @@
2929

3030
<script>
3131
import { mapActions, mapGetters } from 'vuex'
32-
import { $auth } from '@/firebase-config'
3332
3433
export default {
3534
name: 'AssignButton',
3635
props: {
37-
impulseId: String
36+
impulseId: {
37+
type: String,
38+
required: true
39+
}
3840
},
3941
computed: {
40-
user () {
41-
return $auth.currentUser
42-
},
4342
isAssigned () {
44-
return this.impulseIsAssigned(this.impulseId)
43+
return this.isAssignedImpulse(this.impulseId)
4544
},
46-
canBeChecked () {
47-
return this.impulseIsCheckable(this.impulseId)
45+
isCheckable () {
46+
return this.isCheckableImpulse(this.impulseId)
4847
},
4948
getSelectedPointsById () {
5049
return this.getSelectedPoints(this.impulseId)
5150
},
5251
...mapGetters({
53-
impulseIsAssigned: 'Userdata/impulseIsAssigned',
54-
impulseIsCheckable: 'Userdata/impulseIsCheckable',
55-
allPointsFromImpulse: 'Userdata/allPointsFromImpulse',
52+
isAssignedImpulse: 'Userdata/isAssignedImpulse',
53+
isCheckableImpulse: 'Userdata/isCheckableImpulse',
5654
getSelectedPoints: 'Impulse/getSelectedPoints'
5755
})
5856
},

src/components/cards/ImpulseCard.vue

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,25 @@
11
<template>
22
<div class="card-body" v-on:scrollToCard="scrollToCard">
3-
<router-link :to="detailLink">
4-
<div class="card-content">
3+
<div class="card-content" @click="flipCard">
54
<div class="card-text-headline">
65
<category-label :categoryId="impulse.category" />
76
<a :name="impulse.id" />
87
<h3>{{ impulse.title }}</h3>
98
</div>
109
<div class="card-text">
11-
<div v-if="impulse.forMe">
10+
<template v-if="impulse.forMe">
1211
<h4>Was bringt es mir?</h4>
1312
<div v-html="impulse.forMe" />
14-
</div>
15-
<div v-if="impulse.forWorld">
13+
</template>
14+
<template v-if="impulse.forWorld">
1615
<h4>Was bringt es der Welt?</h4>
1716
<div v-html="impulse.forWorld" />
18-
</div>
17+
</template>
1918
</div>
2019
</div>
21-
</router-link>
22-
<assign-button :impulseId="impulse.id" />
23-
<div class="card-background">
24-
<img src="@/assets/cards/Card-blue.svg">
25-
</div>
20+
<assign-button :impulseId="impulse.id" />
21+
<img class="card-background"
22+
src="@/assets/cards/Card-blue.svg">
2623
</div>
2724
</template>
2825
<script>
@@ -62,6 +59,9 @@ export default {
6259
if (impulseId && impulseId === this.impulse.id) {
6360
this.$el.scrollIntoView()
6461
}
62+
},
63+
flipCard () {
64+
this.$router.push(this.detailLink)
6565
}
6666
}
6767
}
@@ -85,9 +85,6 @@ export default {
8585
8686
.card-background {
8787
width: 100%;
88-
img {
89-
width: 100%;
90-
}
9188
}
9289
9390
.card-content {

src/router/index.js

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import Vue from 'vue'
55
import VueRouter from 'vue-router'
66
import store from '../store'
77
import Home from '../views/Home.vue'
8-
import RequestResetPassword from '../views/RequestResetPassword.vue'
98
import AssignedImpulse from '../views/AssignedImpulse.vue'
109

1110
Vue.use(VueRouter)
@@ -123,39 +122,36 @@ const routes = [
123122
{
124123
path: '/highscore',
125124
name: 'Highscore',
126-
// route level code-splitting
127-
// this generates a separate chunk (about.[hash].js) for this route
128-
// which is lazy-loaded when the route is visited.
129125
component: () => import(/* webpackChunkName: "highscore" */ '../views/Highscore.vue')
130126
},
131127
{
132128
path: '/login',
133129
name: 'Login',
134-
component: () => import('../views/Login.vue'),
130+
component: () => import(/* webpackChunkName: "auth" */ '../views/Login.vue'),
135131
meta: {
136132
requiresAuth: false
137133
}
138134
},
139135
{
140136
path: '/signup',
141137
name: 'SignUp',
142-
component: () => import('../views/SignUp.vue'),
138+
component: () => import(/* webpackChunkName: "auth" */ '../views/SignUp.vue'),
143139
meta: {
144140
requiresAuth: false
145141
}
146142
},
147143
{
148144
path: '/mail-verify',
149145
name: 'MailVerify',
150-
component: () => import('../views/MailNotVerified.vue'),
146+
component: () => import(/* webpackChunkName: "auth" */ '../views/MailNotVerified.vue'),
151147
meta: {
152148
requiresAuth: false
153149
}
154150
},
155151
{
156152
path: '/reset-password',
157153
name: 'ResetPassword',
158-
component: RequestResetPassword,
154+
component: () => import(/* webpackChunkName: "auth" */ '../views/RequestResetPassword.vue'),
159155
meta: {
160156
requiresAuth: false
161157
}
@@ -211,7 +207,9 @@ router.beforeEach((to, from, next) => {
211207
if (requiresAuth && !currentUser && to !== '/login') {
212208
next({
213209
path: '/login',
214-
params: { nextUrl: to.fullPath }
210+
query: {
211+
nextUrl: to
212+
}
215213
})
216214
} else {
217215
next()

src/store/modules/Auth.store.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,11 @@ export const actions = {
8585
$auth.signInWithEmailAndPassword(user.email, user.password)
8686
.then(result => {
8787
this.dispatch('Userdata/syncUser')
88-
router.push('/profile')
88+
if (user.redirect) {
89+
router.push(user.redirect)
90+
} else {
91+
router.push('/profile')
92+
}
8993
})
9094
.catch(error => {
9195
Vue.notify({
@@ -97,12 +101,16 @@ export const actions = {
97101
console.log(error)
98102
})
99103
},
100-
signInWithGoogle ({ commit }) {
104+
signInWithGoogle ({ commit }, redirect) {
101105
const provider = new firebase.auth.GoogleAuthProvider()
102106
$auth.signInWithPopup(provider)
103107
.then(user => {
104108
this.dispatch('Userdata/syncUser')
105-
router.push('/profile')
109+
if (redirect) {
110+
router.push(redirect)
111+
} else {
112+
router.push('/profile')
113+
}
106114
}).catch(error => {
107115
Vue.notify({
108116
group: 'notification',

src/store/modules/Userdata.store.js

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -196,13 +196,15 @@ export const getters = {
196196
return []
197197
}
198198
},
199-
impulseIsAssigned: (state) => (impulseId) => {
200-
const assignedImpulseMap = state.userdata.assignedImpulseMap || []
201-
if (Array.isArray(assignedImpulseMap)) {
202-
const found = assignedImpulseMap.some(impulse => impulse.impulseId === impulseId)
203-
return !!found
204-
} else {
205-
return false
199+
isAssignedImpulse: (state) => (impulseId) => {
200+
if (state.userdata) {
201+
const assignedImpulseMap = state.userdata.assignedImpulseMap || []
202+
if (Array.isArray(assignedImpulseMap)) {
203+
const found = assignedImpulseMap.some(impulse => impulse.impulseId === impulseId)
204+
return !!found
205+
} else {
206+
return false
207+
}
206208
}
207209
},
208210
allPointsFromImpulse: (state) => (impulseId) => {
@@ -212,20 +214,22 @@ export const getters = {
212214
const allPoints = timeStampArray.map(timeStamp => timeStamp.points).reduce((accumulator, currentValue) => accumulator + currentValue)
213215
return allPoints
214216
},
215-
impulseIsCheckable: (state) => (impulseId) => {
216-
const assignedImpulseMap = state.userdata.assignedImpulseMap
217-
const currentImpulse = assignedImpulseMap.find(impulse => impulse.impulseId === impulseId)
218-
const timeStampArray = currentImpulse.points
219-
const lastTimeStamp = timeStampArray[timeStampArray.length - 1]
220-
const todayDate = new Date()
221-
todayDate.setHours(0, 0, 0, 0)
222-
const today = firebase.firestore.Timestamp.fromDate(todayDate)
223-
const todayPlusOneDay = firebase.firestore.Timestamp.fromDate(
224-
new Date((lastTimeStamp.date.seconds * 1000) + 86400000))
225-
if (timeStampArray.length === 1) {
226-
return true
217+
isCheckableImpulse: (state) => (impulseId) => {
218+
if (state.userdata) {
219+
const assignedImpulseMap = state.userdata.assignedImpulseMap
220+
const currentImpulse = assignedImpulseMap.find(impulse => impulse.impulseId === impulseId)
221+
const timeStampArray = currentImpulse.points
222+
const lastTimeStamp = timeStampArray[timeStampArray.length - 1]
223+
const todayDate = new Date()
224+
todayDate.setHours(0, 0, 0, 0)
225+
const today = firebase.firestore.Timestamp.fromDate(todayDate)
226+
const todayPlusOneDay = firebase.firestore.Timestamp.fromDate(
227+
new Date((lastTimeStamp.date.seconds * 1000) + 86400000))
228+
if (timeStampArray.length === 1) {
229+
return true
230+
}
231+
return today > todayPlusOneDay
227232
}
228-
return today > todayPlusOneDay
229233
},
230234
displayName: (state) => {
231235
return state.userdata ? state.userdata.displayName : null

src/views/CardDetailPage.vue

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
<template>
2-
<div>
3-
<main-header headerTitle="Impuls" :backlink="backlink"></main-header>
2+
<div id="impulse-detail-view">
3+
<main-header headerTitle="Impuls" :backlink="backlink" />
44
<b-container>
5-
<div v-if="impulse" id="impulse-detail-view" class="my-4 mb-6 mx-2 p-2">
6-
<h1 class="mb-5 card-title">{{ impulse.title }}</h1>
7-
5+
<div v-if="impulse" class="impulse-card my-4 mb-6 mx-2 p-2">
6+
<div class="header">
7+
<category-label :categoryId="impulse.category" />
8+
<h1 class="mb-3 card-title">{{ impulse.title }}</h1>
9+
</div>
810
<div v-if="impulse.forMe">
911
<h2>Was bringt das mir?</h2>
1012
<div
1113
v-html="impulse.forMe"
1214
class="for-me"
1315
/>
14-
<hr class="my-4">
16+
<hr class="my-2">
1517
</div>
1618
<div v-if="impulse.forWorld">
1719
<h2>Was bringt es der Welt?</h2>
@@ -39,6 +41,7 @@
3941
<script>
4042
import { mapActions, mapGetters } from 'vuex'
4143
import MainHeader from '@/components/_base/Header'
44+
import CategoryLabel from '@/components/_base/CategoryLabel.vue'
4245
4346
export default {
4447
metaInfo () {
@@ -54,7 +57,7 @@ export default {
5457
}
5558
},
5659
components: {
57-
MainHeader
60+
MainHeader, CategoryLabel
5861
},
5962
created () {
6063
const impulseId = this.$route.params.id
@@ -88,11 +91,25 @@ export default {
8891
</script>
8992

9093
<style lang="scss" scoped>
91-
#impulse-detail-view {
94+
.impulse-card {
95+
--border-radius: 30px;
96+
97+
overflow: hidden;
9298
border: 5px solid $color-blue;
93-
border-radius: 30px;
99+
border-radius: var(--border-radius);
94100
max-width: 770px;
95101
102+
.header {
103+
margin-top: -0.5rem;
104+
margin-left: -0.5rem;
105+
margin-right: -0.5rem;
106+
margin-bottom: 0.5rem;
107+
border-top-left-radius: calc( var(--border-radius) - 2.5px);
108+
border-top-right-radius: var(--border-radius);
109+
padding: .5rem;
110+
background-color: $gray-200
111+
}
112+
96113
@media only screen and (max-width: 991px) {
97114
.card-title {
98115
font-size: 1.75rem;

0 commit comments

Comments
 (0)