Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions src/elements/ListView/ListView.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,16 @@ class CUI.ListView extends CUI.SimplePane
ignoreKeyEvents:
check: Boolean
default: false
hierarchyDragAndDrop:
check: Boolean
default: false
onHierarchyDrop:
check: Function

readOpts: ->
if @opts.rowMove and @opts.hierarchyDragAndDrop
throw new Error("rowMove and hierarchyDragAndDrop cannot be set together")

if @opts.header
@opts.header_center = @opts.header

Expand Down Expand Up @@ -1093,6 +1101,33 @@ class CUI.ListView extends CUI.SimplePane
row_i = parseInt(row.getAttribute("row"))
@__rows[row_i].push(row)

if @_hierarchyDragAndDrop
# prevent root node from being draggable
if row_i > 0
new CUI.Draggable
element: row
axis: "y"
create: =>
return {
rowNode: CUI.dom.data(row, "listViewRow")
}

new CUI.Droppable
element: row
dropHelper: true
accept: (event, info) =>
rowNode = CUI.dom.data(row, "listViewRow")

if info.globalDrag.rowNode in rowNode.getPath(true)
return false

if rowNode == info.globalDrag.rowNode.getFather()
return false

return true
drop: (event, info) =>
@_onHierarchyDrop?(CUI.dom.data(row, "listViewRow"), info)

return

anchor_row_idx = 0
Expand Down