Optimize agenda tree save method on client side.
with ui-tree Fixes #1660
This commit is contained in:
parent
7d6c202200
commit
f30d62a11f
@ -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