mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-23 22:10: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:
parent
2bc46f097e
commit
6fd1e01fe7
4 changed files with 32 additions and 11 deletions
|
@ -22,11 +22,20 @@ final class ManiphestBatchEditController extends ManiphestController {
|
|||
|
||||
if ($request->isFormPost() && is_array($actions)) {
|
||||
foreach ($tasks as $task) {
|
||||
$field_list = PhabricatorCustomField::getObjectFields(
|
||||
$task,
|
||||
PhabricatorCustomField::ROLE_EDIT);
|
||||
$field_list->readFieldsFromStorage($task);
|
||||
|
||||
$xactions = $this->buildTransactions($actions, $task);
|
||||
if ($xactions) {
|
||||
$editor = new ManiphestTransactionEditor();
|
||||
$editor->setActor($user);
|
||||
$editor->applyTransactions($task, $xactions);
|
||||
// TODO: Set content source to "batch edit".
|
||||
|
||||
$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;
|
||||
}
|
||||
|
||||
$template = new ManiphestTransaction();
|
||||
$template->setAuthorPHID($this->getRequest()->getUser()->getPHID());
|
||||
|
||||
// TODO: Set content source to "batch edit".
|
||||
|
||||
$template->setContentSource(
|
||||
PhabricatorContentSource::newFromRequest($this->getRequest()));
|
||||
$template = new ManiphestTransactionPro();
|
||||
|
||||
foreach ($value_map as $type => $value) {
|
||||
$xaction = clone $template;
|
||||
|
@ -310,7 +313,9 @@ final class ManiphestBatchEditController extends ManiphestController {
|
|||
|
||||
switch ($type) {
|
||||
case PhabricatorTransactions::TYPE_COMMENT:
|
||||
$xaction->setComments($value);
|
||||
$xaction->attachComment(
|
||||
id(new ManiphestTransactionComment())
|
||||
->setContent($value));
|
||||
break;
|
||||
default:
|
||||
$xaction->setNewValue($value);
|
||||
|
|
|
@ -253,6 +253,7 @@ final class ManiphestTransactionEditor extends PhabricatorEditor {
|
|||
$main_body = array();
|
||||
foreach ($transactions as $transaction) {
|
||||
$main_body[] = id(clone $transaction->getModernTransaction())
|
||||
->attachViewer($this->getActor())
|
||||
->setHandles($handles)
|
||||
->setRenderingTarget('text')
|
||||
->getTitle();
|
||||
|
|
|
@ -65,6 +65,10 @@ abstract class PhabricatorApplicationTransactionQuery
|
|||
|
||||
$xactions = $table->loadAllFromArray($data);
|
||||
|
||||
foreach ($xactions as $xaction) {
|
||||
$xaction->attachViewer($this->getViewer());
|
||||
}
|
||||
|
||||
if ($this->needComments) {
|
||||
$comment_phids = array_filter(mpull($xactions, 'getCommentPHID'));
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@ abstract class PhabricatorApplicationTransaction
|
|||
private $handles;
|
||||
private $renderingTarget = self::TARGET_HTML;
|
||||
private $transactionGroup = array();
|
||||
private $viewer = self::ATTACHABLE;
|
||||
|
||||
abstract public function getApplicationTransactionType();
|
||||
|
||||
|
@ -120,6 +121,15 @@ abstract class PhabricatorApplicationTransaction
|
|||
return $this->renderingTarget;
|
||||
}
|
||||
|
||||
public function attachViewer(PhabricatorUser $viewer) {
|
||||
$this->viewer = $viewer;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getViewer() {
|
||||
return $this->assertAttached($this->viewer);
|
||||
}
|
||||
|
||||
public function getRequiredHandlePHIDs() {
|
||||
$phids = array();
|
||||
|
||||
|
@ -363,6 +373,7 @@ abstract class PhabricatorApplicationTransaction
|
|||
PhabricatorCustomField::ROLE_APPLICATIONTRANSACTIONS,
|
||||
$key);
|
||||
if ($field) {
|
||||
$field->setViewer($this->getViewer());
|
||||
return $field->getApplicationTransactionTitle($this);
|
||||
} else {
|
||||
return pht(
|
||||
|
|
Loading…
Reference in a new issue