Merge pull request #2166 from umbraco/lars-erik-U4-7580-rename-containers

Make U4-7580 (DocTypes/MediaTypes folder re-nameable feature) work with Deploy
This commit is contained in:
Robert
2017-09-11 11:19:30 +02:00
committed by GitHub
12 changed files with 202 additions and 1 deletions

View File

@@ -266,6 +266,17 @@ function contentTypeResource($q, $http, umbRequestHelper, umbDataFormatter) {
$http.post(umbRequestHelper.getApiUrl("contentTypeApiBaseUrl", "PostCreateContainer", { parentId: parentId, name: name })),
'Failed to create a folder under parent id ' + parentId);
},
renameContainer: function(id, name) {
return umbRequestHelper.resourcePromise(
$http.post(umbRequestHelper.getApiUrl("contentTypeApiBaseUrl",
"PostRenameContainer",
{ id: id, name: name })),
"Failed to rename the folder with id " + id
);
}
};

View File

@@ -203,6 +203,17 @@ function mediaTypeResource($q, $http, umbRequestHelper, umbDataFormatter) {
"PostCreateContainer",
{ parentId: parentId, name: name })),
'Failed to create a folder under parent id ' + parentId);
},
renameContainer: function (id, name) {
return umbRequestHelper.resourcePromise(
$http.post(umbRequestHelper.getApiUrl("mediaTypeApiBaseUrl",
"PostRenameContainer",
{ id: id, name: name })),
"Failed to rename the folder with id " + id
);
}
};

View File

@@ -0,0 +1,63 @@
angular.module("umbraco")
.controller("Umbraco.Editors.ContentTypeContainers.RenameController",
[
"$scope",
"$injector",
"navigationService",
"notificationsService",
"localizationService",
function (scope, injector, navigationService, notificationsService, localizationService) {
var notificationHeader;
function reportSuccessAndClose(treeName) {
var lastComma = scope.currentNode.path.lastIndexOf(","),
path = lastComma === -1
? scope.currentNode.path
: scope.currentNode.path.substring(0, lastComma - 1);
navigationService.syncTree({
tree: treeName,
path: path,
forceReload: true,
activate: true
});
localizationService.localize(
"renamecontainer_folderWasRenamed",
[scope.currentNode.name, scope.model.folderName])
.then(function (msg) {
notificationsService.showNotification({
type: 0,
header: notificationHeader,
message: msg
});
});
navigationService.hideMenu();
}
localizationService.localize("renamecontainer_renamed")
.then(function (s) { notificationHeader = s; });
scope.model = {
folderName: scope.currentNode.name
}
scope.renameContainer = function (resourceKey, treeName) {
var resource = injector.get(resourceKey);
resource.renameContainer(scope.currentNode.id, scope.model.folderName)
.then(function () {
reportSuccessAndClose(treeName);
}, function (err) {
scope.error = err;
if (angular.isArray(err.data.notifications)) {
for (var i = 0; i < err.data.notifications.length; i++) {
notificationsService.showNotification(err.data.notifications[i]);
}
}
});
}
}
]);

View File

@@ -0,0 +1,22 @@
<div class="umbracoDialog umb-dialog-body with-footer" ng-controller="Umbraco.Editors.ContentTypeContainers.RenameController" ng-cloak>
<div class="umb-pane">
<form novalidate name="renameFolderForm"
ng-submit="renameContainer('contentTypeResource', 'documenttypes')"
val-form-manager>
<div ng-show="error">
<h5 class="text-error">{{error.errorMsg}}</h5>
<p class="text-error">{{error.data.message}}</p>
</div>
<umb-control-group label="@renamecontainer_enterNewFolderName" hide-label="false">
<input type="text" name="folderName" ng-model="model.folderName" class="umb-textstring textstring input-block-level" umb-auto-focus required />
</umb-control-group>
<button type="submit" class="btn btn-primary"><localize key="general_rename">Rename</localize></button>
</form>
</div>
</div>

View File

@@ -0,0 +1,21 @@
<div class="umbracoDialog umb-dialog-body with-footer" ng-controller="Umbraco.Editors.ContentTypeContainers.RenameController" ng-cloak>
<div class="umb-pane">
<form novalidate name="renameFolderForm"
ng-submit="renameContainer('mediaTypeResource', 'mediatypes')"
val-form-manager>
<div ng-show="error">
<h5 class="text-error">{{error.errorMsg}}</h5>
<p class="text-error">{{error.data.message}}</p>
</div>
<umb-control-group label="@renamecontainer_enterNewFolderName" hide-label="false">
<input type="text" name="folderName" ng-model="model.folderName" class="umb-textstring textstring input-block-level" umb-auto-focus required />
</umb-control-group>
<button type="submit" class="btn btn-primary"><localize key="general_rename">Rename</localize></button>
</form>
</div>
</div>