Fix bug #741: Kanban/Taskboard/Backlog drag and drop start on all the element

stable
Jesús Espino 2014-09-05 13:26:13 +02:00
parent bcf87d7df1
commit 68f48f6a1c
11 changed files with 60 additions and 20 deletions

View File

@ -52,7 +52,6 @@ BacklogSortableDirective = ($repo, $rs, $rootscope) ->
$el.sortable({
connectWith: ".sprint-table"
handle: ".icon-drag-v",
containment: ".wrapper"
dropOnEmpty: true
placeholder: "row us-item-row us-item-drag sortable-placeholder"
@ -75,6 +74,7 @@ BacklogSortableDirective = ($repo, $rs, $rootscope) ->
deleteElement(ui.item)
$scope.$emit("sprint:us:move", itemUs, itemIndex, null)
ui.item.find('a').removeClass('noclick')
$el.on "sortstop", (event, ui) ->
# When parent not exists, do nothing
@ -84,6 +84,10 @@ BacklogSortableDirective = ($repo, $rs, $rootscope) ->
itemUs = ui.item.scope().us
itemIndex = ui.item.index()
$scope.$emit("sprint:us:move", itemUs, itemIndex, null)
ui.item.find('a').removeClass('noclick')
$el.on "sortstart", (event, ui) ->
ui.item.find('a').addClass('noclick')
$scope.$on "$destroy", ->
$el.off()
@ -109,6 +113,7 @@ BacklogEmptySortableDirective = ($repo, $rs, $rootscope) ->
deleteElement(ui.item)
$scope.$emit("sprint:us:move", itemUs, itemIndex, null)
ui.item.find('a').removeClass('noclick')
$scope.$on "$destroy", ->
$el.off()
@ -132,6 +137,7 @@ SprintSortableDirective = ($repo, $rs, $rootscope) ->
deleteElement(ui.item)
$scope.$emit("sprint:us:move", itemUs, itemIndex, $scope.sprint.id)
ui.item.find('a').removeClass('noclick')
$el.on "sortstop", (event, ui) ->
# When parent not exists, do nothing
@ -142,6 +148,7 @@ SprintSortableDirective = ($repo, $rs, $rootscope) ->
itemIndex = ui.item.index()
$scope.$emit("sprint:us:move", itemUs, itemIndex, $scope.sprint.id)
ui.item.find('a').removeClass('noclick')
return {link:link}

View File

@ -109,6 +109,9 @@ NavigationUrlsDirective = ($navurls, $auth, $q, $location) ->
event.preventDefault()
target = $(event.currentTarget)
if target.hasClass('noclick')
return
fullUrl = target.data("fullUrl")
switch event.which

View File

@ -74,9 +74,6 @@ class KanbanController extends mixOf(taiga.Controller, taiga.PageMixin, taiga.Fi
# Template actions
editUserStory: (us) ->
@rootscope.$broadcast("usform:edit", us)
addNewUs: (type, statusId) ->
switch type
when "standard" then @rootscope.$broadcast("usform:new", @scope.projectId, statusId, @scope.usStatusList)
@ -245,8 +242,14 @@ module.directive("tgKanbanRowSizeFixer", KanbanRowSizeFixer)
## Kaban User Story Directive
#############################################################################
KanbanUserstoryDirective = ->
link = ($scope, $el, $attrs) ->
KanbanUserstoryDirective = ($rootscope) ->
link = ($scope, $el, $attrs, $model) ->
$el.find(".icon-edit").on "click", (event) ->
if $el.find('.icon-edit').hasClass('noclick')
return
$scope.$apply ->
$rootscope.$broadcast("usform:edit", $model.$modelValue)
$el.disableSelection()
return {
@ -256,7 +259,7 @@ KanbanUserstoryDirective = ->
}
module.directive("tgKanbanUserstory", KanbanUserstoryDirective)
module.directive("tgKanbanUserstory", ["$rootScope", KanbanUserstoryDirective])
#############################################################################
@ -322,6 +325,9 @@ KanbanUserDirective = ($log) ->
username_label = $el.parent().find("a.task-assigned")
username_label.html(ctx.name)
username_label.on "click", (event) ->
if $el.find('a').hasClass('noclick')
return
us = $model.$modelValue
$ctrl = $el.controller()
$ctrl.changeUsAssignedTo(us)
@ -330,6 +336,9 @@ KanbanUserDirective = ($log) ->
if project.my_permissions.indexOf("modify_us") > -1
clickable = true
$el.on "click", (event) =>
if $el.find('a').hasClass('noclick')
return
us = $model.$modelValue
$ctrl = $el.controller()
$ctrl.changeUsAssignedTo(us)

View File

@ -58,7 +58,7 @@ KanbanSortableDirective = ($repo, $rs, $rootscope) ->
itemEl.remove()
tdom.sortable({
handle: ".icon-drag-h"
handle: ".kanban-task-inner"
dropOnEmpty: true
connectWith: ".kanban-uses-box"
revert: 400
@ -80,8 +80,11 @@ KanbanSortableDirective = ($repo, $rs, $rootscope) ->
$scope.$apply ->
$rootscope.$broadcast("kanban:us:move", itemUs, newStatusId, itemIndex)
ui.item.find('a').removeClass('noclick')
tdom.on "sortstart", (event, ui) ->
oldParentScope = ui.item.parent().scope()
ui.item.find('a').addClass('noclick')
$scope.$on "$destroy", ->
$el.off()

View File

@ -181,9 +181,6 @@ class TaskboardController extends mixOf(taiga.Controller, taiga.PageMixin)
when "standard" then @rootscope.$broadcast("taskform:new", @scope.sprintId, us?.id)
when "bulk" then @rootscope.$broadcast("taskform:bulk", @scope.sprintId, us?.id)
editTask: (task) ->
@rootscope.$broadcast("taskform:edit", task)
editTaskAssignedTo: (task) ->
@rootscope.$broadcast("assigned-to:add", task)
@ -222,15 +219,21 @@ module.directive("tgTaskboard", ["$rootScope", TaskboardDirective])
## Taskboard Task Directive
#############################################################################
TaskboardTaskDirective = ->
link = ($scope, $el, $attrs) ->
TaskboardTaskDirective = ($rootscope) ->
link = ($scope, $el, $attrs, $model) ->
console.log "taskboard task"
$el.find(".icon-edit").on "click", (event) ->
if $el.find('.icon-edit').hasClass('noclick')
return
$scope.$apply ->
$rootscope.$broadcast("taskform:edit", $scope.task)
$el.disableSelection()
return {link:link}
module.directive("tgTaskboardTask", TaskboardTaskDirective)
module.directive("tgTaskboardTask", ["$rootScope", TaskboardTaskDirective])
#############################################################################
@ -283,13 +286,23 @@ TaskboardUserDirective = ($log) ->
html = template(ctx)
$el.html(html)
username_label = $el.parent().find("a.task-assigned")
username_label.html(ctx.name)
username_label.on "click", (event) ->
if $el.find('a').hasClass('noclick')
return
$el.parent().find("a.task-assigned").html(ctx.name)
us = $model.$modelValue
$ctrl = $el.controller()
$ctrl.editTaskAssignedTo(us)
bindOnce $scope, "project", (project) ->
if project.my_permissions.indexOf("modify_task") > -1
clickable = true
$el.on "click", (event) =>
if $el.find('a').hasClass('noclick')
return
us = $model.$modelValue
$ctrl = $el.controller()
$ctrl.editTaskAssignedTo(us)

View File

@ -48,7 +48,7 @@ TaskboardSortableDirective = ($repo, $rs, $rootscope) ->
itemEl.remove()
tdom.sortable({
handle: ".icon-drag-h",
handle: ".taskboard-task-inner",
dropOnEmpty: true
connectWith: ".taskboard-tasks-box"
revert: 400
@ -72,8 +72,11 @@ TaskboardSortableDirective = ($repo, $rs, $rootscope) ->
$scope.$apply ->
$rootscope.$broadcast("taskboard:task:move", itemTask, newUsId, newStatusId, itemIndex)
ui.item.find('a').removeClass('noclick')
tdom.on "sortstart", (event, ui) ->
oldParentScope = ui.item.parent().scope()
ui.item.find('a').addClass('noclick')
$scope.$on "$destroy", ->
$el.off()

View File

@ -9,5 +9,5 @@ div.kanban-task-inner
p.task-points
span(tg-bind-html="us.total_points") --
span points
a.icon.icon-edit(tg-check-permission, permission="modify_us", href="", title="Edit", ng-click="ctrl.editUserStory(us)")
a.icon.icon-edit(tg-check-permission, permission="modify_us", href="", title="Edit")
a.icon.icon-drag-h(tg-check-permission, permission="modify_us", href="", title="Drag&Drop")

View File

@ -1,16 +1,15 @@
div.taskboard-tagline(tg-colorize-tags="task.tags", tg-colorize-tags-type="taskboard")
div.taskboard-task-inner
div.taskboard-user-avatar(tg-taskboard-user-avatar="task.assigned_to", ng-model="task",
click="ctrl.editTaskAssignedTo(task)",
ng-class="{iocaine: task.is_iocaine}")
span.icon.icon-iocaine(ng-if="task.is_iocaine")
p.taskboard-text
a.task-assigned(href="", ng-click="ctrl.editTaskAssignedTo(task)", title="Assign task")
a.task-assigned(href="", title="Assign task")
span.task-num(tg-bo-ref="task.ref")
a.task-name(href="", title="See task details", tg-bind-html="task.subject",
tg-nav="project-tasks-detail:project=project.slug,ref=task.ref")
a.icon.icon-edit(tg-check-permission, permission="modify_task",
href="", title="Edit task", ng-click="ctrl.editTask(task)")
href="", title="Edit task")
a.icon.icon-drag-h(tg-check-permission, permission="modify_task",
href="", title="Drag&Drop")

View File

@ -1,5 +1,6 @@
.kanban-task {
background: $postit;
cursor: move;
position: relative;
&:last-child {
margin: 0;

View File

@ -2,6 +2,7 @@
@include transition (box-shadow .4s linear);
background: $postit;
box-shadow: none;
cursor: move;
min-height: 7rem;
position: relative;
&:hover {

View File

@ -108,6 +108,7 @@
.backlog-table-body {
.row {
cursor: move;
position: relative;
&:hover {
@include transition (background .2s ease-in);