X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=public%2Fjavascripts%2Fcomponents%2FproblemSummary.js;h=e7e1db7c60377faa7417db3438571365f70e3853;hb=b5fb8e693dc82037eec2617a7dc49d838a9a8441;hp=6003f08516db83417f9883cf620d207236b1e40a;hpb=da06a6eb0237123ce43fdb01cb06246b8b57f5e5;p=vchess.git diff --git a/public/javascripts/components/problemSummary.js b/public/javascripts/components/problemSummary.js index 6003f085..e7e1db7c 100644 --- a/public/javascripts/components/problemSummary.js +++ b/public/javascripts/components/problemSummary.js @@ -1,17 +1,33 @@ -// Show a problem summary on variant page +// Show a problem summary on variant page or new problem preview Vue.component('my-problem-summary', { - props: ['prob'], + props: ['prob','preview'], template: ` -
-
- {{ getDiagram(prob.fen) }} +
+
-
- {{ prob.instructions.substr(0,32) }} -
-
- {{ prob.added }} +
+

+

+

{{ timestamp2date(prob.added) }}

`, + methods: { + getDiagram: function(fen) { + const fenParsed = V.ParseFen(fen); + return getDiagram({ + position: fenParsed.position, + turn: fenParsed.turn, + // No need for flags here + }); + }, + timestamp2date(ts) { + return getDate(new Date(ts)); + }, + // Propagate "show problem" event to parent component (my-problems) + showProblem: function() { + this.$emit('show-problem'); + }, + }, })