mirror of
https://github.com/sudoxnym/habitica-self-host.git
synced 2026-07-14 18:22:21 +00:00
Adding checklist item drag and drop feature
This commit is contained in:
parent
8da33857e4
commit
36bf09d984
4 changed files with 28 additions and 3 deletions
|
|
@ -473,6 +473,6 @@ form
|
|||
|
||||
[type="checkbox"]
|
||||
margin: 0px 10px 3px 0px
|
||||
width: 5%
|
||||
width: 4%
|
||||
li:hover .checklist-icons
|
||||
opacity:1
|
||||
|
|
@ -142,6 +142,11 @@ habitrpg.controller("TasksCtrl", ['$scope', '$rootScope', '$location', 'User','N
|
|||
$event.preventDefault();
|
||||
}
|
||||
}
|
||||
$scope.swapChecklistItems = function(task, oldIndex, newIndex) {
|
||||
var toSwap = task.checklist.splice(oldIndex, 1)[0];
|
||||
task.checklist.splice(newIndex, 0, toSwap);
|
||||
$scope.saveTask(task, true);
|
||||
}
|
||||
$scope.navigateChecklist = function(task,$index,$event){
|
||||
focusChecklist(task, $event.keyCode == '40' ? $index+1 : $index-1);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -118,6 +118,24 @@ habitrpg.directive('hrpgSortTasks', ['User', function(User) {
|
|||
}
|
||||
}]);
|
||||
|
||||
habitrpg.directive('hrpgSortChecklist', ['User', function(User) {
|
||||
return function($scope, element, attrs, ngModel) {
|
||||
$(element).sortable({
|
||||
axis: "y",
|
||||
distance: 5,
|
||||
start: function (event, ui) {
|
||||
ui.item.data('startIndex', ui.item.index());
|
||||
},
|
||||
stop: function (event, ui) {
|
||||
var task = angular.element(ui.item[0]).scope().task,
|
||||
startIndex = ui.item.data('startIndex');
|
||||
//$scope.saveTask(task, true);
|
||||
$scope.swapChecklistItems(task, startIndex, ui.item.index());
|
||||
}
|
||||
});
|
||||
}
|
||||
}]);
|
||||
|
||||
habitrpg.directive('hrpgSortTags', ['User', function(User) {
|
||||
return function($scope, element, attrs, ngModel) {
|
||||
$(element).sortable({
|
||||
|
|
|
|||
|
|
@ -132,10 +132,12 @@ li(bindonce='list', bo-id='"task-"+task.id', ng-repeat='task in obj[list.type+"s
|
|||
fieldset.option-group.task-checklist(ng-if='!$state.includes("options.social.challenges")')
|
||||
legend.option-title
|
||||
span.hint(popover=env.t('checklistText'),popover-trigger='mouseenter',popover-placement='bottom')=env.t('checklist')
|
||||
ul.list-unstyled
|
||||
li(ng-repeat='item in task.checklist')
|
||||
ul(hrpg-sort-checklist).list-unstyled
|
||||
li(ng-repeat='item in task.checklist')
|
||||
a.pull-right.checklist-icons(ng-click='removeChecklistItem(task,$event,$index,true)')
|
||||
span.glyphicon.glyphicon-trash(tooltip=env.t('delete'))
|
||||
span.checklist-icons.glyphicon.glyphicon-resize-vertical()
|
||||
|
|
||||
input(type='checkbox',ng-model='item.completed',ng-change='saveTask(task,true)')
|
||||
//-,ng-blur='saveTask(task,true)')
|
||||
input.inline-edit(type='text',ng-model='item.text',ui-keydown="{'8 46':'removeChecklistItem(task,$event,$index)'}",ui-keyup="{'13':'addChecklistItem(task,$event,$index)','38 40':'navigateChecklist(task,$index,$event)'}")
|
||||
|
|
|
|||
Loading…
Reference in a new issue