fix(search): Fix event search order

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel
2023-04-26 16:33:11 +02:00
parent 4375438dc9
commit a4e7ee37be
5 changed files with 65 additions and 28 deletions

View File

@@ -39,7 +39,7 @@ import { IAddress } from "@/types/address.model";
import { AddressSearchType } from "@/types/enums";
import { computed, defineAsyncComponent } from "vue";
import { useI18n } from "vue-i18n";
import { useRouter } from "vue-router";
import { useRouter, useRoute } from "vue-router";
import RouteName from "@/router/name";
const FullAddressAutoComplete = defineAsyncComponent(
@@ -53,6 +53,7 @@ const props = defineProps<{
}>();
const router = useRouter();
const route = useRoute();
const emit = defineEmits<{
(event: "update:location", location: IAddress | null): void;
@@ -89,6 +90,7 @@ const submit = () => {
router.push({
name: RouteName.SEARCH,
query: {
...route.query,
locationName: location.value?.locality ?? location.value?.region,
lat,
lon,

View File

@@ -818,6 +818,7 @@ enum ViewMode {
enum EventSortValues {
MATCH_DESC = "MATCH_DESC",
START_TIME_ASC = "START_TIME_ASC",
START_TIME_DESC = "START_TIME_DESC",
CREATED_AT_DESC = "CREATED_AT_DESC",
CREATED_AT_ASC = "CREATED_AT_ASC",
@@ -831,6 +832,7 @@ enum GroupSortValues {
enum SortValues {
MATCH_DESC = "MATCH_DESC",
START_TIME_ASC = "START_TIME_ASC",
START_TIME_DESC = "START_TIME_DESC",
CREATED_AT_DESC = "CREATED_AT_DESC",
CREATED_AT_ASC = "CREATED_AT_ASC",
@@ -1157,7 +1159,7 @@ const sortOptions = computed(() => {
if (contentType.value == ContentType.EVENTS) {
options.push(
{
key: SortValues.START_TIME_DESC,
key: SortValues.START_TIME_ASC,
label: t("Event date"),
},
{
@@ -1239,6 +1241,9 @@ const sortByForType = (
value: SortValues,
allowed: typeof EventSortValues | typeof GroupSortValues
): SortValues | undefined => {
if (value === SortValues.START_TIME_ASC && when.value === "past") {
value = SortValues.START_TIME_DESC;
}
return Object.values(allowed).includes(value) ? value : undefined;
};