mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
AccompanyingCourseWorkEdit: replace document by a new one (working now)
This commit is contained in:
parent
dbe186547f
commit
6eac6044cd
@ -297,10 +297,6 @@ export default {
|
||||
this.$store.commit('addDocument', {key: this.evaluation.key, document: document});
|
||||
},
|
||||
replaceDocument(oldDocument, storedObject) {
|
||||
|
||||
console.log(oldDocument);
|
||||
console.log(storedObject);
|
||||
//console.log(oldDocument) how to get the old document?
|
||||
let document = {
|
||||
type: 'accompanying_period_work_evaluation_document',
|
||||
storedObject: storedObject,
|
||||
|
@ -213,27 +213,28 @@ const store = createStore({
|
||||
}));
|
||||
},
|
||||
removeDocument(state, {key, document}) {
|
||||
let evaluations = state.evaluationsPicked.find(e => e.key === key);
|
||||
let evaluation = state.evaluationsPicked.find(e => e.key === key);
|
||||
|
||||
if (evaluations === undefined) {
|
||||
if (evaluation === undefined) {
|
||||
return;
|
||||
}
|
||||
|
||||
evaluations.documents = evaluations.documents.filter(d => d.key !== document.key);
|
||||
evaluation.documents = evaluation.documents.filter(d => d.key !== document.key);
|
||||
},
|
||||
replaceDocument(state, payload) {
|
||||
console.log('payload', payload)
|
||||
console.log(state.evaluationsPicked)
|
||||
let evaluations = state.evaluationsPicked.find(e => e.key === payload.key);
|
||||
console.log(evaluations)
|
||||
if (evaluations === undefined) {
|
||||
let evaluation = state.evaluationsPicked.find(e => e.key === payload.key);
|
||||
if (evaluation === undefined) {
|
||||
return;
|
||||
}
|
||||
|
||||
//Add document with map
|
||||
evaluations.documents = evaluations.documents.map(d => d.key === payload.oldDocument.key ? payload.document : d); //TODO no key on documents!
|
||||
console.log(evaluations)
|
||||
|
||||
let newDocument = Object.assign(
|
||||
payload.document, {
|
||||
key: evaluation.documents.length + 1,
|
||||
workflows_availables: state.work.workflows_availables_evaluation_documents,
|
||||
workflows: [],
|
||||
}
|
||||
);
|
||||
evaluation.documents = evaluation.documents.map(d => d.id === payload.oldDocument.id ? newDocument : d);
|
||||
},
|
||||
addEvaluation(state, evaluation) {
|
||||
let e = {
|
||||
|
Loading…
x
Reference in New Issue
Block a user