fix rename controller

This commit is contained in:
Mads Rasmussen
2018-10-24 11:11:25 +02:00
parent aa4acb33e8
commit ac14d38961

View File

@@ -1,13 +1,13 @@
angular.module("umbraco")
.controller("Umbraco.Editors.ContentTypeContainers.RenameController",
function(scope, injector, navigationService, notificationsService, localizationService) {
function($scope, $injector, navigationService, notificationsService, localizationService) {
var notificationHeader;
function reportSuccessAndClose(treeName) {
var lastComma = scope.currentNode.path.lastIndexOf(","),
var lastComma = $scope.currentNode.path.lastIndexOf(","),
path = lastComma === -1
? scope.currentNode.path
: scope.currentNode.path.substring(0, lastComma - 1);
? $scope.currentNode.path
: $scope.currentNode.path.substring(0, lastComma - 1);
navigationService.syncTree({
tree: treeName,
@@ -18,7 +18,7 @@
localizationService.localize(
"renamecontainer_folderWasRenamed",
[scope.currentNode.name, scope.model.folderName])
[$scope.currentNode.name, $scope.model.folderName])
.then(function(msg) {
notificationsService.showNotification({
type: 0,
@@ -33,18 +33,18 @@
localizationService.localize("renamecontainer_renamed")
.then(function(s) { notificationHeader = s; });
scope.model = {
folderName: scope.currentNode.name
$scope.model = {
folderName: $scope.currentNode.name
}
scope.renameContainer = function(resourceKey, treeName) {
var resource = injector.get(resourceKey);
$scope.renameContainer = function(resourceKey, treeName) {
var resource = $injector.get(resourceKey);
resource.renameContainer(scope.currentNode.id, scope.model.folderName)
resource.renameContainer($scope.currentNode.id, $scope.model.folderName)
.then(function() {
reportSuccessAndClose(treeName);
}, function(err) {
scope.error = err;
$scope.error = err;
});
}
}