Optimize agenda tree save method on client side.

with ui-tree
Fixes #1660
This commit is contained in:
Emanuel Schuetze 2016-02-01 23:06:13 +01:00
parent 7d6c202200
commit f30d62a11f

View File

@ -332,10 +332,17 @@ angular.module('OpenSlidesApp.agenda.site', ['OpenSlidesApp.agenda'])
$scope.items = AgendaTree.getTree(Agenda.getAll()); $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 = { $scope.treeOptions = {
dropped: function() { dropped: function(event) {
$http.put('/rest/agenda/item/tree/', {tree: $scope.items}); 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});
});
} }
}; };
} }