Move wp-group-sums to wp-table components

pull/3956/head
Alex Dik 9 years ago
parent a3b8533a49
commit f5b64a2cc4
  1. 28
      frontend/app/components/wp-table/directives/wp-group-sums/wp-group-sums.directive.js
  2. 8
      frontend/app/components/wp-table/directives/wp-group-sums/wp-group-sums.directive.test.js
  3. 2
      frontend/app/components/wp-table/directives/wp-table/wp-table.directive.html
  4. 2
      frontend/app/work_packages/directives/index.js

@ -1,4 +1,4 @@
//-- copyright
// -- copyright
// OpenProject is a project management system.
// Copyright (C) 2012-2015 the OpenProject Foundation (OPF)
//
@ -24,29 +24,27 @@
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
// See doc/COPYRIGHT.rdoc for more details.
//++
// ++
module.exports = function() {
angular
.module('openproject.workPackages.directives')
.directive('wpGroupSums', wpGroupSums);
function wpGroupSums() {
return {
restrict: 'A',
scope: true,
compile: function(tElement) {
compile: function() {
return {
pre: function(scope, iElement, iAttrs, controller) {
pre: function(scope) {
scope.currentGroup = scope.row.groupName;
function setSums() {
if(scope.groupSums == null) return;
scope.sums = scope.groupSums.map(function(groupSum){
return groupSum[scope.currentGroup];
});
}
scope.$watch('groupSums.length', function(newVal, oldVal) {
if(newVal != oldVal) {
// map columns to sums if the column data is a number
setSums();
if(newVal != oldVal && scope.groupSums) {
scope.sums = scope.groupSums.map(function(groupSum){
return groupSum[scope.currentGroup];
});
}
});
}

@ -1,4 +1,4 @@
//-- copyright
// -- copyright
// OpenProject is a project management system.
// Copyright (C) 2012-2015 the OpenProject Foundation (OPF)
//
@ -24,7 +24,7 @@
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
// See doc/COPYRIGHT.rdoc for more details.
//++
// ++
/*jshint expr: true*/
@ -34,7 +34,7 @@ describe('workPackageGroupSums Directive', function() {
beforeEach(angular.mock.module('openproject.workPackages.directives',
'openproject.models',
'openproject.services'));
beforeEach(module('openproject.api', 'openproject.templates', function($provide) {
beforeEach(angular.mock.module('openproject.api', 'openproject.templates', function($provide) {
var configurationService = {};
configurationService.isTimezoneSet = sinon.stub().returns(false);
@ -44,7 +44,7 @@ describe('workPackageGroupSums Directive', function() {
beforeEach(inject(function($rootScope, $compile) {
var html;
html = '<tr work-package-group-sums><td ng-repeat="sum in sums">{{ sum }}</td></tr>';
html = '<tr wp-group-sums><td ng-repeat="sum in sums">{{ sum }}</td></tr>';
element = angular.element(html);
rootScope = $rootScope;

@ -126,7 +126,7 @@
<!-- Sums for groups -->
<tr work-package-group-sums
<tr wp-group-sums
ng-repeat-end
ng-if="displaySums && !!groupByColumn &&
($last || row.groupName !== rows[$index+1].groupName)"

@ -76,8 +76,6 @@ angular.module('openproject.workPackages.directives')
])
.directive('workPackageDynamicAttribute', ['$compile', require(
'./work-package-dynamic-attribute-directive')])
.directive('workPackageGroupSums', require(
'./work-package-group-sums-directive'))
.directive('workPackageTotalSums', [
'WorkPackageService',
require('./work-package-total-sums-directive')

Loading…
Cancel
Save