From e2ef802f65f2ad07d0e8a669d73dc1a179b70aa7 Mon Sep 17 00:00:00 2001 From: Shannon Date: Fri, 12 Jul 2013 14:36:35 +1000 Subject: [PATCH] Got delete working for legacy items... just need to get the tree to respond, do tree syncing, etc... but it is working. --- src/Umbraco.Web.UI.Client/gruntFile.js | 8 +++-- .../src/common/resources/content.resource.js | 2 +- .../src/common/resources/legacy.resource.js | 30 +++++++++++++++++++ .../src/common/resources/media.resource.js | 2 +- .../src/common/services/utill.service.js | 4 +-- .../common/dialogs/legacydelete.controller.js | 11 +++++-- .../src/views/common/navigation.controller.js | 2 +- src/Umbraco.Web.UI/Umbraco.Web.UI.csproj | 2 -- .../Editors/BackOfficeController.cs | 3 +- src/Umbraco.Web/Editors/LegacyController.cs | 6 ++-- .../WebApi/UmbracoApiController.cs | 4 +-- 11 files changed, 58 insertions(+), 16 deletions(-) create mode 100644 src/Umbraco.Web.UI.Client/src/common/resources/legacy.resource.js diff --git a/src/Umbraco.Web.UI.Client/gruntFile.js b/src/Umbraco.Web.UI.Client/gruntFile.js index 0ec8db3e3a..a118085506 100644 --- a/src/Umbraco.Web.UI.Client/gruntFile.js +++ b/src/Umbraco.Web.UI.Client/gruntFile.js @@ -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, 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 07f2d1c966..a1928fa2ac 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 @@ -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); }, diff --git a/src/Umbraco.Web.UI.Client/src/common/resources/legacy.resource.js b/src/Umbraco.Web.UI.Client/src/common/resources/legacy.resource.js new file mode 100644 index 0000000000..d5a6351253 --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/common/resources/legacy.resource.js @@ -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); \ No newline at end of file diff --git a/src/Umbraco.Web.UI.Client/src/common/resources/media.resource.js b/src/Umbraco.Web.UI.Client/src/common/resources/media.resource.js index af1f34c3a1..d01ff6d59c 100644 --- a/src/Umbraco.Web.UI.Client/src/common/resources/media.resource.js +++ b/src/Umbraco.Web.UI.Client/src/common/resources/media.resource.js @@ -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); }, diff --git a/src/Umbraco.Web.UI.Client/src/common/services/utill.service.js b/src/Umbraco.Web.UI.Client/src/common/services/utill.service.js index b3b9807223..3f35b689af 100644 --- a/src/Umbraco.Web.UI.Client/src/common/services/utill.service.js +++ b/src/Umbraco.Web.UI.Client/src/common/services/utill.service.js @@ -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); } }; } diff --git a/src/Umbraco.Web.UI.Client/src/views/common/dialogs/legacydelete.controller.js b/src/Umbraco.Web.UI.Client/src/views/common/dialogs/legacydelete.controller.js index 9e7a15e29e..46b1718424 100644 --- a/src/Umbraco.Web.UI.Client/src/views/common/dialogs/legacydelete.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/common/dialogs/legacydelete.controller.js @@ -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() { diff --git a/src/Umbraco.Web.UI.Client/src/views/common/navigation.controller.js b/src/Umbraco.Web.UI.Client/src/views/common/navigation.controller.js index 4865cf8a23..8c5ecb1aef 100644 --- a/src/Umbraco.Web.UI.Client/src/views/common/navigation.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/common/navigation.controller.js @@ -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; diff --git a/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj b/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj index ca4a3672c9..429ba87931 100644 --- a/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj +++ b/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj @@ -2584,8 +2584,6 @@ xcopy "$(ProjectDir)"..\packages\SqlServerCE.4.0.0.0\x86\*.* "$(TargetDir)x86\" 6130 / http://localhost:6130 - True - http://localhost:61644/Vdir False False diff --git a/src/Umbraco.Web/Editors/BackOfficeController.cs b/src/Umbraco.Web/Editors/BackOfficeController.cs index fa603d985a..116a941212 100644 --- a/src/Umbraco.Web/Editors/BackOfficeController.cs +++ b/src/Umbraco.Web/Editors/BackOfficeController.cs @@ -59,7 +59,8 @@ namespace Umbraco.Web.Editors {"treeApplicationApiBaseUrl", Url.GetUmbracoApiServiceBaseUrl("GetApplicationTrees")}, {"contentTypeApiBaseUrl", Url.GetUmbracoApiServiceBaseUrl("GetAllowedChildren")}, {"mediaTypeApiBaseUrl", Url.GetUmbracoApiServiceBaseUrl("GetAllowedChildren")}, - {"authenticationApiBaseUrl", Url.GetUmbracoApiServiceBaseUrl("PostLogin")} + {"authenticationApiBaseUrl", Url.GetUmbracoApiServiceBaseUrl("PostLogin")}, + {"legacyApiBaseUrl", Url.GetUmbracoApiServiceBaseUrl("DeleteLegacyItem")} } }, { diff --git a/src/Umbraco.Web/Editors/LegacyController.cs b/src/Umbraco.Web/Editors/LegacyController.cs index 9b2e018763..0d840a8f81 100644 --- a/src/Umbraco.Web/Editors/LegacyController.cs +++ b/src/Umbraco.Web/Editors/LegacyController.cs @@ -39,8 +39,10 @@ namespace Umbraco.Web.Editors /// has functionality included in the ui.xml structure. /// /// - 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 diff --git a/src/Umbraco.Web/WebApi/UmbracoApiController.cs b/src/Umbraco.Web/WebApi/UmbracoApiController.cs index 4694f6d96c..6462988827 100644 --- a/src/Umbraco.Web/WebApi/UmbracoApiController.cs +++ b/src/Umbraco.Web/WebApi/UmbracoApiController.cs @@ -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(true, new HttpContextWrapper(httpContext)); + return new Attempt(true, httpContext); } } return Attempt.False;