Fixes deleting a template - uses the correct way to delete stuff with angular and not relying on legacy code

This commit is contained in:
Shannon
2017-09-08 15:45:10 +10:00
parent 38c961209e
commit 75ace2b162
4 changed files with 65 additions and 6 deletions

View File

@@ -0,0 +1,33 @@
/**
* @ngdoc controller
* @name Umbraco.Editors.Templates.DeleteController
* @function
*
* @description
* The controller for the template delete dialog
*/
function TemplatesDeleteController($scope, templateResource , treeService, navigationService) {
$scope.performDelete = function() {
//mark it for deletion (used in the UI)
$scope.currentNode.loading = true;
templateResource.deleteById($scope.currentNode.id).then(function () {
$scope.currentNode.loading = false;
//get the root node before we remove it
var rootNode = treeService.getTreeRoot($scope.currentNode);
//TODO: Need to sync tree, etc...
treeService.removeNode($scope.currentNode);
navigationService.hideMenu();
});
};
$scope.cancel = function() {
navigationService.hideDialog();
};
}
angular.module("umbraco").controller("Umbraco.Editors.Templates.DeleteController", TemplatesDeleteController);

View File

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