if (edit) {
let editedP = this.problems.find(p => p.id == this.curproblem.id);
this.copyProblem(this.curproblem, editedP);
- } //new problem
+ }
else {
+ // New problem
let newProblem = Object.assign({}, this.curproblem);
newProblem.id = ret.id;
newProblem.uid = this.st.user.id;
newProblem.uname = this.st.user.name;
- this.problems = this.problems.concat(newProblem);
+ this.problems = [newProblem].concat(this.problems);
+ this.resetCurProb();
}
- this.resetCurProb();
this.infoMsg = "";
+ document.getElementById("modalNewprob").checked = false;
}
);
},
editProblem: function(prob) {
- if (!prob.diag) this.setDiagram(prob); //V is loaded at this stage
+ // prob.diag might correspond to some other problem or be empty:
+ this.setDiagram(prob); //V is loaded at this stage
this.copyProblem(prob, this.curproblem);
window.doClick("modalNewprob");
},