c0b409debc9bc8e1e2d8cb2ffd0b7d928ecdda5a
[vchess.git] / public / javascripts / components / problemSummary.js
1 // Show a problem summary on variant page
2 Vue.component('my-problem-summary', {
3 props: ['prob'],
4 template: `
5 <div class="problem col-sm-12" @click="showProblem()">
6 <div class="diagram" v-html="getDiagram(prob.fen)"></div>
7 <div class="problem-instructions" v-html="prob.instructions.substr(0,32)"></div>
8 <div class="problem-time">{{ timestamp2date(prob.added) }}</div>
9 </div>
10 `,
11 methods: {
12 getDiagram: function(fen) {
13 const fenParts = fen.split(" ");
14 return getDiagram({
15 position: fenParts[0],
16 // No need for flags here
17 turn: fenParts[2],
18 });
19 },
20 timestamp2date(ts) {
21 return getDate(new Date(ts));
22 },
23 // Propagate "show problem" event to parent component (my-problems)
24 showProblem: function() {
25 this.$emit('show-problem');
26 },
27 },
28 })