Skip to content
Open
Show file tree
Hide file tree
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
41 changes: 41 additions & 0 deletions public/cui.js
Original file line number Diff line number Diff line change
Expand Up @@ -52056,11 +52056,21 @@ CUI.ListView = (function(superClass) {
ignoreKeyEvents: {
check: Boolean,
"default": false
},
hierarchyDragAndDrop: {
check: Boolean,
"default": false
},
onHierarchyDrop: {
check: Function
}
});
};

ListView.prototype.readOpts = function() {
if (this.opts.rowMove && this.opts.hierarchyDragAndDrop) {
throw new Error("rowMove and hierarchyDragAndDrop cannot be set together");
}
if (this.opts.header) {
this.opts.header_center = this.opts.header;
}
Expand Down Expand Up @@ -53223,6 +53233,37 @@ CUI.ListView = (function(superClass) {
row = _rows[n];
row_i = parseInt(row.getAttribute("row"));
_this.__rows[row_i].push(row);
if (_this._hierarchyDragAndDrop) {
if (row_i > 0) {
new CUI.Draggable({
element: row,
axis: "y",
create: function() {
return {
rowNode: CUI.dom.data(row, "listViewRow")
};
}
});
}
new CUI.Droppable({
element: row,
dropHelper: true,
accept: function(event, info) {
var ref6, rowNode;
rowNode = CUI.dom.data(row, "listViewRow");
if (ref6 = info.globalDrag.rowNode, indexOf.call(rowNode.getPath(true), ref6) >= 0) {
return false;
}
if (rowNode === info.globalDrag.rowNode.getFather()) {
return false;
}
return true;
},
drop: function(event, info) {
return typeof _this._onHierarchyDrop === "function" ? _this._onHierarchyDrop(CUI.dom.data(row, "listViewRow"), info) : void 0;
}
});
}
}
};
})(this);
Expand Down
2 changes: 1 addition & 1 deletion public/cui.min.js

Large diffs are not rendered by default.

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