X-Git-Url: https://git.auder.net/js/rpsls.js?a=blobdiff_plain;f=client%2Fsrc%2Fviews%2FProblems.vue;h=338eaaf2ff920b7cd2198c8ccb6ba49d3b19da43;hb=b3ef5759ad2cf1dcc1e48813bcfc9e1a67b92c7a;hp=e17bead7ea68ff4cfb5b1991a5d6dbddbdb12ba4;hpb=910d631b73cad5ffef1b4461157b704e7e7057d8;p=vchess.git diff --git a/client/src/views/Problems.vue b/client/src/views/Problems.vue index e17bead7..338eaaf2 100644 --- a/client/src/views/Problems.vue +++ b/client/src/views/Problems.vue @@ -8,7 +8,7 @@ main role="dialog" data-checkbox="modalNewprob" ) - .card(@keyup.enter="sendProblem()") + .card label#closeNewprob.modal-close(for="modalNewprob") fieldset label(for="selectVariant") {{ st.tr["Variant"] }} @@ -45,7 +45,7 @@ main button(@click="sendProblem()") {{ st.tr["Send"] }} #dialog.text-center {{ st.tr[infoMsg] }} .row(v-if="showOne") - .col-sm-12.col-md-10.col-md-offset-2 + .col-sm-12.col-md-10.col-md-offset-1.col-lg-8.col-lg-offset-2 #topPage span.vname {{ curproblem.vname }} span.uname ({{ curproblem.uname }}) @@ -60,7 +60,7 @@ main @click="deleteProblem(curproblem)" ) | {{ st.tr["Delete"] }} - p.clickable( + p.oneInstructions.clickable( v-html="parseHtml(curproblem.instruction)" @click="curproblem.showSolution=!curproblem.showSolution" ) @@ -72,7 +72,7 @@ main .row(v-else) .col-sm-12.col-md-10.col-md-offset-1.col-lg-8.col-lg-offset-2 #controls - button#newProblem(onClick="window.doClick('modalNewprob')") + button#newProblem(@click="prepareNewProblem()") | {{ st.tr["New problem"] }} label(for="checkboxMine") {{ st.tr["My problems"] }} input#checkboxMine( @@ -86,7 +86,7 @@ main :value="v.id" ) | {{ v.name }} - table + table#tProblems tr th {{ st.tr["Variant"] }} th {{ st.tr["Instructions"] }} @@ -159,7 +159,6 @@ export default { let names = {}; this.problems.forEach(p => { if (p.uid != this.st.user.id) names[p.uid] = ""; - //unknwon for now else p.uname = this.st.user.name; }); const showOneIfPid = () => { @@ -171,7 +170,10 @@ export default { res2.users.forEach(u => { names[u.id] = u.name; }); - this.problems.forEach(p => (p.uname = names[p.uid])); + this.problems.forEach(p => { + if (!p.uname) + p.uname = names[p.uid]; + }); showOneIfPid(); }); } else showOneIfPid(); @@ -273,7 +275,7 @@ export default { }, displayProblem: function(p) { return ( - (this.selectedVar == 0 || p.vid == this.selectedVar) && + (!this.selectedVar || p.vid == this.selectedVar) && ((this.onlyMines && p.uid == this.st.user.id) || (!this.onlyMines && p.uid != this.st.user.id)) ); @@ -290,10 +292,14 @@ export default { this.showOne = true; }); }, + prepareNewProblem: function() { + this.resetCurProb(); + window.doClick("modalNewprob"); + }, sendProblem: function() { const error = checkProblem(this.curproblem); if (error) { - alert(error); + alert(this.st.tr[error]); return; } const edit = this.curproblem.id > 0; @@ -306,21 +312,23 @@ export default { if (edit) { let editedP = this.problems.find(p => p.id == this.curproblem.id); this.copyProblem(this.curproblem, editedP); - } //new problem + this.showProblem(editedP); + } else { let newProblem = Object.assign({}, this.curproblem); newProblem.id = ret.id; newProblem.uid = this.st.user.id; newProblem.uname = this.st.user.name; - this.problems = this.problems.concat(newProblem); + this.problems = [newProblem].concat(this.problems); } - this.resetCurProb(); + document.getElementById("modalNewprob").checked = false; this.infoMsg = ""; } ); }, editProblem: function(prob) { - if (!prob.diag) this.setDiagram(prob); //V is loaded at this stage + // prob.diag might correspond to some other problem or be empty: + this.setDiagram(prob); //V is loaded at this stage this.copyProblem(prob, this.curproblem); window.doClick("modalNewprob"); }, @@ -351,6 +359,9 @@ textarea margin: 0 auto max-width: 400px +table#tProblems + max-height: 100% + #controls margin: 0 width: 100% @@ -358,6 +369,11 @@ textarea & > * margin: 0 +p.oneInstructions + margin: 0 + padding: 2px 5px + background-color: lightgreen + #topPage span.vname font-weight: bold