editable flag moved to grider

This commit is contained in:
Jan Prochazka
2020-10-30 19:33:21 +01:00
parent 5f56aa2cf6
commit d243e8cee5
6 changed files with 12 additions and 3 deletions

View File

@@ -16,7 +16,6 @@ export class FreeTableGridDisplay extends GridDisplay {
this.columns = this.getDisplayColumns(model); this.columns = this.getDisplayColumns(model);
this.filterable = false; this.filterable = false;
this.sortable = false; this.sortable = false;
this.editable = true;
} }
getDisplayColumns(model: FreeTableModel) { getDisplayColumns(model: FreeTableModel) {

View File

@@ -16,7 +16,7 @@ export class ViewGridDisplay extends GridDisplay {
this.columns = this.getDisplayColumns(view); this.columns = this.getDisplayColumns(view);
this.filterable = true; this.filterable = true;
this.sortable = true; this.sortable = true;
this.editable = true; this.editable = false;
} }
getDisplayColumns(view: ViewInfo) { getDisplayColumns(view: ViewInfo) {

View File

@@ -66,6 +66,10 @@ export default class ChangeSetGrider extends Grider {
this.rowCacheIndexes.add(index); this.rowCacheIndexes.add(index);
} }
get editable() {
return this.display.editable;
}
get canInsert() { get canInsert() {
return !!this.display.baseTable; return !!this.display.baseTable;
} }

View File

@@ -152,7 +152,7 @@ export default function DataGridCore(props) {
const [inplaceEditorState, dispatchInsplaceEditor] = React.useReducer((state, action) => { const [inplaceEditorState, dispatchInsplaceEditor] = React.useReducer((state, action) => {
switch (action.type) { switch (action.type) {
case 'show': case 'show':
if (!display.editable) return {}; if (!grider.editable) return {};
return { return {
cell: action.cell, cell: action.cell,
text: action.text, text: action.text,

View File

@@ -25,6 +25,9 @@ export default abstract class Grider {
revertAllChanges() {} revertAllChanges() {}
undo() {} undo() {}
redo() {} redo() {}
get editable() {
return false;
}
get canInsert() { get canInsert() {
return false; return false;
} }

View File

@@ -30,6 +30,9 @@ export default class FreeTableGrider extends Grider {
rows: model.rows.map((row, i) => (index == i ? { ...row, [uniqueName]: value } : row)), rows: model.rows.map((row, i) => (index == i ? { ...row, [uniqueName]: value } : row)),
}; };
} }
get editable() {
return true;
}
get canInsert() { get canInsert() {
return true; return true;
} }