Fixes up the error handling with move/copy dialogs.

This commit is contained in:
Shannon
2015-11-09 17:58:43 +01:00
parent 85e5c0c219
commit a351f6cfc8
6 changed files with 46 additions and 20 deletions

View File

@@ -1,5 +1,5 @@
angular.module("umbraco").controller("Umbraco.Editors.Content.CopyController",
function ($scope, eventsService, contentResource, navigationService, appState, treeService, localizationService) {
function ($scope, eventsService, contentResource, navigationService, appState, treeService, localizationService, notificationsService) {
var dialogOptions = $scope.dialogOptions;
var searchText = "Search...";
@@ -120,6 +120,12 @@ angular.module("umbraco").controller("Umbraco.Editors.Content.CopyController",
$scope.success = false;
$scope.error = err;
$scope.busy = false;
//show any notifications
if (angular.isArray(err.data.notifications)) {
for (var i = 0; i < err.data.notifications.length; i++) {
notificationsService.showNotification(err.data.notifications[i]);
}
}
});
};

View File

@@ -1,5 +1,5 @@
angular.module("umbraco").controller("Umbraco.Editors.Content.MoveController",
function ($scope, eventsService, contentResource, navigationService, appState, treeService, localizationService) {
function ($scope, eventsService, contentResource, navigationService, appState, treeService, localizationService, notificationsService) {
var dialogOptions = $scope.dialogOptions;
var searchText = "Search...";
@@ -120,6 +120,12 @@ angular.module("umbraco").controller("Umbraco.Editors.Content.MoveController",
$scope.success = false;
$scope.error = err;
$scope.busy = false;
//show any notifications
if (angular.isArray(err.data.notifications)) {
for (var i = 0; i < err.data.notifications.length; i++) {
notificationsService.showNotification(err.data.notifications[i]);
}
}
});
};

View File

@@ -9,9 +9,9 @@
<div class="umb-loader"></div>
</div>
<div class="alert alert-error" ng-show="error">
<h4>{{error.errorMsg}}</h4>
<p>{{error.data.Message}}</p>
<div ng-show="error">
<h5 class="text-error">{{error.errorMsg}}</h5>
<p class="text-error">{{error.data.message}}</p>
</div>
<div class="alert alert-success" ng-show="success">

View File

@@ -10,17 +10,13 @@
<div class="umb-loader"></div>
</div>
<div class="alert alert-error" ng-show="error">
<h4>{{error.errorMsg}}</h4>
<p>{{error.data.Message}}</p>
<div ng-show="error">
<h5 class="text-error">{{error.errorMsg}}</h5>
<p class="text-error">{{error.data.message}}</p>
</div>
<div class="alert alert-success" ng-show="success">
<p>
<strong>{{currentNode.name}}</strong> was moved underneath
<strong>{{target.name}}</strong>
</p>
<div ng-show="success">
<h5 class="text-success"><strong>{{currentNode.name}}</strong> was moved underneath<strong>{{target.name}}</strong></h5>
<button class="btn btn-primary" ng-click="nav.hideDialog()">Ok</button>
</div>

View File

@@ -602,8 +602,12 @@ namespace Umbraco.Web.Editors
//cannot move if the content item is not allowed at the root
if (toMove.ContentType.AllowedAsRoot == false)
{
var notificationModel = new SimpleNotificationModel();
notificationModel.AddErrorNotification(Services.TextService.Localize("moveOrCopy/notAllowedAtRoot"), "");
var msg = Services.TextService.Localize("moveOrCopy/notAllowedAtRoot");
var notificationModel = new SimpleNotificationModel
{
Message = msg
};
notificationModel.AddErrorNotification(msg, "");
throw new HttpResponseException( Request.CreateValidationErrorResponse(notificationModel));
}
}
@@ -621,16 +625,24 @@ namespace Umbraco.Web.Editors
if (parent.ContentType.AllowedContentTypes.Select(x => x.Id).ToArray()
.Any(x => x.Value == toMove.ContentType.Id) == false)
{
var notificationModel = new SimpleNotificationModel();
notificationModel.AddErrorNotification(Services.TextService.Localize("moveOrCopy/notAllowedByContentType"), "");
var msg = Services.TextService.Localize("moveOrCopy/notAllowedByContentType");
var notificationModel = new SimpleNotificationModel
{
Message = msg
};
notificationModel.AddErrorNotification(msg, "");
throw new HttpResponseException(Request.CreateValidationErrorResponse(notificationModel));
}
// Check on paths
if ((string.Format(",{0},", parent.Path)).IndexOf(string.Format(",{0},", toMove.Id), StringComparison.Ordinal) > -1)
{
var notificationModel = new SimpleNotificationModel();
notificationModel.AddErrorNotification(Services.TextService.Localize("moveOrCopy/notAllowedByPath"), "");
var msg = Services.TextService.Localize("moveOrCopy/notAllowedByPath");
var notificationModel = new SimpleNotificationModel
{
Message = msg
};
notificationModel.AddErrorNotification(msg, "");
throw new HttpResponseException(Request.CreateValidationErrorResponse(notificationModel));
}
}

View File

@@ -21,5 +21,11 @@ namespace Umbraco.Web.Models.ContentEditing
/// </summary>
[DataMember(Name = "notifications")]
public List<Notification> Notifications { get; private set; }
/// <summary>
/// A default msg
/// </summary>
[DataMember(Name = "message")]
public string Message { get; set; }
}
}