Changeset View
Changeset View
Standalone View
Standalone View
webroot/rsrc/js/application/projects/WorkboardColumn.js
Show First 20 Lines • Show All 46 Lines • ▼ Show 20 Lines | members: { | ||||
getRoot: function() { | getRoot: function() { | ||||
return this._root; | return this._root; | ||||
}, | }, | ||||
getCards: function() { | getCards: function() { | ||||
return this._cards; | return this._cards; | ||||
}, | }, | ||||
_getObjects: function() { | |||||
return this._objects; | |||||
}, | |||||
getCard: function(phid) { | getCard: function(phid) { | ||||
return this._cards[phid]; | return this._cards[phid]; | ||||
}, | }, | ||||
getBoard: function() { | getBoard: function() { | ||||
return this._board; | return this._board; | ||||
}, | }, | ||||
▲ Show 20 Lines • Show All 58 Lines • ▼ Show 20 Lines | addCard: function(card, after) { | ||||
this._naturalOrder.push(phid); | this._naturalOrder.push(phid); | ||||
} else { | } else { | ||||
this._naturalOrder.splice(index, 0, phid); | this._naturalOrder.splice(index, 0, phid); | ||||
} | } | ||||
return this; | return this; | ||||
}, | }, | ||||
getCardNodes: function() { | getDropTargetNodes: function() { | ||||
var cards = this.getCards(); | var objects = this._getObjects(); | ||||
var nodes = []; | var nodes = []; | ||||
for (var k in cards) { | for (var ii = 0; ii < objects.length; ii++) { | ||||
nodes.push(cards[k].getNode()); | var object = objects[ii]; | ||||
nodes.push(object.getNode()); | |||||
} | } | ||||
return nodes; | return nodes; | ||||
}, | }, | ||||
getCardPHIDs: function() { | getCardPHIDs: function() { | ||||
return JX.keys(this.getCards()); | return JX.keys(this.getCards()); | ||||
}, | }, | ||||
Show All 12 Lines | members: { | ||||
getHeader: function(key) { | getHeader: function(key) { | ||||
if (!this._headers[key]) { | if (!this._headers[key]) { | ||||
this._headers[key] = new JX.WorkboardHeader(this, key); | this._headers[key] = new JX.WorkboardHeader(this, key); | ||||
} | } | ||||
return this._headers[key]; | return this._headers[key]; | ||||
}, | }, | ||||
handleDragGhost: function(default_handler, ghost, node) { | |||||
// If the column has headers, don't let the user drag a card above | |||||
// the topmost header: for example, you can't change a task to have | |||||
// a priority higher than the highest possible priority. | |||||
if (this._hasColumnHeaders()) { | |||||
if (!node) { | |||||
return false; | |||||
} | |||||
} | |||||
return default_handler(ghost, node); | |||||
}, | |||||
_hasColumnHeaders: function() { | |||||
var board = this.getBoard(); | |||||
var order = board.getOrder(); | |||||
switch (order) { | |||||
case 'natural': | |||||
return false; | |||||
} | |||||
return true; | |||||
}, | |||||
_getCardHeaderKey: function(card, order) { | _getCardHeaderKey: function(card, order) { | ||||
switch (order) { | switch (order) { | ||||
case 'priority': | case 'priority': | ||||
return 'priority(' + card.getPriority() + ')'; | return 'priority(' + card.getPriority() + ')'; | ||||
default: | default: | ||||
return null; | return null; | ||||
} | } | ||||
}, | }, | ||||
redraw: function() { | redraw: function() { | ||||
var board = this.getBoard(); | var board = this.getBoard(); | ||||
var order = board.getOrder(); | var order = board.getOrder(); | ||||
var list; | var list; | ||||
var has_headers; | |||||
if (order == 'natural') { | if (order == 'natural') { | ||||
list = this._getCardsSortedNaturally(); | list = this._getCardsSortedNaturally(); | ||||
has_headers = false; | |||||
} else { | } else { | ||||
list = this._getCardsSortedByKey(order); | list = this._getCardsSortedByKey(order); | ||||
has_headers = true; | |||||
} | } | ||||
var ii; | var ii; | ||||
var objects = []; | var objects = []; | ||||
var has_headers = this._hasColumnHeaders(); | |||||
var header_keys = []; | var header_keys = []; | ||||
var seen_headers = {}; | var seen_headers = {}; | ||||
if (has_headers) { | if (has_headers) { | ||||
var header_templates = board.getHeaderTemplatesForOrder(order); | var header_templates = board.getHeaderTemplatesForOrder(order); | ||||
for (var k in header_templates) { | for (var k in header_templates) { | ||||
header_keys.push(header_templates[k].getHeaderKey()); | header_keys.push(header_templates[k].getHeaderKey()); | ||||
} | } | ||||
header_keys.reverse(); | header_keys.reverse(); | ||||
▲ Show 20 Lines • Show All 43 Lines • ▼ Show 20 Lines | redraw: function() { | ||||
this._dirty = false; | this._dirty = false; | ||||
}, | }, | ||||
compareHandler: function(src_list, src_node, dst_list, dst_node) { | compareHandler: function(src_list, src_node, dst_list, dst_node) { | ||||
var board = this.getBoard(); | var board = this.getBoard(); | ||||
var order = board.getOrder(); | var order = board.getOrder(); | ||||
var src_phid = JX.Stratcom.getData(src_node).objectPHID; | var u_vec = this._getNodeOrderVector(src_node, order); | ||||
var dst_phid = JX.Stratcom.getData(dst_node).objectPHID; | var v_vec = this._getNodeOrderVector(dst_node, order); | ||||
var u_vec = board.getOrderVector(src_phid, order); | |||||
var v_vec = board.getOrderVector(dst_phid, order); | |||||
return board.compareVectors(u_vec, v_vec); | return board.compareVectors(u_vec, v_vec); | ||||
}, | }, | ||||
_getNodeOrderVector: function(node, order) { | |||||
var board = this.getBoard(); | |||||
var data = JX.Stratcom.getData(node); | |||||
if (data.objectPHID) { | |||||
return board.getOrderVector(data.objectPHID, order); | |||||
} | |||||
return board.getHeaderTemplate(data.headerKey).getVector(); | |||||
}, | |||||
setIsDropTarget: function(is_target) { | setIsDropTarget: function(is_target) { | ||||
var node = this.getWorkpanelNode(); | var node = this.getWorkpanelNode(); | ||||
JX.DOM.alterClass(node, 'workboard-column-drop-target', is_target); | JX.DOM.alterClass(node, 'workboard-column-drop-target', is_target); | ||||
}, | }, | ||||
_getCardsSortedNaturally: function() { | _getCardsSortedNaturally: function() { | ||||
var list = []; | var list = []; | ||||
▲ Show 20 Lines • Show All 113 Lines • Show Last 20 Lines |