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/app/assets/javascripts/angular/helpers/components/work-packages-helper.js

41 lines
918 B

angular.module('openproject.uiComponents')
.factory('WorkPackagesHelper', [function() {
var WorkPackagesHelper = {
getRowObjectContent: function(object, option) {
var content = object[option];
switch(typeof(content)) {
case 'object':
if (content === null) return '';
return content.name || content.subject;
default:
return content || '';
}
},
getSum: function(rows, columnName) {
var values = rows
.map(function(row){
return WorkPackagesHelper.getRowObjectContent(row.object, columnName);
})
.filter(function(value) {
return typeof(value) === 'number';
});
if (values.length > 0) {
sum = values.reduce(function(a, b) {
return a + b;
});
} else {
sum = null;
}
return sum;
}
};
return WorkPackagesHelper;
}]);