diff --git a/src/app/services/template/result_set_pager.html b/src/app/services/template/result_set_pager.html index a39f4a29..acf8f10e 100644 --- a/src/app/services/template/result_set_pager.html +++ b/src/app/services/template/result_set_pager.html @@ -30,7 +30,7 @@ - + diff --git a/src/app/stories/controller/story_detail_controller.js b/src/app/stories/controller/story_detail_controller.js index 94562cec..299d6f22 100644 --- a/src/app/stories/controller/story_detail_controller.js +++ b/src/app/stories/controller/story_detail_controller.js @@ -1,5 +1,6 @@ /* * Copyright (c) 2014 Hewlett-Packard Development Company, L.P. + * Copyright (c) 2016 Codethink Ltd. * * Licensed under the Apache License, Version 2.0 (the 'License'); you may * not use this file except in compliance with the License. You may obtain @@ -23,7 +24,7 @@ angular.module('sb.story').controller('StoryDetailController', Story, Project, Branch, creator, tasks, Task, DSCacheFactory, User, $q, storyboardApiBase, SessionModalService, moment, $document, $anchorScroll, $timeout, $location, currentUser, - enableEditableComments, Tags) { + enableEditableComments, Tags, worklists) { 'use strict'; var pageSize = Preference.get('story_detail_page_size'); @@ -85,8 +86,7 @@ angular.module('sb.story').controller('StoryDetailController', story_id: $scope.story.id, branch_id: branch.id, project_id: project.id, - status: 'todo', - priority: 'medium' + status: 'todo' }); $scope.projects[project.name] .branchNames.push(branch.name); @@ -97,6 +97,61 @@ angular.module('sb.story').controller('StoryDetailController', angular.forEach(tasks, mapTaskToProject); + /** + * All worklists containing this story or tasks within it, with + * information about which task is relevant added. + * + * @type {[Worklist]} + */ + function setWorklists() { + function isNotArchived(card) { + return !card.archived; + } + + var taskIds = $scope.tasks.map(function(task) { + return task.id; + }); + for (var i = 0; i < worklists.length; i++) { + var worklist = worklists[i]; + worklist.relatedItems = []; + worklist.items = worklist.items.filter(isNotArchived); + for (var j = 0; j < worklist.items.length; j++) { + var item = worklist.items[j]; + if (item.item_type === 'story') { + if (item.item_id === story.id) { + worklist.relatedItems.push(item); + } + } else if (item.item_type === 'task') { + if (taskIds.indexOf(item.item_id) > -1) { + worklist.relatedItems.push(item); + } + } + } + } + $scope.worklists = worklists.map(function(list) { + if (list.relatedItems.length > 0) { + return list; + } + }).filter(function(list) { return list; }); + } + + setWorklists(); + + $scope.showWorklistsModal = function() { + var modalInstance = $modal.open({ + templateUrl: 'app/stories/template/worklists.html', + controller: 'StoryWorklistsController', + resolve: { + worklists: function () { + return $scope.worklists; + } + } + }); + + // Return the modal's promise. + return modalInstance.result; + }; + // Load the preference for each display event. function reloadPagePreferences() { TimelineEventTypes.forEach(function (type) { @@ -531,8 +586,7 @@ angular.module('sb.story').controller('StoryDetailController', */ $scope.newTask = new Task({ story_id: $scope.story.id, - status: 'todo', - priority: 'medium' + status: 'todo' }); /** diff --git a/src/app/stories/controller/story_worklists_controller.js b/src/app/stories/controller/story_worklists_controller.js new file mode 100644 index 00000000..0b8e899d --- /dev/null +++ b/src/app/stories/controller/story_worklists_controller.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2016 Codethink Ltd. + * + * Licensed under the Apache License, Version 2.0 (the 'License'); you may + * not use this file except in compliance with the License. You may obtain + * a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ + +/** + * Modal to display worklists related to stories + */ +angular.module('sb.story').controller('StoryWorklistsController', + function($scope, $modalInstance, worklists) { + 'use strict'; + + /** + * Close this modal. + */ + $scope.close = function () { + $modalInstance.dismiss('cancel'); + }; + + $scope.worklists = worklists; + } +); diff --git a/src/app/stories/module.js b/src/app/stories/module.js index b699756a..00895369 100644 --- a/src/app/stories/module.js +++ b/src/app/stories/module.js @@ -75,6 +75,19 @@ angular.module('sb.story', ['ui.router', 'sb.services', 'sb.util', return {}; }); return user; + }, + worklists: function(Worklist, $stateParams, CurrentUser) { + var userPromise = CurrentUser.resolve(); + + return userPromise.then(function(user) { + return Worklist.browse({ + story_id: $stateParams.storyId, + subscriber_id: user.id, + hide_lanes: '' + }).$promise; + }, function() { + return []; + }); } } }); diff --git a/src/app/stories/template/detail.html b/src/app/stories/template/detail.html index 13991384..b04b6da4 100644 --- a/src/app/stories/template/detail.html +++ b/src/app/stories/template/detail.html @@ -23,6 +23,14 @@ This story is private. Edit this story to change the privacy settings. + + + + + + + @@ -31,6 +39,15 @@ src="'/inline/story_detail_form.html'" ng-show="showEditForm"> + + + + + + + + @@ -257,6 +274,58 @@ + + + +