prevent dragging for anonymous user on taskboard
parent
3e24fa77a3
commit
cb782dd2b9
|
@ -36,47 +36,52 @@ module = angular.module("taigaBacklog")
|
||||||
|
|
||||||
TaskboardSortableDirective = ($repo, $rs, $rootscope) ->
|
TaskboardSortableDirective = ($repo, $rs, $rootscope) ->
|
||||||
link = ($scope, $el, $attrs) ->
|
link = ($scope, $el, $attrs) ->
|
||||||
oldParentScope = null
|
bindOnce $scope, "project", (project) ->
|
||||||
newParentScope = null
|
# If the user has not enough permissions we don't enable the sortable
|
||||||
itemEl = null
|
if not (project.my_permissions.indexOf("modify_us") > -1)
|
||||||
tdom = $el
|
return
|
||||||
|
|
||||||
deleteElement = (itemEl) ->
|
oldParentScope = null
|
||||||
# Completelly remove item and its scope from dom
|
newParentScope = null
|
||||||
itemEl.scope().$destroy()
|
itemEl = null
|
||||||
itemEl.off()
|
tdom = $el
|
||||||
itemEl.remove()
|
|
||||||
|
|
||||||
tdom.sortable({
|
deleteElement = (itemEl) ->
|
||||||
handle: ".taskboard-task-inner",
|
# Completelly remove item and its scope from dom
|
||||||
dropOnEmpty: true
|
itemEl.scope().$destroy()
|
||||||
connectWith: ".taskboard-tasks-box"
|
itemEl.off()
|
||||||
revert: 400
|
itemEl.remove()
|
||||||
})
|
|
||||||
|
|
||||||
tdom.on "sortstop", (event, ui) ->
|
tdom.sortable({
|
||||||
parentEl = ui.item.parent()
|
handle: ".taskboard-task-inner",
|
||||||
itemEl = ui.item
|
dropOnEmpty: true
|
||||||
itemTask = itemEl.scope().task
|
connectWith: ".taskboard-tasks-box"
|
||||||
itemIndex = itemEl.index()
|
revert: 400
|
||||||
newParentScope = parentEl.scope()
|
})
|
||||||
|
|
||||||
oldUsId = if oldParentScope.us then oldParentScope.us.id else null
|
tdom.on "sortstop", (event, ui) ->
|
||||||
oldStatusId = oldParentScope.st.id
|
parentEl = ui.item.parent()
|
||||||
newUsId = if newParentScope.us then newParentScope.us.id else null
|
itemEl = ui.item
|
||||||
newStatusId = newParentScope.st.id
|
itemTask = itemEl.scope().task
|
||||||
|
itemIndex = itemEl.index()
|
||||||
|
newParentScope = parentEl.scope()
|
||||||
|
|
||||||
if newStatusId != oldStatusId or newUsId != oldUsId
|
oldUsId = if oldParentScope.us then oldParentScope.us.id else null
|
||||||
deleteElement(itemEl)
|
oldStatusId = oldParentScope.st.id
|
||||||
|
newUsId = if newParentScope.us then newParentScope.us.id else null
|
||||||
|
newStatusId = newParentScope.st.id
|
||||||
|
|
||||||
$scope.$apply ->
|
if newStatusId != oldStatusId or newUsId != oldUsId
|
||||||
$rootscope.$broadcast("taskboard:task:move", itemTask, newUsId, newStatusId, itemIndex)
|
deleteElement(itemEl)
|
||||||
|
|
||||||
ui.item.find('a').removeClass('noclick')
|
$scope.$apply ->
|
||||||
|
$rootscope.$broadcast("taskboard:task:move", itemTask, newUsId, newStatusId, itemIndex)
|
||||||
|
|
||||||
tdom.on "sortstart", (event, ui) ->
|
ui.item.find('a').removeClass('noclick')
|
||||||
oldParentScope = ui.item.parent().scope()
|
|
||||||
ui.item.find('a').addClass('noclick')
|
tdom.on "sortstart", (event, ui) ->
|
||||||
|
oldParentScope = ui.item.parent().scope()
|
||||||
|
ui.item.find('a').addClass('noclick')
|
||||||
|
|
||||||
$scope.$on "$destroy", ->
|
$scope.$on "$destroy", ->
|
||||||
$el.off()
|
$el.off()
|
||||||
|
|
Loading…
Reference in New Issue