Make task ordering in Story view selectable

This patch gives users the option of ordering tasks in story view on the basis of id,title or status.

Task: 28150
Change-Id: I4fcf53c647fdf5302176a023179285b5707a9f26
This commit is contained in:
Riju19 2019-03-08 11:21:55 +05:30
parent 9a4638bcee
commit 11331ef260
2 changed files with 60 additions and 18 deletions

View File

@ -60,6 +60,29 @@ angular.module('sb.story').controller('StoryDetailController',
$scope.projects = {};
$scope.tasks = tasks;
/**
* Allowing sorting tasks in search results by certain fields.
*/
$scope.tasks_sort_field = {
label: 'Id',
value: 'id'
};
$scope.changeOrder = function(orderBy){
$scope.tasks_sort_field.label = orderBy.toString();
switch(orderBy) {
case 'Id':
$scope.tasks_sort_field.value = 'id';
break;
case 'Status':
$scope.tasks_sort_field.value = 'status';
break;
case 'Title':
$scope.tasks_sort_field.value = 'title';
break;
}
};
function mapTaskToProject(task) {
Project.get({id: task.project_id}).$promise.then(function(project) {
var idx = $scope.projectNames.indexOf(project.name);

View File

@ -391,6 +391,25 @@
<!-- Template for the task list -->
<script type="text/ng-template" id="/inline/task_list.html">
<div class="pull-right">
Sort by:
<span class="dropdown form-control-static" dropdown="">
<button class="btn btn-xs btn-default" dropdown-toggle="" aria-haspopup="true" aria-expanded="true">
<li class="dropdown-header">{{tasks_sort_field.label}}</li>
</button>
<ul class="dropdown-menu dropdown-menu-right" role="menu">
<li ng-click="changeOrder('Id')">
<a>Id</a>
</li>
<li ng-click="changeOrder('Title')">
<a>Title</a>
</li>
<li ng-click="changeOrder('Status')">
<a>Status</a>
</li>
</ul>
</span>
</div>
<h3>Tasks</h3>
<div ng-repeat="name in projectNames | orderBy">
<h4>
@ -428,24 +447,24 @@
<!-- Template for a table of tasks -->
<script type="text/ng-template" id="/inline/task_table.html">
<table class="table table-striped table-supercondensed">
<tr ng-repeat="task in projects[name].branches[branchName].tasks | orderBy: 'id'"
ng-include src="'/inline/task_list_item.html'">
</tr>
<tr ng-show="isLoggedIn && !projects[name].branches[branchName].showAddTask">
<td class="text-center">
<a href
ng-click="projects[name].branches[branchName].showAddTask =
!projects[name].branches[branchName].showAddTask">
<i class="fa fa-plus-circle"></i>
Add task affecting this project
</a>
</td>
</tr>
<tr ng-show="projects[name].branches[branchName].showAddTask"
ng-include src="'/inline/task_edit_form.html'">
</tr>
</table>
<table class="table table-striped table-supercondensed">
<tr ng-repeat="task in projects[name].branches[branchName].tasks | orderBy: tasks_sort_field.value"
ng-include src="'/inline/task_list_item.html'">
</tr>
<tr ng-show="isLoggedIn && !projects[name].branches[branchName].showAddTask">
<td class="text-center">
<a href
ng-click="projects[name].branches[branchName].showAddTask =
!projects[name].branches[branchName].showAddTask">
<i class="fa fa-plus-circle"></i>
Add task affecting this project
</a>
</td>
</tr>
<tr ng-show="projects[name].branches[branchName].showAddTask"
ng-include src="'/inline/task_edit_form.html'">
</tr>
</table>
</script>
<!-- Template for an item in the task list -->