mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-10 08:52:39 +01:00
Provide Maniphest auxiliary fields access to the viewer and task
Summary: Maniphest auxiliary fields currently do not have access to the viewing user or task. This is fine for very simple fields, but insufficient for more complex fields. Generally, bring these in line with DifferentialFieldSpecifications. This supercedes the additional $user/$viewer threading provided by D5247 and provides viewers to all fields, as well as access to the task object itself. Test Plan: Created, viewed and edited a task with custom fields. Created a similar subtask. Reviewers: hach-que, btrahan Reviewed By: btrahan CC: aran Maniphest Tasks: T2575 Differential Revision: https://secure.phabricator.com/D5280
This commit is contained in:
parent
e3181fcbe7
commit
a3099e27bc
4 changed files with 40 additions and 18 deletions
|
@ -12,6 +12,26 @@ abstract class ManiphestAuxiliaryFieldSpecification {
|
|||
private $auxiliaryKey;
|
||||
private $caption;
|
||||
private $value;
|
||||
private $user;
|
||||
private $task;
|
||||
|
||||
public function setTask(ManiphestTask $task) {
|
||||
$this->task = $task;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getTask() {
|
||||
return $this->task;
|
||||
}
|
||||
|
||||
public function setUser(PhabricatorUser $user) {
|
||||
$this->user = $user;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getUser() {
|
||||
return $this->user;
|
||||
}
|
||||
|
||||
public function setLabel($val) {
|
||||
$this->label = $val;
|
||||
|
|
|
@ -129,10 +129,7 @@ final class ManiphestTaskDetailController extends ManiphestController {
|
|||
$engine->process();
|
||||
|
||||
$extensions = ManiphestTaskExtensions::newExtensions();
|
||||
$aux_fields = $extensions->getAuxiliaryFieldSpecifications();
|
||||
if ($aux_fields) {
|
||||
$task->loadAndAttachAuxiliaryAttributes();
|
||||
}
|
||||
$aux_fields = $extensions->loadFields($task, $user);
|
||||
|
||||
$transaction_types = ManiphestTransactionType::getTransactionTypeMap();
|
||||
$resolution_types = ManiphestTaskStatus::getTaskStatusMap();
|
||||
|
@ -467,8 +464,6 @@ final class ManiphestTaskDetailController extends ManiphestController {
|
|||
: phutil_tag('em', array(), pht('None')));
|
||||
|
||||
foreach ($aux_fields as $aux_field) {
|
||||
$aux_key = $aux_field->getAuxiliaryKey();
|
||||
$aux_field->setValue($task->getAuxiliaryAttribute($aux_key));
|
||||
$value = $aux_field->renderForDetailView();
|
||||
if (strlen($value)) {
|
||||
$view->addProperty($aux_field->getLabel(), $value);
|
||||
|
|
|
@ -70,10 +70,9 @@ final class ManiphestTaskEditController extends ManiphestController {
|
|||
$e_title = true;
|
||||
|
||||
$extensions = ManiphestTaskExtensions::newExtensions();
|
||||
$aux_fields = $extensions->getAuxiliaryFieldSpecifications();
|
||||
$aux_fields = $extensions->loadFields($task, $user);
|
||||
|
||||
if ($request->isFormPost()) {
|
||||
|
||||
$changes = array();
|
||||
|
||||
$new_title = $request->getStr('title');
|
||||
|
@ -185,7 +184,6 @@ final class ManiphestTaskEditController extends ManiphestController {
|
|||
}
|
||||
|
||||
if ($aux_fields) {
|
||||
$task->loadAndAttachAuxiliaryAttributes();
|
||||
foreach ($aux_fields as $aux_field) {
|
||||
$transaction = clone $template;
|
||||
$transaction->setTransactionType(
|
||||
|
@ -253,15 +251,6 @@ final class ManiphestTaskEditController extends ManiphestController {
|
|||
->setURI($redirect_uri);
|
||||
}
|
||||
} else {
|
||||
if ($aux_fields) {
|
||||
$task->loadAndAttachAuxiliaryAttributes();
|
||||
foreach ($aux_fields as $aux_field) {
|
||||
$aux_key = $aux_field->getAuxiliaryKey();
|
||||
$value = $task->getAuxiliaryAttribute($aux_key);
|
||||
$aux_field->setValueFromStorage($value);
|
||||
}
|
||||
}
|
||||
|
||||
if (!$task->getID()) {
|
||||
$task->setCCPHIDs(array(
|
||||
$user->getPHID(),
|
||||
|
|
|
@ -17,4 +17,22 @@ abstract class ManiphestTaskExtensions {
|
|||
return PhabricatorEnv::newObjectFromConfig($key);
|
||||
}
|
||||
|
||||
public function loadFields(ManiphestTask $task, PhabricatorUser $viewer) {
|
||||
$aux_fields = $this->getAuxiliaryFieldSpecifications();
|
||||
if (!$aux_fields) {
|
||||
return array();
|
||||
}
|
||||
|
||||
$task->loadAndAttachAuxiliaryAttributes();
|
||||
foreach ($aux_fields as $aux) {
|
||||
$aux->setUser($viewer);
|
||||
$aux->setTask($task);
|
||||
|
||||
$key = $aux->getAuxiliaryKey();
|
||||
$aux->setValueFromStorage($task->getAuxiliaryAttribute($key));
|
||||
}
|
||||
|
||||
return $aux_fields;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue