OpenProject is the leading open source project management software.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
openproject/mocha/factories/project_factory.js

63 lines
1.9 KiB

function addProjectToOwnTimeline(Project) {
if (Project && Project.timeline) {
var t = Project.timeline;
t.projects = t.projects || {};
t.projects[Project.id] = Project;
}
}
Factory.define('Project', Timeline.Project)
.sequence('id')
.sequence('name', function (i) {return "Project No. " + i;})
.sequence('identifier', function (i) {return "projectno" + i;})
.attr('description', 'Description for Project')
.after(function(Project) {
if(Project && Project.planning_elements) {
var i;
for (i = 0; i < Project.planning_elements.length; i += 1) {
var current = Project.planning_elements[i];
current.project = Project;
current.parent = Project;
current.timeline = Project.timeline;
if (!Timeline.PlanningElement.is(current)) {
Project.planning_elements[i] = Factory.build('PlanningElement', current);
}
}
}
})
.after(function(Project) {
if(Project && Project.children) {
var i;
for (i = 0; i < Project.children.length; i += 1) {
var current = Project.children[i];
current.project = Project;
current.parent = Project;
current.timeline = Project.timeline;
addProjectToOwnTimeline(current);
if (!current.is(Timeline.Project)) {
Project.children[i] = Factory.build('Project', current);
}
}
}
})
.after(function(Project) {
if(Project && Project.reporters) {
var i;
for (i = 0; i < Project.reporters.length; i += 1) {
var current = Project.reporters[i];
current.timeline = Project.timeline;
addProjectToOwnTimeline(current);
if (current.identifier !== Timeline.Reporting.identifier) {
Project.reporters[i] = Factory.build('Reporting', current);
}
}
}
})
.after(function (Project) {
addProjectToOwnTimeline(Project);
});