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/directives/work_packages/query-columns-directive.js

45 lines
1.7 KiB

angular.module('openproject.workPackages.directives')
.directive('queryColumns', ['WorkPackagesTableHelper', 'WorkPackageService', function(WorkPackagesTableHelper, WorkPackageService) {
return {
restrict: 'E',
replace: true,
templateUrl: '/templates/work_packages/query_columns.html',
compile: function(tElement) {
return {
pre: function(scope) {
scope.moveColumns = function (columnNames, fromColumns, toColumns, requires_extension) {
angular.forEach(columnNames, function(columnName){
removeColumn(columnName, fromColumns, function(removedColumn){
toColumns.push(removedColumn);
});
});
if (requires_extension) extendRowsWithColumnData(columnNames);
};
scope.moveSelectedColumnBy = function(by) {
var nameOfColumnToBeMoved = scope.markedSelectedColumns.first();
WorkPackagesTableHelper.moveColumnBy(scope.columns, nameOfColumnToBeMoved, by);
};
function extendRowsWithColumnData(columnNames) {
var workPackages = scope.rows.map(function(row) {
return row.object;
});
var newColumns = WorkPackagesTableHelper.selectColumnsByName(scope.columns, columnNames);
// work package rows
scope.withLoading(WorkPackageService.augmentWorkPackagesWithColumnsData, [workPackages, newColumns]);
}
function removeColumn(columnName, columns, callback) {
var removed = columns.splice(WorkPackagesTableHelper.getColumnIndexByName(columns, columnName), 1).first();
return !(typeof(callback) === 'undefined') ? callback.call(this, removed) : null;
}
}
};
}
};
}]);