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 ceceebacc3..fc9cc117a0 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 @@ -211,15 +211,71 @@ function mediaResource($q, $http, umbDataFormatter, umbRequestHelper) { }, - getChildren: function (parentId) { + /** + * @ngdoc method + * @name umbraco.resources.mediaResource#getChildren + * @methodOf umbraco.resources.mediaResource + * + * @description + * Gets children of a media item with a given id + * + * ##usage + *
+ * mediaResource.getChildren(1234, {pageSize: 10, pageNumber: 2})
+ * .then(function(contentArray) {
+ * var children = contentArray;
+ * alert('they are here!');
+ * });
+ *
+ *
+ * @param {Int} parentid id of content item to return children of
+ * @param {Object} options optional options object
+ * @param {Int} options.pageSize if paging data, number of nodes per page, default = 0
+ * @param {Int} options.pageNumber if paging data, current page index, default = 0
+ * @param {String} options.filter if provided, query will only return those with names matching the filter
+ * @param {String} options.orderDirection can be `Ascending` or `Descending` - Default: `Ascending`
+ * @param {String} options.orderBy property to order items by, default: `SortOrder`
+ * @returns {Promise} resourcePromise object containing an array of content items.
+ *
+ */
+ getChildren: function (parentId, options) {
+
+ var defaults = {
+ pageSize: 0,
+ pageNumber: 0,
+ filter: '',
+ orderDirection: "Ascending",
+ orderBy: "SortOrder"
+ };
+ if (options === undefined) {
+ options = {};
+ }
+ //overwrite the defaults if there are any specified
+ angular.extend(defaults, options);
+ //now copy back to the options we will use
+ options = defaults;
+ //change asc/desct
+ if (options.orderDirection === "asc") {
+ options.orderDirection = "Ascending";
+ }
+ else if (options.orderDirection === "desc") {
+ options.orderDirection = "Descending";
+ }
return umbRequestHelper.resourcePromise(
- $http.get(
- umbRequestHelper.getApiUrl(
- "mediaApiBaseUrl",
- "GetChildren",
- [{ parentId: parentId }])),
- 'Failed to retreive data for root media');
+ $http.get(
+ umbRequestHelper.getApiUrl(
+ "mediaApiBaseUrl",
+ "GetChildren",
+ [
+ { id: parentId },
+ { pageNumber: options.pageNumber },
+ { pageSize: options.pageSize },
+ { orderBy: options.orderBy },
+ { orderDirection: options.orderDirection },
+ { filter: options.filter }
+ ])),
+ 'Failed to retreive children for media item ' + parentId);
},
/** saves or updates a media object */
diff --git a/src/Umbraco.Web.UI.Client/src/views/common/dialogs/mediapicker.controller.js b/src/Umbraco.Web.UI.Client/src/views/common/dialogs/mediapicker.controller.js
index 988950a996..2c21f85a70 100644
--- a/src/Umbraco.Web.UI.Client/src/views/common/dialogs/mediapicker.controller.js
+++ b/src/Umbraco.Web.UI.Client/src/views/common/dialogs/mediapicker.controller.js
@@ -45,7 +45,7 @@ angular.module("umbraco")
$scope.images = [];
$scope.searchTerm = "";
- $scope.images = data;
+ $scope.images = data.items;
//update the thumbnail property
_.each($scope.images, function(img) {
img.thumbnail = imageHelper.getThumbnail({ imageModel: img, scope: $scope });
diff --git a/src/Umbraco.Web.UI.Client/src/views/media/media.sort.controller.js b/src/Umbraco.Web.UI.Client/src/views/media/media.sort.controller.js
index 91266043bb..524233b19d 100644
--- a/src/Umbraco.Web.UI.Client/src/views/media/media.sort.controller.js
+++ b/src/Umbraco.Web.UI.Client/src/views/media/media.sort.controller.js
@@ -15,12 +15,12 @@ function MediaSortController($scope, mediaResource, treeService) {
mediaResource.getChildren($scope.currentNode.id).then(function (data) {
$scope.sortableModel.itemsToSort = [];
- for (var i = 0; i < data.length; i++) {
+ for (var i = 0; i < data.items.length; i++) {
$scope.sortableModel.itemsToSort.push({
- id: data[i].id,
- column1: data[i].name,
- column2: data[i].updateDate,
- column3: data[i].sortOrder
+ id: data.items[i].id,
+ column1: data.items[i].name,
+ column2: data.items[i].updateDate,
+ column3: data.items[i].sortOrder
});
}
});
diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/folderbrowser/folderbrowser.controller.js b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/folderbrowser/folderbrowser.controller.js
index 1d3df2ce6f..798b37ec2e 100644
--- a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/folderbrowser/folderbrowser.controller.js
+++ b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/folderbrowser/folderbrowser.controller.js
@@ -32,7 +32,7 @@ angular.module("umbraco")
$scope.loadChildren = function(id){
mediaResource.getChildren(id)
.then(function(data) {
- $scope.images = data;
+ $scope.images = data.items;
});
};
diff --git a/src/Umbraco.Web/Editors/ContentController.cs b/src/Umbraco.Web/Editors/ContentController.cs
index 354134d78a..39ca4704b4 100644
--- a/src/Umbraco.Web/Editors/ContentController.cs
+++ b/src/Umbraco.Web/Editors/ContentController.cs
@@ -122,21 +122,18 @@ namespace Umbraco.Web.Editors
Direction orderDirection = Direction.Ascending,
string filter = "")
{
- //TODO: Not sure how to handle 'filter' just yet!
+ //TODO: Not sure how to handle 'filter' just yet! - SD: have implemented this for EntityService so I just need to get it working here,
+ // will be a post filter though.
//TODO: This will be horribly inefficient for paging! This is because our datasource/repository
// doesn't support paging at the SQL level... and it'll be pretty interesting to try to make that work.
- var foundContent = Services.ContentService.GetById(id);
- if (foundContent == null)
- {
- HandleContentNotFound(id);
- }
-
- var totalChildren = ((ContentService) Services.ContentService).CountChildren(id);
- var result = foundContent.Children()
- .Select(Mapper.Map