mirror of
https://github.com/sudoxnym/habitica.git
synced 2026-08-01 23:40:25 +00:00
Make tags sortable with drag&drop
This commit is contained in:
parent
b19649ce37
commit
e5bb299ad0
4 changed files with 33 additions and 1 deletions
|
|
@ -60,6 +60,24 @@ habitrpg.directive('habitrpgSortable', ['User', function(User) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}]);
|
}]);
|
||||||
|
habitrpg.directive('tagsSortable', ['User', function(User) {
|
||||||
|
return function($scope, element, attrs, ngModel) {
|
||||||
|
var el = element;
|
||||||
|
$(element).sortable({
|
||||||
|
axis: "x",
|
||||||
|
start: function (event, ui) {
|
||||||
|
ui.item.data('startIndex', ui.item.index());
|
||||||
|
},
|
||||||
|
stop: function (event, ui) {
|
||||||
|
User.user.ops.sortTag({query:{
|
||||||
|
from: ui.item.data('startIndex') - 3,
|
||||||
|
to:ui.item.index() - 3
|
||||||
|
}});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}]);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
habitrpg
|
habitrpg
|
||||||
|
|
|
||||||
|
|
@ -299,6 +299,7 @@ api.addTenGems = function(req, res, next) {
|
||||||
// api.deleteTag // handled in Shared.ops
|
// api.deleteTag // handled in Shared.ops
|
||||||
// api.addTag // handled in Shared.ops
|
// api.addTag // handled in Shared.ops
|
||||||
// api.updateTag // handled in Shared.ops
|
// api.updateTag // handled in Shared.ops
|
||||||
|
// api.sortTag // handled in Shared.ops
|
||||||
|
|
||||||
/*
|
/*
|
||||||
------------------------------------------------------------------------
|
------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
|
@ -131,6 +131,7 @@ module.exports = (swagger, v2) ->
|
||||||
]
|
]
|
||||||
action: user.sortTask
|
action: user.sortTask
|
||||||
|
|
||||||
|
|
||||||
"/user/tasks/clear-completed":
|
"/user/tasks/clear-completed":
|
||||||
spec:
|
spec:
|
||||||
method: 'POST'
|
method: 'POST'
|
||||||
|
|
@ -327,6 +328,16 @@ module.exports = (swagger, v2) ->
|
||||||
]
|
]
|
||||||
action: user.addTag
|
action: user.addTag
|
||||||
|
|
||||||
|
"/user/tags/sort":
|
||||||
|
spec:
|
||||||
|
method: 'POST'
|
||||||
|
description: 'Sort tags'
|
||||||
|
parameters: [
|
||||||
|
query("from","Index where you're sorting from (0-based)","integer")
|
||||||
|
query("to","Index where you're sorting to (0-based)","integer")
|
||||||
|
]
|
||||||
|
action: user.sortTag
|
||||||
|
|
||||||
"/user/tags/{id}:PUT":
|
"/user/tags/{id}:PUT":
|
||||||
spec:
|
spec:
|
||||||
path: '/user/tags/{id}'
|
path: '/user/tags/{id}'
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@
|
||||||
form.hrpg-input-group
|
form.hrpg-input-group
|
||||||
input(type='text', ng-model='_newTag', placeholder=env.t('newTag'))
|
input(type='text', ng-model='_newTag', placeholder=env.t('newTag'))
|
||||||
button(ng-click='createTag(_newTag)')=env.t('add')
|
button(ng-click='createTag(_newTag)')=env.t('add')
|
||||||
|
ul(ng-if='!areTagsHidden || _editing', tags-sortable)
|
||||||
li.filters-edit(bindonce='user.tags', ng-class='{active: user.filters[tag.id]}', ng-repeat='tag in user.tags')
|
li.filters-edit(bindonce='user.tags', ng-class='{active: user.filters[tag.id]}', ng-repeat='tag in user.tags')
|
||||||
//- Edit tags
|
//- Edit tags
|
||||||
form.hrpg-input-group(ng-show='_editing')
|
form.hrpg-input-group(ng-show='_editing')
|
||||||
|
|
@ -29,7 +30,8 @@
|
||||||
button(ng-click='user.ops.deleteTag({params:{id:tag.id}})')
|
button(ng-click='user.ops.deleteTag({params:{id:tag.id}})')
|
||||||
span.glyphicon.glyphicon-trash
|
span.glyphicon.glyphicon-trash
|
||||||
//- List of Tags
|
//- List of Tags
|
||||||
li.filters-tags(ng-if='!_editing', bindonce='user.tags', ng-class='{active: user.filters[tag.id], challenge: tag.challenge}', ng-repeat='tag in user.tags')
|
li.filters-tags(ng-if='!_editing', bindonce='user.tags',
|
||||||
|
ng-class='{active: user.filters[tag.id], challenge: tag.challenge}', ng-repeat='tag in user.tags')
|
||||||
a(ng-click='toggleFilter(tag)')
|
a(ng-click='toggleFilter(tag)')
|
||||||
span.glyphicon.glyphicon-bullhorn(bo-if="tag.challenge")
|
span.glyphicon.glyphicon-bullhorn(bo-if="tag.challenge")
|
||||||
markdown(ng-model='tag.name')
|
markdown(ng-model='tag.name')
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue