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 isValidating and events #152

Merged
merged 5 commits into from
Mar 31, 2017
Merged

Added isValidating and events #152

merged 5 commits into from
Mar 31, 2017

Conversation

SuperCoolFrog
Copy link
Contributor

Added a function named isValidating to changeset.
Added events beforeValidation and afterValidation.

Copy link
Collaborator

@poteto poteto left a comment

Choose a reason for hiding this comment

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

Sorry about the delay. Minor formatting issues.

Could you please also update the readme about isValidating please? Thanks.

addon/index.js Outdated
@@ -49,7 +53,7 @@ const defaultOptions = { skipValidate: false };
export function changeset(obj, validateFn = defaultValidatorFn, validationMap = {}, options = {}) {
assert('Underlying object for changeset is missing', isPresent(obj));

return EmberObject.extend({
return EmberObject.extend(Ember.Evented, {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Destructure please

addon/index.js Outdated
isValidating(key) {
let runningValidations = get(this, RUNNING_VALIDATIONS);
let ks = emberArray(keys(runningValidations));
if(key) { return ks.includes(key); }
Copy link
Collaborator

Choose a reason for hiding this comment

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

space after if

addon/index.js Outdated
let runningValidations = get(this, RUNNING_VALIDATIONS);
let count = get(runningValidations, key) || 0;

if(value) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

space after if

addon/index.js Outdated

if(value) {
set(runningValidations, key, count + 1);
}else {
Copy link
Collaborator

Choose a reason for hiding this comment

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

space after }

addon/index.js Outdated
if(value) {
set(runningValidations, key, count + 1);
}else {
if(count === 1) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

space after if

@SuperCoolFrog
Copy link
Contributor Author

No problem and thanks for reviewing it. I made those changes and also included in the readme documentation for the events I added. Let me know if there is anything else.

@poteto poteto merged commit 65cc027 into adopted-ember-addons:master Mar 31, 2017
ppegusii pushed a commit to aspensquare/ember-changeset that referenced this pull request Apr 4, 2017
* Added isValidating function to changeset

* Added beforeValidation and afterValidation events

* Updated README.md for isValidating and events

* Update README.md

* Update index.js
poteto pushed a commit that referenced this pull request Apr 10, 2017
* Add option to skip validations when setting values (#148)

* Add option to skip validations on setting values

* Rename option for skipping validation

* Change object merge to use pureAssign

* Update readme to reflect `skipValidate` option

* Update helper to pass along `skipValidate` option

* obj.hasOwnProperty(key) => key in obj (#151)

obj.hasOwnProerty(key) seems to be returning false for ember data models. key in obj  seems to work for me.

* [BUG]: clear errors for ember 1.13.13 (#157)

* [BUG]: clear errors for ember 1.13.13

* Update index.js

* Released v1.2.3

* Added isValidating and events (#152)

* Added isValidating function to changeset

* Added beforeValidation and afterValidation events

* Updated README.md for isValidating and events

* Update README.md

* Update index.js

* Update ember and friends (#165)

* update to ember-cli 2.8.0

* update to ember-cli 2.9.0

* update to ember-cli 2.10.1

* update to ember-cli 2.12.1

* remove bower from circle build

* update ember-try configuration

* remove bower install from circle setup

ember-cli removed the bower.json file so running this step causes the
tests to fail as it can't find the file.

* add ember 1.13 back to try tests

* add yarn lock file for yarn support (#164)

* allow empty objects (#166)
poteto pushed a commit that referenced this pull request Jul 26, 2017
* Add option to skip validations when setting values (#148)

* Add option to skip validations on setting values

* Rename option for skipping validation

* Change object merge to use pureAssign

* Update readme to reflect `skipValidate` option

* Update helper to pass along `skipValidate` option

* obj.hasOwnProperty(key) => key in obj (#151)

obj.hasOwnProerty(key) seems to be returning false for ember data models. key in obj  seems to work for me.

* [BUG]: clear errors for ember 1.13.13 (#157)

* [BUG]: clear errors for ember 1.13.13

* Update index.js

* Released v1.2.3

* Added isValidating and events (#152)

* Added isValidating function to changeset

* Added beforeValidation and afterValidation events

* Updated README.md for isValidating and events

* Update README.md

* Update index.js

* Update ember and friends (#165)

* update to ember-cli 2.8.0

* update to ember-cli 2.9.0

* update to ember-cli 2.10.1

* update to ember-cli 2.12.1

* remove bower from circle build

* update ember-try configuration

* remove bower install from circle setup

ember-cli removed the bower.json file so running this step causes the
tests to fail as it can't find the file.

* add ember 1.13 back to try tests

* add yarn lock file for yarn support (#164)

* allow empty objects (#166)

* Remove changes on set when model is Ember.ProxyObject (#169)

`key in obj` does not correctly detect properties that are defined on
the underlying object of an `Ember.ProxyObject`. Since this conditional
is for deciding whether or not to delete a change, I think it makes
sense to check the `changes` object for its existence anyway.

* Restore ember-cli-release (#184)

* Released v1.3.0

* Remove jQuery and test without it (#185)
steverhoades pushed a commit to steverhoades/ember-changeset that referenced this pull request Oct 6, 2017
* Add option to skip validations when setting values (adopted-ember-addons#148)

* Add option to skip validations on setting values

* Rename option for skipping validation

* Change object merge to use pureAssign

* Update readme to reflect `skipValidate` option

* Update helper to pass along `skipValidate` option

* obj.hasOwnProperty(key) => key in obj (adopted-ember-addons#151)

obj.hasOwnProerty(key) seems to be returning false for ember data models. key in obj  seems to work for me.

* [BUG]: clear errors for ember 1.13.13 (adopted-ember-addons#157)

* [BUG]: clear errors for ember 1.13.13

* Update index.js

* Released v1.2.3

* Added isValidating and events (adopted-ember-addons#152)

* Added isValidating function to changeset

* Added beforeValidation and afterValidation events

* Updated README.md for isValidating and events

* Update README.md

* Update index.js

* Update ember and friends (adopted-ember-addons#165)

* update to ember-cli 2.8.0

* update to ember-cli 2.9.0

* update to ember-cli 2.10.1

* update to ember-cli 2.12.1

* remove bower from circle build

* update ember-try configuration

* remove bower install from circle setup

ember-cli removed the bower.json file so running this step causes the
tests to fail as it can't find the file.

* add ember 1.13 back to try tests

* add yarn lock file for yarn support (adopted-ember-addons#164)

* allow empty objects (adopted-ember-addons#166)
steverhoades pushed a commit to steverhoades/ember-changeset that referenced this pull request Oct 6, 2017
…#192)

* Add option to skip validations when setting values (adopted-ember-addons#148)

* Add option to skip validations on setting values

* Rename option for skipping validation

* Change object merge to use pureAssign

* Update readme to reflect `skipValidate` option

* Update helper to pass along `skipValidate` option

* obj.hasOwnProperty(key) => key in obj (adopted-ember-addons#151)

obj.hasOwnProerty(key) seems to be returning false for ember data models. key in obj  seems to work for me.

* [BUG]: clear errors for ember 1.13.13 (adopted-ember-addons#157)

* [BUG]: clear errors for ember 1.13.13

* Update index.js

* Released v1.2.3

* Added isValidating and events (adopted-ember-addons#152)

* Added isValidating function to changeset

* Added beforeValidation and afterValidation events

* Updated README.md for isValidating and events

* Update README.md

* Update index.js

* Update ember and friends (adopted-ember-addons#165)

* update to ember-cli 2.8.0

* update to ember-cli 2.9.0

* update to ember-cli 2.10.1

* update to ember-cli 2.12.1

* remove bower from circle build

* update ember-try configuration

* remove bower install from circle setup

ember-cli removed the bower.json file so running this step causes the
tests to fail as it can't find the file.

* add ember 1.13 back to try tests

* add yarn lock file for yarn support (adopted-ember-addons#164)

* allow empty objects (adopted-ember-addons#166)

* Remove changes on set when model is Ember.ProxyObject (adopted-ember-addons#169)

`key in obj` does not correctly detect properties that are defined on
the underlying object of an `Ember.ProxyObject`. Since this conditional
is for deciding whether or not to delete a change, I think it makes
sense to check the `changes` object for its existence anyway.

* Restore ember-cli-release (adopted-ember-addons#184)

* Released v1.3.0

* Remove jQuery and test without it (adopted-ember-addons#185)
steverhoades pushed a commit to steverhoades/ember-changeset that referenced this pull request Oct 6, 2017
* Add option to skip validations when setting values (adopted-ember-addons#148)

* Add option to skip validations on setting values

* Rename option for skipping validation

* Change object merge to use pureAssign

* Update readme to reflect `skipValidate` option

* Update helper to pass along `skipValidate` option

* obj.hasOwnProperty(key) => key in obj (adopted-ember-addons#151)

obj.hasOwnProerty(key) seems to be returning false for ember data models. key in obj  seems to work for me.

* [BUG]: clear errors for ember 1.13.13 (adopted-ember-addons#157)

* [BUG]: clear errors for ember 1.13.13

* Update index.js

* Released v1.2.3

* Added isValidating and events (adopted-ember-addons#152)

* Added isValidating function to changeset

* Added beforeValidation and afterValidation events

* Updated README.md for isValidating and events

* Update README.md

* Update index.js

* Update ember and friends (adopted-ember-addons#165)

* update to ember-cli 2.8.0

* update to ember-cli 2.9.0

* update to ember-cli 2.10.1

* update to ember-cli 2.12.1

* remove bower from circle build

* update ember-try configuration

* remove bower install from circle setup

ember-cli removed the bower.json file so running this step causes the
tests to fail as it can't find the file.

* add ember 1.13 back to try tests

* add yarn lock file for yarn support (adopted-ember-addons#164)

* allow empty objects (adopted-ember-addons#166)
steverhoades pushed a commit to steverhoades/ember-changeset that referenced this pull request Oct 6, 2017
…#192)

* Add option to skip validations when setting values (adopted-ember-addons#148)

* Add option to skip validations on setting values

* Rename option for skipping validation

* Change object merge to use pureAssign

* Update readme to reflect `skipValidate` option

* Update helper to pass along `skipValidate` option

* obj.hasOwnProperty(key) => key in obj (adopted-ember-addons#151)

obj.hasOwnProerty(key) seems to be returning false for ember data models. key in obj  seems to work for me.

* [BUG]: clear errors for ember 1.13.13 (adopted-ember-addons#157)

* [BUG]: clear errors for ember 1.13.13

* Update index.js

* Released v1.2.3

* Added isValidating and events (adopted-ember-addons#152)

* Added isValidating function to changeset

* Added beforeValidation and afterValidation events

* Updated README.md for isValidating and events

* Update README.md

* Update index.js

* Update ember and friends (adopted-ember-addons#165)

* update to ember-cli 2.8.0

* update to ember-cli 2.9.0

* update to ember-cli 2.10.1

* update to ember-cli 2.12.1

* remove bower from circle build

* update ember-try configuration

* remove bower install from circle setup

ember-cli removed the bower.json file so running this step causes the
tests to fail as it can't find the file.

* add ember 1.13 back to try tests

* add yarn lock file for yarn support (adopted-ember-addons#164)

* allow empty objects (adopted-ember-addons#166)

* Remove changes on set when model is Ember.ProxyObject (adopted-ember-addons#169)

`key in obj` does not correctly detect properties that are defined on
the underlying object of an `Ember.ProxyObject`. Since this conditional
is for deciding whether or not to delete a change, I think it makes
sense to check the `changes` object for its existence anyway.

* Restore ember-cli-release (adopted-ember-addons#184)

* Released v1.3.0

* Remove jQuery and test without it (adopted-ember-addons#185)
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.

2 participants