AccCourseWorkEdit: fix setting title on documents

This commit is contained in:
nobohan 2022-02-25 11:52:04 +01:00
parent 15487cd84c
commit 289d79e011
2 changed files with 5 additions and 15 deletions

View File

@ -76,7 +76,7 @@
class="form-control form-control-sm" class="form-control form-control-sm"
type="string" type="string"
:value=d.title :value=d.title
:id=i :id=d.id
@input="onInputDocumentTitle"/> @input="onInputDocumentTitle"/>
</div> </div>
</div> </div>
@ -260,9 +260,9 @@ export default {
return this.$store.dispatch('submit', callback).catch(e => { console.log(e); throw e; }); return this.$store.dispatch('submit', callback).catch(e => { console.log(e); throw e; });
}, },
onInputDocumentTitle(event) { onInputDocumentTitle(event) {
const id = event.target.id; const id = Number(event.target.id);
const title = event.target.value; const title = event.target.value;
this.$store.commit('updateDocumentTitle', {key: id, evaluationKey: this.evaluation.key, title: title}); this.$store.commit('updateDocumentTitle', {id: id, evaluationKey: this.evaluation.key, title: title});
}, },
addDocument(storedObject) { addDocument(storedObject) {
console.log(storedObject); console.log(storedObject);

View File

@ -295,18 +295,8 @@ const store = createStore({
state.isPosting = st; state.isPosting = st;
}, },
updateDocumentTitle(state, payload) { updateDocumentTitle(state, payload) {
state.evaluationsPicked.forEach( state.evaluationsPicked.find(e => e.key === payload.evaluationKey)
e => { .documents.find(d => d.id === payload.id).title = payload.title;
console.log(e);
if (e.key === payload.evaluationKey) {
e.documents.forEach(
d => {
d.title = payload.title;
}
)
}
}
)
} }
}, },
actions: { actions: {