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

added ability to have changesets extend down to nested objects #211

Conversation

webark
Copy link
Contributor

@webark webark commented Nov 16, 2017

Just wanted to set up a cleaner PR then #140 for expediting the adopting and reviewing of these changes.

@webark webark mentioned this pull request Nov 16, 2017
@nucleartide
Copy link
Contributor

Awesome, will take a look at this tomorrow if not later tonight.

@nucleartide
Copy link
Contributor

nucleartide commented Nov 17, 2017

@webark Looking at this now (edit: after grabbing some food). First things first, would you mind resolving the merge conflict in package.json, and re-generating yarn.lock (with Yarn 1.3.2)?

@poteto If you get the chance, please enable Circle CI builds – it doesn't seem like we can run builds on DockYard's Circle account anymore.

🙂

@webark
Copy link
Contributor Author

webark commented Nov 17, 2017

@nucleartide it might not be a bad idea to just pick up the "migrate to Travis" ticket.

Copy link
Contributor

@nucleartide nucleartide left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! Just a couple of minor comments.

let changeset = new Changeset(data);
this.set('childChangeset', changeset.get('person'));
this.render(hbs`
<h1>{{childChangeset.firstName}} {{childChangeset.lastName}}</h1>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor nitpick: please un-indent by 2 spaces here.

let changeset = new Changeset(data);
this.set('changeset', changeset);
this.render(hbs`
<h1>{{changeset.person.firstName}} {{changeset.person.lastName}}</h1>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor nitpick: please un-indent by 2 spaces here.

this.set('childChangeset', changeset.get('person'));
this.on('reset', () => changeset.rollback());
this.render(hbs`
<h1>{{childChangeset.firstName}} {{childChangeset.lastName}}</h1>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor nitpick: please un-indent by 2 spaces here.

ma: { name: null }
}
});
let dummyChangeset = new Changeset(dummyModel, dummyValidator);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's rename dummyChangeset to c for brevity. :) It'll cut down on some of the dummyChangeset noise.

dummyChangeset.set('org.usa.ma', { name: 'Massachusetts' });
dummyChangeset.execute();
assert.deepEqual(get(dummyChangeset, 'change'), expectedResult, 'should have correct shape');
assert.deepEqual(get(dummyModel, 'org'), expectedResult.org, 'should set value');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These assertions seem redundant since we're already doing a .deepEqual above. Let's remove these?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed the tests below, and pulled out the rollback tests and have those just in their own now.

});
let dummyChangeset = new Changeset(dummyModel, dummyValidator, dummyValidations);

dummyChangeset.validate('org.usa.ny').then(() => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor nitpick: un-indent by 2 spaces please. :)

dummyChangeset.set('org.asia.sg', 'sg');
assert.equal(dummyChangeset.get('org.asia.sg'), 'sg', 'returns newly set value');
let childChangeset = dummyChangeset.get('org.asia');
assert.equal(childChangeset.get('sg'), 'sg', 'child changeseet sees changed value');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor nitpick: spelling (changeseet to changeset)

ny: null,
ma: { name: null }
}
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add a newline here just to mark different parts of the function.

let dummyChangeset = new Changeset(dummyModel, dummyValidator);
assert.equal(dummyChangeset.get('org.asia.sg'), '_initial', 'returns initial value');
dummyChangeset.set('org.asia.sg', 'sg');
assert.equal(dummyChangeset.get('org.asia.sg'), 'sg', 'returns newly set value');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Newline here as well.

* @param {String} [scope=''] A sring that can be prepended to the key.
* @return {Array}
*/
_allKeys(object, keys = [], scope = '') {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, will Object.entries cause any IE issues?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

umm.. Doesn't babel still pick that up?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like Babel needs a plugin for this - the local, transpiled version still has Object.entries in the code.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:(

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@nucleartide
Copy link
Contributor

@webark Ahh yeah, will take a look at the Travis ticket.

@webark webark force-pushed the cleaner-branch-nested-key-support branch from e0bba4e to 4cd35ea Compare November 17, 2017 22:40
@webark
Copy link
Contributor Author

webark commented Nov 17, 2017

k. @nucleartide I think that's all the changes. Let me know if there are any others! Glad to have movement on this! :)

@nucleartide
Copy link
Contributor

@webark Excellent work! We'll need @poteto to set up CI, but I ran yarn test locally and everything passes.

Going to merge this. 👍

@nucleartide nucleartide merged commit dcc28a6 into adopted-ember-addons:master Nov 19, 2017
@poteto
Copy link
Collaborator

poteto commented Nov 19, 2017

@nucleartide Should be active now!

@erichaus
Copy link

very nice, do you guys want to add any update to the readme/docs for this? for example do I need to create "child" changesets? will this work with validation? trying to piece together a custom form using nested pojo as model

@tamzinblake
Copy link

Will this be in a release soon?

@nucleartide
Copy link
Contributor

nucleartide commented Nov 20, 2017

@thomblake Yep, will get to it sometime this week. As @erichonkanen mentioned we'll need to update docs and such.

@nucleartide
Copy link
Contributor

Just for everyone's info, I scheduled time on Friday to work on getting a release out. Sorry for the delay!

@BillyRayPreachersSon
Copy link

BillyRayPreachersSon commented Nov 23, 2017

I'd like to thank everyone involved in making this happen. Your work is much appreciated!

This was referenced Nov 25, 2017
@nmccready
Copy link

When will this be added to the readme?

@nucleartide
Copy link
Contributor

Hey @nmccready, please see #256.

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.

7 participants