diff --git a/frontend/app/components/routes/controllers/work-package-details.controller.js b/frontend/app/components/routes/controllers/work-package-details.controller.js index 6630cef16b..1db30bd498 100644 --- a/frontend/app/components/routes/controllers/work-package-details.controller.js +++ b/frontend/app/components/routes/controllers/work-package-details.controller.js @@ -31,8 +31,8 @@ angular .controller('WorkPackageDetailsController', WorkPackageDetailsController); function WorkPackageDetailsController($scope, $state, latestTab, workPackage, I18n, RELATION_TYPES, - RELATION_IDENTIFIERS, $q, $rootScope, $filter, WorkPackagesHelper, PathHelper, UsersHelper, - ConfigurationService, WorkPackageService, ActivityService, CommonRelationsHandler, + RELATION_IDENTIFIERS, $q, $rootScope, WorkPackagesHelper, PathHelper, UsersHelper, + WorkPackageService, CommonRelationsHandler, ChildrenRelationsHandler, ParentRelationsHandler, NotificationsService) { $scope.$on('$stateChangeSuccess', function(event, toState){ @@ -86,11 +86,6 @@ function WorkPackageDetailsController($scope, $state, latestTab, workPackage, I1 var projectId = workPackage.embedded.project.props.id; $scope.autocompletePath = PathHelper.staticWorkPackagesAutocompletePath(projectId); - // activities and latest activities - $scope.activitiesSortedInDescendingOrder = ConfigurationService.commentsSortedInDescendingOrder(); - $scope.activities = []; - aggregateActivities($scope.workPackage); - // watchers if(workPackage.links.watchers) { $scope.watchers = workPackage.embedded.watchers.embedded.elements; @@ -143,52 +138,6 @@ function WorkPackageDetailsController($scope, $state, latestTab, workPackage, I1 return !!($scope.workPackage && $scope.workPackage.embedded.watchers !== undefined); }; - $scope.isInitialActivity = ActivityService.isInitialActivity; - - function aggregateActivities(workPackage) { - // Do not yet add any intermittent result to the scope, - // as we will get an inconsistent activity view - // As we may not what activities will be added at a given time, - // let them be aggregated asynchronously. - var aggregated = [], - totalActivities = 0; - - var aggregate = function(success, activity) { - - if (success === true) { - aggregated = aggregated.concat(activity); - } - - if (++totalActivities === 2) { - $scope.activities = $filter('orderBy')(aggregated, - 'props.createdAt', - $scope.activitiesSortedInDescendingOrder - ); - } - }; - - addDisplayedActivities(workPackage, aggregate); - addDisplayedRevisions(workPackage, aggregate); - } - - function addDisplayedActivities(workPackage, aggregate) { - var activities = workPackage.embedded.activities.embedded.elements; - aggregate(true, activities); - } - - function addDisplayedRevisions(workPackage, aggregate) { - var linkedRevisions = workPackage.links.revisions; - - if (linkedRevisions === undefined) { - return aggregate(); - } - - linkedRevisions - .fetch() - .then(function(data) { - aggregate(true, data.embedded.elements); - }, aggregate); - } // toggles diff --git a/frontend/app/components/routes/controllers/work-package-show.controller.js b/frontend/app/components/routes/controllers/work-package-show.controller.js index 3fb5d528b9..daade32e26 100644 --- a/frontend/app/components/routes/controllers/work-package-show.controller.js +++ b/frontend/app/components/routes/controllers/work-package-show.controller.js @@ -31,8 +31,8 @@ angular .controller('WorkPackageShowController', WorkPackageShowController); function WorkPackageShowController($scope, $rootScope, $state, latestTab, workPackage, I18n, - RELATION_TYPES, RELATION_IDENTIFIERS, $filter, $q, WorkPackagesHelper, PathHelper, UsersHelper, - ConfigurationService, WorkPackageService, ActivityService, CommonRelationsHandler, + RELATION_TYPES, RELATION_IDENTIFIERS, $q, WorkPackagesHelper, PathHelper, UsersHelper, + WorkPackageService, CommonRelationsHandler, ChildrenRelationsHandler, ParentRelationsHandler, WorkPackagesOverviewService, WorkPackageFieldService, EditableFieldsState, WorkPackagesDisplayHelper, NotificationsService, WorkPackageAuthorization, PERMITTED_MORE_MENU_ACTIONS, HookService, $window, @@ -145,50 +145,6 @@ function WorkPackageShowController($scope, $rootScope, $state, latestTab, workPa $scope.outputMessage = outputMessage; // expose to child controllers $scope.outputError = outputError; // expose to child controllers - function aggregateActivities(workPackage) { - // Do not yet add any intermittent result to the scope, - // as we will get an inconsistent activity view - // As we may not what activities will be added at a given time, - // let them be aggregated asynchronously. - var aggregated = [], - totalActivities = 0; - - var aggregate = function(success, activity) { - - if (success === true) { - aggregated = aggregated.concat(activity); - } - - if (++totalActivities === 2) { - $scope.activities = $filter('orderBy')(aggregated, - 'props.createdAt', - $scope.activitiesSortedInDescendingOrder - ); - } - }; - - addDisplayedActivities(workPackage, aggregate); - addDisplayedRevisions(workPackage, aggregate); - } - - function addDisplayedActivities(workPackage, aggregate) { - var activities = workPackage.embedded.activities.embedded.elements; - aggregate(true, activities); - } - - function addDisplayedRevisions(workPackage, aggregate) { - var linkedRevisions = workPackage.links.revisions; - - if (linkedRevisions === undefined) { - return aggregate(); - } - - linkedRevisions - .fetch() - .then(function(data) { - aggregate(true, data.embedded.elements); - }, aggregate); - } function setWorkPackageScopeProperties(workPackage){ $scope.workPackage = workPackage; @@ -200,10 +156,6 @@ function WorkPackageShowController($scope, $rootScope, $state, latestTab, workPa var projectId = workPackage.embedded.project.props.id; $scope.autocompletePath = PathHelper.staticWorkPackagesAutocompletePath(projectId); - // activities and latest activities - $scope.activitiesSortedInDescendingOrder = ConfigurationService.commentsSortedInDescendingOrder(); - $scope.activities = []; - aggregateActivities($scope.workPackage); // watchers if(workPackage.links.watchers) { @@ -264,8 +216,6 @@ function WorkPackageShowController($scope, $rootScope, $state, latestTab, workPa return !!($scope.workPackage && $scope.workPackage.embedded.watchers !== undefined); }; - $scope.isInitialActivity = ActivityService.isInitialActivity; - // toggles $scope.toggleStates = { diff --git a/frontend/app/components/wp-panels/activity-panel/activity-panel.controller.js b/frontend/app/components/wp-panels/activity-panel/activity-panel.controller.js new file mode 100644 index 0000000000..0815e2b9c0 --- /dev/null +++ b/frontend/app/components/wp-panels/activity-panel/activity-panel.controller.js @@ -0,0 +1,78 @@ +// -- copyright +// OpenProject is a project management system. +// Copyright (C) 2012-2015 the OpenProject Foundation (OPF) +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License version 3. +// +// OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows: +// Copyright (C) 2006-2013 Jean-Philippe Lang +// Copyright (C) 2010-2013 the ChiliProject Team +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// See doc/COPYRIGHT.rdoc for more details. +// ++ + +angular + .module('openproject.workPackages.controllers') + .controller('ActivityPanelController', ActivityPanelController); + +function ActivityPanelController($filter, $scope, ConfigurationService, ActivityService){ + + $scope.isInitialActivity = ActivityService.isInitialActivity; + $scope.activitiesSortedInDescendingOrder = ConfigurationService.commentsSortedInDescendingOrder(); + $scope.activities = []; + + aggregateActivities($scope.workPackage); + + function aggregateActivities(workPackage) { + var aggregated = [], + totalActivities = 0; + + var aggregate = function(success, activity) { + + if (success === true) { + aggregated = aggregated.concat(activity); + } + + if (++totalActivities === 2) { + $scope.activities = $filter('orderBy')( + aggregated, 'props.createdAt', $scope.activitiesSortedInDescendingOrder + ); + } + }; + + addDisplayedActivities(workPackage, aggregate); + addDisplayedRevisions(workPackage, aggregate); + } + + function addDisplayedActivities(workPackage, aggregate) { + var activities = workPackage.embedded.activities.embedded.elements; + aggregate(true, activities); + } + + function addDisplayedRevisions(workPackage, aggregate) { + var linkedRevisions = workPackage.links.revisions; + + if (linkedRevisions === undefined) { + return aggregate(); + } + + linkedRevisions.fetch().then(function(data) { + aggregate(true, data.embedded.elements); + }, aggregate); + } +} diff --git a/frontend/app/components/wp-panels/activity-panel/activity-panel.directive.js b/frontend/app/components/wp-panels/activity-panel/activity-panel.directive.js index dc8a3799f2..882df94c51 100644 --- a/frontend/app/components/wp-panels/activity-panel/activity-panel.directive.js +++ b/frontend/app/components/wp-panels/activity-panel/activity-panel.directive.js @@ -33,7 +33,8 @@ angular function activityPanel(){ return { restrict: 'E', + templateUrl: '/components/wp-panels/activity-panel/activity-panel.directive.html', - templateUrl: '/components/wp-panels/activity-panel/activity-panel.directive.html' + controller: 'ActivityPanelController' }; }