(rowId: string, field: DbField, value: string)
| 118 | } |
| 119 | |
| 120 | const commitCell = (rowId: string, field: DbField, value: string): void => { |
| 121 | if (field.type === 'select' || field.type === 'multiSelect') { |
| 122 | // Ensure each chosen value exists as an option (schema), then set the cell. |
| 123 | let next = doc |
| 124 | const values = field.type === 'multiSelect' ? splitMultiSelect(value) : value ? [value] : [] |
| 125 | for (const v of values) next = ensureSelectOption(next, field.id, v) |
| 126 | next = setCell(next, rowId, field.id, value) |
| 127 | updateDatabaseSchema(csvPath, next) |
| 128 | } else { |
| 129 | updateDatabaseRows(csvPath, setCell(doc, rowId, field.id, value)) |
| 130 | } |
| 131 | // Keep the linked page note's filename in step with the title field. |
| 132 | if (field.id === titleFieldId && doc.pages?.[rowId]) { |
| 133 | void renameRecordPage(csvPath, rowId) |
| 134 | } |
| 135 | } |
| 136 | |
| 137 | // Keep the active cell within bounds as rows/columns change. |
| 138 | useEffect(() => { |
no test coverage detected