X-Git-Url: https://git.auder.net/pieces/Checkered/cn.svg?a=blobdiff_plain;f=client%2Fsrc%2Fviews%2FProblems.vue;h=7f8632da5e58879a0837dc2cfa07b428f0788f45;hb=5fbc0680d484bf6b8f4ea183f26bbe22797f92a3;hp=4f832fadce8aadf724ec8d1db6aca2a5623d032f;hpb=89021f181ac0689bbc785ce0ebd9a910e66352b0;p=vchess.git
diff --git a/client/src/views/Problems.vue b/client/src/views/Problems.vue
index 4f832fad..7f8632da 100644
--- a/client/src/views/Problems.vue
+++ b/client/src/views/Problems.vue
@@ -1,127 +1,574 @@
main
- input#modalNewprob.modal(type="checkbox" @change="infoMsg=''")
- div#newprobDiv(role="dialog" data-checkbox="modalNewprob")
- .card(@keyup.enter="newProblem()")
+ input#modalRules.modal(type="checkbox")
+ div#rulesDiv(
+ role="dialog"
+ data-checkbox="modalRules"
+ )
+ .card
+ label.modal-close(for="modalRules")
+ a#variantNameInProblems(:href="'/#/variants/'+game.vname")
+ | {{ game.vname }}
+ div(v-html="rulesContent")
+ input#modalNewprob.modal(
+ type="checkbox"
+ @change="fenFocusIfOpened($event)"
+ )
+ div#newprobDiv(
+ role="dialog"
+ data-checkbox="modalNewprob"
+ )
+ .card
label#closeNewprob.modal-close(for="modalNewprob")
- form(@submit.prevent="newProblem()" @keyup.enter="newProblem()")
- fieldset
- label(for="selectVariant") {{ st.tr["Variant"] }}
- select#selectVariant(v-model="newproblem.vid" @change="loadVariant()")
- option(v-for="v in [emptyVar].concat(st.variants)" :value="v.id"
- :selected="newproblem.vid==v.id")
- | {{ v.name }}
- fieldset
- label(for="inputFen") FEN
- input#inputFen(type="text" v-model="newproblem.fen" @input="tryGetDiagram()")
- fieldset
- textarea#instructions(:placeholder="st.tr['Instructions']")
- textarea#solution(:placeholder="st.tr['Solution']")
- #preview
- div(v-html="curDiag")
- p instru: v-html=... .replace("\n", "
") --> si pas de tags détectés !
- p solution: v-html=...
- button(@click="newProblem()") {{ st.tr["Send problem"] }}
+ fieldset
+ label(for="selectVariant") {{ st.tr["Variant"] }}
+ select#selectVariant(
+ v-model="curproblem.vid"
+ @change="changeVariant(curproblem)"
+ )
+ option(
+ v-for="v in [emptyVar].concat(st.variants)"
+ v-if="!v.noProblems"
+ :value="v.id"
+ :selected="curproblem.vid==v.id"
+ )
+ | {{ v.name }}
+ fieldset
+ input#inputFen(
+ type="text"
+ placeholder="FEN"
+ v-model="curproblem.fen"
+ @input="trySetDiagram(curproblem)"
+ )
+ #diagram(v-html="curproblem.diag")
+ fieldset
+ textarea(
+ :placeholder="st.tr['Instructions']"
+ v-model="curproblem.instruction"
+ )
+ p(v-html="parseHtml(curproblem.instruction)")
+ fieldset
+ textarea(
+ :placeholder="st.tr['Solution']"
+ v-model="curproblem.solution"
+ )
+ p(v-html="parseHtml(curproblem.solution)")
+ button(@click="sendProblem()") {{ st.tr["Send"] }}
#dialog.text-center {{ st.tr[infoMsg] }}
- .row
- .col-sm-12
- button#newProblem(onClick="doClick('modalNewprob')") {{ st.tr["New problem"] }}
- .row
+ .row(v-if="showOne")
.col-sm-12.col-md-10.col-md-offset-1.col-lg-8.col-lg-offset-2
- label(for="checkboxMine") {{ st.tr["My problems"] }}
- input#checkboxMine(type="checkbox" v-model="onlyMines")
- label(for="selectVariant") {{ st.tr["Variant"] }}
- select#selectVariant(v-model="newproblem.vid")
- option(v-for="v in [emptyVar].concat(st.variants)" :value="v.id")
- | {{ v.name }}
- // TODO: nice problems printing :: same as in preview ==> subComponent (inlined?)
- div(v-for="p in problems" v-show="showProblem(p)")
- p {{ p.vid }}
- p {{ p.fen }}
- p {{ p.instruction }}
- p {{ p.solution }}
+ #topPage
+ .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(curproblem,1)")
+ | {{ st.tr["Previous_p"] }}
+ button.nomargin(@click="gotoPrevNext(curproblem,-1)")
+ | {{ st.tr["Next_p"] }}
+ p.oneInstructions.clickable(
+ v-html="parseHtml(curproblem.instruction)"
+ @click="curproblem.showSolution=!curproblem.showSolution"
+ )
+ | {{ st.tr["Show solution"] }}
+ p(
+ v-show="curproblem.showSolution"
+ v-html="parseHtml(curproblem.solution)"
+ )
+ .row(v-else)
+ .col-sm-12.col-md-10.col-md-offset-1.col-lg-8.col-lg-offset-2
+ #controls
+ button#newProblem(@click="prepareNewProblem()")
+ | {{ st.tr["New problem"] }}
+ div#myProblems(v-if="st.user.id > 0")
+ label(for="checkboxMine") {{ st.tr["My problems"] }}
+ input#checkboxMine(
+ type="checkbox"
+ v-model="onlyMine"
+ )
+ label(for="selectVariant") {{ st.tr["Variant"] }}
+ select#selectVariant(v-model="selectedVar")
+ option(
+ v-for="v in [emptyVar].concat(st.variants)"
+ v-if="!v.noProblems"
+ :value="v.id"
+ )
+ | {{ v.name }}
+ table#tProblems
+ tr
+ th {{ st.tr["Variant"] }}
+ th {{ st.tr["Instructions"] }}
+ th {{ st.tr["Number"] }}
+ tr(
+ v-for="p in problems[onlyMine ? 'mine' : 'others']"
+ v-show="onlyMine || !selectedVar || p.vid == selectedVar"
+ @click="setHrefPid(p)"
+ )
+ td {{ p.vname }}
+ td {{ firstChars(p.instruction) }}
+ td {{ p.id }}
+ button#loadMoreBtn(
+ v-if="hasMore[onlyMine ? 'mine' : 'others']"
+ @click="loadMore(onlyMine ? 'mine' : 'others')"
+ )
+ | {{ st.tr["Load more"] }}
+ BaseGame(
+ ref="basegame"
+ v-if="showOne"
+ :game="game"
+ )
+
+