diff --git a/components/data-view.vue b/components/data-view.vue index 48704457..f280deb7 100644 --- a/components/data-view.vue +++ b/components/data-view.vue @@ -1,4 +1,5 @@ diff --git a/composables/use-get-search-results.ts b/composables/use-get-search-results.ts index 0759a86d..8928b6aa 100644 --- a/composables/use-get-search-results.ts +++ b/composables/use-get-search-results.ts @@ -23,6 +23,29 @@ export const categories = [ "valueTypeID", ] as const; +/** + * The columns that can be sorted on. + * @id apiColumns + */ +export const columns = [ + "id", + "name", + "cidoc_class", + "system_class", + "begin_from", + "begin_to", + "end_from", + "end_to", +] as const; + +export type Column = (typeof columns)[number]; + +// Write a check to see if an object is of typed column +export function isColumn(value: unknown): value is Column { + return columns.includes(value as Column); +} + + export type Category = (typeof categories)[number]; export const operators = [ diff --git a/messages/de/common.json b/messages/de/common.json index 492a2358..3f65e600 100644 --- a/messages/de/common.json +++ b/messages/de/common.json @@ -132,6 +132,7 @@ "header": { "begin": "Anfang", "class": "Klasse", + "dates": "Datum", "description": "Beschreibung", "end": "Ende", "name": "Name" diff --git a/messages/en/common.json b/messages/en/common.json index b1efeee3..5b841d18 100644 --- a/messages/en/common.json +++ b/messages/en/common.json @@ -132,6 +132,7 @@ "header": { "begin": "Begin", "class": "Class", + "dates": "Dates", "description": "Description", "end": "End", "name": "Name" diff --git a/utils/data-table-value-updater.ts b/utils/data-table-value-updater.ts new file mode 100644 index 00000000..2a4c62ab --- /dev/null +++ b/utils/data-table-value-updater.ts @@ -0,0 +1,8 @@ +import type { Updater } from "@tanstack/vue-table"; +import type { Ref } from "vue"; + +// eslint-disable-next-line @typescript-eslint/no-explicit-any +export function valueUpdater>(updaterOrValue: T, ref: Ref) { + // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment + ref.value = typeof updaterOrValue === "function" ? updaterOrValue(ref.value) : updaterOrValue; +}