xh / hoist-react

🏗️ ⚛️ The XH Hoist toolkit for React
https://xh.io
Apache License 2.0
24 stars 9 forks source link

Store handling of structural changes #2354

Open haynesjm42 opened 3 years ago

haynesjm42 commented 3 years ago

Currently if you want to make a structural change to the records in a Store you need to use the updateData() method to first remove a record from its existing parent in 1 transaction, and then subsequently re-add the record to the new parent in another transaction. We also don't support changing parents in the modifyRecords() method so changing the structure of the store is always going to "commit" that record and the structural change cannot be reverted.

Seems like we could support a move in our RecordSet transactions and add some support to the Store updateData() and modifyRecords() apis to handle moving records around in the hierarchy. This likely requires considering the parent in any record equality checking and tracking a "committed" parent on the record itself to be consistent with the record data - either committedData or committedParent being different than data or parent would indicate that the Record (and Store) has been modified and needs to be committed.

Note that this change is in support of a client app need for drag-and-drop hierarchy changes in an inline-editing enabled grid which needs to make use of the Store/Record add/modify/remove apis.

lbwexler commented 3 years ago

😱