Fixes: U4-3350 Content Validation: Can't get rid of DateTime error

This commit is contained in:
Shannon
2013-11-07 14:58:41 +11:00
parent 345b96e253
commit 3d6eea9470
4 changed files with 25 additions and 12 deletions

View File

@@ -26,17 +26,20 @@ function valServer(serverValidationManager) {
}
}
//subscribe to the changed event of the view model. This is required because when we
//Need to watch the value model for it to change, previously we had subscribed to
//ctrl.$viewChangeListeners but this is not good enough if you have an editor that
// doesn't specifically have a 2 way ng binding. This is required because when we
// have a server error we actually invalidate the form which means it cannot be
// resubmitted. So once a field is changed that has a server error assigned to it
// we need to re-validate it for the server side validator so the user can resubmit
// the form. Of course normal client-side validators will continue to execute.
//TODO: Should we be using $render here instead?
ctrl.$viewChangeListeners.push(function () {
scope.$watch(function() {
return ctrl.$modelValue;
}, function (newValue) {
if (ctrl.$invalid) {
ctrl.$setValidity('valServer', true);
}
});
});
//subscribe to the server validation changes
serverValidationManager.subscribe(currentProperty.alias, fieldName, function (isValid, propertyErrors, allErrors) {

View File

@@ -1,5 +1,5 @@
angular.module("umbraco").controller("Umbraco.PropertyEditors.DatepickerController",
function ($scope, notificationsService, assetsService) {
function ($scope, notificationsService, assetsService, angularHelper) {
//setup the default config
var config = {
@@ -12,17 +12,19 @@ angular.module("umbraco").controller("Umbraco.PropertyEditors.DatepickerControll
//map back to the model
$scope.model.config = config;
function applyDate(e){
function applyDate(e) {
angularHelper.safeApply($scope, function() {
// when a date is changed, update the model
if (e.localDate) {
if ($scope.model.config.format == "yyyy-MM-dd HH:mm:ss") {
$scope.$apply(function(){
$scope.model.value = e.localDate.toIsoDateTimeString();
});
}else{
$scope.model.value = e.localDate.toIsoDateTimeString();
}
else {
$scope.model.value = e.localDate.toIsoDateString();
}
}
});
}
assetsService.loadJs(