2014-01-13 21:23:57 +01:00
|
|
|
/**
|
|
|
|
* @provides javelin-behavior-project-boards
|
|
|
|
* @requires javelin-behavior
|
|
|
|
* javelin-dom
|
|
|
|
* javelin-util
|
2014-09-09 23:20:27 +02:00
|
|
|
* javelin-vector
|
2014-01-13 21:24:36 +01:00
|
|
|
* javelin-stratcom
|
|
|
|
* javelin-workflow
|
2016-02-10 14:59:46 +01:00
|
|
|
* javelin-workboard-controller
|
2019-03-19 23:27:21 +01:00
|
|
|
* javelin-workboard-drop-effect
|
2014-01-13 21:23:57 +01:00
|
|
|
*/
|
|
|
|
|
2015-04-28 23:51:49 +02:00
|
|
|
JX.behavior('project-boards', function(config, statics) {
|
2014-01-13 21:23:57 +01:00
|
|
|
|
2015-04-28 23:51:49 +02:00
|
|
|
function update_statics(update_config) {
|
|
|
|
statics.boardID = update_config.boardID;
|
|
|
|
statics.projectPHID = update_config.projectPHID;
|
|
|
|
statics.order = update_config.order;
|
|
|
|
statics.moveURI = update_config.moveURI;
|
|
|
|
}
|
|
|
|
|
2015-05-12 20:37:55 +02:00
|
|
|
function setup() {
|
2015-04-28 23:51:49 +02:00
|
|
|
JX.Stratcom.listen('click', 'boards-dropdown-menu', function(e) {
|
|
|
|
var data = e.getNodeData('boards-dropdown-menu');
|
|
|
|
if (data.menu) {
|
|
|
|
return;
|
2014-03-06 03:40:28 +01:00
|
|
|
}
|
2015-04-28 23:51:49 +02:00
|
|
|
|
|
|
|
e.kill();
|
|
|
|
|
|
|
|
var list = JX.$H(data.items).getFragment().firstChild;
|
|
|
|
|
|
|
|
var button = e.getNode('boards-dropdown-menu');
|
|
|
|
data.menu = new JX.PHUIXDropdownMenu(button);
|
|
|
|
data.menu.setContent(list);
|
|
|
|
data.menu.open();
|
2014-03-06 03:40:28 +01:00
|
|
|
});
|
2014-08-15 18:28:08 +02:00
|
|
|
|
2015-04-28 23:51:49 +02:00
|
|
|
JX.Stratcom.listen(
|
|
|
|
'quicksand-redraw',
|
|
|
|
null,
|
|
|
|
function (e) {
|
|
|
|
var data = e.getData();
|
|
|
|
if (!data.newResponse.boardConfig) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
var new_config;
|
|
|
|
if (data.fromServer) {
|
|
|
|
new_config = data.newResponse.boardConfig;
|
|
|
|
statics.boardConfigCache[data.newResponseID] = new_config;
|
|
|
|
} else {
|
|
|
|
new_config = statics.boardConfigCache[data.newResponseID];
|
|
|
|
statics.boardID = new_config.boardID;
|
|
|
|
}
|
|
|
|
update_statics(new_config);
|
|
|
|
});
|
2016-02-06 23:05:15 +01:00
|
|
|
|
2015-04-28 23:51:49 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!statics.setup) {
|
|
|
|
update_statics(config);
|
|
|
|
var current_page_id = JX.Quicksand.getCurrentPageID();
|
|
|
|
statics.boardConfigCache = {};
|
|
|
|
statics.boardConfigCache[current_page_id] = config;
|
2015-05-12 20:37:55 +02:00
|
|
|
statics.setup = setup();
|
2015-04-28 23:51:49 +02:00
|
|
|
}
|
|
|
|
|
2016-02-09 13:47:25 +01:00
|
|
|
if (!statics.workboard) {
|
2016-02-10 14:59:46 +01:00
|
|
|
statics.workboard = new JX.WorkboardController()
|
2016-02-09 15:14:42 +01:00
|
|
|
.setUploadURI(config.uploadURI)
|
|
|
|
.setCoverURI(config.coverURI)
|
|
|
|
.setMoveURI(config.moveURI)
|
|
|
|
.setChunkThreshold(config.chunkThreshold)
|
|
|
|
.start();
|
2016-02-09 13:47:25 +01:00
|
|
|
}
|
|
|
|
|
2016-02-10 14:59:46 +01:00
|
|
|
var board_phid = config.projectPHID;
|
|
|
|
var board_node = JX.$(config.boardID);
|
|
|
|
|
|
|
|
var board = statics.workboard.newBoard(board_phid, board_node)
|
2016-02-10 22:53:36 +01:00
|
|
|
.setOrder(config.order)
|
|
|
|
.setPointsEnabled(config.pointsEnabled);
|
2016-02-10 14:59:46 +01:00
|
|
|
|
|
|
|
var templates = config.templateMap;
|
|
|
|
for (var k in templates) {
|
2019-03-11 03:53:25 +01:00
|
|
|
board.getCardTemplate(k)
|
|
|
|
.setNodeHTMLTemplate(templates[k]);
|
2016-02-10 14:59:46 +01:00
|
|
|
}
|
|
|
|
|
2019-03-11 16:58:46 +01:00
|
|
|
var ii;
|
2019-03-19 23:27:21 +01:00
|
|
|
var jj;
|
|
|
|
var effects;
|
|
|
|
|
|
|
|
for (ii = 0; ii < config.columnTemplates.length; ii++) {
|
|
|
|
var spec = config.columnTemplates[ii];
|
|
|
|
|
|
|
|
var column = board.getColumn(spec.columnPHID);
|
|
|
|
|
|
|
|
effects = [];
|
|
|
|
for (jj = 0; jj < spec.effects.length; jj++) {
|
|
|
|
effects.push(
|
|
|
|
JX.WorkboardDropEffect.newFromDictionary(
|
|
|
|
spec.effects[jj]));
|
|
|
|
}
|
|
|
|
column.setDropEffects(effects);
|
|
|
|
|
|
|
|
for (jj = 0; jj < spec.cardPHIDs.length; jj++) {
|
|
|
|
column.newCard(spec.cardPHIDs[jj]);
|
2016-02-10 14:59:46 +01:00
|
|
|
}
|
2019-03-21 21:19:12 +01:00
|
|
|
|
|
|
|
if (spec.triggerPreviewEffect) {
|
|
|
|
column.setTriggerPreviewEffect(
|
|
|
|
JX.WorkboardDropEffect.newFromDictionary(
|
|
|
|
spec.triggerPreviewEffect));
|
|
|
|
}
|
2016-02-10 14:59:46 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
var order_maps = config.orderMaps;
|
|
|
|
for (var object_phid in order_maps) {
|
2019-03-11 03:53:25 +01:00
|
|
|
var order_card = board.getCardTemplate(object_phid);
|
|
|
|
for (var order_key in order_maps[object_phid]) {
|
|
|
|
order_card.setSortVector(order_key, order_maps[object_phid][order_key]);
|
|
|
|
}
|
2016-02-10 14:59:46 +01:00
|
|
|
}
|
|
|
|
|
2016-02-10 22:53:36 +01:00
|
|
|
var property_maps = config.propertyMaps;
|
|
|
|
for (var property_phid in property_maps) {
|
2019-03-11 03:53:25 +01:00
|
|
|
board.getCardTemplate(property_phid)
|
|
|
|
.setObjectProperties(property_maps[property_phid]);
|
2016-02-10 22:53:36 +01:00
|
|
|
}
|
|
|
|
|
Add priority group headers to workboard columns (display only)
Summary:
Ref T10333. When workboards are ordered (for example, by priority), add headers to the various groups. Major goals are:
- Allow users to drag-and-drop to set values that no cards currently have: for example, you can change a card priority to "normal" by dragging it under the "normal" header, even if no other cards in the column are currently "Normal".
- Make future orderings more useful, particularly "order by assignee". We don't really have room to put the username on every card and it would create a fair amount of clutter, but we can put usernames in these headers and then reference them with just the profile picture. This also allows you to assign to users who are not currently assigned anything in a given column.
- Make the drag-and-drop behavior more obvious by showing what it will do more clearly (see T8135).
- Make things a little easier to scan in general: because space on cards is limited, some information isn't conveyed very clearly (for example, priority information is currently conveyed //only// through color, which can be hard to pick out visually and is probably not functional for users who need vision accommodations).
- Maybe do "swimlanes": this is pretty much a "swimlanes" UI if we add whitespace at the bottom of each group so that the headers line up across all the columns (e.g., "Normal" is at the same y-axis position in every column as you scroll down the page). Not sold on this being useful, but it's just a UI adjustment if we do want to try it.
NOTE: This only makes these headers work for display.
They aren't yet recognized as targets by the drag list UI, so you can't drag cards into an empty group. I'll tackle that in a followup.
Test Plan: {F6257686}
Reviewers: amckinley
Reviewed By: amckinley
Maniphest Tasks: T10333
Differential Revision: https://secure.phabricator.com/D20247
2019-03-05 15:00:12 +01:00
|
|
|
var headers = config.headers;
|
2019-03-11 16:58:46 +01:00
|
|
|
for (ii = 0; ii < headers.length; ii++) {
|
|
|
|
var header = headers[ii];
|
Add priority group headers to workboard columns (display only)
Summary:
Ref T10333. When workboards are ordered (for example, by priority), add headers to the various groups. Major goals are:
- Allow users to drag-and-drop to set values that no cards currently have: for example, you can change a card priority to "normal" by dragging it under the "normal" header, even if no other cards in the column are currently "Normal".
- Make future orderings more useful, particularly "order by assignee". We don't really have room to put the username on every card and it would create a fair amount of clutter, but we can put usernames in these headers and then reference them with just the profile picture. This also allows you to assign to users who are not currently assigned anything in a given column.
- Make the drag-and-drop behavior more obvious by showing what it will do more clearly (see T8135).
- Make things a little easier to scan in general: because space on cards is limited, some information isn't conveyed very clearly (for example, priority information is currently conveyed //only// through color, which can be hard to pick out visually and is probably not functional for users who need vision accommodations).
- Maybe do "swimlanes": this is pretty much a "swimlanes" UI if we add whitespace at the bottom of each group so that the headers line up across all the columns (e.g., "Normal" is at the same y-axis position in every column as you scroll down the page). Not sold on this being useful, but it's just a UI adjustment if we do want to try it.
NOTE: This only makes these headers work for display.
They aren't yet recognized as targets by the drag list UI, so you can't drag cards into an empty group. I'll tackle that in a followup.
Test Plan: {F6257686}
Reviewers: amckinley
Reviewed By: amckinley
Maniphest Tasks: T10333
Differential Revision: https://secure.phabricator.com/D20247
2019-03-05 15:00:12 +01:00
|
|
|
|
2019-03-19 23:27:21 +01:00
|
|
|
effects = [];
|
|
|
|
for (jj = 0; jj < header.effects.length; jj++) {
|
|
|
|
effects.push(
|
|
|
|
JX.WorkboardDropEffect.newFromDictionary(
|
|
|
|
header.effects[jj]));
|
|
|
|
}
|
|
|
|
|
Add priority group headers to workboard columns (display only)
Summary:
Ref T10333. When workboards are ordered (for example, by priority), add headers to the various groups. Major goals are:
- Allow users to drag-and-drop to set values that no cards currently have: for example, you can change a card priority to "normal" by dragging it under the "normal" header, even if no other cards in the column are currently "Normal".
- Make future orderings more useful, particularly "order by assignee". We don't really have room to put the username on every card and it would create a fair amount of clutter, but we can put usernames in these headers and then reference them with just the profile picture. This also allows you to assign to users who are not currently assigned anything in a given column.
- Make the drag-and-drop behavior more obvious by showing what it will do more clearly (see T8135).
- Make things a little easier to scan in general: because space on cards is limited, some information isn't conveyed very clearly (for example, priority information is currently conveyed //only// through color, which can be hard to pick out visually and is probably not functional for users who need vision accommodations).
- Maybe do "swimlanes": this is pretty much a "swimlanes" UI if we add whitespace at the bottom of each group so that the headers line up across all the columns (e.g., "Normal" is at the same y-axis position in every column as you scroll down the page). Not sold on this being useful, but it's just a UI adjustment if we do want to try it.
NOTE: This only makes these headers work for display.
They aren't yet recognized as targets by the drag list UI, so you can't drag cards into an empty group. I'll tackle that in a followup.
Test Plan: {F6257686}
Reviewers: amckinley
Reviewed By: amckinley
Maniphest Tasks: T10333
Differential Revision: https://secure.phabricator.com/D20247
2019-03-05 15:00:12 +01:00
|
|
|
board.getHeaderTemplate(header.key)
|
|
|
|
.setOrder(header.order)
|
Modularize workboard column orders
Summary:
Depends on D20267. Depends on D20268. Ref T10333. Currently, we support "Natural" and "Priority" orders, but a lot of the particulars are pretty hard-coded, including some logic in `ManiphestTask`.
Although it's not clear that we'll ever put other types of objects on workboards, it seems generally bad that you need to modify `ManiphestTask` to get a new ordering.
Pull the ordering logic out into a `ProjectColumnOrder` hierarchy instead, and let each ordering define the things it needs to work (name, icon, what headers look like, how different objects are sorted, and how to apply an edit when you drop an object under a header).
Then move the existing "Natural" and "Priority" orders into this new hierarchy.
This has a minor bug where using the "Edit" workflow to change a card's priority on a priority-ordered board doesn't fully refresh card/header order since the response isn't ordering-aware. I'll fix that in an upcoming change.
Test Plan: Grouped workboards by "Natural" and "Priority", dragged stuff around within and between columns, grepped for all touched symbols.
Reviewers: amckinley
Reviewed By: amckinley
Maniphest Tasks: T10333
Differential Revision: https://secure.phabricator.com/D20269
2019-03-11 05:49:12 +01:00
|
|
|
.setNodeHTMLTemplate(header.template)
|
Make drag-and-drop on workboards interact with priority column headers
Summary:
Ref T10333. Ref T8135. Depends on D20247. Allow users to drag-and-drop cards on a priority-sorted workboard under headers, even if the header has no other cards.
As of D20247, headers show up but they aren't really interactive. Now, you can drag cards directly underneath a header (instead of only between other cards). For example, if a column has only one "Wishlist" task, you may drag it under the "High", "Normal", or "Low" priority headers to select a specific priority.
(Some of this code still feels a little rough, but I think it will generalize once other types of sorting are available.)
Test Plan: Dragged cards within and between priority groups, saw appropriate priority edits applied in every case I could come up with.
Reviewers: amckinley
Reviewed By: amckinley
Maniphest Tasks: T10333, T8135
Differential Revision: https://secure.phabricator.com/D20248
2019-03-05 16:38:35 +01:00
|
|
|
.setVector(header.vector)
|
2019-03-19 23:27:21 +01:00
|
|
|
.setEditProperties(header.editProperties)
|
|
|
|
.setDropEffects(effects);
|
Add priority group headers to workboard columns (display only)
Summary:
Ref T10333. When workboards are ordered (for example, by priority), add headers to the various groups. Major goals are:
- Allow users to drag-and-drop to set values that no cards currently have: for example, you can change a card priority to "normal" by dragging it under the "normal" header, even if no other cards in the column are currently "Normal".
- Make future orderings more useful, particularly "order by assignee". We don't really have room to put the username on every card and it would create a fair amount of clutter, but we can put usernames in these headers and then reference them with just the profile picture. This also allows you to assign to users who are not currently assigned anything in a given column.
- Make the drag-and-drop behavior more obvious by showing what it will do more clearly (see T8135).
- Make things a little easier to scan in general: because space on cards is limited, some information isn't conveyed very clearly (for example, priority information is currently conveyed //only// through color, which can be hard to pick out visually and is probably not functional for users who need vision accommodations).
- Maybe do "swimlanes": this is pretty much a "swimlanes" UI if we add whitespace at the bottom of each group so that the headers line up across all the columns (e.g., "Normal" is at the same y-axis position in every column as you scroll down the page). Not sold on this being useful, but it's just a UI adjustment if we do want to try it.
NOTE: This only makes these headers work for display.
They aren't yet recognized as targets by the drag list UI, so you can't drag cards into an empty group. I'll tackle that in a followup.
Test Plan: {F6257686}
Reviewers: amckinley
Reviewed By: amckinley
Maniphest Tasks: T10333
Differential Revision: https://secure.phabricator.com/D20247
2019-03-05 15:00:12 +01:00
|
|
|
}
|
|
|
|
|
2019-03-11 16:58:46 +01:00
|
|
|
var orders = config.orders;
|
|
|
|
for (ii = 0; ii < orders.length; ii++) {
|
|
|
|
var order = orders[ii];
|
|
|
|
|
|
|
|
board.getOrderTemplate(order.orderKey)
|
|
|
|
.setHasHeaders(order.hasHeaders)
|
|
|
|
.setCanReorder(order.canReorder);
|
|
|
|
}
|
|
|
|
|
Modularize workboard column orders
Summary:
Depends on D20267. Depends on D20268. Ref T10333. Currently, we support "Natural" and "Priority" orders, but a lot of the particulars are pretty hard-coded, including some logic in `ManiphestTask`.
Although it's not clear that we'll ever put other types of objects on workboards, it seems generally bad that you need to modify `ManiphestTask` to get a new ordering.
Pull the ordering logic out into a `ProjectColumnOrder` hierarchy instead, and let each ordering define the things it needs to work (name, icon, what headers look like, how different objects are sorted, and how to apply an edit when you drop an object under a header).
Then move the existing "Natural" and "Priority" orders into this new hierarchy.
This has a minor bug where using the "Edit" workflow to change a card's priority on a priority-ordered board doesn't fully refresh card/header order since the response isn't ordering-aware. I'll fix that in an upcoming change.
Test Plan: Grouped workboards by "Natural" and "Priority", dragged stuff around within and between columns, grepped for all touched symbols.
Reviewers: amckinley
Reviewed By: amckinley
Maniphest Tasks: T10333
Differential Revision: https://secure.phabricator.com/D20269
2019-03-11 05:49:12 +01:00
|
|
|
var header_keys = config.headerKeys;
|
|
|
|
for (var header_phid in header_keys) {
|
|
|
|
board.getCardTemplate(header_phid)
|
|
|
|
.setHeaderKey(config.order, header_keys[header_phid]);
|
|
|
|
}
|
|
|
|
|
2016-02-10 14:59:46 +01:00
|
|
|
board.start();
|
2016-02-09 13:47:25 +01:00
|
|
|
|
2019-03-21 23:22:09 +01:00
|
|
|
// In Safari, we can only play sounds that we've already loaded, and we can
|
|
|
|
// only load them in response to an explicit user interaction like a click.
|
|
|
|
var sounds = config.preloadSounds;
|
|
|
|
var listener = JX.Stratcom.listen('mousedown', null, function() {
|
|
|
|
for (var ii = 0; ii < sounds.length; ii++) {
|
|
|
|
JX.Sound.load(sounds[ii]);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Remove this callback once it has run once.
|
|
|
|
listener.remove();
|
|
|
|
});
|
|
|
|
|
2014-01-13 21:23:57 +01:00
|
|
|
});
|