Merge pull request #2476 from barryokane/U4-9996
(uDuf) Prevent unsaved dialogue appearing when no changes made on FileUpload
This commit is contained in:
@@ -10,12 +10,12 @@ function noDirtyCheck() {
|
||||
require: 'ngModel',
|
||||
link: function (scope, elm, attrs, ctrl) {
|
||||
|
||||
elm.focus(function () {
|
||||
scope.$watch(function() {
|
||||
ctrl.$pristine = false;
|
||||
});
|
||||
});
|
||||
|
||||
var alwaysFalse = {
|
||||
get: function () { return false; },
|
||||
set: function () { }
|
||||
};
|
||||
Object.defineProperty(ctrl, '$pristine', alwaysFalse);
|
||||
Object.defineProperty(ctrl, '$dirty', alwaysFalse);
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
@@ -130,6 +130,9 @@ function fileUploadController($scope, $element, $compile, imageHelper, fileManag
|
||||
// in the description of this controller, it states that this value isn't actually used for persistence,
|
||||
// but we need to set it so that the editor and the server can detect that it's been changed, and it is used for validation.
|
||||
$scope.model.value = { selectedFiles: newVal.trimEnd(",") };
|
||||
|
||||
//need to explicity setDirty here as file upload field can't track dirty & we can't use the fileCount (hidden field/model)
|
||||
$scope.propertyForm.$setDirty();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -31,6 +31,6 @@
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<input type="hidden" name="fileCount" ng-model="files.length" val-property-validator="validateMandatory"/>
|
||||
<input type="hidden" name="fileCount" ng-model="files.length" val-property-validator="validateMandatory" no-dirty-check />
|
||||
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user