diff --git a/src/app/stories/controllers/story_task_list_item_controller.js b/src/app/stories/controllers/story_task_list_item_controller.js index 4e5dc3fe..abb2fadf 100644 --- a/src/app/stories/controllers/story_task_list_item_controller.js +++ b/src/app/stories/controllers/story_task_list_item_controller.js @@ -31,4 +31,12 @@ angular.module('sb.story').controller('StoryTaskListItemController', $scope.project = null; }); } + + /** + * Updates this task's status + */ + $scope.updateStatus = function (status) { + $scope.task.status = status; + $scope.task.$update(); + }; }); diff --git a/src/app/templates/story/detail.html b/src/app/templates/story/detail.html index 757fb46d..93b54b3d 100644 --- a/src/app/templates/story/detail.html +++ b/src/app/templates/story/detail.html @@ -167,10 +167,12 @@ - - {{task.status}} - - +
+ +

{{task.title}}

diff --git a/src/app/templates/util/task_status_dropdown.html b/src/app/templates/util/task_status_dropdown.html new file mode 100644 index 00000000..134d1264 --- /dev/null +++ b/src/app/templates/util/task_status_dropdown.html @@ -0,0 +1,23 @@ + + {{status}} + + diff --git a/src/app/util/directive/task_status_dropdown.js b/src/app/util/directive/task_status_dropdown.js new file mode 100644 index 00000000..76873093 --- /dev/null +++ b/src/app/util/directive/task_status_dropdown.js @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2013 Hewlett-Packard Development Company, L.P. + * + * 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. + */ + +/** + * A convenience directive that allows us to bind the current task status onto + * a control. This control will automatically render itself either as a + * dropdown (if editable) or as a label (if not). It will also automatically + * color itself based on the status. + * + * TODO(krotscheck): Once we can load task status types from the database, + * allow binding that to this control. At that point we can revisit the color + * mapping too, because it might be possible to genericize this. + */ +angular.module('sb.util').directive('taskStatusDropdown', + function () { + 'use strict'; + + /** + * Map our task status to a display style. + */ + function setStyle(status) { + switch (status) { + case 'Landed': + return 'success'; + case 'In review': + return 'info'; + case 'Todo': + return 'default'; + default: + return 'default'; + } + } + + return { + restrict: 'E', + templateUrl: 'app/templates/util/task_status_dropdown.html', + scope: { + status: '@', + onChange: '&', + editable: '@' + }, + link: function ($scope) { + + // Initialize the style. + $scope.style = setStyle($scope.status); + + // Make sure our scope can set its own status + $scope.setStatus = function (newStatus) { + if (newStatus !== $scope.status) { + $scope.style = setStyle(newStatus); + $scope.status = newStatus; + $scope.onChange({status: newStatus}); + } + }; + } + }; + }); \ No newline at end of file