Changeset View
Changeset View
Standalone View
Standalone View
webroot/rsrc/js/application/projects/WorkboardBoard.js
/** | /** | ||||
* @provides javelin-workboard-board | * @provides javelin-workboard-board | ||||
* @requires javelin-install | * @requires javelin-install | ||||
* javelin-dom | * javelin-dom | ||||
* javelin-util | * javelin-util | ||||
* javelin-stratcom | * javelin-stratcom | ||||
* javelin-workflow | * javelin-workflow | ||||
* phabricator-draggable-list | * phabricator-draggable-list | ||||
* javelin-workboard-column | * javelin-workboard-column | ||||
* javelin-workboard-header-template | |||||
* @javelin | * @javelin | ||||
*/ | */ | ||||
JX.install('WorkboardBoard', { | JX.install('WorkboardBoard', { | ||||
construct: function(controller, phid, root) { | construct: function(controller, phid, root) { | ||||
this._controller = controller; | this._controller = controller; | ||||
this._phid = phid; | this._phid = phid; | ||||
this._root = root; | this._root = root; | ||||
this._templates = {}; | this._templates = {}; | ||||
this._orderMaps = {}; | this._orderMaps = {}; | ||||
this._propertiesMap = {}; | this._propertiesMap = {}; | ||||
this._headers = {}; | |||||
this._buildColumns(); | this._buildColumns(); | ||||
}, | }, | ||||
properties: { | properties: { | ||||
order: null, | order: null, | ||||
pointsEnabled: false | pointsEnabled: false | ||||
}, | }, | ||||
members: { | members: { | ||||
_controller: null, | _controller: null, | ||||
_phid: null, | _phid: null, | ||||
_root: null, | _root: null, | ||||
_columns: null, | _columns: null, | ||||
_templates: null, | _templates: null, | ||||
_orderMaps: null, | _orderMaps: null, | ||||
_propertiesMap: null, | _propertiesMap: null, | ||||
_headers: null, | |||||
getRoot: function() { | getRoot: function() { | ||||
return this._root; | return this._root; | ||||
}, | }, | ||||
getColumns: function() { | getColumns: function() { | ||||
return this._columns; | return this._columns; | ||||
}, | }, | ||||
getColumn: function(k) { | getColumn: function(k) { | ||||
return this._columns[k]; | return this._columns[k]; | ||||
}, | }, | ||||
getPHID: function() { | getPHID: function() { | ||||
return this._phid; | return this._phid; | ||||
}, | }, | ||||
setCardTemplate: function(phid, template) { | setCardTemplate: function(phid, template) { | ||||
this._templates[phid] = template; | this._templates[phid] = template; | ||||
return this; | return this; | ||||
}, | }, | ||||
getHeaderTemplate: function(header_key) { | |||||
if (!this._headers[header_key]) { | |||||
this._headers[header_key] = new JX.WorkboardHeaderTemplate(header_key); | |||||
} | |||||
return this._headers[header_key]; | |||||
}, | |||||
getHeaderTemplatesForOrder: function(order) { | |||||
var templates = []; | |||||
for (var k in this._headers) { | |||||
var header = this._headers[k]; | |||||
if (header.getOrder() !== order) { | |||||
continue; | |||||
} | |||||
templates.push(header); | |||||
} | |||||
templates.sort(JX.bind(this, this._sortHeaderTemplates)); | |||||
return templates; | |||||
}, | |||||
_sortHeaderTemplates: function(u, v) { | |||||
return this.compareVectors(u.getVector(), v.getVector()); | |||||
}, | |||||
setObjectProperties: function(phid, properties) { | setObjectProperties: function(phid, properties) { | ||||
this._propertiesMap[phid] = properties; | this._propertiesMap[phid] = properties; | ||||
return this; | return this; | ||||
}, | }, | ||||
getObjectProperties: function(phid) { | getObjectProperties: function(phid) { | ||||
return this._propertiesMap[phid]; | return this._propertiesMap[phid]; | ||||
}, | }, | ||||
Show All 10 Lines | setOrderMap: function(phid, map) { | ||||
this._orderMaps[phid] = map; | this._orderMaps[phid] = map; | ||||
return this; | return this; | ||||
}, | }, | ||||
getOrderVector: function(phid, key) { | getOrderVector: function(phid, key) { | ||||
return this._orderMaps[phid][key]; | return this._orderMaps[phid][key]; | ||||
}, | }, | ||||
compareVectors: function(u_vec, v_vec) { | |||||
for (var ii = 0; ii < u_vec.length; ii++) { | |||||
if (u_vec[ii] > v_vec[ii]) { | |||||
return 1; | |||||
} | |||||
if (u_vec[ii] < v_vec[ii]) { | |||||
return -1; | |||||
} | |||||
} | |||||
return 0; | |||||
}, | |||||
start: function() { | start: function() { | ||||
this._setupDragHandlers(); | this._setupDragHandlers(); | ||||
for (var k in this._columns) { | for (var k in this._columns) { | ||||
this._columns[k].redraw(); | this._columns[k].redraw(); | ||||
} | } | ||||
}, | }, | ||||
▲ Show 20 Lines • Show All 186 Lines • Show Last 20 Lines |