1
0
Fork 0
mirror of synced 2024-09-10 06:26:02 +12:00

Centralise readonly column logic

This commit is contained in:
Andrew Kingston 2024-06-24 08:12:46 +01:00
parent e2df7ae6db
commit bf77537792
No known key found for this signature in database
2 changed files with 17 additions and 6 deletions

View file

@ -6,6 +6,7 @@
const {
rows,
columns,
focusedCellId,
focusedCellAPI,
menu,
@ -40,13 +41,10 @@
// Determine if the cell is editable
$: readonly =
column.schema.autocolumn ||
column.schema.disabled ||
column.schema.type === "formula" ||
(!$config.canEditRows && !row._isNewRow) ||
column.schema.readonly
columns.actions.isReadonly(column) ||
(!$config.canEditRows && !row._isNewRow)
// Register this cell API if the row is focused
// Register this cell API if this cell is focused
$: {
if (focused) {
focusedCellAPI.set(cellAPI)

View file

@ -110,11 +110,24 @@ export const createActions = context => {
await datasource.actions.saveSchemaMutations()
}
const isReadonly = column => {
if (!column?.schema) {
return false
}
return (
column.schema.autocolumn ||
column.schema.disabled ||
column.schema.type === "formula" ||
column.schema.readonly
)
}
return {
columns: {
...columns,
actions: {
changeAllColumnWidths,
isReadonly,
},
},
}