diff --git a/app/assets/javascripts/angular/directives/work_packages/work-package-column-directive.js b/app/assets/javascripts/angular/directives/work_packages/work-package-column-directive.js index 39916e4722..c48524a42a 100644 --- a/app/assets/javascripts/angular/directives/work_packages/work-package-column-directive.js +++ b/app/assets/javascripts/angular/directives/work_packages/work-package-column-directive.js @@ -36,7 +36,8 @@ angular.module('openproject.workPackages.directives') scope: { workPackage: '=', column: '=', - displayType: '@' + displayType: '@', + displayEmpty: '=' }, templateUrl: '/templates/work_packages/work_package_column.html', link: function(scope, element, attributes) { @@ -50,12 +51,12 @@ angular.module('openproject.workPackages.directives') if (scope.column.custom_field) { var custom_field = scope.column.custom_field; - scope.displayText = WorkPackagesHelper.getFormattedCustomValue(scope.workPackage, custom_field) || ''; + scope.displayText = WorkPackagesHelper.getFormattedCustomValue(scope.workPackage, custom_field) || scope.displayEmpty || ''; } else { // custom display types if (scope.column.name === 'done_ratio') scope.displayType = 'progress_bar'; - scope.displayText = WorkPackagesHelper.getFormattedColumnData(scope.workPackage, scope.column) || ''; + scope.displayText = WorkPackagesHelper.getFormattedColumnData(scope.workPackage, scope.column) || scope.displayEmpty || ''; } // Example of how we can look to the provided meta data to format the column diff --git a/app/assets/javascripts/angular/directives/work_packages/work-packages-options-directive.js b/app/assets/javascripts/angular/directives/work_packages/work-packages-options-directive.js index beb730d6ce..aeccc946f3 100644 --- a/app/assets/javascripts/angular/directives/work_packages/work-packages-options-directive.js +++ b/app/assets/javascripts/angular/directives/work_packages/work-packages-options-directive.js @@ -39,7 +39,7 @@ angular.module('openproject.workPackages.directives') return column.name; }).indexOf(groupBy); - scope.groupByColumn = scope.columns[groupByColumnIndex]; + scope.groupByColumn = scope.groupableColumns[groupByColumnIndex]; scope.updateBackUrl(); } }); diff --git a/app/assets/javascripts/angular/helpers/components/work-packages-helper.js b/app/assets/javascripts/angular/helpers/components/work-packages-helper.js index 559cb66dea..f24f6f9f01 100644 --- a/app/assets/javascripts/angular/helpers/components/work-packages-helper.js +++ b/app/assets/javascripts/angular/helpers/components/work-packages-helper.js @@ -31,7 +31,11 @@ angular.module('openproject.workPackages.helpers') .factory('WorkPackagesHelper', ['dateFilter', 'CustomFieldHelper', function(dateFilter, CustomFieldHelper) { var WorkPackagesHelper = { getRowObjectContent: function(object, option) { - var content = object[option]; + if(CustomFieldHelper.isCustomFieldKey(option)){ + var content = WorkPackagesHelper.getRawCustomValue(object, CustomFieldHelper.getCustomFieldId(option)); + } else { + var content = object[option]; + } switch(typeof(content)) { case 'object': @@ -54,6 +58,20 @@ angular.module('openproject.workPackages.helpers') } }, + getRawCustomValue: function(object, customFieldId) { + if (!object.custom_values) return null; + + var customValue = object.custom_values.filter(function(customValue){ + return customValue && customValue.custom_field_id === customFieldId; + }).first(); + + if (customValue) { + return customValue.value; + } else { + return ''; + } + }, + getFormattedCustomValue: function(object, customField) { if (!object.custom_values) return null; diff --git a/app/assets/javascripts/angular/models/query.js b/app/assets/javascripts/angular/models/query.js index 1c8518d17a..6270a5bf44 100644 --- a/app/assets/javascripts/angular/models/query.js +++ b/app/assets/javascripts/angular/models/query.js @@ -51,9 +51,7 @@ angular.module('openproject.models') return angular.extend.apply(this, [ { 'f[]': this.getFilterNames(this.getActiveConfiguredFilters()), - 'c[]': this.columns.map(function(column) { - return column.name; - }), + 'c[]': this.getParamColumns(), 'group_by': this.groupBy, 'sort': this.sortation.encode() }].concat(this.getActiveConfiguredFilters().map(function(filter) { @@ -141,6 +139,17 @@ angular.module('openproject.models') }); }, + getParamColumns: function(){ + var selectedColumns = this.columns.map(function(column) { + return column.name; + }); + // To be able to group the work packages we need to add in the group by column if it is not already in the selected columns + if(selectedColumns.indexOf(this.groupBy) == -1){ + selectedColumns.push(this.groupBy); + } + return selectedColumns; + }, + getFilterByName: function(filterName) { return this.filters.filter(function(filter){ return filter.name === filterName; diff --git a/public/templates/work_packages/work_packages_table.html b/public/templates/work_packages/work_packages_table.html index 5527448f5f..47469694ff 100644 --- a/public/templates/work_packages/work_packages_table.html +++ b/public/templates/work_packages/work_packages_table.html @@ -61,7 +61,7 @@ - +