Got delete working for legacy items... just need to get the tree to respond, do tree syncing, etc... but it is working.

This commit is contained in:
Shannon
2013-07-12 14:36:35 +10:00
parent cdf114df4b
commit e2ef802f65
11 changed files with 58 additions and 16 deletions

View File

@@ -260,7 +260,9 @@ module.exports = function (grunt) {
newcap:true,
noarg:true,
sub:true,
boss:true,
boss: true,
//NOTE: This is required so it doesn't barf on reserved words like delete when doing $http.delete
es5: true,
eqnull: true,
//NOTE: we need to use eval sometimes so ignore it
evil: true,
@@ -281,7 +283,9 @@ module.exports = function (grunt) {
newcap:true,
noarg:true,
sub:true,
boss:true,
boss: true,
//NOTE: This is required so it doesn't barf on reserved words like delete when doing $http.delete
es5: true,
eqnull: true,
//NOTE: we need to use eval sometimes so ignore it
evil: true,

View File

@@ -50,7 +50,7 @@ function contentResource($q, $http, umbDataFormatter, umbRequestHelper) {
umbRequestHelper.getApiUrl(
"contentApiBaseUrl",
"GetEmpty",
[{ contentTypeAlias: contentTypeAlias }, { parentId: parentId }])),
[{ contentTypeAlias: alias }, { parentId: parentId }])),
'Failed to retreive data for empty content item type ' + alias);
},

View File

@@ -0,0 +1,30 @@
/**
* @ngdoc service
* @name umbraco.resources.sectionResource
* @description Loads in data for section
**/
function legacyResource($q, $http, umbRequestHelper) {
//the factory object returned
return {
/** Loads in the data to display the section list */
deleteItem: function (args) {
if (!args.nodeId || !args.nodeType) {
throw "The args parameter is not formatted correct, it requires properties: nodeId, nodeType";
}
return umbRequestHelper.resourcePromise(
$http.delete(
umbRequestHelper.getApiUrl(
"legacyApiBaseUrl",
"DeleteLegacyItem",
[{ nodeId: args.nodeId }, { nodeType: args.nodeType }])),
'Failed to delete item ' + args.nodeId);
}
};
}
angular.module('umbraco.resources').factory('legacyResource', legacyResource);

View File

@@ -35,7 +35,7 @@ function mediaResource($q, $http, umbDataFormatter, umbRequestHelper) {
umbRequestHelper.getApiUrl(
"mediaApiBaseUrl",
"GetEmpty",
[{ contentTypeAlias: contentTypeAlias }, { parentId: parentId }])),
[{ contentTypeAlias: alias }, { parentId: parentId }])),
'Failed to retreive data for empty media item type ' + alias);
},

View File

@@ -9,13 +9,13 @@
* @description
* Used to lazy load in any JS dependencies that need to be manually loaded in
*/
function legacyJsLoader(scriptLoader) {
function legacyJsLoader(scriptLoader, umbRequestHelper) {
return {
/** Called to load in the legacy tree js which is required on startup if a user is logged in or
after login, but cannot be called until they are authenticated which is why it needs to be lazy loaded. */
loadLegacyTreeJs: function(scope) {
return scriptLoader.load([Umbraco.Sys.ServerVariables.legacyTreeJs], scope);
return scriptLoader.load([umbRequestHelper.getApiUrl("legacyTreeJs", "", "")], scope);
}
};
}

View File

@@ -6,12 +6,19 @@
* @description
* The controller for deleting content
*/
function LegacyDeleteController($scope) {
function LegacyDeleteController($scope, legacyResource) {
$scope.performDelete = function() {
legacyResource.deleteItem({
nodeId: $scope.currentNode.id,
nodeType: $scope.currentNode.nodetype
}).then(function () {
//TODO: Need to sync tree, etc...
alert("Deleted!");
$scope.hideMenu();
});
alert("Deleted!");
};
$scope.cancel = function() {

View File

@@ -9,7 +9,7 @@
*
* @param {navigationService} navigationService A reference to the navigationService
*/
function NavigationController($scope,$rootScope, $location, navigationService, dialogService, historyService, sectionResource, angularHelper) {
function NavigationController($scope,$rootScope, $location, $log, navigationService, dialogService, historyService, sectionResource, angularHelper) {
//load navigation service handlers
$scope.changeSection = navigationService.changeSection;

View File

@@ -2584,8 +2584,6 @@ xcopy "$(ProjectDir)"..\packages\SqlServerCE.4.0.0.0\x86\*.* "$(TargetDir)x86\"
<DevelopmentServerPort>6130</DevelopmentServerPort>
<DevelopmentServerVPath>/</DevelopmentServerVPath>
<IISUrl>http://localhost:6130</IISUrl>
<OverrideIISAppRootUrl>True</OverrideIISAppRootUrl>
<IISAppRootUrl>http://localhost:61644/Vdir</IISAppRootUrl>
<NTLMAuthentication>False</NTLMAuthentication>
<UseCustomServer>False</UseCustomServer>
<CustomServerUrl>

View File

@@ -59,7 +59,8 @@ namespace Umbraco.Web.Editors
{"treeApplicationApiBaseUrl", Url.GetUmbracoApiServiceBaseUrl<ApplicationTreeController>("GetApplicationTrees")},
{"contentTypeApiBaseUrl", Url.GetUmbracoApiServiceBaseUrl<ContentTypeController>("GetAllowedChildren")},
{"mediaTypeApiBaseUrl", Url.GetUmbracoApiServiceBaseUrl<MediaTypeApiController>("GetAllowedChildren")},
{"authenticationApiBaseUrl", Url.GetUmbracoApiServiceBaseUrl<AuthenticationController>("PostLogin")}
{"authenticationApiBaseUrl", Url.GetUmbracoApiServiceBaseUrl<AuthenticationController>("PostLogin")},
{"legacyApiBaseUrl", Url.GetUmbracoApiServiceBaseUrl<LegacyController>("DeleteLegacyItem")}
}
},
{

View File

@@ -39,8 +39,10 @@ namespace Umbraco.Web.Editors
/// has functionality included in the ui.xml structure.
/// </summary>
/// <returns></returns>
public HttpResponseMessage DeleteLegacyItem(string nodeId, string nodeType, string nodeText)
public HttpResponseMessage DeleteLegacyItem(string nodeId, string nodeType)
{
//TODO: Detect recycle bin node ids and delete permanently!
//In order to process this request we MUST have an HttpContext available
var httpContextAttempt = TryGetHttpContext();
if (httpContextAttempt.Success)
@@ -48,7 +50,7 @@ namespace Umbraco.Web.Editors
int id;
if (int.TryParse(nodeId, out id))
{
LegacyDialogHandler.Delete(httpContextAttempt.Result, UmbracoUser, nodeType, id, nodeText);
LegacyDialogHandler.Delete(httpContextAttempt.Result, UmbracoUser, nodeType, id, "");
return new HttpResponseMessage(HttpStatusCode.OK);
}
//We must have an integer id for this to work

View File

@@ -31,10 +31,10 @@ namespace Umbraco.Web.WebApi
object context;
if (Request.Properties.TryGetValue("MS_HttpContext", out context))
{
var httpContext = context as HttpContext;
var httpContext = context as HttpContextBase;
if (httpContext != null)
{
return new Attempt<HttpContextBase>(true, new HttpContextWrapper(httpContext));
return new Attempt<HttpContextBase>(true, httpContext);
}
}
return Attempt<HttpContextBase>.False;