Centralise readonly column logic
This commit is contained in:
parent
e2df7ae6db
commit
bf77537792
|
@ -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)
|
||||
|
|
|
@ -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,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue