From: Benjamin Auder Date: Sun, 29 Dec 2019 22:21:43 +0000 (+0100) Subject: A few fixes, drop planned problems support (replaced by forum + mode analyze) X-Git-Url: https://git.auder.net/variants/current/css/img/pieces/scripts/index.css?a=commitdiff_plain;h=afd3240d89a2f6191fe9426960dc0c1667b40c77;p=vchess.git A few fixes, drop planned problems support (replaced by forum + mode analyze) --- diff --git a/client/next_src/views/MyGames.vue b/client/next_src/views/MyGames.vue deleted file mode 100644 index 5f183da1..00000000 --- a/client/next_src/views/MyGames.vue +++ /dev/null @@ -1,45 +0,0 @@ - -// "My" games: tabs my archived local games, my correspondance games -// + my imported games (of any type). -// TODO: later, also add possibility to upload a game (parse PGN). -Vue.component("my-tab-games", { - props: ["settings"], - data: function() { - return { - display: "", - imported: [], - local: [], - corr: [] - }; - }, - template: ` -
-
- - - -
- - - - - - - -
- `, - created: function() { - // TODO: fetch corr games, local and corr - // if any corr game where it's my turn, set display = "corr", - // else set display = "local" (if any) or imported (if any and no local) - }, - methods: { - update: function() { - // TODO: scan local + imported games, if any new then add it - }, - }, -}); diff --git a/client/next_src/views/Problem.vue b/client/next_src/views/Problem.vue new file mode 100644 index 00000000..b30a22e9 --- /dev/null +++ b/client/next_src/views/Problem.vue @@ -0,0 +1,94 @@ +//TODO: new problem form + problem visualisation, like Game.vue (but simpler) +// --> mode analyze, moves = [], "load problem" +
+ +
+
+ +

{{ translate("Add a problem") }}

+
+
+ + +
+
+

{{ translate("Safe HTML tags allowed") }}

+ + + + + +
+
+
+
+ + + +
+ + +
+
+
+ previewProblem: function() { + if (!V.IsGoodFen(this.modalProb.fen)) + return alert(translations["Bad FEN description"]); + if (this.modalProb.instructions.trim().length == 0) + return alert(translations["Empty instructions"]); + if (this.modalProb.solution.trim().length == 0) + return alert(translations["Empty solution"]); + Vue.set(this.modalProb, "preview", true); + }, + editProblem: function(prob) { + this.modalProb = prob; + Vue.set(this.modalProb, "preview", false); + document.getElementById("modal-newproblem").checked = true; + }, + deleteProblem: function(pid) { + ajax( + "/problems/" + pid, + "DELETE", + response => { + // Delete problem from the list on client side + let problems = this.curProblems(); + const pIdx = problems.findIndex(p => p.id == pid); + problems.splice(pIdx, 1); + } + ); + }, + sendProblem: function() { + // Send it to the server and close modal + ajax( + "/problems/" + variant.id, + (this.modalProb.id > 0 ? "PUT" : "POST"), + this.modalProb, + response => { + document.getElementById("modal-newproblem").checked = false; + Vue.set(this.modalProb, "preview", false); + if (this.modalProb.id == 0) + { + this.myProblems.unshift({ + added: Date.now(), + id: response.id, + uid: user.id, + fen: this.modalProb.fen, + instructions: this.modalProb.instructions, + solution: this.modalProb.solution, + }); + if (!this.curProb && this.display != "mine") + this.display = "mine"; + } + else + this.modalProb.id = 0; + } + ); + }, diff --git a/client/next_src/views/Problems.vue b/client/next_src/views/Problems.vue index b7f217d0..368e09a7 100644 --- a/client/next_src/views/Problems.vue +++ b/client/next_src/views/Problems.vue @@ -47,52 +47,6 @@ Vue.component('my-problems', { }, // NOTE: always modals first, because otherwise "scroll to the end" undesirable effect template: ` -
- -
-
- -

{{ translate("Add a problem") }}

-
-
- - -
-
-

{{ translate("Safe HTML tags allowed") }}

- - - - - -
-
-
-
- - - -
- - -
-
-
- -
-
- -

{{ nomoreMessage }}

-
-