From 98fb976e16bd19564c960d64fceda49955c14fa6 Mon Sep 17 00:00:00 2001 From: Benjamin Auder Date: Mon, 17 Feb 2020 08:00:18 +0100 Subject: [PATCH] Sort problems by datetime --- client/src/views/Problems.vue | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) 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; -- 2.44.0