Skip to content
Snippets Groups Projects
Commit f6f78784 authored by Ron Lucke's avatar Ron Lucke Committed by Elmar Ludwig
Browse files

fix #996

Closes #996

Merge request studip/studip!1106
parent ce3b0ab8
No related branches found
No related tags found
No related merge requests found
...@@ -75,6 +75,7 @@ ...@@ -75,6 +75,7 @@
<courseware-file-chooser <courseware-file-chooser
v-model="card.front_file_id" v-model="card.front_file_id"
:isImage="true" :isImage="true"
:canBeEmpty="true"
@selectFile="updateFile(index, 'front', $event)" @selectFile="updateFile(index, 'front', $event)"
/> />
</label> </label>
...@@ -87,6 +88,7 @@ ...@@ -87,6 +88,7 @@
<courseware-file-chooser <courseware-file-chooser
v-model="card.back_file_id" v-model="card.back_file_id"
:isImage="true" :isImage="true"
:canBeEmpty="true"
@selectFile="updateFile(index, 'back', $event)" @selectFile="updateFile(index, 'back', $event)"
/> />
</label> </label>
...@@ -154,8 +156,8 @@ export default { ...@@ -154,8 +156,8 @@ export default {
} }
}, },
hasNoNext() { hasNoNext() {
if(this.currentCards[this.currentCards.length -1] !== undefined) { if (this.currentCards[this.currentCards.length - 1] !== undefined) {
return this.currentCards[this.currentCards.length -1].active; return this.currentCards[this.currentCards.length - 1].active;
} else { } else {
return true; return true;
} }
...@@ -170,7 +172,14 @@ export default { ...@@ -170,7 +172,14 @@ export default {
}), }),
initCurrentData() { initCurrentData() {
if (this.cards !== '') { if (this.cards !== '') {
this.currentCards = JSON.parse(JSON.stringify(this.cards)); let cards = JSON.parse(JSON.stringify(this.cards));
cards.forEach((card, index) => {
card.active = false;
if (index === 0) {
card.active = true;
}
});
this.currentCards = cards;
} }
this.setCardTab = 0; this.setCardTab = 0;
}, },
...@@ -180,6 +189,7 @@ export default { ...@@ -180,6 +189,7 @@ export default {
cards.forEach((card) => { cards.forEach((card) => {
delete card.front_file; delete card.front_file;
delete card.back_file; delete card.back_file;
delete card.active;
}); });
let attributes = {}; let attributes = {};
attributes.payload = {}; attributes.payload = {};
...@@ -193,12 +203,23 @@ export default { ...@@ -193,12 +203,23 @@ export default {
}, },
updateFile(cardIndex, side, file) { updateFile(cardIndex, side, file) {
if (side === 'front') { if (side === 'front') {
this.currentCards[cardIndex].front_file_id = file.id; if (file) {
this.currentCards[cardIndex].front_file = file; this.currentCards[cardIndex].front_file_id = file.id;
this.currentCards[cardIndex].front_file = file;
}
else {
this.currentCards[cardIndex].front_file_id = '';
this.currentCards[cardIndex].front_file = [];
}
} }
if (side === 'back') { if (side === 'back') {
this.currentCards[cardIndex].back_file_id = file.id; if (file) {
this.currentCards[cardIndex].back_file = file; this.currentCards[cardIndex].back_file_id = file.id;
this.currentCards[cardIndex].back_file = file;
} else {
this.currentCards[cardIndex].back_file_id = '';
this.currentCards[cardIndex].back_file = [];
}
} }
}, },
addCard() { addCard() {
...@@ -209,8 +230,12 @@ export default { ...@@ -209,8 +230,12 @@ export default {
front_text: '', front_text: '',
back_file_id: '', back_file_id: '',
back_text: '', back_text: '',
back_file: [] back_file: [],
active: false
}); });
const index = this.currentCards.length - 1;
this.activateCard(index);
this.$nextTick(() => { this.setCardTab = index; });
}, },
removeCard(cardIndex){ removeCard(cardIndex){
this.currentCards = this.currentCards.filter((val, index) => { this.currentCards = this.currentCards.filter((val, index) => {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment