Merge pull request #1933 from emanuelschuetze/agendaTree
Optimize agenda tree save method on client side.
This commit is contained in:
commit
8b72f6d821
@ -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});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user