Merge pull request #974 from opf/fix/timelines-second-level-grouping-4887

Fix/timelines second level grouping 4887
pull/1415/head
Jan Sandbrink 11 years ago
commit 35c34baecc
  1. 31
      app/assets/javascripts/timelines.js
  2. 1
      doc/CHANGELOG.md

@ -504,29 +504,22 @@ jQuery.extend(Timeline, {
var listToRemove = []; var listToRemove = [];
// for all projects on the first level // for all projects on the first level
jQuery.each(root.getReporters(), function (i, e) { jQuery.each(root.getReporters(), function (i, reporter) {
// find all projects that are associated // find all projects that are associated
jQuery.each(associations, function (j, a) { jQuery.each(associations, function (j, association) {
if (a.involves(e)) { // check if the reporter is involved and hasn't already been included by a second level grouping adjustment
var other = a.getOther(e); if (!reporter.hasSecondLevelGroupingAdjustment && association.involves(reporter)) {
var other = association.getOther(reporter);
if (typeof other.getProjectType === "function") { if (typeof other.getProjectType === "function") {
var pt = other.getProjectType(); var projectType = other.getProjectType();
var type = pt !== null ? pt.id : -1; var projectTypeId = projectType !== null ? projectType.id : -1;
//check if the type is selected as 2nd level grouping //check if the type is selected as 2nd level grouping
var relevant = false; if (grouping.indexOf(projectTypeId) !== -1) {
jQuery.each(grouping, function(k, l) {
if (l === type) {
relevant = true;
}
});
if (relevant) {
// add the other project as a simulated reporter to the current one. // add the other project as a simulated reporter to the current one.
e.addReporter(other); reporter.addReporter(other);
other.hasSecondLevelGroupingAdjustment = true; other.hasSecondLevelGroupingAdjustment = true;
// remove the project from the root level of the report. // remove the project from the root level of the report.
listToRemove.push(other); listToRemove.push(other);
@ -538,8 +531,8 @@ jQuery.extend(Timeline, {
}); });
// remove all children of root that we couldn't remove while still iterating. // remove all children of root that we couldn't remove while still iterating.
jQuery.each(listToRemove, function(i, e) { jQuery.each(listToRemove, function(i, reporter) {
root.removeReporter(e); root.removeReporter(reporter);
}); });
} }
}); });
@ -651,7 +644,7 @@ jQuery.extend(Timeline, {
} }
var i, selection = this.options.grouping_one_selection; var i, selection = this.options.grouping_one_selection;
var p, groups = [], children; var p, groups = [], children;
if (this.isGrouping()) { if (this.isGrouping() && selection) {
for ( i = 0; i < selection.length; i++ ) { for ( i = 0; i < selection.length; i++ ) {
p = this.getProject(selection[i]); p = this.getProject(selection[i]);
if (p === undefined) { if (p === undefined) {

@ -36,6 +36,7 @@ See doc/COPYRIGHT.rdoc for more details.
* `#4296` Adapt new workpackage form layout * `#4296` Adapt new workpackage form layout
* `#4793` Fix: [Search] Current project scope not shown * `#4793` Fix: [Search] Current project scope not shown
* `#4858` XSS in wp auto-completion * `#4858` XSS in wp auto-completion
* `#4887` Second grouping criterion seems to have an and conjunction
* Added pry-byebug for ruby 2.1 * Added pry-byebug for ruby 2.1
* Allows redirecting to a back url on version#update * Allows redirecting to a back url on version#update

Loading…
Cancel
Save