X-Git-Url: https://git.auder.net/?p=vchess.git;a=blobdiff_plain;f=client%2Fsrc%2Fviews%2FProblems.vue;h=bcfb3a3939cb2989b711dc4565eae6e74f7fbe88;hp=270707d3a46fa0a401ac7508f3ff30e72cbd90c5;hb=a9e7935190d8fc112e674add05e86b8d0152e8df;hpb=2c5d7b20742b802d9c47916915c1114bcfc9a9c3 diff --git a/client/src/views/Problems.vue b/client/src/views/Problems.vue index 270707d3..bcfb3a39 100644 --- a/client/src/views/Problems.vue +++ b/client/src/views/Problems.vue @@ -18,6 +18,7 @@ main ) option( v-for="v in [emptyVar].concat(st.variants)" + v-if="!v.noProblems" :value="v.id" :selected="curproblem.vid==v.id" ) @@ -53,9 +54,9 @@ main span.vname {{ curproblem.vname }} span.uname ({{ curproblem.uname }}) button.marginleft(@click="backToList()") {{ st.tr["Back to list"] }} - button.nomargin(@click="gotoPrevNext($event,curproblem,1)") + button.nomargin(@click="gotoPrevNext(curproblem,1)") | {{ st.tr["Previous_p"] }} - button.nomargin(@click="gotoPrevNext($event,curproblem,-1)") + button.nomargin(@click="gotoPrevNext(curproblem,-1)") | {{ st.tr["Next_p"] }} p.oneInstructions.clickable( v-html="parseHtml(curproblem.instruction)" @@ -114,6 +115,7 @@ main import { store } from "@/store"; import { ajax } from "@/utils/ajax"; import { checkProblem } from "@/data/problemCheck"; +import params from "@/parameters"; import { getDiagram } from "@/utils/printDiagram"; import { processModalClick } from "@/utils/modalClick"; import { ArrayFun } from "@/utils/array"; @@ -153,7 +155,6 @@ export default { onlyMine: false, showOne: false, infoMsg: "", - admins: [1], //hard-coded for now. TODO game: { players: [{ name: "Problem" }, { name: "Problem" }], mode: "analyze" @@ -318,6 +319,7 @@ export default { // $nextTick to be sure $refs["basegame"] exists this.$nextTick(() => { this.$refs["basegame"].re_setVariables(this.game); }); + this.curproblem.showSolution = false; //in case of this.copyProblem(p, this.curproblem); }); }; @@ -346,14 +348,22 @@ export default { ); } else processWhenWeHaveProb(); }, - gotoPrevNext: function(e, prob, dir) { + gotoPrevNext: function(prob, dir) { const mode = (this.onlyMine ? "mine" : "others"); const problems = this.problems[mode]; const startIdx = problems.findIndex(p => p.id == prob.id); const nextIdx = startIdx + dir; if (nextIdx >= 0 && nextIdx < problems.length) this.setHrefPid(problems[nextIdx]); - else if (this.hasMore[mode]) this.loadMore(mode); + else if (this.hasMore[mode]) { + this.loadMore( + mode, + (nbProbs) => { + if (nbProbs > 0) this.gotoPrevNext(prob, dir); + else alert(this.st.tr["No more problems"]); + } + ); + } else alert(this.st.tr["No more problems"]); }, prepareNewProblem: function() { @@ -399,7 +409,7 @@ export default { ); }, canIedit: function(puid) { - return this.admins.concat([puid]).includes(this.st.user.id); + return params.devs.concat([puid]).includes(this.st.user.id); }, editProblem: function(prob) { // prob.diag might correspond to some other problem or be empty: @@ -441,9 +451,16 @@ export default { const pids = this.problems[mode].map(p => p.id); ArrayFun.remove(res.problems, p => pids.includes(p.id), "all"); this.decorate(res.problems); - this.problems[mode] = this.problems[mode].concat(res.problems); + this.problems[mode] = + this.problems[mode].concat(res.problems) + // TODO: problems are alrady sorted, would just need to insert + // the current individual problem in list; more generally + // there is probably only one misclassified problem. + // (Unless the user navigated several times by URL to show a + // single problem...) + .sort((p1, p2) => p2.added - p1.added); } else this.hasMore[mode] = false; - if (!!cb) cb(); + if (!!cb) cb(L); } } );