adding media move dialog and support for media containers
media containers are disabled currently for UI reasons
This commit is contained in:
@@ -61,8 +61,53 @@ function mediaResource($q, $http, umbDataFormatter, umbRequestHelper) {
|
||||
parentId: args.parentId,
|
||||
idSortOrder: args.sortedIds
|
||||
}),
|
||||
'Failed to sort content');
|
||||
'Failed to sort media');
|
||||
},
|
||||
|
||||
/**
|
||||
* @ngdoc method
|
||||
* @name umbraco.resources.mediaResource#move
|
||||
* @methodOf umbraco.resources.mediaResource
|
||||
*
|
||||
* @description
|
||||
* Moves a node underneath a new parentId
|
||||
*
|
||||
* ##usage
|
||||
* <pre>
|
||||
* mediaResource.move({ parentId: 1244, id: 123 })
|
||||
* .then(function() {
|
||||
* alert("node was moved");
|
||||
* }, function(err){
|
||||
* alert("node didnt move:" + err.data.Message);
|
||||
* });
|
||||
* </pre>
|
||||
* @param {Object} args arguments object
|
||||
* @param {Int} args.idd the ID of the node to move
|
||||
* @param {Int} args.parentId the ID of the parent node to move to
|
||||
* @returns {Promise} resourcePromise object.
|
||||
*
|
||||
*/
|
||||
move: function (args) {
|
||||
if (!args) {
|
||||
throw "args cannot be null";
|
||||
}
|
||||
if (!args.parentId) {
|
||||
throw "args.parentId cannot be null";
|
||||
}
|
||||
if (!args.id) {
|
||||
throw "args.id cannot be null";
|
||||
}
|
||||
|
||||
return umbRequestHelper.resourcePromise(
|
||||
$http.post(umbRequestHelper.getApiUrl("mediaApiBaseUrl", "PostMove"),
|
||||
{
|
||||
parentId: args.parentId,
|
||||
id: args.id
|
||||
}),
|
||||
'Failed to move media');
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* @ngdoc method
|
||||
* @name umbraco.resources.mediaResource#getById
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
//used for the media picker dialog
|
||||
angular.module("umbraco").controller("Umbraco.Editors.Media.MoveController",
|
||||
function ($scope, eventsService, mediaResource, $log) {
|
||||
var dialogOptions = $scope.$parent.dialogOptions;
|
||||
|
||||
$scope.dialogTreeEventHandler = $({});
|
||||
var node = dialogOptions.currentNode;
|
||||
|
||||
$scope.dialogTreeEventHandler.bind("treeNodeSelect", function(ev, args){
|
||||
args.event.preventDefault();
|
||||
args.event.stopPropagation();
|
||||
|
||||
eventsService.publish("Umbraco.Editors.Media.MoveController.Select", args).then(function(args){
|
||||
var c = $(args.event.target.parentElement);
|
||||
if($scope.selectedEl){
|
||||
$scope.selectedEl.find(".temporary").remove();
|
||||
$scope.selectedEl.find("i.umb-tree-icon").show();
|
||||
}
|
||||
|
||||
c.find("i.umb-tree-icon").hide()
|
||||
.after("<i class='icon umb-tree-icon sprTree icon-check blue temporary'></i>");
|
||||
|
||||
$scope.target = args.node;
|
||||
$scope.selectedEl = c;
|
||||
});
|
||||
});
|
||||
|
||||
$scope.move = function(){
|
||||
mediaResource.move({parentId: $scope.target.id, id: node.id})
|
||||
.then(function(){
|
||||
$scope.error = false;
|
||||
$scope.success = true;
|
||||
},function(err){
|
||||
$scope.success = false;
|
||||
$scope.error = err;
|
||||
});
|
||||
};
|
||||
});
|
||||
38
src/Umbraco.Web.UI.Client/src/views/media/move.html
Normal file
38
src/Umbraco.Web.UI.Client/src/views/media/move.html
Normal file
@@ -0,0 +1,38 @@
|
||||
<div ng-controller="Umbraco.Editors.Media.MoveController">
|
||||
<div class="umb-dialog-body">
|
||||
<div class="umb-pane">
|
||||
|
||||
<p class="abstract" ng-hide="success">
|
||||
Choose where to move <strong>{{currentNode.name}}</strong> to in the tree struture below
|
||||
</p>
|
||||
|
||||
<div class="alert alert-error" ng-show="error">
|
||||
<h4>{{error.errorMsg}}</h4>
|
||||
<p>{{error.data.Message}}</p>
|
||||
</div>
|
||||
|
||||
<div class="alert alert-success" ng-show="success">
|
||||
<p><strong>{{currentNode.name}}</strong> was moved underneath
|
||||
<strong>{{target.name}}</strong></p>
|
||||
|
||||
<button class="btn btn-primary" ng-click="nav.hideDialog()">Ok</button>
|
||||
</div>
|
||||
|
||||
<div ng-hide="success">
|
||||
<umb-tree
|
||||
section="media"
|
||||
cachekey="movepickerDialog"
|
||||
showheader="true"
|
||||
showoptions="false"
|
||||
eventhandler="dialogTreeEventHandler">
|
||||
</umb-tree>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="umb-dialog-footer btn-toolbar umb-btn-toolbar" ng-hide="success">
|
||||
<a class="btn btn-link" ng-click="nav.hideDialog()">Cancel</a>
|
||||
<button class="btn btn-primary" ng-click="move()">Move</button>
|
||||
</div>
|
||||
</div>
|
||||
Reference in New Issue
Block a user