revert: champ Relation retiré — doublon avec wikilinks [[note]]
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user