1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-26 08:42:41 +01:00

Show transaction types in Maniphest previews

Summary: When rendering a Maniphest comment preview, also render a preview of the transaction.

Test Plan: tested previews for all transaction types, got reasonable renders
This commit is contained in:
epriestley 2011-05-11 04:17:48 -07:00
parent 3b8ff34f9b
commit 47895afbd1
4 changed files with 72 additions and 12 deletions

View file

@ -284,16 +284,18 @@ class ManiphestTaskDetailController extends ManiphestController {
id(new AphrontFormSubmitControl()) id(new AphrontFormSubmitControl())
->setValue('Avast!')); ->setValue('Avast!'));
Javelin::initBehavior('maniphest-transaction-controls', array( $control_map = array(
'select' => 'transaction-action',
'controlMap' => array(
ManiphestTransactionType::TYPE_STATUS => 'resolution', ManiphestTransactionType::TYPE_STATUS => 'resolution',
ManiphestTransactionType::TYPE_OWNER => 'assign_to', ManiphestTransactionType::TYPE_OWNER => 'assign_to',
ManiphestTransactionType::TYPE_CCS => 'ccs', ManiphestTransactionType::TYPE_CCS => 'ccs',
ManiphestTransactionType::TYPE_PRIORITY => 'priority', ManiphestTransactionType::TYPE_PRIORITY => 'priority',
ManiphestTransactionType::TYPE_PROJECTS => 'projects', ManiphestTransactionType::TYPE_PROJECTS => 'projects',
ManiphestTransactionType::TYPE_ATTACH => 'file', ManiphestTransactionType::TYPE_ATTACH => 'file',
), );
Javelin::initBehavior('maniphest-transaction-controls', array(
'select' => 'transaction-action',
'controlMap' => $control_map,
'tokenizers' => array( 'tokenizers' => array(
ManiphestTransactionType::TYPE_PROJECTS => array( ManiphestTransactionType::TYPE_PROJECTS => array(
'id' => 'projects-tokenizer', 'id' => 'projects-tokenizer',
@ -317,6 +319,8 @@ class ManiphestTaskDetailController extends ManiphestController {
'uri' => '/maniphest/transaction/preview/'.$task->getID().'/', 'uri' => '/maniphest/transaction/preview/'.$task->getID().'/',
'preview' => 'transaction-preview', 'preview' => 'transaction-preview',
'comments' => 'transaction-comments', 'comments' => 'transaction-comments',
'action' => 'transaction-action',
'map' => $control_map,
)); ));

View file

@ -48,13 +48,31 @@ class ManiphestTransactionPreviewController extends ManiphestController {
$draft->setDraft($comments); $draft->setDraft($comments);
$draft->save(); $draft->save();
$handles = id(new PhabricatorObjectHandleData(array($user->getPHID()))) $phids = array($user->getPHID());
->loadHandles();
$action = $request->getStr('action');
$transaction = new ManiphestTransaction(); $transaction = new ManiphestTransaction();
$transaction->setAuthorPHID($user->getPHID()); $transaction->setAuthorPHID($user->getPHID());
$transaction->setComments($comments); $transaction->setComments($comments);
$transaction->setTransactionType(ManiphestTransactionType::TYPE_NONE); $transaction->setTransactionType($action);
$value = $request->getStr('value');
switch ($action) {
case ManiphestTransactionType::TYPE_OWNER:
if (!$value) {
$value = $user->getPHID();
}
$phids[] = $value;
break;
case ManiphestTransactionType::TYPE_PRIORITY:
$transaction->setOldValue($task->getPriority());
break;
}
$transaction->setNewValue($value);
$handles = id(new PhabricatorObjectHandleData($phids))
->loadHandles();
$transactions = array(); $transactions = array();
$transactions[] = $transaction; $transactions[] = $transaction;

View file

@ -198,6 +198,11 @@ class ManiphestTransactionDetailView extends AphrontView {
} }
break; break;
case ManiphestTransactionType::TYPE_CCS: case ManiphestTransactionType::TYPE_CCS:
if ($this->preview) {
$verb = 'Changed CC';
$desc = 'changed CCs..';
break;
}
$added = array_diff($new, $old); $added = array_diff($new, $old);
$removed = array_diff($old, $new); $removed = array_diff($old, $new);
if ($added && !$removed) { if ($added && !$removed) {
@ -221,6 +226,11 @@ class ManiphestTransactionDetailView extends AphrontView {
} }
break; break;
case ManiphestTransactionType::TYPE_PROJECTS: case ManiphestTransactionType::TYPE_PROJECTS:
if ($this->preview) {
$verb = 'Changed Projects';
$desc = 'changed projects..';
break;
}
$added = array_diff($new, $old); $added = array_diff($new, $old);
$removed = array_diff($old, $new); $removed = array_diff($old, $new);
if ($added && !$removed) { if ($added && !$removed) {
@ -286,6 +296,12 @@ class ManiphestTransactionDetailView extends AphrontView {
} }
break; break;
case ManiphestTransactionType::TYPE_ATTACH: case ManiphestTransactionType::TYPE_ATTACH:
if ($this->preview) {
$verb = 'Changed Attached';
$desc = 'changed attachments..';
break;
}
$old_raw = nonempty($old, array()); $old_raw = nonempty($old, array());
$new_raw = nonempty($new, array()); $new_raw = nonempty($new, array());
@ -330,6 +346,7 @@ class ManiphestTransactionDetailView extends AphrontView {
$desc = 'detached '.$plural.': '.$rem_desc; $desc = 'detached '.$plural.': '.$rem_desc;
} }
} else { } else {
$verb = 'Changed Attached';
$desc = 'changed attached '.$plural.', added: '.$add_desc. $desc = 'changed attached '.$plural.', added: '.$add_desc.
'removed: '.$rem_desc; 'removed: '.$rem_desc;
} }

View file

@ -9,14 +9,34 @@
JX.behavior('maniphest-transaction-preview', function(config) { JX.behavior('maniphest-transaction-preview', function(config) {
var comments = JX.$(config.comments); var comments = JX.$(config.comments);
var action = JX.$(config.action);
var callback = function(r) { var callback = function(r) {
JX.DOM.setContent(JX.$(config.preview), JX.$H(r)); JX.DOM.setContent(JX.$(config.preview), JX.$H(r));
}; };
var getdata = function() { var getdata = function() {
var selected = action.value;
var value = null;
try {
var control = JX.$(config.map[selected]);
var input = ([]
.concat(JX.DOM.scry(control, 'select'))
.concat(JX.DOM.scry(control, 'input')))[0];
value = input.value;
if (JX.DOM.isType(input, 'input') && input.type != 'hidden') {
// Avoid reading 'value' out of the tokenizer free text input.
value = null;
}
} catch (_ignored_) {
// Ignored.
}
return { return {
comments : comments.value comments : comments.value,
action : selected,
value : value || ''
}; };
} }
@ -24,6 +44,7 @@ JX.behavior('maniphest-transaction-preview', function(config) {
var trigger = JX.bind(request, request.trigger); var trigger = JX.bind(request, request.trigger);
JX.DOM.listen(comments, 'keydown', null, trigger); JX.DOM.listen(comments, 'keydown', null, trigger);
JX.DOM.listen(action, 'change', null, trigger);
request.start(); request.start();
}); });