Can now move elements from list to list

This commit is contained in:
Kylart 2017-05-13 23:13:22 +02:00
parent 9824e8b048
commit 2d2f21fde2
2 changed files with 38 additions and 7 deletions

View File

@ -32,9 +32,11 @@
right>
<v-btn secondary dark slot="activator">Move to</v-btn>
<v-list>
<v-list-item v-for="action in actions(i)" :key="action">
<v-list-item @click.capture="moveTo(action.list, i)"
v-for="action in actions(i)"
:key="action">
<v-list-tile>
<v-list-tile-title>{{ action }}</v-list-tile-title>
<v-list-tile-title>{{ action.name }}</v-list-tile-title>
</v-list-tile>
</v-list-item>
</v-list>
@ -117,10 +119,16 @@
2: '',
3: ''
},
actionsList: [
'Watch list',
'Watching',
'Seen'
actionsList: [{
name: 'Watch list',
list: 'watchList'
}, {
name:'Watching',
list: 'watching'
}, {
name: 'Seen',
list: 'seen'
}
],
allSelected: {
1: false,
@ -161,7 +169,6 @@
},
addEntry (i) {
if (this.entries[i] !== '') {
console.log(i - 1)
console.log(`[${(new Date()).toLocaleTimeString()}]: Adding ${this.entries[i]} to list.`)
this.$store.commit('updateList', {
entry: this.entries[i],
@ -207,6 +214,24 @@
this.allSelected[i] = true
}
},
moveTo (name, i) {
this.selected[i].forEach((anime) => {
this.$store.commit('updateList', {
listName: name,
entry: anime
})
this.$store.commit('removeFromList', {
listName: this.actionsList[i - 1].list,
entry: anime
})
})
// Remove all selected class
const elems = document.getElementsByClassName('elem')
for (let j = 0, l = elems.length; j < l; ++j) { elems[j].children[0].classList.remove('selected') }
}
}
}

View File

@ -167,6 +167,12 @@ const store = new Vuex.Store({
log(`${listName} list updated.`)
}
},
removeFromList (state, data) {
const listName = data.listName
const index = state.watchLists[listName].indexOf(data.entry)
state.watchLists[listName].splice(index, 1)
}
},
actions: {