From da2ae333c9310645f2e8a08532ba032c00ed25c2 Mon Sep 17 00:00:00 2001 From: Gitea Date: Sat, 21 Aug 2021 08:26:14 +0200 Subject: [PATCH] Extracting sorting modes into its own model --- js/src/types/sorting.model.ts | 19 +++++++++++++ js/src/views/Home.vue | 52 ++++++++++++----------------------- 2 files changed, 37 insertions(+), 34 deletions(-) create mode 100644 js/src/types/sorting.model.ts diff --git a/js/src/types/sorting.model.ts b/js/src/types/sorting.model.ts new file mode 100644 index 000000000..57271875c --- /dev/null +++ b/js/src/types/sorting.model.ts @@ -0,0 +1,19 @@ +import { EventSortField, SortDirection } from "./enums"; + +export interface ISorting { + title: string; + orderBy: EventSortField; + direction: SortDirection; +} + +export class SortingUpcoming implements ISorting { + title = "Upcoming Events"; + orderBy = EventSortField.BEGINS_ON; + direction = SortDirection.ASC; +} + +export class SortingCreated implements ISorting { + title = "Recently created Events"; + orderBy = EventSortField.INSERTED_AT; + direction = SortDirection.DESC; +} diff --git a/js/src/views/Home.vue b/js/src/views/Home.vue index 8bb25d623..24034e735 100644 --- a/js/src/views/Home.vue +++ b/js/src/views/Home.vue @@ -51,15 +51,7 @@ >

- {{ - $t( - config && - config.instanceHomepageSorting === - InstanceHomepageSorting.UPCOMING - ? "Upcoming Events" - : "Last published events" - ) - }} + {{ $t(this.sorting.title) }}

@@ -297,15 +289,7 @@ />

- {{ - $t( - config && - config.instanceHomepageSorting === - InstanceHomepageSorting.UPCOMING - ? "Upcoming Events" - : "Last published events" - ) - }} + {{ $t(this.sorting.title) }}

@@ -337,12 +321,7 @@