.row(v-if="showOne")
.col-sm-12.col-md-10.col-md-offset-1.col-lg-8.col-lg-offset-2
#topPage
- .button-group(v-if="st.user.id == curproblem.uid")
+ .button-group(v-if="canIedit(curproblem.uid)")
button(@click="editProblem(curproblem)") {{ st.tr["Edit"] }}
button(@click="deleteProblem(curproblem)") {{ st.tr["Delete"] }}
span.vname {{ curproblem.vname }}
span.uname ({{ curproblem.uname }})
button.marginleft(@click="backToList()") {{ st.tr["Back to list"] }}
button.nomargin(@click="gotoPrevNext($event,curproblem,1)")
- | {{ st.tr["Previous"] }}
+ | {{ st.tr["Previous_p"] }}
button.nomargin(@click="gotoPrevNext($event,curproblem,-1)")
| {{ st.tr["Next_p"] }}
p.oneInstructions.clickable(
select#selectVariant(v-model="selectedVar")
option(
v-for="v in [emptyVar].concat(st.variants)"
+ v-if="!v.noProblems"
:value="v.id"
)
| {{ v.name }}
problems: { "mine": [], "others": [] },
// timestamp of oldest showed problem:
cursor: {
- "mine": Number.MAX_SAFE_INTEGER,
- "others": Number.MAX_SAFE_INTEGER
+ mine: Number.MAX_SAFE_INTEGER,
+ others: Number.MAX_SAFE_INTEGER
},
// hasMore == TRUE: a priori there could be more problems to load
- hasMore: { "mine": true, "others": true },
+ hasMore: { mine: true, others: true },
onlyMine: false,
showOne: false,
infoMsg: "",
+ admins: [1], //hard-coded for now. TODO
game: {
players: [{ name: "Problem" }, { name: "Problem" }],
mode: "analyze"
this.loadVariant(prob.vid, () => {
// Set FEN if possible (might not be correct yet)
if (V.IsGoodFen(prob.fen)) this.setDiagram(prob);
+ else prob.diag = "";
});
},
loadVariant: async function(vid, cb) {
// variant could not be ready, or not defined
if (prob.vid > 0 && this.loadedVar == prob.vid && V.IsGoodFen(prob.fen))
this.setDiagram(prob);
+ else prob.diag = "";
},
setDiagram: function(prob) {
// Condition: prob.fen is correct and global V is ready
data: { prob: this.curproblem },
success: (ret) => {
if (edit) {
- let editedP = this.problems.find(p => p.id == this.curproblem.id);
+ let editedP = this.problems["mine"]
+ .find(p => p.id == this.curproblem.id);
+ if (!editedP)
+ // I'm an admin and edit another user' problem
+ editedP = this.problems["others"]
+ .find(p => p.id == this.curproblem.id);
this.copyProblem(this.curproblem, editedP);
this.showProblem(editedP);
}
newProblem.id = ret.id;
newProblem.uid = this.st.user.id;
newProblem.uname = this.st.user.name;
- this.problems["mine"] = [newProblem].concat(this.problems["mine"]);
+ this.problems["mine"] =
+ [newProblem].concat(this.problems["mine"]);
}
document.getElementById("modalNewprob").checked = false;
this.infoMsg = "";
}
);
},
+ canIedit: function(puid) {
+ return this.admins.concat([puid]).includes(this.st.user.id);
+ },
editProblem: function(prob) {
// prob.diag might correspond to some other problem or be empty:
this.setDiagram(prob); //V is loaded at this stage