From a9022a02dd0a054265705ae6c80b0f242f2cff8d Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Tue, 18 Oct 2022 17:01:05 +0200 Subject: [PATCH] feat: sort projects by end date priority (first to last) - still active with last start date - still active - ended last --- src/components/Timeline.vue | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/components/Timeline.vue b/src/components/Timeline.vue index b5a391d..fbf1b27 100644 --- a/src/components/Timeline.vue +++ b/src/components/Timeline.vue @@ -143,7 +143,18 @@ export default class Timeline extends Vue { this.projects = []; return; } - this.projects = projects.bySkill(skill); + this.projects = projects.bySkill(skill).sort( (a, b) => { + if( b.stopped_at == null && a.stopped_at == null ){ + return b.started_at.getTime() - a.started_at.getTime() + } + if( a.stopped_at != null && b.stopped_at == null ){ + return 1; + } + if( b.stopped_at != null && a.stopped_at == null ){ + return -1; + } + return b.started_at.getTime() - a.started_at.getTime(); + }); } private mounted() {