mirror of
https://we.phorge.it/source/phorge.git
synced 2025-01-03 03:11:01 +01: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:
parent
3f920d8904
commit
9bca1a56da
4 changed files with 108 additions and 36 deletions
|
@ -415,7 +415,8 @@ return array(
|
||||||
'rsrc/js/application/phortune/phortune-credit-card-form.js' => '2290aeef',
|
'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-control.js' => 'd0c516d5',
|
||||||
'rsrc/js/application/policy/behavior-policy-rule-editor.js' => '5e9f347c',
|
'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-project-create.js' => '065227cc',
|
||||||
'rsrc/js/application/projects/behavior-reorder-columns.js' => 'e1d25dfb',
|
'rsrc/js/application/projects/behavior-reorder-columns.js' => 'e1d25dfb',
|
||||||
'rsrc/js/application/releeph/releeph-preview-branch.js' => 'b2b4fbaf',
|
'rsrc/js/application/releeph/releeph-preview-branch.js' => 'b2b4fbaf',
|
||||||
|
@ -655,7 +656,7 @@ return array(
|
||||||
'javelin-behavior-phui-profile-menu' => '12884df9',
|
'javelin-behavior-phui-profile-menu' => '12884df9',
|
||||||
'javelin-behavior-policy-control' => 'd0c516d5',
|
'javelin-behavior-policy-control' => 'd0c516d5',
|
||||||
'javelin-behavior-policy-rule-editor' => '5e9f347c',
|
'javelin-behavior-policy-rule-editor' => '5e9f347c',
|
||||||
'javelin-behavior-project-boards' => 'a1807fd7',
|
'javelin-behavior-project-boards' => 'a1b41573',
|
||||||
'javelin-behavior-project-create' => '065227cc',
|
'javelin-behavior-project-create' => '065227cc',
|
||||||
'javelin-behavior-quicksand-blacklist' => '7927a7d3',
|
'javelin-behavior-quicksand-blacklist' => '7927a7d3',
|
||||||
'javelin-behavior-recurring-edit' => '5f1c4d5f',
|
'javelin-behavior-recurring-edit' => '5f1c4d5f',
|
||||||
|
@ -722,6 +723,7 @@ return array(
|
||||||
'javelin-view-renderer' => '6c2b09a2',
|
'javelin-view-renderer' => '6c2b09a2',
|
||||||
'javelin-view-visitor' => 'efe49472',
|
'javelin-view-visitor' => 'efe49472',
|
||||||
'javelin-websocket' => 'e292eaf4',
|
'javelin-websocket' => 'e292eaf4',
|
||||||
|
'javelin-workboard' => '761753ee',
|
||||||
'javelin-workflow' => '5b2e3e2b',
|
'javelin-workflow' => '5b2e3e2b',
|
||||||
'lightbox-attachment-css' => '7acac05d',
|
'lightbox-attachment-css' => '7acac05d',
|
||||||
'maniphest-batch-editor' => 'b0f0b6d5',
|
'maniphest-batch-editor' => 'b0f0b6d5',
|
||||||
|
@ -1393,6 +1395,16 @@ return array(
|
||||||
'javelin-json',
|
'javelin-json',
|
||||||
'phabricator-prefab',
|
'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(
|
'76b9fc3e' => array(
|
||||||
'javelin-behavior',
|
'javelin-behavior',
|
||||||
'javelin-stratcom',
|
'javelin-stratcom',
|
||||||
|
@ -1604,7 +1616,7 @@ return array(
|
||||||
'javelin-dom',
|
'javelin-dom',
|
||||||
'javelin-reactor-dom',
|
'javelin-reactor-dom',
|
||||||
),
|
),
|
||||||
'a1807fd7' => array(
|
'a1b41573' => array(
|
||||||
'javelin-behavior',
|
'javelin-behavior',
|
||||||
'javelin-dom',
|
'javelin-dom',
|
||||||
'javelin-util',
|
'javelin-util',
|
||||||
|
@ -1613,6 +1625,7 @@ return array(
|
||||||
'javelin-workflow',
|
'javelin-workflow',
|
||||||
'phabricator-draggable-list',
|
'phabricator-draggable-list',
|
||||||
'phabricator-drag-and-drop-file-upload',
|
'phabricator-drag-and-drop-file-upload',
|
||||||
|
'javelin-workboard',
|
||||||
),
|
),
|
||||||
'a2828756' => array(
|
'a2828756' => array(
|
||||||
'javelin-dom',
|
'javelin-dom',
|
||||||
|
|
|
@ -231,7 +231,12 @@ final class PhabricatorProjectBoardViewController
|
||||||
|
|
||||||
$board = id(new PHUIWorkboardView())
|
$board = id(new PHUIWorkboardView())
|
||||||
->setUser($viewer)
|
->setUser($viewer)
|
||||||
->setID($board_id);
|
->setID($board_id)
|
||||||
|
->addSigil('jx-workboard')
|
||||||
|
->setMetadata(
|
||||||
|
array(
|
||||||
|
'boardPHID' => $project->getPHID(),
|
||||||
|
));
|
||||||
|
|
||||||
$behavior_config = array(
|
$behavior_config = array(
|
||||||
'boardID' => $board_id,
|
'boardID' => $board_id,
|
||||||
|
|
79
webroot/rsrc/js/application/projects/Workboard.js
Normal file
79
webroot/rsrc/js/application/projects/Workboard.js
Normal 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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
|
@ -8,6 +8,7 @@
|
||||||
* javelin-workflow
|
* javelin-workflow
|
||||||
* phabricator-draggable-list
|
* phabricator-draggable-list
|
||||||
* phabricator-drag-and-drop-file-upload
|
* phabricator-drag-and-drop-file-upload
|
||||||
|
* javelin-workboard
|
||||||
*/
|
*/
|
||||||
|
|
||||||
JX.behavior('project-boards', function(config, statics) {
|
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
|
// When the user drags the workboard background, pan the workboard
|
||||||
// horizontally. This allows you to scroll across cards with only the
|
// horizontally. This allows you to scroll across cards with only the
|
||||||
// mouse, without shift + scrollwheel or using the scrollbar.
|
// mouse, without shift + scrollwheel or using the scrollbar.
|
||||||
|
@ -435,4 +404,10 @@ JX.behavior('project-boards', function(config, statics) {
|
||||||
statics.setup = setup();
|
statics.setup = setup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!statics.workboard) {
|
||||||
|
statics.workboard = new JX.Workboard(config);
|
||||||
|
}
|
||||||
|
|
||||||
|
statics.workboard.addBoard(config.projectPHID, JX.$(config.boardID));
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue