Dry up stuff in work package column directive

pull/913/head
Till Breuer 11 years ago
parent a905586569
commit 4ad8fbe911
  1. 18
      app/assets/javascripts/angular/directives/components/work-package-column-directive.js
  2. 4
      app/assets/javascripts/angular/directives/work_packages/work-package-group-header.js
  3. 4
      app/assets/javascripts/angular/filters/work-package-table-filters.js
  4. 20
      app/assets/javascripts/angular/helpers/components/work-packages-helper.js
  5. 14
      app/assets/javascripts/angular/helpers/work-packages-table-helper.js
  6. 6
      app/assets/javascripts/angular/openproject-app.js
  7. 2
      public/templates/work_packages/work_packages_table.html

@ -1,7 +1,7 @@
// TODO move to UI components
angular.module('openproject.uiComponents')
.directive('workPackageColumn', ['PathHelper', function(PathHelper){
.directive('workPackageColumn', ['PathHelper', 'WorkPackagesHelper', function(PathHelper, WorkPackagesHelper){
return {
restrict: 'EA',
replace: true,
@ -11,22 +11,10 @@ angular.module('openproject.uiComponents')
},
templateUrl: '/templates/components/work_package_column.html',
link: function(scope, element, attributes) {
var data = scope.workPackage[scope.column.name];
var defaultText = '';
// Get display text from 'name' if it is an object
var displayText = defaultText;
switch(typeof(data)) {
case 'string':
displayText = data;
break;
case 'object':
displayText = data['name'];
break;
}
// Set type specific scope
scope.displayText = displayText;
// Set text to be displayed
scope.displayText = WorkPackagesHelper.getRowObjectContent(scope.workPackage, scope.column.name) || defaultText;
switch (scope.column.name){
case 'subject':

@ -1,13 +1,13 @@
angular.module('openproject.workPackages.directives')
.directive('workPackageGroupHeader', ['WorkPackagesTableHelper', function(WorkPackagesTableHelper) {
.directive('workPackageGroupHeader', ['WorkPackagesHelper', function(WorkPackagesHelper) {
return {
restrict: 'A',
compile: function(tElement) {
return {
pre: function(scope, iElement, iAttrs, controller) {
scope.currentGroup = WorkPackagesTableHelper.getRowObjectContent(scope.row.object, scope.groupBy); // TODO get group directly from row
scope.currentGroup = WorkPackagesHelper.getRowObjectContent(scope.row.object, scope.groupBy); // TODO get group directly from row
pushGroup(scope.currentGroup);

@ -1,7 +1,7 @@
angular.module('openproject.workPackages.filters')
// work packages
.filter('columnContent', ['WorkPackagesTableHelper', function(WorkPackagesTableHelper){
return WorkPackagesTableHelper.getRowObjectContent;
.filter('columnContent', ['WorkPackagesHelper', function(WorkPackagesHelper){
return WorkPackagesHelper.getRowObjectContent;
}]);

@ -0,0 +1,20 @@
angular.module('openproject.uiComponents')
.factory('WorkPackagesHelper', [function() {
var WorkPackagesHelper = {
getRowObjectContent: function(object, option) {
var content = object[option];
switch(typeof(content)) {
case 'string':
return content;
case 'object':
return content.name;
default:
return '';
}
}
};
return WorkPackagesHelper;
}]);

@ -26,20 +26,8 @@ angular.module('openproject.workPackages.helpers')
});
return rows;
},
getRowObjectContent: function(object, option) {
var content = object[option];
switch(typeof(content)) {
case 'string':
return content;
case 'object':
return content.name;
default:
return '';
}
}
};
return WorkPackagesTableHelper;

@ -9,9 +9,9 @@ angular.module('openproject.timelines.directives', ['openproject.timelines.model
// work packages
angular.module('openproject.workPackages', ['openproject.workPackages.controllers', 'openproject.workPackages.directives', 'openproject.workPackages.filters']);
angular.module('openproject.workPackages.helpers', []);
angular.module('openproject.workPackages.filters', ['openproject.workPackages.helpers']);
angular.module('openproject.workPackages.controllers', []);
angular.module('openproject.workPackages.directives', ['openproject.workPackages.helpers']);
angular.module('openproject.workPackages.filters', ['openproject.uiComponents']);
angular.module('openproject.workPackages.controllers', ['openproject.workPackages.helpers']);
angular.module('openproject.workPackages.directives', ['openproject.uiComponents']);
// global

@ -54,7 +54,7 @@
{{ row.object | columnContent:groupBy || '-' }}
<span class="count">
{{ countByGroup[(row.object | columnContent:groupBy)] }}
({{ countByGroup[(row.object | columnContent:groupBy)] }})
<span aria-hidden="true" role="presentation" tabindex="-1">
<a class="toggle-all" ng-href="#" ng-click="toggleAllGroups()">

Loading…
Cancel
Save