Open mbektas opened 4 years ago
Thanks @mbektasbbg! I just wanted to comment and say this looks awesome at first glance. I'll give it a more in-depth review with comments in the the immediate future :)
I also sat down with Mehmet and we discussed some code style things as well as tested and found some behavior bugs in Firefox/Safari, which he took notes on.
Mehmet also mentioned he views this as an initial WIP implementation, and he has some design questions and wants to consider the implementation and design as definitely open for discussion.
And I'll add, @mbektasbbg, that I'm also really excited about this!
Hi @sccolbert (cc. @jasongrout, @blink1073, @afshin, @ellisonbg, @SylvainCorlay) I have been working on adding editing capabilities to DataGrid and trying to have a flexible design so that it is possibly something that can be merged to upstream and useful for everyone. It is still a work in progress and I would appreciate any feedback.
In a short summary, it adds a new DataModel (MutableDataModel), ICellEditorController interface with a concrete implementation and ICellEditor interface with several editor implementations and ICellInputValidator interface with concrete implementations for some types. I also added cursor movement using Tab & Enter keys within body or confined to selections when there are any.
Editing is possible if data model is of type MutableDataModel and there is a selection model. It is triggered using double click or typing. Editing can also be triggered programmatically, optionally with a custom editor and validator. Editor type to use is inferred from metadata if the metadata follows the schema defined in https://frictionlessdata.io/specs/table-schema/, otherwise if cell data is a primitive type TextCellEditor is used.
Cell editors to used can be set/overridden based on cell data type or metadata key-value pair match.
DataGrid example is modified to present most of the editing features including a custom cell editor.
Some Documentation to help with PR
Cursor movement
Deleting Cell values (setting to null) using Delete key
MutableDataModel which defines new method setData
Cell Editor
TextCellEditor
{type: 'string'}
NumberCellEditor
{type: 'number'}
IntegerCellEditor
{type: 'integer'}
BooleanCellEditor
{type: 'boolean'}
DateCellEditor
{type: 'date'}
OptionCellEditor
{type: any, constraint: {enum: [list of options]}}
DynamicOptionCellEditor
{type: any, constraint: {enum: 'dynamic'}}
. This is not a standard schema format, I extended it.Editor Controller
Validators
TextInputValidator
NumberInputValidator
IntegerInputValidator