{"action":"created","issue":{"url":"https://api.github.com/repos/emberjs/data/issues/3705","repository_url":"https://api.github.com/repos/emberjs/data","labels_url":"https://api.github.com/repos/emberjs/data/issues/3705/labels{/name}","comments_url":"https://api.github.com/repos/emberjs/data/issues/3705/comments","events_url":"https://api.github.com/repos/emberjs/data/issues/3705/events","html_url":"https://github.com/emberjs/data/issues/3705","id":103298021,"number":3705,"title":"Add ability to rollback specific attributes","user":{"login":"Panman8201","id":3475765,"avatar_url":"https://avatars.githubusercontent.com/u/3475765?v=3","gravatar_id":"","url":"https://api.github.com/users/Panman8201","html_url":"https://github.com/Panman8201","followers_url":"https://api.github.com/users/Panman8201/followers","following_url":"https://api.github.com/users/Panman8201/following{/other_user}","gists_url":"https://api.github.com/users/Panman8201/gists{/gist_id}","starred_url":"https://api.github.com/users/Panman8201/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Panman8201/subscriptions","organizations_url":"https://api.github.com/users/Panman8201/orgs","repos_url":"https://api.github.com/users/Panman8201/repos","events_url":"https://api.github.com/users/Panman8201/events{/privacy}","received_events_url":"https://api.github.com/users/Panman8201/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/emberjs/data/labels/Needs%20Team%20Discussion","name":"Needs Team Discussion","color":"5319e7"}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":9,"created_at":"2015-08-26T15:32:07Z","updated_at":"2016-10-26T10:54:25Z","closed_at":null,"body":"TL;DR `model.rollbackAttributes(['attrA','attrC'])`\r\n\r\nIt would be nice if the `.rollbackAttributes()` method accepted an array of attribute names that would be rolled back, leaving the others as-is. Ex: `model.rollbackAttributes(['attrA','attrC'])`\r\n\r\nSo in the example above, attributes 'attrA' and 'attrC' would have their values reverted to the previous, if changed. Other attributes, such as 'attrB', would retain their new value, if changed.\r\n\r\nRelated state information should properly reflect the rollback; `hasDirtyAttributes` and `changedAttributes()`. If there are other attributes *not* rolled back ('attrB') that have changed values, then `hasDirtyAttributes` would remain true. And calls to `changedAttributes()` would not return the rolled back attributes, but *would* return others that were changed.\r\n\r\nPassing in an empty array should trigger the default behavior, as though no array was passed in at all, rolling back all attributes."},"comment":{"url":"https://api.github.com/repos/emberjs/data/issues/comments/256313979","html_url":"https://github.com/emberjs/data/issues/3705#issuecomment-256313979","issue_url":"https://api.github.com/repos/emberjs/data/issues/3705","id":256313979,"user":{"login":"bluscreen","id":5500197,"avatar_url":"https://avatars.githubusercontent.com/u/5500197?v=3","gravatar_id":"","url":"https://api.github.com/users/bluscreen","html_url":"https://github.com/bluscreen","followers_url":"https://api.github.com/users/bluscreen/followers","following_url":"https://api.github.com/users/bluscreen/following{/other_user}","gists_url":"https://api.github.com/users/bluscreen/gists{/gist_id}","starred_url":"https://api.github.com/users/bluscreen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bluscreen/subscriptions","organizations_url":"https://api.github.com/users/bluscreen/orgs","repos_url":"https://api.github.com/users/bluscreen/repos","events_url":"https://api.github.com/users/bluscreen/events{/privacy}","received_events_url":"https://api.github.com/users/bluscreen/received_events","type":"User","site_admin":false},"created_at":"2016-10-26T10:54:25Z","updated_at":"2016-10-26T10:54:25Z","body":"I had the same issue and managed to create a little workaround via changedAttributes like so:\r\n`rollbackSpecificAttribs: function (specificAttribs) {\r\n        const changedAttribs = this.changedAttributes()\r\n        Object.keys(changedAttribs).forEach(attrib => {\r\n            if (specificAttribs.includes(attrib)) {\r\n                const oldVal = changedAttribs[attrib][0];\r\n                this.set(attrib, oldVal)\r\n            }\r\n        })\r\n    }`\r\ncurrently works only for flat structures and might be risky but it seems sufficient for my case.."}}
{"actor":{"display_login":"bluscreen"}}