-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Allow to pass in boolean to noDirtyCheck directive #8638
Changes from 5 commits
dd5f65b
22d87df
db2f095
2514d2b
0ab8651
0bb2d18
eb48dbd
9a4867d
0a5b442
c08f11c
115a475
b63e218
94e8e39
6dbc4b4
f5c04ee
8807bf5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -10,13 +10,12 @@ function noDirtyCheck() { | |||||||
require: 'ngModel', | ||||||||
link: function (scope, elm, attrs, ctrl) { | ||||||||
|
||||||||
var alwaysFalse = { | ||||||||
get: function () { return false; }, | ||||||||
set: function () { } | ||||||||
}; | ||||||||
Object.defineProperty(ctrl, '$pristine', alwaysFalse); | ||||||||
Object.defineProperty(ctrl, '$dirty', alwaysFalse); | ||||||||
// If no attribute value is "false", then skip and use default behaviour. | ||||||||
var dirtyCheck = scope.$eval(attrs.noDirtyCheck) === false; | ||||||||
if (dirtyCheck) | ||||||||
return; | ||||||||
|
||||||||
ctrl.$setDirty = Utilities.noop; | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. While I'm sure this works, I'm a tad worried it's too good to be true. The quite intricate solution with the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure if there is a specific reason it change There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep I agree with you. As I tried to explain, it should work fine, but the current solution seems quite explicitly done as-is. There can be two reasons for this: Either the current solution is over complicated and implemented as such due to lack of knowledge/understanding, or else the current solution covers edge cases we can't right now. My point is it can't hurt to retain the current solution from a better-safe-than-sorry standpoint? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, not sure if It seems it only rely on Umbraco-CMS/src/Umbraco.Web.UI.Client/src/common/directives/validation/valformmanager.directive.js Lines 175 to 177 in 0140d90
|
||||||||
} | ||||||||
}; | ||||||||
} | ||||||||
|
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.
There must be a native JS function to evaluate a boolean instead of depending on AngularJS to do it for us?
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.
Yes, probably. However I have noticed the
$eval
function is used several other places to parse attribute values.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.
With the above changes in mind, shouldn't this be
var dirtyCheck = Object.toBoolean(attrs.noDirtyCheck) === false;
?