Merge pull request #1933 from emanuelschuetze/agendaTree

Optimize agenda tree save method on client side.
This commit is contained in:
Norman Jäckel 2016-02-01 23:56:20 +01:00
commit 8b72f6d821

View File

@ -332,10 +332,17 @@ angular.module('OpenSlidesApp.agenda.site', ['OpenSlidesApp.agenda'])
$scope.items = AgendaTree.getTree(Agenda.getAll());
});
// set changed agenda tree
// save parent and weight of moved agenda item (and all items on same level)
$scope.treeOptions = {
dropped: function() {
$http.put('/rest/agenda/item/tree/', {tree: $scope.items});
dropped: function(event) {
var parentID = null;
var droppedItemID = event.source.nodeScope.$modelValue.id;
if (event.dest.nodesScope.item) {
parentID = event.dest.nodesScope.item.id;
}
angular.forEach(event.dest.nodesScope.$modelValue, function(item, index) {
$http.patch('/rest/agenda/item/' + item.id + '/', {parent_id: parentID, weight: index});
});
}
};
}