Merge pull request #1054 from taigaio/bug/4345/disable-drag-and-drop-on-wiki-links-without-permissions
Bug#4345: Disable drag and drop on wikilink without permissionsstable
commit
8cdab3c1bf
|
@ -45,31 +45,35 @@ WikiNavDirective = ($tgrepo, $log, $location, $confirm, $analytics, $loading, $t
|
|||
itemEl = null
|
||||
tdom = $el.find(".sortable")
|
||||
|
||||
drake = dragula([tdom[0]], {
|
||||
direction: 'vertical',
|
||||
copySortSource: false,
|
||||
copy: false,
|
||||
mirrorContainer: tdom[0],
|
||||
moves: (item) -> return $(item).is('li')
|
||||
})
|
||||
addWikiLinkPermission = $scope.project.my_permissions.indexOf("add_wiki_link") > -1
|
||||
|
||||
drake.on 'dragend', (item) ->
|
||||
itemEl = $(item)
|
||||
item = itemEl.scope().link
|
||||
itemIndex = itemEl.index()
|
||||
$scope.$emit("wiki:links:move", item, itemIndex)
|
||||
if addWikiLinkPermission
|
||||
drake = dragula([tdom[0]], {
|
||||
direction: 'vertical',
|
||||
copySortSource: false,
|
||||
copy: false,
|
||||
mirrorContainer: tdom[0],
|
||||
moves: (item) -> return $(item).is('li')
|
||||
})
|
||||
|
||||
scroll = autoScroll(window, {
|
||||
margin: 20,
|
||||
pixels: 30,
|
||||
scrollWhenOutside: true,
|
||||
autoScroll: () ->
|
||||
return this.down && drake.dragging;
|
||||
})
|
||||
drake.on 'dragend', (item) ->
|
||||
itemEl = $(item)
|
||||
item = itemEl.scope().link
|
||||
itemIndex = itemEl.index()
|
||||
$scope.$emit("wiki:links:move", item, itemIndex)
|
||||
|
||||
scroll = autoScroll(window, {
|
||||
margin: 20,
|
||||
pixels: 30,
|
||||
scrollWhenOutside: true,
|
||||
autoScroll: () ->
|
||||
return this.down && drake.dragging;
|
||||
})
|
||||
|
||||
$scope.$on "$destroy", ->
|
||||
$el.off()
|
||||
drake.destroy()
|
||||
if addWikiLinkPermission
|
||||
drake.destroy()
|
||||
|
||||
linkWikiLinks = ($scope, $el, $attrs) ->
|
||||
$ctrl = $el.controller()
|
||||
|
|
|
@ -18,7 +18,12 @@ nav
|
|||
)
|
||||
|
||||
ul.sortable
|
||||
li.wiki-link(ng-repeat="link in wikiLinks", data-id!="{{ $index }}", tg-bind-scope)
|
||||
li.wiki-link(
|
||||
ng-repeat="link in wikiLinks"
|
||||
data-id!="{{ $index }}"
|
||||
tg-bind-scope
|
||||
tg-class-permission="{'is-sortable': 'add_wiki_link'}"
|
||||
)
|
||||
<% if (addWikiLinkPermission) { %>
|
||||
tg-svg.dragger(svg-icon="icon-drag")
|
||||
<% } %>
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
@include font-type(text);
|
||||
align-items: center;
|
||||
border-bottom: 1px solid $gray-light;
|
||||
cursor: move;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
padding: 1rem 0;
|
||||
|
@ -22,6 +21,9 @@
|
|||
transition-delay: .2s;
|
||||
}
|
||||
}
|
||||
&.is-sortable {
|
||||
cursor: move;
|
||||
}
|
||||
.dragger {
|
||||
margin-right: .5rem;
|
||||
opacity: 0;
|
||||
|
|
Loading…
Reference in New Issue