1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-09-20 01:08:50 +02:00

Begin generalizing Javascript for Workboard state handling

Summary:
Ref T4900. Broadly, workboard state management is fairly ad-hoc now, which makes things like this (where some kind of edit affects global state) difficult:

  - Updating points header to reflect a sum change after dragging a task.
  - Changing progress bars after editing a task to change resolution or points value.
  - Moving a card to the correct column after editing it and changing subprojects/iterations.
  - Responding to real-time notifications about other users moving cards.

This begins rewriting the code in a way that can better accommodate these kinds of far-reaching state update.

This change just moves cover image stuff. I'll continue moving features one at a time until boards work better.

Test Plan: Updated some cover images.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T4900

Differential Revision: https://secure.phabricator.com/D15224
This commit is contained in:
epriestley 2016-02-09 04:47:25 -08:00
parent 3f920d8904
commit 9bca1a56da
4 changed files with 108 additions and 36 deletions

View file

@ -415,7 +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/behavior-project-boards.js' => 'a1807fd7',
'rsrc/js/application/projects/Workboard.js' => '761753ee',
'rsrc/js/application/projects/behavior-project-boards.js' => 'a1b41573',
'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',
@ -655,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' => 'a1807fd7',
'javelin-behavior-project-boards' => 'a1b41573',
'javelin-behavior-project-create' => '065227cc',
'javelin-behavior-quicksand-blacklist' => '7927a7d3',
'javelin-behavior-recurring-edit' => '5f1c4d5f',
@ -722,6 +723,7 @@ return array(
'javelin-view-renderer' => '6c2b09a2',
'javelin-view-visitor' => 'efe49472',
'javelin-websocket' => 'e292eaf4',
'javelin-workboard' => '761753ee',
'javelin-workflow' => '5b2e3e2b',
'lightbox-attachment-css' => '7acac05d',
'maniphest-batch-editor' => 'b0f0b6d5',
@ -1393,6 +1395,16 @@ return array(
'javelin-json',
'phabricator-prefab',
),
'761753ee' => array(
'javelin-install',
'javelin-dom',
'javelin-util',
'javelin-vector',
'javelin-stratcom',
'javelin-workflow',
'phabricator-draggable-list',
'phabricator-drag-and-drop-file-upload',
),
'76b9fc3e' => array(
'javelin-behavior',
'javelin-stratcom',
@ -1604,7 +1616,7 @@ return array(
'javelin-dom',
'javelin-reactor-dom',
),
'a1807fd7' => array(
'a1b41573' => array(
'javelin-behavior',
'javelin-dom',
'javelin-util',
@ -1613,6 +1625,7 @@ return array(
'javelin-workflow',
'phabricator-draggable-list',
'phabricator-drag-and-drop-file-upload',
'javelin-workboard',
),
'a2828756' => array(
'javelin-dom',

View file

@ -231,7 +231,12 @@ final class PhabricatorProjectBoardViewController
$board = id(new PHUIWorkboardView())
->setUser($viewer)
->setID($board_id);
->setID($board_id)
->addSigil('jx-workboard')
->setMetadata(
array(
'boardPHID' => $project->getPHID(),
));
$behavior_config = array(
'boardID' => $board_id,

View file

@ -0,0 +1,79 @@
/**
* @provides javelin-workboard
* @requires javelin-install
* javelin-dom
* javelin-util
* javelin-vector
* javelin-stratcom
* javelin-workflow
* phabricator-draggable-list
* phabricator-drag-and-drop-file-upload
* @javelin
*/
JX.install('Workboard', {
construct: function(config) {
this._config = config;
this._boardNodes = {};
this._setupCoverImageHandlers();
},
members: {
_config: null,
_boardNodes: null,
_currentBoard: null,
addBoard: function(board_phid, board_node) {
this._currentBoard = board_phid;
this._boardNodes[board_phid] = board_node;
},
_getConfig: function() {
return this._config;
},
_setupCoverImageHandlers: function() {
if (!JX.PhabricatorDragAndDropFileUpload.isSupported()) {
return;
}
var config = this._getConfig();
var drop = new JX.PhabricatorDragAndDropFileUpload('project-card')
.setURI(config.uploadURI)
.setChunkThreshold(config.chunkThreshold);
drop.listen('didBeginDrag', function(node) {
JX.DOM.alterClass(node, 'phui-workcard-upload-target', true);
});
drop.listen('didEndDrag', function(node) {
JX.DOM.alterClass(node, 'phui-workcard-upload-target', false);
});
drop.listen('didUpload', function(file) {
var node = file.getTargetNode();
var board = JX.DOM.findAbove(node, 'div', 'jx-workboard');
var data = {
boardPHID: JX.Stratcom.getData(board).boardPHID,
objectPHID: JX.Stratcom.getData(node).objectPHID,
filePHID: file.getPHID()
};
new JX.Workflow(config.coverURI, data)
.setHandler(function(r) {
JX.DOM.replace(node, JX.$H(r.task));
})
.start();
});
drop.start();
}
}
});

View file

@ -8,6 +8,7 @@
* javelin-workflow
* phabricator-draggable-list
* phabricator-drag-and-drop-file-upload
* javelin-workboard
*/
JX.behavior('project-boards', function(config, statics) {
@ -350,38 +351,6 @@ JX.behavior('project-boards', function(config, statics) {
}
});
if (JX.PhabricatorDragAndDropFileUpload.isSupported()) {
var drop = new JX.PhabricatorDragAndDropFileUpload('project-card')
.setURI(config.uploadURI)
.setChunkThreshold(config.chunkThreshold);
drop.listen('didBeginDrag', function(node) {
JX.DOM.alterClass(node, 'phui-workcard-upload-target', true);
});
drop.listen('didEndDrag', function(node) {
JX.DOM.alterClass(node, 'phui-workcard-upload-target', false);
});
drop.listen('didUpload', function(file) {
var node = file.getTargetNode();
var data = {
boardPHID: statics.projectPHID,
objectPHID: JX.Stratcom.getData(node).objectPHID,
filePHID: file.getPHID()
};
new JX.Workflow(config.coverURI, data)
.setHandler(function(r) {
JX.DOM.replace(node, JX.$H(r.task));
})
.start();
});
drop.start();
}
// When the user drags the workboard background, pan the workboard
// horizontally. This allows you to scroll across cards with only the
// mouse, without shift + scrollwheel or using the scrollbar.
@ -435,4 +404,10 @@ JX.behavior('project-boards', function(config, statics) {
statics.setup = setup();
}
if (!statics.workboard) {
statics.workboard = new JX.Workboard(config);
}
statics.workboard.addBoard(config.projectPHID, JX.$(config.boardID));
});