Move toId to shared/utils/functions.ts
This commit is contained in:
parent
02be8a37a5
commit
262a691ed6
4 changed files with 8 additions and 13 deletions
|
@ -90,15 +90,12 @@
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import type { ChangeRecord, ScheduleLocation } from '~/shared/types/schedule';
|
import type { ChangeRecord, ScheduleLocation } from '~/shared/types/schedule';
|
||||||
import { applyChangeArray } from '~/shared/utils/changes';
|
import { applyChangeArray } from '~/shared/utils/changes';
|
||||||
|
import { toId } from '~/shared/utils/functions';
|
||||||
|
|
||||||
defineProps<{
|
defineProps<{
|
||||||
edit?: boolean
|
edit?: boolean
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
function toId(name: string) {
|
|
||||||
return name.toLowerCase().replace(/ /g, "-");
|
|
||||||
}
|
|
||||||
|
|
||||||
const schedule = await useSchedule();
|
const schedule = await useSchedule();
|
||||||
|
|
||||||
const changes = ref<ChangeRecord<ScheduleLocation>[]>([]);
|
const changes = ref<ChangeRecord<ScheduleLocation>[]>([]);
|
||||||
|
|
|
@ -210,7 +210,7 @@
|
||||||
import { DateTime, Duration } from 'luxon';
|
import { DateTime, Duration } from 'luxon';
|
||||||
import type { ChangeRecord, Schedule, ScheduleEvent, ScheduleLocation, TimeSlot } from '~/shared/types/schedule';
|
import type { ChangeRecord, Schedule, ScheduleEvent, ScheduleLocation, TimeSlot } from '~/shared/types/schedule';
|
||||||
import { applyChangeArray } from '~/shared/utils/changes';
|
import { applyChangeArray } from '~/shared/utils/changes';
|
||||||
import { enumerate, pairs } from '~/shared/utils/functions';
|
import { enumerate, pairs, toId } from '~/shared/utils/functions';
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
edit?: boolean,
|
edit?: boolean,
|
||||||
|
@ -240,10 +240,6 @@ interface Gap {
|
||||||
end: DateTime,
|
end: DateTime,
|
||||||
}
|
}
|
||||||
|
|
||||||
function toId(name: string) {
|
|
||||||
return name.toLowerCase().replace(/[^a-z0-9]+/g, "-");
|
|
||||||
}
|
|
||||||
|
|
||||||
function status(eventSlot: EventSlot) {
|
function status(eventSlot: EventSlot) {
|
||||||
if (
|
if (
|
||||||
!eventSlot.event
|
!eventSlot.event
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import { Account } from "~/shared/types/account";
|
import { Account } from "~/shared/types/account";
|
||||||
import { Role, Schedule, Shift, ShiftSlot, TimeSlot } from "~/shared/types/schedule";
|
import { Role, Schedule, Shift, ShiftSlot, TimeSlot } from "~/shared/types/schedule";
|
||||||
|
import { toId } from "~/shared/utils/functions";
|
||||||
|
|
||||||
const locations = [
|
const locations = [
|
||||||
{
|
{
|
||||||
|
@ -184,10 +185,6 @@ const rota = [
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
function toId(name: string) {
|
|
||||||
return name.toLowerCase().replace(/ /g, "-");
|
|
||||||
}
|
|
||||||
|
|
||||||
function toIso(date: Date) {
|
function toIso(date: Date) {
|
||||||
return date.toISOString().replace(":00.000Z", "Z");
|
return date.toISOString().replace(":00.000Z", "Z");
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,11 @@ export function* enumerate<T>(iterable: Iterable<T>) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Converts a name to an id */
|
||||||
|
export function toId(name: string) {
|
||||||
|
return name.toLowerCase().replace(/[^a-z0-9]+/g, "-");
|
||||||
|
}
|
||||||
|
|
||||||
/** Returns adjacent pairs from iterable */
|
/** Returns adjacent pairs from iterable */
|
||||||
export function* pairs<T>(iterable: Iterable<T>) {
|
export function* pairs<T>(iterable: Iterable<T>) {
|
||||||
let first;
|
let first;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue