Fixes up the error handling with move/copy dialogs.
This commit is contained in:
@@ -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]);
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@@ -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]);
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@@ -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">
|
||||
|
||||
@@ -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>
|
||||
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user