FIxes: U4-9547, Fixes: U4-9546 even though GetChildFolders isn't used anymore i made it work slightly faster
This commit is contained in:
@@ -118,7 +118,7 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
|
||||
if (objectTypes.Any())
|
||||
{
|
||||
sql = sql.Where("umbracoNode.nodeObjectType IN (@objectTypes)", objectTypes);
|
||||
sql = sql.Where("umbracoNode.nodeObjectType IN (@objectTypes)", new {objectTypes = objectTypes});
|
||||
}
|
||||
|
||||
return Database.Fetch<string>(sql);
|
||||
|
||||
@@ -438,7 +438,7 @@ function mediaResource($q, $http, umbDataFormatter, umbRequestHelper) {
|
||||
*
|
||||
* @param {int} parentId Id of the media item to query for child folders
|
||||
* @returns {Promise} resourcePromise object.
|
||||
*
|
||||
* @deprecated This method is no longer used and shouldn't be because it performs poorly when there are a lot of media items
|
||||
*/
|
||||
getChildFolders: function (parentId) {
|
||||
if (!parentId) {
|
||||
|
||||
@@ -7,6 +7,19 @@ function mediaTypeHelper(mediaTypeResource, $q) {
|
||||
|
||||
var mediaTypeHelperService = {
|
||||
|
||||
isFolderType: function(mediaEntity) {
|
||||
if (!mediaEntity) {
|
||||
throw "mediaEntity is null";
|
||||
}
|
||||
if (!mediaEntity.contentTypeAlias) {
|
||||
throw "mediaEntity.contentTypeAlias is null";
|
||||
}
|
||||
|
||||
//if you create a media type, which has an alias that ends with ...Folder then its a folder: ex: "secureFolder", "bannerFolder", "Folder"
|
||||
//this is the exact same logic that is performed in MediaController.GetChildFolders
|
||||
return mediaEntity.contentTypeAlias.endsWith("Folder");
|
||||
},
|
||||
|
||||
getAllowedImagetypes: function (mediaId){
|
||||
|
||||
// Get All allowedTypes
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
function listViewController($rootScope, $scope, $routeParams, $injector, $cookieStore, notificationsService, iconHelper, dialogService, editorState, localizationService, $location, appState, $timeout, $q, mediaResource, listViewHelper, userService, navigationService, treeService) {
|
||||
function listViewController($rootScope, $scope, $routeParams, $injector, $cookieStore, mediaTypeHelper, notificationsService, iconHelper, dialogService, editorState, localizationService, $location, appState, $timeout, $q, mediaResource, listViewHelper, userService, navigationService, treeService) {
|
||||
|
||||
//this is a quick check to see if we're in create mode, if so just exit - we cannot show children for content
|
||||
// that isn't created yet, if we continue this will use the parent id in the route params which isn't what
|
||||
@@ -261,24 +261,25 @@ function listViewController($rootScope, $scope, $routeParams, $injector, $cookie
|
||||
$scope.actionInProgress = false;
|
||||
$scope.listViewResultSet = data;
|
||||
|
||||
//update all values for display
|
||||
//reset
|
||||
$scope.folders = [];
|
||||
|
||||
//update all values for display
|
||||
if ($scope.listViewResultSet.items) {
|
||||
_.each($scope.listViewResultSet.items, function (e, index) {
|
||||
setPropertyValues(e);
|
||||
setPropertyValues(e);
|
||||
|
||||
//special case, we need to check if any of these types are folder types
|
||||
//and add them to the folders collection
|
||||
if ($scope.entityType === 'media') {
|
||||
if (mediaTypeHelper.isFolderType(e)) {
|
||||
$scope.folders.push(e);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if ($scope.entityType === 'media') {
|
||||
|
||||
mediaResource.getChildFolders($scope.contentId)
|
||||
.then(function (folders) {
|
||||
$scope.folders = folders;
|
||||
$scope.viewLoaded = true;
|
||||
});
|
||||
|
||||
} else {
|
||||
$scope.viewLoaded = true;
|
||||
}
|
||||
$scope.viewLoaded = true;
|
||||
|
||||
//NOTE: This might occur if we are requesting a higher page number than what is actually available, for example
|
||||
// if you have more than one page and you delete all items on the last page. In this case, we need to reset to the last
|
||||
|
||||
@@ -160,19 +160,25 @@ namespace Umbraco.Web.Editors
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns media items known to be a container of other media items
|
||||
/// Returns media items known to be of a "Folder" type
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
[Obsolete("This is no longer used and shouldn't be because it performs poorly when there are a lot of media items")]
|
||||
[FilterAllowedOutgoingMedia(typeof(IEnumerable<ContentItemBasic<ContentPropertyBasic, IMedia>>))]
|
||||
public IEnumerable<ContentItemBasic<ContentPropertyBasic, IMedia>> GetChildFolders(int id = -1)
|
||||
{
|
||||
//Suggested convention for folder mediatypes - we can make this more or less complicated as long as we document it...
|
||||
//if you create a media type, which has an alias that ends with ...Folder then its a folder: ex: "secureFolder", "bannerFolder", "Folder"
|
||||
var folderTypes = Services.ContentTypeService.GetAllMediaTypes().ToArray().Where(x => x.Alias.EndsWith("Folder")).Select(x => x.Id);
|
||||
var folderTypes = Services.ContentTypeService
|
||||
.GetAllContentTypeAliases(Constants.ObjectTypes.MediaTypeGuid)
|
||||
.Where(x => x.EndsWith("Folder"));
|
||||
|
||||
var children = (id < 0)
|
||||
? Services.MediaService.GetRootMedia()
|
||||
: Services.MediaService.GetChildren(id);
|
||||
|
||||
var children = (id < 0) ? Services.MediaService.GetRootMedia() : Services.MediaService.GetById(id).Children();
|
||||
return children.Where(x => folderTypes.Contains(x.ContentTypeId)).Select(Mapper.Map<IMedia, ContentItemBasic<ContentPropertyBasic, IMedia>>);
|
||||
return children.Where(x => folderTypes.Contains(x.ContentType.Alias)).Select(Mapper.Map<IMedia, ContentItemBasic<ContentPropertyBasic, IMedia>>);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user