From dd5f65b84e897c79421e055a04e2cd1e7d456730 Mon Sep 17 00:00:00 2001 From: Bjarne Fyrstenborg Date: Mon, 17 Aug 2020 13:34:51 +0200 Subject: [PATCH 01/13] Adjust noDirtyCheck directive to accept a parameter to enable/disable dirty check --- .../validation/nodirtycheck.directive.js | 18 ++++++---- .../views/components/forms/umb-checkbox.html | 34 ++++++------------- .../components/forms/umb-radiobutton.html | 34 ++++++------------- 3 files changed, 34 insertions(+), 52 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/validation/nodirtycheck.directive.js b/src/Umbraco.Web.UI.Client/src/common/directives/validation/nodirtycheck.directive.js index 800ac8748088..62223dab1bbb 100644 --- a/src/Umbraco.Web.UI.Client/src/common/directives/validation/nodirtycheck.directive.js +++ b/src/Umbraco.Web.UI.Client/src/common/directives/validation/nodirtycheck.directive.js @@ -10,13 +10,19 @@ 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); + var dirtyCheck = scope.$eval(attrs.noDirtyCheck) === false; + if (dirtyCheck) + return; + ctrl.$setDirty = angular.noop; + + //var alwaysFalse = { + // get: function () { return false; }, + // set: function () { } + //}; + + //Object.defineProperty(ctrl, '$pristine', alwaysFalse); + //Object.defineProperty(ctrl, '$dirty', alwaysFalse); } }; } diff --git a/src/Umbraco.Web.UI.Client/src/views/components/forms/umb-checkbox.html b/src/Umbraco.Web.UI.Client/src/views/components/forms/umb-checkbox.html index c25541da2190..2f3e8985f05d 100644 --- a/src/Umbraco.Web.UI.Client/src/views/components/forms/umb-checkbox.html +++ b/src/Umbraco.Web.UI.Client/src/views/components/forms/umb-checkbox.html @@ -1,29 +1,17 @@