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/components/work-package-column-directi...

42 lines
1.0 KiB

// TODO move to UI components
openprojectApp.directive('workPackageColumn', [function(){
return {
restrict: 'EA',
replace: true,
scope: {
model: '=',
column: '='
},
templateUrl: '/templates/components/work_package_column.html',
link: function(scope, element, attributes) {
var data = scope.model.object[scope.column.name];
// Get display text from 'name' if it is an object
var display_text = 'None';
switch(typeof(data)) {
case 'string':
display_text = data;
break;
case 'object':
display_text = data['name'];
break;
}
// Set type specific scope
scope.display_type = scope.column.display_type;
switch (scope.column.display_type){
case 'text':
// Nothing special
scope.model = display_text;
break;
case 'work_package_link':
scope.url = '/work_packages/' + scope.model.object['id'];
scope.model = display_text;
break;
}
}
};
}]);