From: Benjamin Auder Date: Mon, 17 Feb 2020 07:00:18 +0000 (+0100) Subject: Sort problems by datetime X-Git-Url: https://git.auder.net/img/vendor/vue.min.js?a=commitdiff_plain;h=98fb976e16bd19564c960d64fceda49955c14fa6;p=vchess.git Sort problems by datetime --- diff --git a/client/src/views/Problems.vue b/client/src/views/Problems.vue index d3dfdfd2..9fa2d796 100644 --- a/client/src/views/Problems.vue +++ b/client/src/views/Problems.vue @@ -42,7 +42,7 @@ main .col-sm-12.col-md-10.col-md-offset-2 #topPage span.vname {{ curproblem.vname }} - span.uname {{ "(" + curproblem.uname + ")" }} + span.uname ({{ curproblem.uname }}) button.marginleft(@click="backToList()") {{ st.tr["Back to list"] }} button.nomargin( v-if="st.user.id == curproblem.uid" @@ -86,7 +86,7 @@ main th {{ st.tr["Instructions"] }} th {{ st.tr["Number"] }} tr( - v-for="p in problems" + v-for="p in sortedProblems" v-show="displayProblem(p)" @click="setHrefPid(p)" ) @@ -191,6 +191,12 @@ export default { this.showOne = false }, }, + computed: { + sortedProblems: function() { + // Newest first: + return this.problems.sort( (p1,p2) => p2.added - p1.added); + }, + }, methods: { setVname: function(prob) { prob.vname = this.st.variants.find(v => v.id == prob.vid).name;