1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-30 02:32:42 +01:00
phorge-phorge/webroot/rsrc/js/application/projects/Workboard.js
epriestley 9bca1a56da 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
2016-02-10 13:04:27 -08:00

79 lines
1.9 KiB
JavaScript

/**
* @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();
}
}
});