Merge pull request #1113 from umbraco/temp-U4-7936

U4-7936 Clicking the Recycle Bin shows "Session expired" login screen
This commit is contained in:
Sebastiaan Janssen
2016-02-11 15:48:24 +01:00
9 changed files with 121 additions and 46 deletions

View File

@@ -42,6 +42,15 @@ function contentResource($q, $http, umbDataFormatter, umbRequestHelper) {
return { return {
getRecycleBin: function() {
return umbRequestHelper.resourcePromise(
$http.get(
umbRequestHelper.getApiUrl(
"contentApiBaseUrl",
"GetRecycleBin")),
'Failed to retrieve data for content recycle bin');
},
/** /**
* @ngdoc method * @ngdoc method
* @name umbraco.resources.contentResource#sort * @name umbraco.resources.contentResource#sort

View File

@@ -22,6 +22,15 @@ function mediaResource($q, $http, umbDataFormatter, umbRequestHelper) {
return { return {
getRecycleBin: function () {
return umbRequestHelper.resourcePromise(
$http.get(
umbRequestHelper.getApiUrl(
"mediaApiBaseUrl",
"GetRecycleBin")),
'Failed to retrieve data for media recycle bin');
},
/** /**
* @ngdoc method * @ngdoc method
* @name umbraco.resources.mediaResource#sort * @name umbraco.resources.mediaResource#sort

View File

@@ -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 //ensures the list view doesn't actually load until we query for the list view config
// for the section // for the section
@@ -16,17 +16,23 @@ function ContentRecycleBinController($scope, $routeParams, dataTypeResource, nav
$scope.page.name = "Recycle Bin"; $scope.page.name = "Recycle Bin";
$scope.page.nameLocked = true; $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; $scope.listViewPath = null;
$routeParams.id = "-20"; $routeParams.id = "-20";
dataTypeResource.getById(-95).then(function (result) { contentResource.getRecycleBin().then(function (result) {
_.each(result.preValues, function (i) { //we'll get the 'content item' for the recycle bin, we know that it will contain a single tab and a
$scope.model.config[i.key] = i.value; // 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.listViewPath = 'views/propertyeditors/listview/listview.html';
}); });
$scope.model = { config: { entityType: $routeParams.section } }; $scope.model = { config: { entityType: $routeParams.section, layouts: [] } };
// sync tree node // sync tree node
navigationService.syncTree({ tree: "content", path: ["-1", $routeParams.id], forceReload: false }); navigationService.syncTree({ tree: "content", path: ["-1", $routeParams.id], forceReload: false });
@@ -35,11 +41,11 @@ function ContentRecycleBinController($scope, $routeParams, dataTypeResource, nav
function localizePageName() { function localizePageName() {
var pageName = "general_recycleBin"; var pageName = "general_recycleBin";
localizationService.localize(pageName).then(function(value) { localizationService.localize(pageName).then(function (value) {
$scope.page.name = value; $scope.page.name = value;
}); });
} }
} }

View File

@@ -1,17 +1,16 @@
<umb-editor-view ng-controller="Umbraco.Editors.Content.RecycleBinController"> <umb-editor-view ng-controller="Umbraco.Editors.Content.RecycleBinController">
<form>
<umb-editor-header name="page.name"
name-locked="page.nameLocked"
hide-icon="true"
hide-description="true"
hide-alias="true">
</umb-editor-header>
<umb-editor-header <umb-editor-container>
name="page.name"
name-locked="page.nameLocked"
hide-icon="true"
hide-description="true"
hide-alias="true" >
</umb-editor-header>
<umb-editor-container> <div ng-include="listViewPath"></div>
<div ng-include="listViewPath"></div> </umb-editor-container>
</form>
</umb-editor-container> </umb-editor-view>
</umb-editor-view>

View File

@@ -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 = {};
$scope.page.name = "Recycle Bin"; $scope.page.name = "Recycle Bin";
$scope.page.nameLocked = true; $scope.page.nameLocked = true;
@@ -19,14 +21,18 @@ function MediaRecycleBinController($scope, $routeParams, dataTypeResource, navig
$scope.listViewPath = null; $scope.listViewPath = null;
$routeParams.id = "-21"; $routeParams.id = "-21";
dataTypeResource.getById(-96).then(function (result) { mediaResource.getRecycleBin().then(function (result) {
_.each(result.preValues, function (i) { //we'll get the 'content item' for the recycle bin, we know that it will contain a single tab and a
$scope.model.config[i.key] = i.value; // 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.listViewPath = 'views/propertyeditors/listview/listview.html';
}); });
$scope.model = { config: { entityType: $routeParams.section } }; $scope.model = { config: { entityType: $routeParams.section, layouts: [] } };
// sync tree node // sync tree node
navigationService.syncTree({ tree: "media", path: ["-1", $routeParams.id], forceReload: false }); navigationService.syncTree({ tree: "media", path: ["-1", $routeParams.id], forceReload: false });
@@ -35,14 +41,13 @@ function MediaRecycleBinController($scope, $routeParams, dataTypeResource, navig
function localizePageName() { function localizePageName() {
var pageName = "general_recycleBin"; var pageName = "general_recycleBin";
localizationService.localize(pageName).then(function(value) { localizationService.localize(pageName).then(function (value) {
$scope.page.name = value; $scope.page.name = value;
}); });
} }
} }
angular.module('umbraco').controller("Umbraco.Editors.Media.RecycleBinController", MediaRecycleBinController); angular.module('umbraco').controller("Umbraco.Editors.Media.RecycleBinController", MediaRecycleBinController);

View File

@@ -1,17 +1,16 @@
<umb-editor-view ng-controller="Umbraco.Editors.Media.RecycleBinController"> <umb-editor-view ng-controller="Umbraco.Editors.Media.RecycleBinController">
<form>
<umb-editor-header name="page.name"
name-locked="page.nameLocked"
hide-icon="true"
hide-description="true"
hide-alias="true">
</umb-editor-header>
<umb-editor-header <umb-editor-container>
name="page.name"
name-locked="page.nameLocked"
hide-icon="true"
hide-description="true"
hide-alias="true">
</umb-editor-header>
<umb-editor-container> <div ng-include="listViewPath"></div>
<div ng-include="listViewPath"></div>
</umb-editor-container>
</umb-editor-container>
</form>
</umb-editor-view> </umb-editor-view>

View File

@@ -30,6 +30,7 @@ using Umbraco.Core.Dynamics;
using umbraco.BusinessLogic.Actions; using umbraco.BusinessLogic.Actions;
using umbraco.cms.businesslogic.web; using umbraco.cms.businesslogic.web;
using umbraco.presentation.preview; using umbraco.presentation.preview;
using Umbraco.Core.PropertyEditors;
using Umbraco.Web.UI; using Umbraco.Web.UI;
using Constants = Umbraco.Core.Constants; using Constants = Umbraco.Core.Constants;
using Notification = Umbraco.Web.Models.ContentEditing.Notification; using Notification = Umbraco.Web.Models.ContentEditing.Notification;
@@ -76,13 +77,36 @@ namespace Umbraco.Web.Editors
return foundContent.Select(Mapper.Map<IContent, ContentItemDisplay>); return foundContent.Select(Mapper.Map<IContent, ContentItemDisplay>);
} }
/// <summary>
/// Returns an item to be used to display the recycle bin for content
/// </summary>
/// <returns></returns>
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;
}
/// <summary> /// <summary>
/// Gets the content json for the content id /// Gets the content json for the content id
/// </summary> /// </summary>
/// <param name="id"></param> /// <param name="id"></param>
/// <returns></returns> /// <returns></returns>
[OutgoingEditorModelEvent] [OutgoingEditorModelEvent]
[EnsureUserPermissionForContent("id")] [EnsureUserPermissionForContent("id")]
public ContentItemDisplay GetById(int id) public ContentItemDisplay GetById(int id)
{ {
var foundContent = GetObjectFromRequest(() => Services.ContentService.GetById(id)); var foundContent = GetObjectFromRequest(() => Services.ContentService.GetById(id));

View File

@@ -88,6 +88,29 @@ namespace Umbraco.Web.Editors
return mapped; return mapped;
} }
/// <summary>
/// Returns an item to be used to display the recycle bin for media
/// </summary>
/// <returns></returns>
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;
}
/// <summary> /// <summary>
/// Gets the content json for the content id /// Gets the content json for the content id
/// </summary> /// </summary>
@@ -123,7 +146,7 @@ namespace Umbraco.Web.Editors
/// <summary> /// <summary>
/// Returns media items known to be a container of other media items /// Returns media items known to be a container of other media items
/// </summary> /// </summary>
/// <param name="ids"></param> /// <param name="id"></param>
/// <returns></returns> /// <returns></returns>
[FilterAllowedOutgoingMedia(typeof(IEnumerable<ContentItemBasic<ContentPropertyBasic, IMedia>>))] [FilterAllowedOutgoingMedia(typeof(IEnumerable<ContentItemBasic<ContentPropertyBasic, IMedia>>))]
public IEnumerable<ContentItemBasic<ContentPropertyBasic, IMedia>> GetChildFolders(int id = -1) public IEnumerable<ContentItemBasic<ContentPropertyBasic, IMedia>> GetChildFolders(int id = -1)

View File

@@ -126,6 +126,7 @@ namespace Umbraco.Web.Models.Mapping
/// <param name="display"></param> /// <param name="display"></param>
/// <param name="entityType">This must be either 'content' or 'media'</param> /// <param name="entityType">This must be either 'content' or 'media'</param>
/// <param name="dataTypeService"></param> /// <param name="dataTypeService"></param>
/// <param name="localizedTextService"></param>
internal static void AddListView<TPersisted>(TabbedContentItem<ContentPropertyDisplay, TPersisted> display, string entityType, IDataTypeService dataTypeService, ILocalizedTextService localizedTextService) internal static void AddListView<TPersisted>(TabbedContentItem<ContentPropertyDisplay, TPersisted> display, string entityType, IDataTypeService dataTypeService, ILocalizedTextService localizedTextService)
where TPersisted : IContentBase where TPersisted : IContentBase
{ {