X-Git-Url: https://git.auder.net/assets/icon_infos.svg?a=blobdiff_plain;f=public%2Fjavascripts%2Fcomponents%2Fproblems.js;h=3bd13f63baf8856259deca647cfece614feaef7f;hb=45109880413a50dec3a07298b987fb07d60630b2;hp=68830a4f7f9af93c281455eb43b8521f9a41aaf5;hpb=2d7194bd9c976f444e43e5dc0a725823b6472eb9;p=vchess.git
diff --git a/public/javascripts/components/problems.js b/public/javascripts/components/problems.js
index 68830a4f..3bd13f63 100644
--- a/public/javascripts/components/problems.js
+++ b/public/javascripts/components/problems.js
@@ -1,7 +1,13 @@
Vue.component('my-problems', {
data: function () {
return {
- problems: problemArray //initial value
+ problems: problemArray, //initial value
+ newProblem: {
+ fen: V.GenRandInitFen(),
+ instructions: "",
+ solution: "",
+ stage: "nothing", //or "preview" after new problem is filled
+ },
};
},
template: `
@@ -14,32 +20,31 @@ Vue.component('my-problems', {
-
+
+
+ // TODO: we don't want exactly the same display (-date +solution)
+
+
+
`,
@@ -82,18 +87,20 @@ Vue.component('my-problems', {
showNewproblemModal: function() {
document.getElementById("modal-newproblem").checked = true;
},
- postNewProblem: function() {
- const fen = document.getElementById("newpbFen").value;
- if (!V.IsGoodFen(fen))
+ previewNewProblem: function() {
+ if (!V.IsGoodFen(this.newProblem.fen))
return alert("Bad FEN string");
- const instructions = document.getElementById("newpbInstructions").value;
- const solution = document.getElementById("newpbSolution").value;
+ this.newProblem.stage = "preview";
+ },
+ sendNewProblem: function() {
+ // Send it to the server and close modal
ajax("/problems/" + variant, "POST", {
- fen: fen,
- instructions: instructions,
- solution: solution,
+ fen: this.newProblem.fen,
+ instructions: this.newProblem.instructions,
+ solution: this.newProblem.solution,
}, response => {
document.getElementById("modal-newproblem").checked = false;
+ this.newProblem.stage = "nothing";
});
},
},