Moved localStorage answers to sessionStorage
This commit is contained in:
parent
d8fa9eefaa
commit
f593767d1b
|
@ -6,7 +6,7 @@
|
|||
<ol class="thesis-list">
|
||||
<li v-for="thesis of theses">
|
||||
<label :for="`thesis-${thesis.id}`">
|
||||
{{ thesis.thesis }}
|
||||
{{ getThesisTitle(thesis.thesis) }}
|
||||
</label>
|
||||
<input
|
||||
:name="`thesis-${thesis.id}`"
|
||||
|
@ -44,6 +44,9 @@
|
|||
},
|
||||
|
||||
methods: {
|
||||
getThesisTitle (thesis) {
|
||||
return thesis[this.$i18n.locale]
|
||||
},
|
||||
addThesisEmphasis (thesis, event) {
|
||||
if (event.target.checked) {
|
||||
this.emphasized.push({ thesis: thesis.id })
|
||||
|
@ -53,7 +56,7 @@
|
|||
}
|
||||
},
|
||||
submitEmphasis () {
|
||||
localStorage.setItem('euromat-emphasized', JSON.stringify(this.emphasized))
|
||||
sessionStorage.setItem('euromat-emphasized', JSON.stringify(this.emphasized))
|
||||
this.$router.push({ path: this.isGermanLocale
|
||||
? '/thesen/ergebnis'
|
||||
: '/theses/results'
|
||||
|
|
|
@ -63,7 +63,7 @@
|
|||
if (this.currentThesis === this.thesesCount) {
|
||||
return
|
||||
}
|
||||
return this.getThesis(this.currentThesis).thesis
|
||||
return this.getThesis(this.currentThesis).thesis[this.$i18n.locale]
|
||||
},
|
||||
options () {
|
||||
return options.map(option =>
|
||||
|
@ -101,7 +101,7 @@
|
|||
event && event.target.blur()
|
||||
},
|
||||
forwardToResults () {
|
||||
localStorage.setItem('euromat-answers', JSON.stringify(this.answers))
|
||||
sessionStorage.setItem('euromat-answers', JSON.stringify(this.answers))
|
||||
this.$router.push({ path: this.isGermanLocale
|
||||
? '/thesen/gewichtung'
|
||||
: '/theses/emphasis'
|
||||
|
|
|
@ -133,8 +133,8 @@
|
|||
},
|
||||
|
||||
created () {
|
||||
const emphasized = JSON.parse(localStorage.getItem('euromat-emphasized'))
|
||||
const answers = JSON.parse(localStorage.getItem('euromat-answers'))
|
||||
const emphasized = JSON.parse(sessionStorage.getItem('euromat-emphasized'))
|
||||
const answers = JSON.parse(sessionStorage.getItem('euromat-answers'))
|
||||
|
||||
if (emphasized) this.emphasized = emphasized
|
||||
if (answers) this.answers = answers
|
||||
|
@ -148,8 +148,6 @@
|
|||
this.totalScoredPoints = this.scores
|
||||
.map(s => s.highestScore)
|
||||
.reduce(addUp, 0)
|
||||
|
||||
console.log(this.parties)
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -3,6 +3,13 @@ import EuroMat from './components/euromat'
|
|||
import Emphasis from './components/emphasis'
|
||||
import Results from './components/results'
|
||||
|
||||
function hasAnswers (to, from, next) {
|
||||
if (!sessionStorage.getItem('euromat-answers')) {
|
||||
next({ path: '/' })
|
||||
}
|
||||
next()
|
||||
}
|
||||
|
||||
export default [
|
||||
{
|
||||
path: '/thesen',
|
||||
|
@ -18,13 +25,15 @@ export default [
|
|||
path: 'gewichtung',
|
||||
alias: 'emphasis',
|
||||
name: 'emphasis',
|
||||
component: Emphasis
|
||||
component: Emphasis,
|
||||
beforeEnter: hasAnswers
|
||||
},
|
||||
{
|
||||
path: 'ergebnis',
|
||||
alias: 'results',
|
||||
name: 'results',
|
||||
component: Results
|
||||
component: Results,
|
||||
beforeEnter: hasAnswers
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue