Implement delete

This commit is contained in:
Kenn Jacobsen
2018-11-01 16:01:34 +01:00
parent 617596cba4
commit 57232c9c48
3 changed files with 50 additions and 1 deletions

View File

@@ -0,0 +1,29 @@
/**
* @ngdoc controller
* @name Umbraco.Editors.StyleSheets.DeleteController
* @function
*
* @description
* The controller for deleting stylesheets
*/
function StyleSheetsDeleteController($scope, codefileResource, treeService, navigationService) {
$scope.performDelete = function() {
//mark it for deletion (used in the UI)
$scope.currentNode.loading = true;
codefileResource.deleteByPath('stylesheets', $scope.currentNode.id)
.then(function() {
$scope.currentNode.loading = false;
treeService.removeNode($scope.currentNode);
navigationService.hideMenu();
});
};
$scope.cancel = function() {
navigationService.hideDialog();
};
}
angular.module("umbraco").controller("Umbraco.Editors.StyleSheets.DeleteController", StyleSheetsDeleteController);

View File

@@ -0,0 +1,12 @@
<div class="umb-dialog umb-pane" ng-controller="Umbraco.Editors.StyleSheets.DeleteController">
<div class="umb-dialog-body">
<p class="umb-abstract">
<localize key="defaultdialogs_confirmdelete">Are you sure you want to delete</localize> <strong>{{currentNode.name}}</strong> ?
</p>
<umb-confirm on-confirm="performDelete" on-cancel="cancel">
</umb-confirm>
</div>
</div>

View File

@@ -276,7 +276,7 @@ namespace Umbraco.Web.Editors
/// <summary>
/// Used to delete a specific file from disk via the FileService
/// </summary>
/// <param name="type">This is a string but will be 'scripts' 'partialViews', 'partialViewMacros'</param>
/// <param name="type">This is a string but will be 'scripts' 'partialViews', 'partialViewMacros' or 'stylesheets'</param>
/// <param name="virtualPath">The filename or urlencoded path of the file to delete</param>
/// <returns>Will return a simple 200 if file deletion succeeds</returns>
[HttpDelete]
@@ -327,6 +327,14 @@ namespace Umbraco.Web.Editors
}
return Request.CreateErrorResponse(HttpStatusCode.NotFound, "No Script or folder found with the specified path");
case Core.Constants.Trees.Stylesheets:
if (Services.FileService.GetStylesheetByName(virtualPath) != null)
{
Services.FileService.DeleteStylesheet(virtualPath, Security.CurrentUser.Id);
return Request.CreateResponse(HttpStatusCode.OK);
}
return Request.CreateErrorResponse(HttpStatusCode.NotFound, "No Stylesheet found with the specified path");
default:
return Request.CreateResponse(HttpStatusCode.NotFound);
}