AccompanyingCourseWorkEdit: fix setting title of document with a fresh upload

This commit is contained in:
nobohan 2022-03-14 15:13:21 +01:00
parent 369397bf4f
commit 82052f5d70
2 changed files with 10 additions and 3 deletions

View File

@ -65,7 +65,7 @@
<h5>{{ $t('Documents') }} :</h5> <h5>{{ $t('Documents') }} :</h5>
<div class="flex-table"> <div class="flex-table">
<div class="item-bloc" v-for="(d, i) in evaluation.documents" :key="d.key"> <div class="item-bloc" v-for="(d, i) in evaluation.documents" :key="d.id">
<div class="item-row"> <div class="item-row">
<div class="input-group input-group-lg mb-3"> <div class="input-group input-group-lg mb-3">
<div> <div>
@ -75,6 +75,7 @@
type="text" type="text"
:value="d.title" :value="d.title"
:id="d.id" :id="d.id"
:data-key="i"
@input="onInputDocumentTitle"/> @input="onInputDocumentTitle"/>
</div> </div>
</div> </div>
@ -296,8 +297,9 @@ export default {
}, },
onInputDocumentTitle(event) { onInputDocumentTitle(event) {
const id = Number(event.target.id); const id = Number(event.target.id);
const key = Number(event.target.dataset.key) + 1;
const title = event.target.value; const title = event.target.value;
this.$store.commit('updateDocumentTitle', {id: id, evaluationKey: this.evaluation.key, title: title}); this.$store.commit('updateDocumentTitle', {id: id, key: key, evaluationKey: this.evaluation.key, title: title});
}, },
addDocument(storedObject) { addDocument(storedObject) {
let document = { let document = {

View File

@ -324,8 +324,13 @@ const store = createStore({
state.isPosting = st; state.isPosting = st;
}, },
updateDocumentTitle(state, payload) { updateDocumentTitle(state, payload) {
state.evaluationsPicked.find(e => e.key === payload.evaluationKey) if (payload.id === 0) {
state.evaluationsPicked.find(e => e.key === payload.evaluationKey)
.documents.find(d => d.key === payload.key).title = payload.title;
} else {
state.evaluationsPicked.find(e => e.key === payload.evaluationKey)
.documents.find(d => d.id === payload.id).title = payload.title; .documents.find(d => d.id === payload.id).title = payload.title;
}
} }
}, },
actions: { actions: {