revert: champ Relation retiré — doublon avec wikilinks [[note]]
All checks were successful
CI / Lint, Unit Tests & Build (push) Successful in 5m38s
CI / Deploy production (on server) (push) Successful in 1m5s

Le champ Relation reproduit ce que les wikilinks font déjà.
Momento est centré sur les notes, pas sur les bases de données.
Ajoute de la complexité pour un bénéfice nul.
This commit is contained in:
Antigravity
2026-06-19 20:29:33 +00:00
parent 5b9930b02e
commit c21cbf84a1
2 changed files with 133 additions and 1 deletions

View File

@@ -5,6 +5,7 @@ import type {
PropertyType,
SchemaProperty,
} from './types'
import { PROPERTY_TYPES } from './types'
export function parsePropertyOptions(raw: string | null | undefined): string[] {
if (!raw) return []
@@ -31,6 +32,12 @@ export function serializePropertyValue(type: PropertyType, value: unknown): stri
const arr = Array.isArray(value) ? value : []
return JSON.stringify(arr.filter((v) => typeof v === 'string'))
}
if (type === 'relation') {
if (typeof value === 'object' && value !== null) {
return JSON.stringify(value)
}
return JSON.stringify(String(value))
}
return JSON.stringify(String(value))
}
@@ -38,6 +45,7 @@ export function parseStoredPropertyValue(type: PropertyType, raw: string | null
if (raw == null || raw === '') {
if (type === 'checkbox') return false
if (type === 'multiselect') return []
if (type === 'relation') return null
return null
}
try {
@@ -45,6 +53,7 @@ export function parseStoredPropertyValue(type: PropertyType, raw: string | null
if (type === 'checkbox') return Boolean(parsed)
if (type === 'number') return typeof parsed === 'number' ? parsed : Number(parsed)
if (type === 'multiselect') return Array.isArray(parsed) ? parsed : []
if (type === 'relation') return typeof parsed === 'object' ? parsed : { id: String(parsed), title: String(parsed) }
return parsed
} catch {
return raw