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(); return Agenda.lastModified();
}, function () { }, function () {
if ($scope.element.id) { if ($scope.element.id) {
$scope.rootItem = Agenda.get($scope.element.id); var tree = AgendaTree.getTree(Agenda.getAll());
var tree = AgendaTree.getFlatTree(Agenda.getAll());
var startIndex = tree.indexOf($scope.rootItem); var getRootNode = function (node) {
tree = tree.slice(startIndex); if (node.id == $scope.element.id) {
// define delta to move the whole subtree to level 0 return node;
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 item = tree[i]; for (var i = 0; i < node.children.length; i++) {
// move rootItem (and all childs) to level 0 var result = getRootNode(node.children[i]);
item.parentCount = item.parentCount - parentCountDelta; if (result) {
$scope.items.push(item); 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) { } else if ($scope.element.tree) {
items = _.filter(Agenda.getAll(), function (item) { items = _.filter(Agenda.getAll(), function (item) {
return item.type === 1; return item.type === 1;

View File

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

View File

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