Skip to content
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

Merged
merged 3 commits into from
Jul 18, 2015

Conversation

bmac
Copy link
Member

@bmac bmac commented Jul 13, 2015

No description provided.

drogus and others added 2 commits July 13, 2015 10:51
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')) {
Copy link
Contributor

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();
Copy link
Member

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
@bmac
Copy link
Member Author

bmac commented Jul 14, 2015

@igorT I have updated this pr based on your feedback.

@bmac
Copy link
Member Author

bmac commented Jul 14, 2015

@ianstarz Igor explained why its a good idea to remove disconnectRelationships/reconnectRelationships so I ended up pulling your commit from #3247 into this pr.

@ianstarz
Copy link
Contributor

👍 that's great! I'm glad it could be useful

@@ -685,6 +681,7 @@ var RootState = {
isDirty: false,

setup: function(internalModel) {
internalModel.clearRelationships();
Copy link
Member

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?

Copy link
Member Author

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?

Copy link
Member

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

@bmac
Copy link
Member Author

bmac commented Jul 17, 2015

ping @igorT

igorT added a commit that referenced this pull request Jul 18, 2015
Only remove deleted records form record arrays when saved
@igorT igorT merged commit 55b1e65 into emberjs:master Jul 18, 2015
@bmac bmac deleted the rebase-3247 branch August 20, 2015 17:48
mmpestorich added a commit to swarmbox/data that referenced this pull request Feb 4, 2018
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
mmpestorich added a commit to swarmbox/data that referenced this pull request Feb 4, 2018
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
mmpestorich added a commit to swarmbox/data that referenced this pull request Feb 4, 2018
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
mmpestorich added a commit to swarmbox/data that referenced this pull request Feb 4, 2018
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
mmpestorich added a commit to swarmbox/data that referenced this pull request Feb 4, 2018
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
mmpestorich added a commit to swarmbox/data that referenced this pull request Feb 4, 2018
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
mmpestorich added a commit to swarmbox/data that referenced this pull request Aug 8, 2018
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
mmpestorich added a commit to swarmbox/data that referenced this pull request Aug 8, 2018
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
mmpestorich added a commit to swarmbox/data that referenced this pull request Oct 24, 2019
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
mmpestorich added a commit to swarmbox/data that referenced this pull request Sep 18, 2020
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
mmpestorich added a commit to swarmbox/data that referenced this pull request Jan 1, 2021
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
mmun pushed a commit to Addepar/ember-data that referenced this pull request Oct 12, 2021
This is a backport of a major breaking change in Ember Data 2.0.

emberjs#3539
mmun pushed a commit to Addepar/ember-data that referenced this pull request Oct 12, 2021
This is a backport of a major breaking change in Ember Data 2.0.

emberjs#3539
mmpestorich added a commit to swarmbox/data that referenced this pull request Oct 31, 2022
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
mmpestorich added a commit to swarmbox/data that referenced this pull request Oct 31, 2022
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
jghansell pushed a commit to swarmbox/data that referenced this pull request Apr 13, 2023
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
mmpestorich added a commit to swarmbox/data that referenced this pull request Apr 14, 2023
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
jghansell pushed a commit to swarmbox/data that referenced this pull request Jun 13, 2024
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants