1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-22 23:02:42 +01:00

Mostly move workboard card moves to new Workboard code

Summary:
Ref T4900. This gets moves on the new stuff and cleans them up a little.

Two behaviors haven't been ported yet: height adjustment during drags (which is broken anyway with inner scroll) and updating point counts (coming soon).

Test Plan: Dragged cards around on a board, including top/bottom positions and normal/priority sort.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T4900

Differential Revision: https://secure.phabricator.com/D15226
This commit is contained in:
epriestley 2016-02-09 05:30:08 -08:00
parent 3309ae1a30
commit bc591b1b5f
3 changed files with 109 additions and 121 deletions

View file

@ -415,8 +415,8 @@ return array(
'rsrc/js/application/phortune/phortune-credit-card-form.js' => '2290aeef',
'rsrc/js/application/policy/behavior-policy-control.js' => 'd0c516d5',
'rsrc/js/application/policy/behavior-policy-rule-editor.js' => '5e9f347c',
'rsrc/js/application/projects/Workboard.js' => '555f521a',
'rsrc/js/application/projects/behavior-project-boards.js' => '9ed304e5',
'rsrc/js/application/projects/Workboard.js' => 'b38d2c73',
'rsrc/js/application/projects/behavior-project-boards.js' => '7f4359dd',
'rsrc/js/application/projects/behavior-project-create.js' => '065227cc',
'rsrc/js/application/projects/behavior-reorder-columns.js' => 'e1d25dfb',
'rsrc/js/application/releeph/releeph-preview-branch.js' => 'b2b4fbaf',
@ -656,7 +656,7 @@ return array(
'javelin-behavior-phui-profile-menu' => '12884df9',
'javelin-behavior-policy-control' => 'd0c516d5',
'javelin-behavior-policy-rule-editor' => '5e9f347c',
'javelin-behavior-project-boards' => '9ed304e5',
'javelin-behavior-project-boards' => '7f4359dd',
'javelin-behavior-project-create' => '065227cc',
'javelin-behavior-quicksand-blacklist' => '7927a7d3',
'javelin-behavior-recurring-edit' => '5f1c4d5f',
@ -723,7 +723,7 @@ return array(
'javelin-view-renderer' => '6c2b09a2',
'javelin-view-visitor' => 'efe49472',
'javelin-websocket' => 'e292eaf4',
'javelin-workboard' => '555f521a',
'javelin-workboard' => 'b38d2c73',
'javelin-workflow' => '5b2e3e2b',
'lightbox-attachment-css' => '7acac05d',
'maniphest-batch-editor' => 'b0f0b6d5',
@ -1223,16 +1223,6 @@ return array(
'javelin-request',
'javelin-typeahead-source',
),
'555f521a' => array(
'javelin-install',
'javelin-dom',
'javelin-util',
'javelin-vector',
'javelin-stratcom',
'javelin-workflow',
'phabricator-draggable-list',
'phabricator-drag-and-drop-file-upload',
),
'558829c2' => array(
'javelin-stratcom',
'javelin-behavior',
@ -1456,6 +1446,17 @@ return array(
'javelin-behavior',
'javelin-history',
),
'7f4359dd' => array(
'javelin-behavior',
'javelin-dom',
'javelin-util',
'javelin-vector',
'javelin-stratcom',
'javelin-workflow',
'phabricator-draggable-list',
'phabricator-drag-and-drop-file-upload',
'javelin-workboard',
),
'805b806a' => array(
'javelin-magical-init',
'javelin-install',
@ -1597,17 +1598,6 @@ return array(
'javelin-dom',
'javelin-vector',
),
'9ed304e5' => array(
'javelin-behavior',
'javelin-dom',
'javelin-util',
'javelin-vector',
'javelin-stratcom',
'javelin-workflow',
'phabricator-draggable-list',
'phabricator-drag-and-drop-file-upload',
'javelin-workboard',
),
'9f36c42d' => array(
'javelin-behavior',
'javelin-stratcom',
@ -1727,6 +1717,16 @@ return array(
'javelin-uri',
'javelin-request',
),
'b38d2c73' => array(
'javelin-install',
'javelin-dom',
'javelin-util',
'javelin-vector',
'javelin-stratcom',
'javelin-workflow',
'phabricator-draggable-list',
'phabricator-drag-and-drop-file-upload',
),
'b3a4b884' => array(
'javelin-behavior',
'phabricator-prefab',

View file

@ -33,7 +33,11 @@ JX.install('Workboard', {
addBoard: function(board_phid, board_node) {
this._currentBoard = board_phid;
this._boardNodes[board_phid] = board_node;
if (!this._boardNodes[board_phid]) {
this._boardNodes[board_phid] = board_node;
this._setupDragHandlers(board_node);
}
},
_getConfig: function() {
@ -121,6 +125,85 @@ JX.install('Workboard', {
_onpanmouseup: function() {
this._panOrigin = null;
},
_setupDragHandlers: function(board_node) {
var columns = this._findBoardColumns(board_node);
var column;
var ii;
var lists = [];
for (ii = 0; ii < columns.length; ii++) {
column = columns[ii];
var list = new JX.DraggableList('project-card', column)
.setOuterContainer(board_node)
.setFindItemsHandler(JX.bind(this, this._findCardsInColumn, column))
.setCanDragX(true);
// TODO: Restore these behaviors.
// list.listen('didSend', JX.bind(list, onupdate, cols[ii]));
// list.listen('didReceive', JX.bind(list, onupdate, cols[ii]));
// onupdate(cols[ii]);
list.listen('didDrop', JX.bind(this, this._onmovecard, list));
// TODO: Restore these behaviors.
// list.listen('didBeginDrag', JX.bind(null, onbegindrag));
// list.listen('didEndDrag', JX.bind(null, onenddrag));
lists.push(list);
}
for (ii = 0; ii < lists.length; ii++) {
lists[ii].setGroup(lists);
}
},
_findBoardColumns: function(board_node) {
return JX.DOM.scry(board_node, 'ul', 'project-column');
},
_findCardsInColumn: function(column_node) {
return JX.DOM.scry(column_node, 'li', 'project-card');
},
_onmovecard: function(list, item, after_node) {
list.lock();
JX.DOM.alterClass(item, 'drag-sending', true);
var item_phid = JX.Stratcom.getData(item).objectPHID;
var data = {
objectPHID: item_phid,
columnPHID: JX.Stratcom.getData(list.getRootNode()).columnPHID
};
if (after_node) {
data.afterPHID = JX.Stratcom.getData(after_node).objectPHID;
}
var before_node = item.nextSibling;
if (before_node) {
var before_phid = JX.Stratcom.getData(before_node).objectPHID;
if (before_phid) {
data.beforePHID = before_phid;
}
}
// TODO: This should be managed per-board.
var config = this._getConfig();
data.order = config.order;
new JX.Workflow(config.moveURI, data)
.setHandler(JX.bind(this, this._oncardupdate, item, list))
.start();
},
_oncardupdate: function(item, list, response) {
list.unlock();
JX.DOM.alterClass(item, 'drag-sending', false);
JX.DOM.replace(item, JX.$H(response.task));
}
}

View file

@ -13,9 +13,6 @@
JX.behavior('project-boards', function(config, statics) {
function finditems(col) {
return JX.DOM.scry(col, 'li', 'project-card');
}
function onupdate(col) {
var data = JX.Stratcom.getData(col);
@ -64,15 +61,6 @@ JX.behavior('project-boards', function(config, statics) {
}
}
function onresponse(response, item, list) {
list.unlock();
JX.DOM.alterClass(item, 'drag-sending', false);
JX.DOM.replace(item, JX.$H(response.task));
}
function getcolumns() {
return JX.DOM.scry(JX.$(statics.boardID), 'ul', 'project-column');
}
function colsort(u, v) {
var ud = JX.Stratcom.getData(u).sort || [];
@ -126,56 +114,6 @@ JX.behavior('project-boards', function(config, statics) {
getcontainer().style.minHeight = '';
}
function ondrop(list, item, after) {
list.lock();
JX.DOM.alterClass(item, 'drag-sending', true);
var item_phid = JX.Stratcom.getData(item).objectPHID;
var data = {
objectPHID: item_phid,
columnPHID: JX.Stratcom.getData(list.getRootNode()).columnPHID
};
var after_phid = null;
var items = finditems(list.getRootNode());
if (after) {
after_phid = JX.Stratcom.getData(after).objectPHID;
data.afterPHID = after_phid;
}
var ii;
var ii_item;
var ii_item_phid;
var ii_prev_item_phid = null;
var before_phid = null;
for (ii = 0; ii < items.length; ii++) {
ii_item = items[ii];
ii_item_phid = JX.Stratcom.getData(ii_item).objectPHID;
if (ii_item_phid == item_phid) {
// skip the item we just dropped
continue;
}
// note this handles when there is no after phid - we are at the top of
// the list - quite nicely
if (ii_prev_item_phid == after_phid) {
before_phid = ii_item_phid;
break;
}
ii_prev_item_phid = ii_item_phid;
}
if (before_phid) {
data.beforePHID = before_phid;
}
data.order = statics.order;
var workflow = new JX.Workflow(statics.moveURI, data)
.setHandler(function(response) {
onresponse(response, item, list);
});
workflow.start();
}
function onedit(column, r) {
var new_card = JX.$H(r.tasks).getNode();
var new_data = JX.Stratcom.getData(new_card);
@ -226,35 +164,6 @@ JX.behavior('project-boards', function(config, statics) {
statics.createURI = update_config.createURI;
}
function init_board() {
var lists = [];
var ii;
var cols = getcolumns();
for (ii = 0; ii < cols.length; ii++) {
var list = new JX.DraggableList('project-card', cols[ii])
.setFindItemsHandler(JX.bind(null, finditems, cols[ii]))
.setOuterContainer(JX.$(config.boardID))
.setCanDragX(true);
list.listen('didSend', JX.bind(list, onupdate, cols[ii]));
list.listen('didReceive', JX.bind(list, onupdate, cols[ii]));
list.listen('didDrop', JX.bind(null, ondrop, list));
list.listen('didBeginDrag', JX.bind(null, onbegindrag));
list.listen('didEndDrag', JX.bind(null, onenddrag));
lists.push(list);
onupdate(cols[ii]);
}
for (ii = 0; ii < lists.length; ii++) {
lists[ii].setGroup(lists);
}
}
function setup() {
JX.Stratcom.listen(
@ -346,9 +255,6 @@ JX.behavior('project-boards', function(config, statics) {
statics.boardID = new_config.boardID;
}
update_statics(new_config);
if (data.fromServer) {
init_board();
}
});
return true;
@ -359,7 +265,6 @@ JX.behavior('project-boards', function(config, statics) {
var current_page_id = JX.Quicksand.getCurrentPageID();
statics.boardConfigCache = {};
statics.boardConfigCache[current_page_id] = config;
init_board();
statics.setup = setup();
}