Sort epics

stable
David Barragán Merino 2016-09-02 13:55:21 +02:00
parent 84332ff538
commit 037a3d462f
4 changed files with 69 additions and 39 deletions

View File

@ -1,35 +0,0 @@
###
# Copyright (C) 2014-2016 Taiga Agile LLC <taiga@taiga.io>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# File: epic-sortable.directive.coffee
###
EpicSortableDirective = ($parse) ->
link = (scope, el, attrs) ->
drake = dragula([el[0]])
scope.$on "$destroy", ->
el.off()
drake.destroy()
return {
link: link
}
EpicSortableDirective.$inject = []
angular.module("taigaComponents").directive("tgEpicSortable", EpicSortableDirective)

View File

@ -0,0 +1,61 @@
###
# Copyright (C) 2014-2016 Taiga Agile LLC <taiga@taiga.io>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# File: epics-sortable.directive.coffee
###
EpicsSortableDirective = ($parse) ->
link = (scope, el, attrs) ->
callback = $parse(attrs.tgEpicsSortable)
drake = dragula([el[0]], {
copySortSource: false
copy: false
mirrorContainer: el[0]
moves: (item) ->
return $(item).is('div.epics-table-body-row')
})
drake.on 'dragend', (item) ->
itemEl = $(item)
epic = itemEl.scope().epic
newIndex = itemEl.index()
scope.$apply () ->
callback(scope, {epic: epic, newIndex: newIndex})
scroll = autoScroll(window, {
margin: 20,
pixels: 30,
scrollWhenOutside: true,
autoScroll: () ->
return this.down && drake.dragging
})
scope.$on "$destroy", ->
el.off()
drake.destroy()
return {
link: link
}
EpicsSortableDirective.$inject = [
"$parse"
]
angular.module("taigaComponents").directive("tgEpicsSortable", EpicsSortableDirective)

View File

@ -42,7 +42,8 @@ class EpicsTableController
toggleEpicTableOptions: () ->
@.displayOptions = !@.displayOptions
reorderEpics: (epic, index) ->
console.log epic, index
reorderEpic: (epic, newIndex) ->
console.log epic, newIndex
module.controller("EpicsTableCtrl", EpicsTableController)

View File

@ -88,8 +88,11 @@ mixin epicSwitch(name, model)
for="switch-progress"
)
+epicSwitch('switch-progress', 'vm.column.progress')
.epics-table-body(tg-epic-sortable)
.epics-table-body-row(tg-repeat="epic in vm.epics track by epic.get('id')")
.epics-table-body(tg-epics-sortable="vm.reorderEpic(epic, newIndex)")
.epics-table-body-row(
tg-repeat="epic in vm.epics track by epic.get('id')"
tg-bind-scope
)
tg-epic-row.e2e-epic(
epic="epic"
project="vm.project"