owltide/utils/functions.ts
Hornwitser ae1c653af6 Separate event dipslay from event slot display
Pull out the list of events into its own page sorted by name and show
the event slots in chronological order on the schedule page, with past
slots hidden by default.  This makes the content underneath the schedule
the most immediately useful to have in the moment, while the full list
is kept separately and in a predictable order.
2025-07-16 19:37:23 +02:00

32 lines
940 B
TypeScript

/*
SPDX-FileCopyrightText: © 2025 Hornwitser <code@hornwitser.no>
SPDX-License-Identifier: AGPL-3.0-or-later
*/
import type { LocationQueryValue } from 'vue-router';
import type { Id } from '~/shared/types/common';
export function queryToString(item?: null | LocationQueryValue | LocationQueryValue[]) {
if (item === null)
return "";
if (item instanceof Array)
return queryToString(item[0])
return item;
}
export function queryToNumber(item?: null | LocationQueryValue | LocationQueryValue[]) {
if (item === null || item === undefined)
return undefined;
if (item instanceof Array)
return queryToNumber(item[0])
return Number.parseInt(item, 10);
}
export function queryToBoolean(item?: null | LocationQueryValue | LocationQueryValue[]) {
if (item === undefined)
return false;
return true;
}
export function idMap<T extends { id: Id }>(entities: T[]) {
return new Map(entities.map(entity => [entity.id, entity]));
}