Merge pull request #1361 from umbraco/temp-U4-8416
U4-8416 Empty recycle bin does not refresh or gives feedback to user
This commit is contained in:
@@ -6,18 +6,33 @@
|
||||
* @description
|
||||
* The controller for deleting content
|
||||
*/
|
||||
function ContentEmptyRecycleBinController($scope, contentResource, treeService, navigationService) {
|
||||
function ContentEmptyRecycleBinController($scope, contentResource, treeService, navigationService, notificationsService, $route) {
|
||||
|
||||
$scope.busy = false;
|
||||
|
||||
$scope.performDelete = function() {
|
||||
|
||||
//(used in the UI)
|
||||
$scope.busy = true;
|
||||
$scope.currentNode.loading = true;
|
||||
|
||||
contentResource.emptyRecycleBin($scope.currentNode.id).then(function () {
|
||||
contentResource.emptyRecycleBin($scope.currentNode.id).then(function (result) {
|
||||
|
||||
$scope.busy = false;
|
||||
$scope.currentNode.loading = false;
|
||||
//TODO: Need to sync tree, etc...
|
||||
|
||||
//show any notifications
|
||||
if (angular.isArray(result.notifications)) {
|
||||
for (var i = 0; i < result.notifications.length; i++) {
|
||||
notificationsService.showNotification(result.notifications[i]);
|
||||
}
|
||||
}
|
||||
|
||||
treeService.removeChildNodes($scope.currentNode);
|
||||
navigationService.hideMenu();
|
||||
|
||||
//reload the current view
|
||||
$route.reload();
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
@@ -1,8 +1,17 @@
|
||||
<div class="umb-dialog" ng-controller="Umbraco.Editors.Content.EmptyRecycleBinController">
|
||||
<div class="umb-dialog-body" auto-scale="90">
|
||||
|
||||
<umb-confirm on-confirm="performDelete" on-cancel="cancel">
|
||||
</umb-confirm>
|
||||
<div class="umb-dialog-body">
|
||||
<umb-pane>
|
||||
<div class="umb-loader-wrapper" ng-show="busy">
|
||||
<div class="umb-loader"></div>
|
||||
</div>
|
||||
|
||||
<p class="umb-abstract">
|
||||
<localize key="defaultdialogs_recycleBinWarning">When items are deleted from the recycle bin, they will be gone forever</localize>.
|
||||
<localize key="general_areyousure">Are you sure</localize>?
|
||||
</p>
|
||||
|
||||
<umb-confirm on-confirm="performDelete" on-cancel="cancel">
|
||||
</umb-confirm>
|
||||
</umb-pane>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,8 +1,19 @@
|
||||
<div class="umb-dialog" ng-controller="Umbraco.Editors.Media.EmptyRecycleBinController">
|
||||
<div class="umb-dialog-body">
|
||||
|
||||
<umb-confirm on-confirm="performDelete" on-cancel="cancel">
|
||||
</umb-confirm>
|
||||
<umb-pane>
|
||||
<div class="umb-loader-wrapper" ng-show="busy">
|
||||
<div class="umb-loader"></div>
|
||||
</div>
|
||||
|
||||
<p class="umb-abstract">
|
||||
<localize key="defaultdialogs_recycleBinWarning">When items are deleted from the recycle bin, they will be gone forever</localize>.
|
||||
<localize key="general_areyousure">Are you sure</localize>?
|
||||
</p>
|
||||
|
||||
<umb-confirm on-confirm="performDelete" on-cancel="cancel">
|
||||
</umb-confirm>
|
||||
</umb-pane>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -6,18 +6,33 @@
|
||||
* @description
|
||||
* The controller for deleting media
|
||||
*/
|
||||
function MediaEmptyRecycleBinController($scope, mediaResource, treeService, navigationService) {
|
||||
function MediaEmptyRecycleBinController($scope, mediaResource, treeService, navigationService, notificationsService, $route) {
|
||||
|
||||
$scope.busy = false;
|
||||
|
||||
$scope.performDelete = function() {
|
||||
|
||||
//(used in the UI)
|
||||
$scope.busy = true;
|
||||
$scope.currentNode.loading = true;
|
||||
|
||||
mediaResource.emptyRecycleBin($scope.currentNode.id).then(function () {
|
||||
mediaResource.emptyRecycleBin($scope.currentNode.id).then(function (result) {
|
||||
|
||||
$scope.busy = false;
|
||||
$scope.currentNode.loading = false;
|
||||
//TODO: Need to sync tree, etc...
|
||||
|
||||
//show any notifications
|
||||
if (angular.isArray(result.notifications)) {
|
||||
for (var i = 0; i < result.notifications.length; i++) {
|
||||
notificationsService.showNotification(result.notifications[i]);
|
||||
}
|
||||
}
|
||||
|
||||
treeService.removeChildNodes($scope.currentNode);
|
||||
navigationService.hideMenu();
|
||||
|
||||
//reload the current view
|
||||
$route.reload();
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
@@ -462,7 +462,8 @@ namespace Umbraco.Web.Editors
|
||||
public HttpResponseMessage EmptyRecycleBin()
|
||||
{
|
||||
Services.ContentService.EmptyRecycleBin();
|
||||
return Request.CreateResponse(HttpStatusCode.OK);
|
||||
|
||||
return Request.CreateNotificationSuccessResponse(Services.TextService.Localize("defaultdialogs/recycleBinIsEmpty"));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -365,7 +365,8 @@ namespace Umbraco.Web.Editors
|
||||
public HttpResponseMessage EmptyRecycleBin()
|
||||
{
|
||||
Services.MediaService.EmptyRecycleBin();
|
||||
return Request.CreateResponse(HttpStatusCode.OK);
|
||||
|
||||
return Request.CreateNotificationSuccessResponse(Services.TextService.Localize("defaultdialogs/recycleBinIsEmpty"));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -9,6 +9,7 @@ using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
using System.Web.Http;
|
||||
using System.Web.Http.ModelBinding;
|
||||
using System.Web.Http.Results;
|
||||
using Microsoft.Owin;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Web.Models.ContentEditing;
|
||||
@@ -124,6 +125,22 @@ namespace Umbraco.Web.WebApi
|
||||
return request.CreateValidationErrorResponse(notificationModel);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a succressful response with notifications in the result to be displayed in the UI
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <param name="successMessage"></param>
|
||||
/// <returns></returns>
|
||||
public static HttpResponseMessage CreateNotificationSuccessResponse(this HttpRequestMessage request, string successMessage)
|
||||
{
|
||||
var notificationModel = new SimpleNotificationModel
|
||||
{
|
||||
Message = successMessage
|
||||
};
|
||||
notificationModel.AddSuccessNotification(successMessage, string.Empty);
|
||||
return request.CreateResponse(HttpStatusCode.OK, notificationModel);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a 400 response message indicating that a validation error occurred
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user