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
|
itemEl = null
|
||||||
tdom = $el.find(".sortable")
|
tdom = $el.find(".sortable")
|
||||||
|
|
||||||
drake = dragula([tdom[0]], {
|
addWikiLinkPermission = $scope.project.my_permissions.indexOf("add_wiki_link") > -1
|
||||||
direction: 'vertical',
|
|
||||||
copySortSource: false,
|
|
||||||
copy: false,
|
|
||||||
mirrorContainer: tdom[0],
|
|
||||||
moves: (item) -> return $(item).is('li')
|
|
||||||
})
|
|
||||||
|
|
||||||
drake.on 'dragend', (item) ->
|
if addWikiLinkPermission
|
||||||
itemEl = $(item)
|
drake = dragula([tdom[0]], {
|
||||||
item = itemEl.scope().link
|
direction: 'vertical',
|
||||||
itemIndex = itemEl.index()
|
copySortSource: false,
|
||||||
$scope.$emit("wiki:links:move", item, itemIndex)
|
copy: false,
|
||||||
|
mirrorContainer: tdom[0],
|
||||||
|
moves: (item) -> return $(item).is('li')
|
||||||
|
})
|
||||||
|
|
||||||
scroll = autoScroll(window, {
|
drake.on 'dragend', (item) ->
|
||||||
margin: 20,
|
itemEl = $(item)
|
||||||
pixels: 30,
|
item = itemEl.scope().link
|
||||||
scrollWhenOutside: true,
|
itemIndex = itemEl.index()
|
||||||
autoScroll: () ->
|
$scope.$emit("wiki:links:move", item, itemIndex)
|
||||||
return this.down && drake.dragging;
|
|
||||||
})
|
scroll = autoScroll(window, {
|
||||||
|
margin: 20,
|
||||||
|
pixels: 30,
|
||||||
|
scrollWhenOutside: true,
|
||||||
|
autoScroll: () ->
|
||||||
|
return this.down && drake.dragging;
|
||||||
|
})
|
||||||
|
|
||||||
$scope.$on "$destroy", ->
|
$scope.$on "$destroy", ->
|
||||||
$el.off()
|
$el.off()
|
||||||
drake.destroy()
|
if addWikiLinkPermission
|
||||||
|
drake.destroy()
|
||||||
|
|
||||||
linkWikiLinks = ($scope, $el, $attrs) ->
|
linkWikiLinks = ($scope, $el, $attrs) ->
|
||||||
$ctrl = $el.controller()
|
$ctrl = $el.controller()
|
||||||
|
|
|
@ -18,7 +18,12 @@ nav
|
||||||
)
|
)
|
||||||
|
|
||||||
ul.sortable
|
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) { %>
|
<% if (addWikiLinkPermission) { %>
|
||||||
tg-svg.dragger(svg-icon="icon-drag")
|
tg-svg.dragger(svg-icon="icon-drag")
|
||||||
<% } %>
|
<% } %>
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
@include font-type(text);
|
@include font-type(text);
|
||||||
align-items: center;
|
align-items: center;
|
||||||
border-bottom: 1px solid $gray-light;
|
border-bottom: 1px solid $gray-light;
|
||||||
cursor: move;
|
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
padding: 1rem 0;
|
padding: 1rem 0;
|
||||||
|
@ -22,6 +21,9 @@
|
||||||
transition-delay: .2s;
|
transition-delay: .2s;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
&.is-sortable {
|
||||||
|
cursor: move;
|
||||||
|
}
|
||||||
.dragger {
|
.dragger {
|
||||||
margin-right: .5rem;
|
margin-right: .5rem;
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
|
|
Loading…
Reference in New Issue