diff --git a/src/Umbraco.Web.UI.Client/src/common/resources/content.resource.js b/src/Umbraco.Web.UI.Client/src/common/resources/content.resource.js index c056f70a92..a663d8e52c 100644 --- a/src/Umbraco.Web.UI.Client/src/common/resources/content.resource.js +++ b/src/Umbraco.Web.UI.Client/src/common/resources/content.resource.js @@ -996,8 +996,38 @@ function contentResource($q, $http, umbDataFormatter, umbRequestHelper) { ), "Failed to update public access for content item with id " + contentId ); - } + }, + /** + * @ngdoc method + * @name umbraco.resources.contentResource#removePublicAccess + * @methodOf umbraco.resources.contentResource + * + * @description + * Removes the public access protection for a content item + * + * ##usage + *
+ * contentResource.removePublicAccess(contentId)
+ * .then(function() {
+ * // do your thing
+ * });
+ *
+ *
+ * @param {Int} contentId The content Id
+ * @returns {Promise} resourcePromise object that's resolved once the public access has been removed
+ *
+ */
+ removePublicAccess: function (contentId) {
+ return umbRequestHelper.resourcePromise(
+ $http.post(
+ umbRequestHelper.getApiUrl("contentApiBaseUrl", "RemovePublicAccess", {
+ contentId: contentId
+ })
+ ),
+ "Failed to remove public access for content item with id " + contentId
+ );
+ }
};
}
diff --git a/src/Umbraco.Web.UI.Client/src/views/content/content.protect.controller.js b/src/Umbraco.Web.UI.Client/src/views/content/content.protect.controller.js
index 84d8619303..3ef930d7af 100644
--- a/src/Umbraco.Web.UI.Client/src/views/content/content.protect.controller.js
+++ b/src/Umbraco.Web.UI.Client/src/views/content/content.protect.controller.js
@@ -1,7 +1,7 @@
(function () {
"use strict";
- function ContentProtectController($scope, $routeParams, contentResource, memberGroupResource, navigationService, editorService) {
+ function ContentProtectController($scope, $routeParams, contentResource, memberGroupResource, navigationService, localizationService) {
var vm = this;
var id = $scope.currentNode.id;
@@ -90,7 +90,11 @@
var roles = _.map(selectedGroups, function(group) { return group.name; });
contentResource.updatePublicAccess(id, vm.userName, vm.password, roles, vm.loginPage.id, vm.errorPage.id).then(
function () {
- vm.saveButtonState = "success";
+ localizationService.localize("publicAccess_paIsProtected", [$scope.currentNode.name]).then(function (value) {
+ vm.success = {
+ message: value
+ };
+ });
navigationService.syncTree({ tree: "content", path: $scope.currentNode.path, forceReload: true });
}, function (error) {
vm.error = error;
@@ -147,7 +151,19 @@
function removeConfirm() {
vm.saveButtonState = "busy";
- // TODO KJAC: remove protection from the page
+ contentResource.removePublicAccess(id).then(
+ function () {
+ localizationService.localize("publicAccess_paIsRemoved", [$scope.currentNode.name]).then(function(value) {
+ vm.success = {
+ message: value
+ };
+ });
+ navigationService.syncTree({ tree: "content", path: $scope.currentNode.path, forceReload: true });
+ }, function (error) {
+ vm.error = error;
+ vm.saveButtonState = "error";
+ }
+ );
}
onInit();
diff --git a/src/Umbraco.Web.UI.Client/src/views/content/protect.html b/src/Umbraco.Web.UI.Client/src/views/content/protect.html
index 93381303d0..8e1a8259cd 100644
--- a/src/Umbraco.Web.UI.Client/src/views/content/protect.html
+++ b/src/Umbraco.Web.UI.Client/src/views/content/protect.html
@@ -1,12 +1,12 @@