X-Git-Url: https://git.auder.net/doc/index.css?a=blobdiff_plain;f=public%2Fjavascripts%2Fcomponents%2Fproblems.js;h=6f03fd973bae4330c0eba1dceada95e00dee5669;hb=60d9063fdfcd4b7628fbc0e0fc594f083bda8761;hp=9a14c7090c4b6ec8be8505572be07b4207555703;hpb=e5dc87e0e8f2d53a910b2b42ed2a0a39ea6787aa;p=vchess.git
diff --git a/public/javascripts/components/problems.js b/public/javascripts/components/problems.js
index 9a14c709..6f03fd97 100644
--- a/public/javascripts/components/problems.js
+++ b/public/javascripts/components/problems.js
@@ -1,4 +1,5 @@
Vue.component('my-problems', {
+ props: ["queryHash","settings"],
data: function () {
return {
userId: user.id,
@@ -8,6 +9,7 @@ Vue.component('my-problems', {
display: "others", //or "mine"
curProb: null, //(reference to) current displayed problem (if any)
showSolution: false,
+ nomoreMessage: "",
pbNum: 0, //to navigate directly to some problem
// New problem (to upload), or existing problem to edit:
modalProb: {
@@ -32,14 +34,14 @@ Vue.component('my-problems', {
skip_next
-
+
{{ curProb.instructions }}
-
//TODO: use my-game in analyze mode ?
-
+
+
{{ translations["Show solution"] }}
@@ -128,9 +130,24 @@ Vue.component('my-problems', {
`,
+ watch: {
+ queryHash: function(newQhash) {
+ if (!!newQhash)
+ {
+ // New query hash = "id=42"; get 42 as problem ID
+ const pid = parseInt(newQhash.substr(2));
+ this.showProblem(pid);
+ }
+ else
+ this.curProb = null; //(back to) list display
+ },
+ },
created: function() {
- if (location.hash.length > 0)
- this.showProblem(location.hash.slice(1));
+ if (!!this.queryHash)
+ {
+ const pid = parseInt(this.queryHash.substr(2));
+ this.showProblem(pid);
+ }
else
this.firstFetch();
},
@@ -248,7 +265,7 @@ Vue.component('my-problems', {
}
}
ajax(
- "/problems/" + variant.name, //TODO: use variant._id ?
+ "/problems/" + variant.id,
"GET",
{
type: type,
@@ -283,7 +300,7 @@ Vue.component('my-problems', {
},
deleteProblem: function(pid) {
ajax(
- "/problems/" + variant.name + "/" + pid, //TODO: with variant.id ?
+ "/problems/" + variant.id + "/" + pid,
"DELETE",
response => {
// Delete problem from the list on client side
@@ -296,7 +313,7 @@ Vue.component('my-problems', {
sendProblem: function() {
// Send it to the server and close modal
ajax(
- "/problems/" + variant.name, //TODO: with variant.id ?
+ "/problems/" + variant.id,
(this.modalProb.id > 0 ? "PUT" : "POST"),
this.modalProb,
response => {