From: Benjamin Auder Date: Fri, 14 Feb 2020 16:18:52 +0000 (+0100) Subject: Draft of a problems section + news system X-Git-Url: https://git.auder.net/doc/html/img/%24%7BgetWhatsApp%28link%29%7D?a=commitdiff_plain;h=604b951e4dc4647da9b251c5fff4ecb4c7b1b298;p=vchess.git Draft of a problems section + news system --- diff --git a/client/src/App.vue b/client/src/App.vue index d720b6eb..6183d66f 100644 --- a/client/src/App.vue +++ b/client/src/App.vue @@ -32,12 +32,13 @@ .clickable#flagContainer(onClick="doClick('modalLang')") img(v-if="!!st.lang" :src="flagImage") router-view - .row - .col-sm-12.col-md-10.col-md-offset-1.col-lg-8.col-lg-offset-2 - footer - router-link.menuitem(to="/about") {{ st.tr["About"] }} - p.clickable(onClick="doClick('modalContact')") - | {{ st.tr["Contact"] }} + .row + .col-sm-12.col-md-10.col-md-offset-1.col-lg-8.col-lg-offset-2 + footer + router-link.menuitem(to="/about") {{ st.tr["About"] }} + router-link.menuitem(to="/news") {{ st.tr["News"] }} + p.clickable(onClick="doClick('modalContact')") + | {{ st.tr["Contact"] }} + + diff --git a/client/src/views/Problems.vue b/client/src/views/Problems.vue index 4f832fad..9eca44b6 100644 --- a/client/src/views/Problems.vue +++ b/client/src/views/Problems.vue @@ -2,119 +2,267 @@ main input#modalNewprob.modal(type="checkbox" @change="infoMsg=''") div#newprobDiv(role="dialog" data-checkbox="modalNewprob") - .card(@keyup.enter="newProblem()") + .card(@keyup.enter="sendProblem()") 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)" + :value="v.id" + :selected="curproblem.vid==v.id" + ) + | {{ v.name }} + fieldset + label(for="inputFen") FEN + input#inputFen( + type="text" + v-model="curproblem.fen" + @input="trySetDiagram(curproblem)" + ) + div(v-html="curproblem.diag") + fieldset + textarea#instructions( + :placeholder="st.tr['Instructions']" + v-model="curproblem.instruction" + ) + p(v-html="parseHtml(curproblem.instruction)") + fieldset + textarea#solution( + :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 + button#newProblem(onClick="doClick('modalNewprob')") + | {{ st.tr["New problem"] }} + .row(v-if="showOne") + .col-sm-12.col-md-10.col-md-offset-1.col-lg-8.col-lg-offset-2 + #actions + button(@click="showOne=false") {{ st.tr["Back to list"] }} + button( + v-if="st.user.id == curproblem.uid" + @click="editProblem(curproblem)" + ) + | {{ st.tr["Edit"] }} + button( + v-if="st.user.id == curproblem.uid" + @click="deleteProblem(curproblem)" + ) + | {{ st.tr["Delete"] }} + h4 {{ curproblem.vname }} + p(v-html="parseHtml(curproblem.instruction)") + h4(@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 label(for="checkboxMine") {{ st.tr["My problems"] }} - input#checkboxMine(type="checkbox" v-model="onlyMines") + 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") + select#selectVariant(v-model="selectedVar") + 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 }} + div( + v-for="p in problems" + v-show="displayProblem(p)" + @click="showProblem(p)" + ) + h4 {{ p.vname }} p {{ p.fen }} - p {{ p.instruction }} - p {{ p.solution }} + p(v-html="p.instruction") + BaseGame(v-if="showOne" :game="game" :vr="vr")