Commit | Line | Data |
---|---|---|
81da2786 | 1 | // Preview a problem on variant page |
60d9063f | 2 | Vue.component('my-problem-summary', { |
badeb466 | 3 | props: ['prob','userid','preview'], |
81da2786 BA |
4 | template: ` |
5 | <div class="row problem"> | |
6 | <div class="col-sm-12 col-md-6 diagram" | |
7 | v-html="getDiagram(prob.fen)"> | |
8 | </div> | |
9 | <div class="col-sm-12 col-md-6"> | |
10 | <p v-html="prob.instructions"></p> | |
8ef618ef BA |
11 | <p v-if="!!prob.preview" v-html="prob.solution"></p> |
12 | <p v-else class="problem-time">{{ timestamp2date(prob.added) }}</p> | |
9e76c73c | 13 | <button v-show="!preview" @click="$emit('show-problem')">Show</button> |
badeb466 | 14 | <div v-show="prob.uid==userid && !preview" class="button-group"> |
936dc463 BA |
15 | <button @click="$emit('edit-problem')">Edit</button> |
16 | <button @click="$emit('delete-problem')">Delete</button> | |
8ef618ef | 17 | </div> |
81da2786 BA |
18 | </div> |
19 | </div> | |
20 | `, | |
21 | methods: { | |
22 | getDiagram: function(fen) { | |
23 | const fenParsed = V.ParseFen(fen); | |
24 | return getDiagram({ | |
25 | position: fenParsed.position, | |
26 | turn: fenParsed.turn, | |
27 | // No need for flags here | |
28 | }); | |
29 | }, | |
8ef618ef BA |
30 | timestamp2date(ts) { |
31 | return getDate(new Date(ts)); | |
32 | }, | |
81da2786 BA |
33 | }, |
34 | }) |