From c6217babc45290925f2107f088ac5962b0817244 Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Wed, 19 Oct 2022 17:24:58 +0200 Subject: [PATCH] feat: display all projects when no skill is selected --- src/components/SkillPicker.vue | 3 ++- src/components/Timeline.vue | 30 ++++++++++++++++-------------- src/locales/en.json | 6 ++++-- src/locales/fr.json | 6 ++++-- src/service/projects.ts | 4 ++++ 5 files changed, 30 insertions(+), 19 deletions(-) diff --git a/src/components/SkillPicker.vue b/src/components/SkillPicker.vue index 6d3bf78..e89860e 100644 --- a/src/components/SkillPicker.vue +++ b/src/components/SkillPicker.vue @@ -39,6 +39,7 @@ +
@@ -74,7 +75,7 @@ export default class SkillPicker extends Vue { // list of available skills public readonly ids: tID[] = skills.available(); // currently selected skill - private sel: tID|null = tID.Vue; + private sel: tID|null = null; // list of ids to display according to the current tag private filtered: tID[] = []; diff --git a/src/components/Timeline.vue b/src/components/Timeline.vue index 1fd7558..a77075f 100644 --- a/src/components/Timeline.vue +++ b/src/components/Timeline.vue @@ -4,7 +4,7 @@
-

{{ $t('timeline.title') }}

+

{{ $t( (skill == null) ? 'timeline.title-all' : 'timeline.title') }}

@@ -137,25 +137,27 @@ export default class Timeline extends Vue { private skill: tID|null = null; private projects: Project[] = []; + private sort_projects(a: Project, b: Project): number { + 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(); + } + public filter(skill: tID|null) { this.skill = skill; if ( skill == null ) { - this.projects = []; + this.projects = projects.all().sort(this.sort_projects); return; } - 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(); - }); + this.projects = projects.bySkill(skill).sort(this.sort_projects); } protected short_date(date: Date): string { diff --git a/src/locales/en.json b/src/locales/en.json index 0199c31..d5bbd2d 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -10,13 +10,15 @@ "home.line5-2": "and", "home.line5-3": "(Arduino, Raspberry).", - "timeline.title": "Timeline of projects featuring", - "timeline.back": "Change skill", + "timeline.title": "Timeline of projects featuring", + "timeline.title-all": "Timeline of all projects", + "timeline.back": "Change skill", "skills.featured-before": "Featured in", "skills.featured-after-1": "project", "skills.featured-after-n": "projects", "skills.browse": "Browse projects", + "skills.browse-all": "Browse all projects", "tag.all": "All", "tag.web": "Web", diff --git a/src/locales/fr.json b/src/locales/fr.json index bfc1ba0..c2b64e5 100644 --- a/src/locales/fr.json +++ b/src/locales/fr.json @@ -10,13 +10,15 @@ "home.line5-2": "et l'", "home.line5-3": "(Arduino, Raspberry).", - "timeline.title": "Chronologie des projets avec", - "timeline.back": "Choisir compétence", + "timeline.title": "Chronologie des projets avec", + "timeline.title-all": "Chronologie des tous les projets", + "timeline.back": "Choisir compétence", "skills.featured-before": "Apparaît dans", "skills.featured-after-1": "projet", "skills.featured-after-n": "projets", "skills.browse": "Parcourir les projets", + "skills.browse-all": "Parcourir tous les projets", "tag.all": "Tout", "tag.web": "Web", diff --git a/src/service/projects.ts b/src/service/projects.ts index 5a07b15..4c45c13 100644 --- a/src/service/projects.ts +++ b/src/service/projects.ts @@ -1,6 +1,10 @@ import { Projects, Project } from '@/model/projects'; import { tID } from '@/model/skills'; +export function all(): Project[] { + return Projects; +} + // returns all projects featuring a specified skill. Keeping the order of the // projects model export function bySkill(skill: tID): Project[] {