Centralise readonly column logic
This commit is contained in:
parent
e2df7ae6db
commit
bf77537792
|
@ -6,6 +6,7 @@
|
||||||
|
|
||||||
const {
|
const {
|
||||||
rows,
|
rows,
|
||||||
|
columns,
|
||||||
focusedCellId,
|
focusedCellId,
|
||||||
focusedCellAPI,
|
focusedCellAPI,
|
||||||
menu,
|
menu,
|
||||||
|
@ -40,13 +41,10 @@
|
||||||
|
|
||||||
// Determine if the cell is editable
|
// Determine if the cell is editable
|
||||||
$: readonly =
|
$: readonly =
|
||||||
column.schema.autocolumn ||
|
columns.actions.isReadonly(column) ||
|
||||||
column.schema.disabled ||
|
(!$config.canEditRows && !row._isNewRow)
|
||||||
column.schema.type === "formula" ||
|
|
||||||
(!$config.canEditRows && !row._isNewRow) ||
|
|
||||||
column.schema.readonly
|
|
||||||
|
|
||||||
// Register this cell API if the row is focused
|
// Register this cell API if this cell is focused
|
||||||
$: {
|
$: {
|
||||||
if (focused) {
|
if (focused) {
|
||||||
focusedCellAPI.set(cellAPI)
|
focusedCellAPI.set(cellAPI)
|
||||||
|
|
|
@ -110,11 +110,24 @@ export const createActions = context => {
|
||||||
await datasource.actions.saveSchemaMutations()
|
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 {
|
return {
|
||||||
columns: {
|
columns: {
|
||||||
...columns,
|
...columns,
|
||||||
actions: {
|
actions: {
|
||||||
changeAllColumnWidths,
|
changeAllColumnWidths,
|
||||||
|
isReadonly,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue