From afd3240d89a2f6191fe9426960dc0c1667b40c77 Mon Sep 17 00:00:00 2001 From: Benjamin Auder Date: Sun, 29 Dec 2019 23:21:43 +0100 Subject: [PATCH] A few fixes, drop planned problems support (replaced by forum + mode analyze) --- client/next_src/views/MyGames.vue | 45 ------------- client/next_src/views/Problem.vue | 94 +++++++++++++++++++++++++++ client/next_src/views/Problems.vue | 99 ----------------------------- client/src/App.vue | 7 +- client/src/components/GameList.vue | 6 +- client/src/router.js | 11 +++- client/src/stylesheets/variant.sass | 48 +------------- client/src/translations/en.js | 18 +----- client/src/translations/fr.js | 18 +----- client/src/views/Game.vue | 5 +- client/src/views/MyGames.vue | 73 +++++++++++++++++++-- server/models/Game.js | 13 ++-- server/routes/games.js | 2 +- 13 files changed, 194 insertions(+), 245 deletions(-) delete mode 100644 client/next_src/views/MyGames.vue create mode 100644 client/next_src/views/Problem.vue 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 }}

-
-