Did a bit of hacking to get grouping by custom values working again.

pull/1134/head
Richard 11 years ago
parent 12195f71b5
commit f7784430c5
  1. 7
      app/assets/javascripts/angular/directives/work_packages/work-package-column-directive.js
  2. 2
      app/assets/javascripts/angular/directives/work_packages/work-packages-options-directive.js
  3. 20
      app/assets/javascripts/angular/helpers/components/work-packages-helper.js
  4. 15
      app/assets/javascripts/angular/models/query.js
  5. 2
      public/templates/work_packages/work_packages_table.html

@ -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

@ -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();
}
});

@ -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;

@ -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;

@ -61,7 +61,7 @@
</span>
<span>
<span work-package-column work-package="row.object" column="groupByColumn">
<span work-package-column work-package="row.object" column="groupByColumn" display-empty="'-'">
</span>
<span class="count">

Loading…
Cancel
Save