Merge pull request #4007 from Alys/pushToBottom-sortOrder-Sep03

add support for pushTaskToBottom to help with To-Do sort order bug
This commit is contained in:
Alice Harris 2014-09-12 14:05:52 +10:00
commit b5ee56b079
2 changed files with 14 additions and 2 deletions

View file

@ -40,6 +40,14 @@ habitrpg.controller("TasksCtrl", ['$scope', '$rootScope', '$location', 'User','N
*/
$scope.clearDoneTodos = function() {};
/**
* Pushes task to top or bottom of list
*/
$scope.pushTask = function(task, index, location) {
var to = (location === 'bottom') ? -1 : 0;
User.user.ops.sortTask({params:{id:task.id},query:{from:index, to:to}})
};
/**
* This is calculated post-change, so task.completed=true if they just checked it
*/

View file

@ -14,8 +14,11 @@ li(bindonce='list', bo-id='"task-"+task.id', ng-repeat='task in obj[list.type+"s
// Icons only available if you own the tasks (aka, hidden from challenge stats)
span(ng-if='!obj._locked')
a(ng-click='User.user.ops.sortTask({params:{id:task.id},query:{from:$index, to:0}})', tooltip=env.t('pushTaskToTop'))
a(ng-click='pushTask(task,$index,"top")', tooltip=env.t('pushTaskToTop'))
span.glyphicon.glyphicon-open
// a(ng-click='pushTask(task,$index,"bottom")', tooltip=env.t('pushTaskToBottom'))
// span.glyphicon.glyphicon-import
// // glyphicon-import or glyphicon-save or glyphicon-sort-by-attributes
a.badge(ng-if='task.checklist[0]', ng-class='{"badge-success":checklistCompletion(task.checklist) == task.checklist.length}', ng-click='collapseChecklist(task)', tooltip=env.t('expandCollapse'))
{{checklistCompletion(task.checklist)}}/{{task.checklist.length}}
span.glyphicon.glyphicon-tags(tooltip='{{Shared.appliedTags(user.tags, task.tags)}}', ng-hide='Shared.noTags(task.tags)')
@ -70,9 +73,10 @@ li(bindonce='list', bo-id='"task-"+task.id', ng-repeat='task in obj[list.type+"s
// Daily & Todos
span.task-checker.action-yesno(bo-if='task.type=="daily" || task.type=="todo"')
input.visuallyhidden.focusable(ng-if='$state.includes("tasks")', id='box-{{obj._id}}_{{task.id}}', type='checkbox', ng-model='task.completed', ng-change='changeCheck(task)')
input.visuallyhidden.focusable(ng-if='$state.includes("tasks")', id='box-{{obj._id}}_{{task.id}}', type='checkbox', ng-model='task.completed', ng-change='pushTask(task,$index,"bottom"); changeCheck(task)')
input.visuallyhidden.focusable(ng-if='!$state.includes("tasks")', id='box-{{obj._id}}_{{task.id}}', type='checkbox')
label(for='box-{{obj._id}}_{{task.id}}')
// main content
div.task-text(ng-dblclick='task._editing ? saveTask(task) : editTask(task)')
markdown(ng-model='task.text',target='_blank')