-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Only remove deleted records form record arrays when saved #3539
Conversation
Before this commit records were deleted from record arrays just after deleting them, but before they were commited. This can be an issue if you want to keep records visible in the UI until they're actually removed.
this._recordWasDeleted(record); | ||
this.changedRecords.forEach((internalModel) => { | ||
if (get(internalModel, 'record.isDestroyed') || get(internalModel, 'record.isDestroying') || | ||
(get(internalModel, 'currentState.stateName') === 'root.deleted.saved')) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
@@ -661,6 +661,7 @@ var RootState = { | |||
// TODO: More robust semantics around save-while-in-flight | |||
willCommit: Ember.K, | |||
didCommit: function(internalModel) { | |||
internalModel.disconnectRelationships(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Entering the deleted.saved state should handle this most likely
…eteRecord - Removed disconnectRelationship method calls from model/states.js - Removed reconnectRelationships from modle/internal-model.js - Remove one-sided disconnect and reconnect relationship methods - Removed method definitions in internal-model for: - disconnectRelationships - reconnectRelationships - Removed method definitions in relationship for: - disconnect - reconnect - addRecordToInverse - Fixed incorrect tests
@igorT I have updated this pr based on your feedback. |
👍 that's great! I'm glad it could be useful |
@@ -685,6 +681,7 @@ var RootState = { | |||
isDirty: false, | |||
|
|||
setup: function(internalModel) { | |||
internalModel.clearRelationships(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We also do this on dematerialize, so it will be called twice now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should I remove the internalModel.clearRelationships();
from the unloadRecord
methods?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, I would rely on it there, and not here, but I think we can fix that later when I merge the unload refactor
ping @igorT |
Only remove deleted records form record arrays when saved
This commit: 1. Allows one to rollback belongsTo and hasMany relationships. 2. Reintroduces dirtyRecordFor*Change hooks on the adapter that allow one to customize when a record becomes dirty. 3. Added 'removeDeletedFromRelationshipsPriorToSave' flag to Adapter that allows one to opt back into the old deleted record from many array behavior (pre emberjs#3539). Known issues: 1. Rolling back a hasMany relationship from the parent side of the relationship does not work (doing the same from the child side works fine). See test that is commented out below as well as the discussion at the end of emberjs#2881#issuecomment-204634262 This was previously emberjs#2881 and is related to emberjs#3698
This commit: 1. Allows one to rollback belongsTo and hasMany relationships. 2. Reintroduces dirtyRecordFor*Change hooks on the adapter that allow one to customize when a record becomes dirty. 3. Added 'removeDeletedFromRelationshipsPriorToSave' flag to Adapter that allows one to opt back into the old deleted record from many array behavior (pre emberjs#3539). Known issues: 1. Rolling back a hasMany relationship from the parent side of the relationship does not work (doing the same from the child side works fine). See test that is commented out below as well as the discussion at the end of emberjs#2881#issuecomment-204634262 This was previously emberjs#2881 and is related to emberjs#3698
This commit: 1. Allows one to rollback belongsTo and hasMany relationships. 2. Reintroduces dirtyRecordFor*Change hooks on the adapter that allow one to customize when a record becomes dirty. 3. Added 'removeDeletedFromRelationshipsPriorToSave' flag to Adapter that allows one to opt back into the old deleted record from many array behavior (pre emberjs#3539). Known issues: 1. Rolling back a hasMany relationship from the parent side of the relationship does not work (doing the same from the child side works fine). See test that is commented out below as well as the discussion at the end of emberjs#2881#issuecomment-204634262 This was previously emberjs#2881 and is related to emberjs#3698
This commit: 1. Allows one to rollback belongsTo and hasMany relationships. 2. Reintroduces dirtyRecordFor*Change hooks on the adapter that allow one to customize when a record becomes dirty. 3. Added 'removeDeletedFromRelationshipsPriorToSave' flag to Adapter that allows one to opt back into the old deleted record from many array behavior (pre emberjs#3539). Known issues: 1. Rolling back a hasMany relationship from the parent side of the relationship does not work (doing the same from the child side works fine). See test that is commented out below as well as the discussion at the end of emberjs#2881#issuecomment-204634262 This was previously emberjs#2881 and is related to emberjs#3698
This commit: 1. Allows one to rollback belongsTo and hasMany relationships. 2. Reintroduces dirtyRecordFor*Change hooks on the adapter that allow one to customize when a record becomes dirty. 3. Added 'removeDeletedFromRelationshipsPriorToSave' flag to Adapter that allows one to opt back into the old deleted record from many array behavior (pre emberjs#3539). Known issues: 1. Rolling back a hasMany relationship from the parent side of the relationship does not work (doing the same from the child side works fine). See test that is commented out below as well as the discussion at the end of emberjs#2881#issuecomment-204634262 This was previously emberjs#2881 and is related to emberjs#3698
This commit: 1. Allows one to rollback belongsTo and hasMany relationships. 2. Reintroduces dirtyRecordFor*Change hooks on the adapter that allow one to customize when a record becomes dirty. 3. Added 'removeDeletedFromRelationshipsPriorToSave' flag to Adapter that allows one to opt back into the old deleted record from many array behavior (pre emberjs#3539). Known issues: 1. Rolling back a hasMany relationship from the parent side of the relationship does not work (doing the same from the child side works fine). See test that is commented out below as well as the discussion at the end of emberjs#2881#issuecomment-204634262 This was previously emberjs#2881 and is related to emberjs#3698
This commit: 1. Allows one to rollback belongsTo and hasMany relationships. 2. Reintroduces dirtyRecordFor*Change hooks on the adapter that allow one to customize when a record becomes dirty. 3. Added 'removeDeletedFromRelationshipsPriorToSave' flag to Adapter that allows one to opt back into the old deleted record from many array behavior (pre emberjs#3539). Known issues: 1. Rolling back a hasMany relationship from the parent side of the relationship does not work (doing the same from the child side works fine). See test that is commented out below as well as the discussion at the end of emberjs#2881#issuecomment-204634262 This was previously emberjs#2881 and is related to emberjs#3698
This commit: 1. Allows one to rollback belongsTo and hasMany relationships. 2. Reintroduces dirtyRecordFor*Change hooks on the adapter that allow one to customize when a record becomes dirty. 3. Added 'removeDeletedFromRelationshipsPriorToSave' flag to Adapter that allows one to opt back into the old deleted record from many array behavior (pre emberjs#3539). Known issues: 1. Rolling back a hasMany relationship from the parent side of the relationship does not work (doing the same from the child side works fine). See test that is commented out below as well as the discussion at the end of emberjs#2881#issuecomment-204634262 This was previously emberjs#2881 and is related to emberjs#3698
This commit: 1. Allows one to rollback belongsTo and hasMany relationships. 2. Reintroduces dirtyRecordFor*Change hooks on the adapter that allow one to customize when a record becomes dirty. 3. Added 'removeDeletedFromRelationshipsPriorToSave' flag to Adapter that allows one to opt back into the old deleted record from many array behavior (pre emberjs#3539). Known issues: 1. Rolling back a hasMany relationship from the parent side of the relationship does not work (doing the same from the child side works fine). See test that is commented out below as well as the discussion at the end of emberjs#2881#issuecomment-204634262 This was previously emberjs#2881 and is related to emberjs#3698
This commit: 1. Allows one to rollback belongsTo and hasMany relationships. 2. Reintroduces dirtyRecordFor*Change hooks on the adapter that allow one to customize when a record becomes dirty. 3. Added 'removeDeletedFromRelationshipsPriorToSave' flag to Adapter that allows one to opt back into the old deleted record from many array behavior (pre emberjs#3539). 4. Adds bin/build.js to build a standalone version of ember-data. Known issues: 1. Rolling back a hasMany relationship from the parent side of the relationship does not work (doing the same from the child side works fine). See test that is commented out below as well as the discussion at the end of emberjs#2881#issuecomment-204634262 This was previously emberjs#2881 and is related to emberjs#3698
This commit: 1. Allows one to rollback belongsTo and hasMany relationships. 2. Reintroduces dirtyRecordFor*Change hooks on the adapter that allow one to customize when a record becomes dirty. 3. Added 'removeDeletedFromRelationshipsPriorToSave' flag to Adapter that allows one to opt back into the old deleted record from many array behavior (pre emberjs#3539). 4. Adds bin/build.js to build a standalone version of ember-data. Known issues: 1. Rolling back a hasMany relationship from the parent side of the relationship does not work (doing the same from the child side works fine). See test that is commented out below as well as the discussion at the end of emberjs#2881#issuecomment-204634262 This was previously emberjs#2881 and is related to emberjs#3698
This is a backport of a major breaking change in Ember Data 2.0. emberjs#3539
This is a backport of a major breaking change in Ember Data 2.0. emberjs#3539
This commit: 1. Allows one to rollback belongsTo and hasMany relationships. 2. Added 'shouldRemoveDeletedFromRelationshipsPriorToSave' flag to Adapter that allows one to opt back into the old deleted record from many array behavior (pre emberjs#3539). 3. Adds bin/build.js to build a standalone version of ember-data. Known issues: 1. Rolling back a hasMany relationship from the parent side of that relationship does not work (doing the same from the child side works fine). See test that is commented out below as well as the discussion at the end of emberjs#2881#issuecomment-204634262 This was previously emberjs#2881 and is related to emberjs#3698
This commit: 1. Allows one to rollback belongsTo and hasMany relationships. 2. Added 'shouldRemoveDeletedFromRelationshipsPriorToSave' flag to Adapter that allows one to opt back into the old deleted record from many array behavior (pre emberjs#3539). 3. Adds bin/build.js to build a standalone version of ember-data. Known issues: 1. Rolling back a hasMany relationship from the parent side of that relationship does not work (doing the same from the child side works fine). See test that is commented out below as well as the discussion at the end of emberjs#2881#issuecomment-204634262 This was previously emberjs#2881 and is related to emberjs#3698
This commit: 1. Allows one to rollback belongsTo and hasMany relationships. 2. Added 'shouldRemoveDeletedFromRelationshipsPriorToSave' flag to Adapter that allows one to opt back into the old deleted record from many array behavior (pre emberjs#3539). 3. Adds bin/build.js to build a standalone version of ember-data. Known issues: 1. Rolling back a hasMany relationship from the parent side of that relationship does not work (doing the same from the child side works fine). See test that is commented out below as well as the discussion at the end of emberjs#2881#issuecomment-204634262 This was previously emberjs#2881 and is related to emberjs#3698
This commit: 1. Allows one to rollback belongsTo and hasMany relationships. 2. Added 'shouldRemoveDeletedFromRelationshipsPriorToSave' flag to Adapter that allows one to opt back into the old deleted record from many array behavior (pre emberjs#3539). 3. Adds bin/build.js to build a standalone version of ember-data. Known issues: 1. Rolling back a hasMany relationship from the parent side of that relationship does not work (doing the same from the child side works fine). See test that is commented out below as well as the discussion at the end of emberjs#2881#issuecomment-204634262 This was previously emberjs#2881 and is related to emberjs#3698
This commit: 1. Allows one to rollback belongsTo and hasMany relationships. 2. Added 'shouldRemoveDeletedFromRelationshipsPriorToSave' flag to Adapter that allows one to opt back into the old deleted record from many array behavior (pre emberjs#3539). 3. Adds bin/build.js to build a standalone version of ember-data. Known issues: 1. Rolling back a hasMany relationship from the parent side of that relationship does not work (doing the same from the child side works fine). See test that is commented out below as well as the discussion at the end of emberjs#2881#issuecomment-204634262 This was previously emberjs#2881 and is related to emberjs#3698
No description provided.