Fixes: U4-4176 v7, cannot disable users in right-click-menu.

This commit is contained in:
Shannon
2014-10-16 18:45:02 +10:00
parent 26059ebad0
commit ca58e8f98f
8 changed files with 112 additions and 20 deletions

View File

@@ -80,7 +80,8 @@ Umbraco.Sys.registerNamespace("Umbraco.Application");
mainWindow: function() {
return top;
},
mainTree: function() {
mainTree: function () {
var injector = getRootInjector();
var navService = injector.get("navigationService");
var appState = injector.get("appState");
@@ -177,23 +178,33 @@ Umbraco.Sys.registerNamespace("Umbraco.Application");
appActions: function() {
var injector = getRootInjector();
var navService = injector.get("navigationService");
var _actions = {};
_actions.openDashboard = function(section){
navService.changeSection(section);
var localizationService = injector.get("localizationService");
var userResource = injector.get("userResource");
//var appState = injector.get("appState");
var angularHelper = injector.get("angularHelper");
var $rootScope = injector.get("$rootScope");
var actions = {
openDashboard : function(section){
navService.changeSection(section);
},
actionDisable: function () {
localizationService.localize("defaultdialogs_confirmdisable").then(function (txtConfirmDisable) {
var currentMenuNode = UmbClientMgr.mainTree().getActionNode();
if (currentMenuNode) {
if (confirm(txtConfirmDisable + ' "' + UmbClientMgr.mainTree().getActionNode().nodeName + '"?\n\n')) {
angularHelper.safeApply($rootScope, function () {
userResource.disableUser(currentMenuNode.nodeId).then(function () {
UmbClientMgr.mainTree().syncTree("-1," + currentMenuNode.nodeId, true);
});
});
}
}
});
}
};
return _actions;
//throw "Not implemented!";
////if the main window has no actions, we'll create some
//if (this._appActions == null) {
// if (typeof this.mainWindow().appActions == 'undefined') {
// this._appActions = new Umbraco.Application.Actions();
// }
// else this._appActions = this.mainWindow().appActions;
//}
//return this._appActions;
return actions;
},
uiKeys: function() {

View File

@@ -0,0 +1,25 @@
/**
* @ngdoc service
* @name umbraco.resources.userResource
**/
function userResource($q, $http, umbDataFormatter, umbRequestHelper) {
return {
disableUser: function (userId) {
if (!userId) {
throw "userId not specified";
}
return umbRequestHelper.resourcePromise(
$http.post(
umbRequestHelper.getApiUrl(
"userApiBaseUrl",
"PostDisableUser", [{ userId: userId }])),
'Failed to disable the user ' + userId);
}
};
}
angular.module('umbraco.resources').factory('userResource', userResource);

View File

@@ -409,7 +409,7 @@ Umbraco.Application.Actions = function() {
_this._debug("actionDelete: Raising public error event");
//raise public error event
jQuery(window.top).trigger("publicError", [error]);
})
});
}
}

View File

@@ -116,6 +116,10 @@ namespace Umbraco.Web.Editors
"embedApiBaseUrl", Url.GetUmbracoApiServiceBaseUrl<RteEmbedController>(
controller => controller.GetEmbed("",0,0))
},
{
"userApiBaseUrl", Url.GetUmbracoApiServiceBaseUrl<UserController>(
controller => controller.PostDisableUser(0))
},
{
"contentApiBaseUrl", Url.GetUmbracoApiServiceBaseUrl<ContentController>(
controller => controller.PostSave(null))

View File

@@ -0,0 +1,46 @@
using System.Net;
using System.Web.Http;
using Umbraco.Web.Mvc;
using Umbraco.Web.WebApi.Filters;
using Constants = Umbraco.Core.Constants;
namespace Umbraco.Web.Editors
{
[PluginController("UmbracoApi")]
[UmbracoApplicationAuthorize(Constants.Applications.Users)]
public class UserController : UmbracoAuthorizedJsonController
{
/// <summary>
/// Constructor
/// </summary>
public UserController()
: this(UmbracoContext.Current)
{
}
/// <summary>
/// Constructor
/// </summary>
/// <param name="umbracoContext"></param>
public UserController(UmbracoContext umbracoContext)
: base(umbracoContext)
{
}
/// <summary>
/// Disables the user with the given user id
/// </summary>
/// <param name="userId"></param>
public bool PostDisableUser([FromUri]int userId)
{
var user = Services.UserService.GetUserById(userId);
if (user == null)
{
throw new HttpResponseException(HttpStatusCode.NotFound);
}
//without the permanent flag, this will just disable
Services.UserService.Delete(user);
return true;
}
}
}

View File

@@ -365,6 +365,11 @@ namespace Umbraco.Web.Trees
node.AdditionalData.Add("treeAlias", xmlTreeNode.TreeType);
}
foreach (var appliedClass in xmlTreeNode.Style.AppliedClasses)
{
node.CssClasses.Add(appliedClass);
}
//This is a special case scenario, we know that content/media works based on the normal Belle routing/editing so we'll ensure we don't
// pass in the legacy JS handler so we do it the new way, for all other trees (Currently, this is a WIP), we'll render
// the legacy js callback,.

View File

@@ -307,6 +307,7 @@
<Compile Include="Editors\PackageInstallController.cs" />
<Compile Include="Editors\TemplateController.cs" />
<Compile Include="Editors\CanvasDesignerController.cs" />
<Compile Include="Editors\UserController.cs" />
<Compile Include="GridTemplateExtensions.cs" />
<Compile Include="Models\PackageInstallModel.cs" />
<Compile Include="Models\ContentEditing\DataTypeBasic.cs" />

View File

@@ -381,9 +381,9 @@ namespace umbraco.cms.presentation.Trees
AppliedClasses = new List<string>();
}
private const string DimNodeCssClass = "dim";
private const string HighlightNodeCssClass = "overlay-new";
private const string SecureNodeCssClass = "overlay-protect";
private const string DimNodeCssClass = "not-published";
private const string HighlightNodeCssClass = "has-unpublished-version";
private const string SecureNodeCssClass = "protected";
internal List<string> AppliedClasses { get; private set; }