Skip to content

Commit

Permalink
Max 4 of the same card in each deck
Browse files Browse the repository at this point in the history
  • Loading branch information
sindreslungaard committed Jun 6, 2020
1 parent 3b0772b commit 49b0556
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
17 changes: 16 additions & 1 deletion webapp/src/views/Decks.vue
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
</select>
<img @click="showWizard = true" class="fl edit-ico" width="25px" src="/assets/images/edit_icon.png">
<div class="right-btns">
<a :href="getShareUrl(selectedDeckUid)" v-if="selectedDeck.public" target="_blank"><img class="fl edit-ico share" width="25px" src="/assets/images/share_icon.png"></a>
<a :href="getShareUrl(selectedDeckUid)" v-if="selectedDeck && selectedDeck.public" target="_blank"><img class="fl edit-ico share" width="25px" src="/assets/images/share_icon.png"></a>
<div @click="newDeck()" class="btn new">New Deck</div>
<template v-if="selectedDeck && deckCopy && !decksEqual(selectedDeck, deckCopy)">
<div @click="save()" class="btn save">Save</div>
Expand Down Expand Up @@ -128,6 +128,14 @@ import { call } from '../remote'
import Header from '../components/Header.vue'
import config from '../config'
const permissions = () => {
let p = localStorage.getItem('permissions')
if(!p) {
return []
}
return p
}
export default {
name: 'decks',
components: {
Expand Down Expand Up @@ -188,6 +196,13 @@ export default {
if(!this.selected) {
return
}
if(this.selectedDeck.cards.filter(x => x == this.selected.uid).length >= 4) {
if(!permissions().includes("admin")) {
return
}
}
this.selectedDeck.cards.push(this.selected.uid)
},
Expand Down
1 change: 1 addition & 0 deletions webapp/src/views/Login.vue
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export default {
localStorage.setItem('email', res.data.user.email)
localStorage.setItem('username', res.data.user.username)
localStorage.setItem('uid', res.data.user.uid)
localStorage.setItem('permissions', res.data.user.permissions)
localStorage.setItem('token', res.data.token)
if(this.redirectTo) {
Expand Down
1 change: 1 addition & 0 deletions webapp/src/views/Register.vue
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export default {
localStorage.setItem('email', res.data.user.email)
localStorage.setItem('username', res.data.user.username)
localStorage.setItem('uid', res.data.user.uid)
localStorage.setItem('permissions', res.data.user.permissions)
localStorage.setItem('token', res.data.token)
if(this.redirectTo) {
Expand Down

0 comments on commit 49b0556

Please sign in to comment.