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-workboard-header-template | ||||
* javelin-workboard-card-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._orderMaps = {}; | |||||
this._propertiesMap = {}; | |||||
this._headers = {}; | this._headers = {}; | ||||
this._cards = {}; | |||||
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, | |||||
_orderMaps: null, | |||||
_propertiesMap: null, | |||||
_headers: null, | _headers: null, | ||||
_cards: 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) { | getCardTemplate: function(phid) { | ||||
this._templates[phid] = template; | if (!this._cards[phid]) { | ||||
return this; | this._cards[phid] = new JX.WorkboardCardTemplate(phid); | ||||
} | |||||
return this._cards[phid]; | |||||
}, | }, | ||||
getHeaderTemplate: function(header_key) { | getHeaderTemplate: function(header_key) { | ||||
if (!this._headers[header_key]) { | if (!this._headers[header_key]) { | ||||
this._headers[header_key] = new JX.WorkboardHeaderTemplate(header_key); | this._headers[header_key] = new JX.WorkboardHeaderTemplate(header_key); | ||||
} | } | ||||
return this._headers[header_key]; | return this._headers[header_key]; | ||||
Show All 16 Lines | getHeaderTemplatesForOrder: function(order) { | ||||
return templates; | return templates; | ||||
}, | }, | ||||
_sortHeaderTemplates: function(u, v) { | _sortHeaderTemplates: function(u, v) { | ||||
return this.compareVectors(u.getVector(), v.getVector()); | return this.compareVectors(u.getVector(), v.getVector()); | ||||
}, | }, | ||||
setObjectProperties: function(phid, properties) { | |||||
this._propertiesMap[phid] = properties; | |||||
return this; | |||||
}, | |||||
getObjectProperties: function(phid) { | |||||
return this._propertiesMap[phid]; | |||||
}, | |||||
getCardTemplate: function(phid) { | |||||
return this._templates[phid]; | |||||
}, | |||||
getController: function() { | getController: function() { | ||||
return this._controller; | return this._controller; | ||||
}, | }, | ||||
setOrderMap: function(phid, map) { | |||||
this._orderMaps[phid] = map; | |||||
return this; | |||||
}, | |||||
getOrderVector: function(phid, key) { | |||||
return this._orderMaps[phid][key]; | |||||
}, | |||||
compareVectors: function(u_vec, v_vec) { | compareVectors: function(u_vec, v_vec) { | ||||
for (var ii = 0; ii < u_vec.length; ii++) { | for (var ii = 0; ii < u_vec.length; ii++) { | ||||
if (u_vec[ii] > v_vec[ii]) { | if (u_vec[ii] > v_vec[ii]) { | ||||
return 1; | return 1; | ||||
} | } | ||||
if (u_vec[ii] < v_vec[ii]) { | if (u_vec[ii] < v_vec[ii]) { | ||||
return -1; | return -1; | ||||
▲ Show 20 Lines • Show All 177 Lines • ▼ Show 20 Lines | members: { | ||||
updateCard: function(response, options) { | updateCard: function(response, options) { | ||||
options = options || {}; | options = options || {}; | ||||
options.dirtyColumns = options.dirtyColumns || {}; | options.dirtyColumns = options.dirtyColumns || {}; | ||||
var columns = this.getColumns(); | var columns = this.getColumns(); | ||||
var phid = response.objectPHID; | var phid = response.objectPHID; | ||||
var card = this.getCardTemplate(phid); | |||||
if (!this._templates[phid]) { | |||||
epriestley: This might be a behavioral change / wrong, but I couldn't figure out why this check existed… | |||||
for (var add_phid in response.columnMaps) { | for (var add_phid in response.columnMaps) { | ||||
var target_column = this.getColumn(add_phid); | var target_column = this.getColumn(add_phid); | ||||
if (!target_column) { | if (!target_column) { | ||||
// If the column isn't visible, don't try to add a card to it. | // If the column isn't visible, don't try to add a card to it. | ||||
continue; | continue; | ||||
} | } | ||||
target_column.newCard(phid); | target_column.newCard(phid); | ||||
} | } | ||||
} | |||||
this.setCardTemplate(phid, response.cardHTML); | card.setNodeHTMLTemplate(response.cardHTML); | ||||
var order_maps = response.orderMaps; | var order_maps = response.orderMaps; | ||||
for (var order_phid in order_maps) { | for (var order_phid in order_maps) { | ||||
this.setOrderMap(order_phid, order_maps[order_phid]); | var card_template = this.getCardTemplate(order_phid); | ||||
for (var order_key in order_maps[order_phid]) { | |||||
card_template.setSortVector( | |||||
order_key, | |||||
order_maps[order_phid][order_key]); | |||||
} | |||||
} | } | ||||
var column_maps = response.columnMaps; | var column_maps = response.columnMaps; | ||||
var natural_column; | var natural_column; | ||||
for (var natural_phid in column_maps) { | for (var natural_phid in column_maps) { | ||||
natural_column = this.getColumn(natural_phid); | natural_column = this.getColumn(natural_phid); | ||||
if (!natural_column) { | if (!natural_column) { | ||||
// Our view of the board may be out of date, so we might get back | // Our view of the board may be out of date, so we might get back | ||||
// information about columns that aren't visible. Just ignore the | // information about columns that aren't visible. Just ignore the | ||||
// position information for any columns we aren't displaying on the | // position information for any columns we aren't displaying on the | ||||
// client. | // client. | ||||
continue; | continue; | ||||
} | } | ||||
natural_column.setNaturalOrder(column_maps[natural_phid]); | natural_column.setNaturalOrder(column_maps[natural_phid]); | ||||
} | } | ||||
var property_maps = response.propertyMaps; | var property_maps = response.propertyMaps; | ||||
for (var property_phid in property_maps) { | for (var property_phid in property_maps) { | ||||
this.setObjectProperties(property_phid, property_maps[property_phid]); | this.getCardTemplate(property_phid) | ||||
.setObjectProperties(property_maps[property_phid]); | |||||
} | } | ||||
for (var column_phid in columns) { | for (var column_phid in columns) { | ||||
var column = columns[column_phid]; | var column = columns[column_phid]; | ||||
var cards = column.getCards(); | var cards = column.getCards(); | ||||
for (var object_phid in cards) { | for (var object_phid in cards) { | ||||
if (object_phid !== phid) { | if (object_phid !== phid) { | ||||
Show All 25 Lines |
This might be a behavioral change / wrong, but I couldn't figure out why this check existed, and I've touched most of this code now in implementing the new "Group By Header" stuff. Generally, all the code handles updates to objects it already knows about gracefully, and the obvious cases (adding a new card / editing an existing card) appear to work fine, so I suspect this wasn't meaningful.