cleanup dataeditor js code and hooks (#2095)
This commit is contained in:
parent
5211706bd4
commit
60c8c1d40e
@ -47,10 +47,21 @@ export function formatCell(value, column) {
|
|||||||
readonly: !editable,
|
readonly: !editable,
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
console.log("Warning: column.type is undefined for column.title=" + column.title)
|
||||||
return {
|
return {
|
||||||
kind: GridCellKind.Text,
|
kind: GridCellKind.Text,
|
||||||
data: value,
|
data: value,
|
||||||
displayData: "type not specified in column definition"
|
displayData: column.type
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export function formatDataEditorCells(col, row, columns, data) {
|
||||||
|
if (row < data.length && col < columns.length) {
|
||||||
|
const column = getDEColumn(columns, col);
|
||||||
|
const rowData = getDERow(data, row);
|
||||||
|
const cellData = locateCell(rowData, column);
|
||||||
|
return formatCell(cellData, column);
|
||||||
|
}
|
||||||
|
return { kind: GridCellKind.Loading };
|
||||||
|
}
|
@ -211,11 +211,9 @@ class DataEditor(NoSSRComponent):
|
|||||||
},
|
},
|
||||||
self.library: {ImportVar(tag="GridCellKind")},
|
self.library: {ImportVar(tag="GridCellKind")},
|
||||||
"/utils/helpers/dataeditor.js": {
|
"/utils/helpers/dataeditor.js": {
|
||||||
ImportVar(tag=f"getDEColumn", is_default=False, install=False),
|
ImportVar(
|
||||||
ImportVar(tag=f"getDERow", is_default=False, install=False),
|
tag=f"formatDataEditorCells", is_default=False, install=False
|
||||||
ImportVar(tag=f"locateCell", is_default=False, install=False),
|
),
|
||||||
ImportVar(tag=f"formatCell", is_default=False, install=False),
|
|
||||||
ImportVar(tag=f"onEditCell", is_default=False, install=False),
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
@ -258,21 +256,16 @@ class DataEditor(NoSSRComponent):
|
|||||||
|
|
||||||
code = [f"function {data_callback}([col, row])" "{"]
|
code = [f"function {data_callback}([col, row])" "{"]
|
||||||
|
|
||||||
|
columns_path = f"{self.columns._var_full_name}"
|
||||||
|
data_path = f"{self.data._var_full_name}"
|
||||||
|
|
||||||
code.extend(
|
code.extend(
|
||||||
[
|
[
|
||||||
f" if (row < {self.data._var_full_name}.length && col < {self.columns._var_full_name}.length)"
|
f" return formatDataEditorCells(col, row, {columns_path}, {data_path});",
|
||||||
" {",
|
|
||||||
f" const column = getDEColumn({self.columns._var_full_name}, col);",
|
|
||||||
f" const rowData = getDERow({self.data._var_full_name}, row);",
|
|
||||||
f" const cellData = locateCell(rowData, column);",
|
|
||||||
" return formatCell(cellData, column);",
|
|
||||||
" }",
|
" }",
|
||||||
" return { kind: GridCellKind.Loading};",
|
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
code.append("}")
|
|
||||||
|
|
||||||
return "\n".join(code)
|
return "\n".join(code)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
Loading…
Reference in New Issue
Block a user