-
-
Notifications
You must be signed in to change notification settings - Fork 141
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
Conversation
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.
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, { |
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.
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); } |
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.
space after if
addon/index.js
Outdated
let runningValidations = get(this, RUNNING_VALIDATIONS); | ||
let count = get(runningValidations, key) || 0; | ||
|
||
if(value) { |
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.
space after if
addon/index.js
Outdated
|
||
if(value) { | ||
set(runningValidations, key, count + 1); | ||
}else { |
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.
space after }
addon/index.js
Outdated
if(value) { | ||
set(runningValidations, key, count + 1); | ||
}else { | ||
if(count === 1) { |
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.
space after if
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. |
* Added isValidating function to changeset * Added beforeValidation and afterValidation events * Updated README.md for isValidating and events * Update README.md * Update index.js
* 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)
* 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)
* 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)
…#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)
* 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)
…#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)
Added a function named isValidating to changeset.
Added events beforeValidation and afterValidation.