Fixed projecting subitems

This commit is contained in:
FinnStutzenstein 2017-09-28 11:13:54 +02:00
parent 4c9a8b4ec7
commit 343ddf5ac5
3 changed files with 24 additions and 19 deletions

View File

@ -82,25 +82,27 @@ angular.module('OpenSlidesApp.agenda.projector', ['OpenSlidesApp.agenda'])
return Agenda.lastModified();
}, function () {
if ($scope.element.id) {
$scope.rootItem = Agenda.get($scope.element.id);
var tree = AgendaTree.getFlatTree(Agenda.getAll());
var startIndex = tree.indexOf($scope.rootItem);
tree = tree.slice(startIndex);
// define delta to move the whole subtree to level 0
var parentCountDelta = 0;
if (tree[0]) {
parentCountDelta = tree[0].parentCount;
}
$scope.items = [];
for (var i = 1; i < tree.length; i++) {
if (tree[i].parentCount - parentCountDelta <= 0) {
break;
var tree = AgendaTree.getTree(Agenda.getAll());
var getRootNode = function (node) {
if (node.id == $scope.element.id) {
return node;
}
var item = tree[i];
// move rootItem (and all childs) to level 0
item.parentCount = item.parentCount - parentCountDelta;
$scope.items.push(item);
}
for (var i = 0; i < node.children.length; i++) {
var result = getRootNode(node.children[i]);
if (result) {
return result;
}
}
return false;
};
_.forEach(tree, function (node) {
var result = getRootNode(node);
if (result) {
$scope.rootItem = result.item;
$scope.tree = result.children;
}
});
} else if ($scope.element.tree) {
items = _.filter(Agenda.getAll(), function (item) {
return item.type === 1;

View File

@ -2,7 +2,7 @@
<h1 ng-if="!element.id" translate>Agenda</h1>
<h1 ng-if="element.id">{{ rootItem.getTitle() }}</h1>
<div class="agendalist">
<div class="agendalist" ng-class="{'spacer-left-lg': element.id}">
<table class="agendalist-table">
<tr ng-repeat="node in tree" ng-include="'projector_agenda_renderer.html'"></tr>
</table>

View File

@ -408,6 +408,9 @@ tr.elected td {
.spacer {
margin-top: 10px;
}
.spacer-left-lg {
margin-left: 20px;
}
.agendalist-table td {
vertical-align: top;