1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-25 06:50:55 +01:00

Run Maniphest batch edits through modern editor

Summary:
Ref T2217. Swaps batch edits to modern editor.

Also, fix some issues with required fields and viewers being required to render certain standard fields (notably, date).

Test Plan: Made various batch edits, verified they went through properly.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T2217

Differential Revision: https://secure.phabricator.com/D7083
This commit is contained in:
epriestley 2013-09-23 14:32:22 -07:00
parent 2bc46f097e
commit 6fd1e01fe7
4 changed files with 32 additions and 11 deletions

View file

@ -22,11 +22,20 @@ final class ManiphestBatchEditController extends ManiphestController {
if ($request->isFormPost() && is_array($actions)) { if ($request->isFormPost() && is_array($actions)) {
foreach ($tasks as $task) { foreach ($tasks as $task) {
$field_list = PhabricatorCustomField::getObjectFields(
$task,
PhabricatorCustomField::ROLE_EDIT);
$field_list->readFieldsFromStorage($task);
$xactions = $this->buildTransactions($actions, $task); $xactions = $this->buildTransactions($actions, $task);
if ($xactions) { if ($xactions) {
$editor = new ManiphestTransactionEditor(); // TODO: Set content source to "batch edit".
$editor->setActor($user);
$editor->applyTransactions($task, $xactions); $editor = id(new ManiphestTransactionEditorPro())
->setActor($user)
->setContentSourceFromRequest($request)
->setContinueOnNoEffect(true)
->applyTransactions($task, $xactions);
} }
} }
@ -296,13 +305,7 @@ final class ManiphestBatchEditController extends ManiphestController {
$value_map[$type] = $value; $value_map[$type] = $value;
} }
$template = new ManiphestTransaction(); $template = new ManiphestTransactionPro();
$template->setAuthorPHID($this->getRequest()->getUser()->getPHID());
// TODO: Set content source to "batch edit".
$template->setContentSource(
PhabricatorContentSource::newFromRequest($this->getRequest()));
foreach ($value_map as $type => $value) { foreach ($value_map as $type => $value) {
$xaction = clone $template; $xaction = clone $template;
@ -310,7 +313,9 @@ final class ManiphestBatchEditController extends ManiphestController {
switch ($type) { switch ($type) {
case PhabricatorTransactions::TYPE_COMMENT: case PhabricatorTransactions::TYPE_COMMENT:
$xaction->setComments($value); $xaction->attachComment(
id(new ManiphestTransactionComment())
->setContent($value));
break; break;
default: default:
$xaction->setNewValue($value); $xaction->setNewValue($value);

View file

@ -253,6 +253,7 @@ final class ManiphestTransactionEditor extends PhabricatorEditor {
$main_body = array(); $main_body = array();
foreach ($transactions as $transaction) { foreach ($transactions as $transaction) {
$main_body[] = id(clone $transaction->getModernTransaction()) $main_body[] = id(clone $transaction->getModernTransaction())
->attachViewer($this->getActor())
->setHandles($handles) ->setHandles($handles)
->setRenderingTarget('text') ->setRenderingTarget('text')
->getTitle(); ->getTitle();

View file

@ -65,6 +65,10 @@ abstract class PhabricatorApplicationTransactionQuery
$xactions = $table->loadAllFromArray($data); $xactions = $table->loadAllFromArray($data);
foreach ($xactions as $xaction) {
$xaction->attachViewer($this->getViewer());
}
if ($this->needComments) { if ($this->needComments) {
$comment_phids = array_filter(mpull($xactions, 'getCommentPHID')); $comment_phids = array_filter(mpull($xactions, 'getCommentPHID'));

View file

@ -28,6 +28,7 @@ abstract class PhabricatorApplicationTransaction
private $handles; private $handles;
private $renderingTarget = self::TARGET_HTML; private $renderingTarget = self::TARGET_HTML;
private $transactionGroup = array(); private $transactionGroup = array();
private $viewer = self::ATTACHABLE;
abstract public function getApplicationTransactionType(); abstract public function getApplicationTransactionType();
@ -120,6 +121,15 @@ abstract class PhabricatorApplicationTransaction
return $this->renderingTarget; return $this->renderingTarget;
} }
public function attachViewer(PhabricatorUser $viewer) {
$this->viewer = $viewer;
return $this;
}
public function getViewer() {
return $this->assertAttached($this->viewer);
}
public function getRequiredHandlePHIDs() { public function getRequiredHandlePHIDs() {
$phids = array(); $phids = array();
@ -363,6 +373,7 @@ abstract class PhabricatorApplicationTransaction
PhabricatorCustomField::ROLE_APPLICATIONTRANSACTIONS, PhabricatorCustomField::ROLE_APPLICATIONTRANSACTIONS,
$key); $key);
if ($field) { if ($field) {
$field->setViewer($this->getViewer());
return $field->getApplicationTransactionTitle($this); return $field->getApplicationTransactionTitle($this);
} else { } else {
return pht( return pht(