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 86584d41f7..5aa56a80af 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 @@ -42,6 +42,15 @@ function contentResource($q, $http, umbDataFormatter, umbRequestHelper) { return { + getRecycleBin: function() { + return umbRequestHelper.resourcePromise( + $http.get( + umbRequestHelper.getApiUrl( + "contentApiBaseUrl", + "GetRecycleBin")), + 'Failed to retrieve data for content recycle bin'); + }, + /** * @ngdoc method * @name umbraco.resources.contentResource#sort 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 f6443735cf..9a2310299f 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 @@ -22,6 +22,15 @@ function mediaResource($q, $http, umbDataFormatter, umbRequestHelper) { return { + getRecycleBin: function () { + return umbRequestHelper.resourcePromise( + $http.get( + umbRequestHelper.getApiUrl( + "mediaApiBaseUrl", + "GetRecycleBin")), + 'Failed to retrieve data for media recycle bin'); + }, + /** * @ngdoc method * @name umbraco.resources.mediaResource#sort diff --git a/src/Umbraco.Web.UI.Client/src/views/content/content.recyclebin.controller.js b/src/Umbraco.Web.UI.Client/src/views/content/content.recyclebin.controller.js index 0e4fe07339..4a8c50db39 100644 --- a/src/Umbraco.Web.UI.Client/src/views/content/content.recyclebin.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/content/content.recyclebin.controller.js @@ -8,7 +8,7 @@ * */ -function ContentRecycleBinController($scope, $routeParams, dataTypeResource, navigationService, localizationService) { +function ContentRecycleBinController($scope, $routeParams, contentResource, navigationService, localizationService) { //ensures the list view doesn't actually load until we query for the list view config // for the section @@ -16,17 +16,23 @@ function ContentRecycleBinController($scope, $routeParams, dataTypeResource, nav $scope.page.name = "Recycle Bin"; $scope.page.nameLocked = true; + //ensures the list view doesn't actually load until we query for the list view config + // for the section $scope.listViewPath = null; $routeParams.id = "-20"; - dataTypeResource.getById(-95).then(function (result) { - _.each(result.preValues, function (i) { - $scope.model.config[i.key] = i.value; + contentResource.getRecycleBin().then(function (result) { + //we'll get the 'content item' for the recycle bin, we know that it will contain a single tab and a + // single property, so we'll extract that property (list view) and use it's data. + var listproperty = result.tabs[0].properties[0]; + + _.each(listproperty.config, function (val, key) { + $scope.model.config[key] = val; }); $scope.listViewPath = 'views/propertyeditors/listview/listview.html'; }); - $scope.model = { config: { entityType: $routeParams.section } }; + $scope.model = { config: { entityType: $routeParams.section, layouts: [] } }; // sync tree node navigationService.syncTree({ tree: "content", path: ["-1", $routeParams.id], forceReload: false }); @@ -35,11 +41,11 @@ function ContentRecycleBinController($scope, $routeParams, dataTypeResource, nav function localizePageName() { - var pageName = "general_recycleBin"; + var pageName = "general_recycleBin"; - localizationService.localize(pageName).then(function(value) { - $scope.page.name = value; - }); + localizationService.localize(pageName).then(function (value) { + $scope.page.name = value; + }); } } diff --git a/src/Umbraco.Web.UI.Client/src/views/content/recyclebin.html b/src/Umbraco.Web.UI.Client/src/views/content/recyclebin.html index f4c22c0220..7e45549ea7 100644 --- a/src/Umbraco.Web.UI.Client/src/views/content/recyclebin.html +++ b/src/Umbraco.Web.UI.Client/src/views/content/recyclebin.html @@ -1,17 +1,16 @@ +
+ + - - + - +
-
- -
- - +
+
+
\ No newline at end of file diff --git a/src/Umbraco.Web.UI.Client/src/views/media/media.recyclebin.controller.js b/src/Umbraco.Web.UI.Client/src/views/media/media.recyclebin.controller.js index 8134d0ad26..4e54bd832a 100644 --- a/src/Umbraco.Web.UI.Client/src/views/media/media.recyclebin.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/media/media.recyclebin.controller.js @@ -8,8 +8,10 @@ * */ -function MediaRecycleBinController($scope, $routeParams, dataTypeResource, navigationService, localizationService) { +function MediaRecycleBinController($scope, $routeParams, mediaResource, navigationService, localizationService) { + //ensures the list view doesn't actually load until we query for the list view config + // for the section $scope.page = {}; $scope.page.name = "Recycle Bin"; $scope.page.nameLocked = true; @@ -19,14 +21,18 @@ function MediaRecycleBinController($scope, $routeParams, dataTypeResource, navig $scope.listViewPath = null; $routeParams.id = "-21"; - dataTypeResource.getById(-96).then(function (result) { - _.each(result.preValues, function (i) { - $scope.model.config[i.key] = i.value; + mediaResource.getRecycleBin().then(function (result) { + //we'll get the 'content item' for the recycle bin, we know that it will contain a single tab and a + // single property, so we'll extract that property (list view) and use it's data. + var listproperty = result.tabs[0].properties[0]; + + _.each(listproperty.config, function (val, key) { + $scope.model.config[key] = val; }); $scope.listViewPath = 'views/propertyeditors/listview/listview.html'; }); - $scope.model = { config: { entityType: $routeParams.section } }; + $scope.model = { config: { entityType: $routeParams.section, layouts: [] } }; // sync tree node navigationService.syncTree({ tree: "media", path: ["-1", $routeParams.id], forceReload: false }); @@ -35,14 +41,13 @@ function MediaRecycleBinController($scope, $routeParams, dataTypeResource, navig function localizePageName() { - var pageName = "general_recycleBin"; + var pageName = "general_recycleBin"; - localizationService.localize(pageName).then(function(value) { - $scope.page.name = value; - }); + localizationService.localize(pageName).then(function (value) { + $scope.page.name = value; + }); } - } angular.module('umbraco').controller("Umbraco.Editors.Media.RecycleBinController", MediaRecycleBinController); diff --git a/src/Umbraco.Web.UI.Client/src/views/media/recyclebin.html b/src/Umbraco.Web.UI.Client/src/views/media/recyclebin.html index bfdfcbf8bf..4a74e4affe 100644 --- a/src/Umbraco.Web.UI.Client/src/views/media/recyclebin.html +++ b/src/Umbraco.Web.UI.Client/src/views/media/recyclebin.html @@ -1,17 +1,16 @@ +
+ + - - + - - -
- -
+
+
+
diff --git a/src/Umbraco.Web/Editors/ContentController.cs b/src/Umbraco.Web/Editors/ContentController.cs index 6358656d00..f321d9d0af 100644 --- a/src/Umbraco.Web/Editors/ContentController.cs +++ b/src/Umbraco.Web/Editors/ContentController.cs @@ -30,6 +30,7 @@ using Umbraco.Core.Dynamics; using umbraco.BusinessLogic.Actions; using umbraco.cms.businesslogic.web; using umbraco.presentation.preview; +using Umbraco.Core.PropertyEditors; using Umbraco.Web.UI; using Constants = Umbraco.Core.Constants; using Notification = Umbraco.Web.Models.ContentEditing.Notification; @@ -76,13 +77,36 @@ namespace Umbraco.Web.Editors return foundContent.Select(Mapper.Map); } + /// + /// Returns an item to be used to display the recycle bin for content + /// + /// + public ContentItemDisplay GetRecycleBin() + { + var display = new ContentItemDisplay + { + Id = Constants.System.RecycleBinContent, + Alias = "recycleBin", + ParentId = -1, + Name = Services.TextService.Localize("general/recycleBin"), + ContentTypeAlias = "recycleBin", + CreateDate = DateTime.Now, + IsContainer = true, + Path = "-1," + Constants.System.RecycleBinContent + }; + + TabsAndPropertiesResolver.AddListView(display, "content", Services.DataTypeService, Services.TextService); + + return display; + } + /// /// Gets the content json for the content id /// /// /// [OutgoingEditorModelEvent] - [EnsureUserPermissionForContent("id")] + [EnsureUserPermissionForContent("id")] public ContentItemDisplay GetById(int id) { var foundContent = GetObjectFromRequest(() => Services.ContentService.GetById(id)); diff --git a/src/Umbraco.Web/Editors/MediaController.cs b/src/Umbraco.Web/Editors/MediaController.cs index 92b0546b80..66889e2206 100644 --- a/src/Umbraco.Web/Editors/MediaController.cs +++ b/src/Umbraco.Web/Editors/MediaController.cs @@ -88,6 +88,29 @@ namespace Umbraco.Web.Editors return mapped; } + /// + /// Returns an item to be used to display the recycle bin for media + /// + /// + public ContentItemDisplay GetRecycleBin() + { + var display = new ContentItemDisplay + { + Id = Constants.System.RecycleBinMedia, + Alias = "recycleBin", + ParentId = -1, + Name = Services.TextService.Localize("general/recycleBin"), + ContentTypeAlias = "recycleBin", + CreateDate = DateTime.Now, + IsContainer = true, + Path = "-1," + Constants.System.RecycleBinMedia + }; + + TabsAndPropertiesResolver.AddListView(display, "media", Services.DataTypeService, Services.TextService); + + return display; + } + /// /// Gets the content json for the content id /// @@ -123,7 +146,7 @@ namespace Umbraco.Web.Editors /// /// Returns media items known to be a container of other media items /// - /// + /// /// [FilterAllowedOutgoingMedia(typeof(IEnumerable>))] public IEnumerable> GetChildFolders(int id = -1) diff --git a/src/Umbraco.Web/Models/Mapping/TabsAndPropertiesResolver.cs b/src/Umbraco.Web/Models/Mapping/TabsAndPropertiesResolver.cs index 0e4549811c..76de186579 100644 --- a/src/Umbraco.Web/Models/Mapping/TabsAndPropertiesResolver.cs +++ b/src/Umbraco.Web/Models/Mapping/TabsAndPropertiesResolver.cs @@ -126,6 +126,7 @@ namespace Umbraco.Web.Models.Mapping /// /// This must be either 'content' or 'media' /// + /// internal static void AddListView(TabbedContentItem display, string entityType, IDataTypeService dataTypeService, ILocalizedTextService localizedTextService) where TPersisted : IContentBase {