mirror of
https://we.phorge.it/source/phorge.git
synced 2025-01-11 15:21:03 +01:00
Make "Create Subtask" work properly in EditEngine
Summary: Ref T9908. This fixes "Create Subtask" so it works with the new stuff. Mostly straightforward. Test Plan: Created some subtasks. Reviewers: chad Reviewed By: chad Maniphest Tasks: T9908 Differential Revision: https://secure.phabricator.com/D14706
This commit is contained in:
parent
e275964f43
commit
d53187e10a
11 changed files with 197 additions and 4 deletions
|
@ -120,6 +120,7 @@ phutil_register_library_map(array(
|
||||||
'AphrontFormDateControlValue' => 'view/form/control/AphrontFormDateControlValue.php',
|
'AphrontFormDateControlValue' => 'view/form/control/AphrontFormDateControlValue.php',
|
||||||
'AphrontFormDividerControl' => 'view/form/control/AphrontFormDividerControl.php',
|
'AphrontFormDividerControl' => 'view/form/control/AphrontFormDividerControl.php',
|
||||||
'AphrontFormFileControl' => 'view/form/control/AphrontFormFileControl.php',
|
'AphrontFormFileControl' => 'view/form/control/AphrontFormFileControl.php',
|
||||||
|
'AphrontFormHandlesControl' => 'view/form/control/AphrontFormHandlesControl.php',
|
||||||
'AphrontFormMarkupControl' => 'view/form/control/AphrontFormMarkupControl.php',
|
'AphrontFormMarkupControl' => 'view/form/control/AphrontFormMarkupControl.php',
|
||||||
'AphrontFormPasswordControl' => 'view/form/control/AphrontFormPasswordControl.php',
|
'AphrontFormPasswordControl' => 'view/form/control/AphrontFormPasswordControl.php',
|
||||||
'AphrontFormPolicyControl' => 'view/form/control/AphrontFormPolicyControl.php',
|
'AphrontFormPolicyControl' => 'view/form/control/AphrontFormPolicyControl.php',
|
||||||
|
@ -1310,9 +1311,11 @@ phutil_register_library_map(array(
|
||||||
'ManiphestTaskHeraldField' => 'applications/maniphest/herald/ManiphestTaskHeraldField.php',
|
'ManiphestTaskHeraldField' => 'applications/maniphest/herald/ManiphestTaskHeraldField.php',
|
||||||
'ManiphestTaskHeraldFieldGroup' => 'applications/maniphest/herald/ManiphestTaskHeraldFieldGroup.php',
|
'ManiphestTaskHeraldFieldGroup' => 'applications/maniphest/herald/ManiphestTaskHeraldFieldGroup.php',
|
||||||
'ManiphestTaskListController' => 'applications/maniphest/controller/ManiphestTaskListController.php',
|
'ManiphestTaskListController' => 'applications/maniphest/controller/ManiphestTaskListController.php',
|
||||||
|
'ManiphestTaskListHTTPParameterType' => 'applications/maniphest/httpparametertype/ManiphestTaskListHTTPParameterType.php',
|
||||||
'ManiphestTaskListView' => 'applications/maniphest/view/ManiphestTaskListView.php',
|
'ManiphestTaskListView' => 'applications/maniphest/view/ManiphestTaskListView.php',
|
||||||
'ManiphestTaskMailReceiver' => 'applications/maniphest/mail/ManiphestTaskMailReceiver.php',
|
'ManiphestTaskMailReceiver' => 'applications/maniphest/mail/ManiphestTaskMailReceiver.php',
|
||||||
'ManiphestTaskOpenStatusDatasource' => 'applications/maniphest/typeahead/ManiphestTaskOpenStatusDatasource.php',
|
'ManiphestTaskOpenStatusDatasource' => 'applications/maniphest/typeahead/ManiphestTaskOpenStatusDatasource.php',
|
||||||
|
'ManiphestTaskPHIDResolver' => 'applications/maniphest/httpparametertype/ManiphestTaskPHIDResolver.php',
|
||||||
'ManiphestTaskPHIDType' => 'applications/maniphest/phid/ManiphestTaskPHIDType.php',
|
'ManiphestTaskPHIDType' => 'applications/maniphest/phid/ManiphestTaskPHIDType.php',
|
||||||
'ManiphestTaskPriority' => 'applications/maniphest/constants/ManiphestTaskPriority.php',
|
'ManiphestTaskPriority' => 'applications/maniphest/constants/ManiphestTaskPriority.php',
|
||||||
'ManiphestTaskPriorityDatasource' => 'applications/maniphest/typeahead/ManiphestTaskPriorityDatasource.php',
|
'ManiphestTaskPriorityDatasource' => 'applications/maniphest/typeahead/ManiphestTaskPriorityDatasource.php',
|
||||||
|
@ -2306,6 +2309,7 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorHandlePool' => 'applications/phid/handle/pool/PhabricatorHandlePool.php',
|
'PhabricatorHandlePool' => 'applications/phid/handle/pool/PhabricatorHandlePool.php',
|
||||||
'PhabricatorHandlePoolTestCase' => 'applications/phid/handle/pool/__tests__/PhabricatorHandlePoolTestCase.php',
|
'PhabricatorHandlePoolTestCase' => 'applications/phid/handle/pool/__tests__/PhabricatorHandlePoolTestCase.php',
|
||||||
'PhabricatorHandleQuery' => 'applications/phid/query/PhabricatorHandleQuery.php',
|
'PhabricatorHandleQuery' => 'applications/phid/query/PhabricatorHandleQuery.php',
|
||||||
|
'PhabricatorHandlesEditField' => 'applications/transactions/editfield/PhabricatorHandlesEditField.php',
|
||||||
'PhabricatorHarbormasterApplication' => 'applications/harbormaster/application/PhabricatorHarbormasterApplication.php',
|
'PhabricatorHarbormasterApplication' => 'applications/harbormaster/application/PhabricatorHarbormasterApplication.php',
|
||||||
'PhabricatorHarbormasterConfigOptions' => 'applications/harbormaster/config/PhabricatorHarbormasterConfigOptions.php',
|
'PhabricatorHarbormasterConfigOptions' => 'applications/harbormaster/config/PhabricatorHarbormasterConfigOptions.php',
|
||||||
'PhabricatorHash' => 'infrastructure/util/PhabricatorHash.php',
|
'PhabricatorHash' => 'infrastructure/util/PhabricatorHash.php',
|
||||||
|
@ -3941,6 +3945,7 @@ phutil_register_library_map(array(
|
||||||
'AphrontFormDateControlValue' => 'Phobject',
|
'AphrontFormDateControlValue' => 'Phobject',
|
||||||
'AphrontFormDividerControl' => 'AphrontFormControl',
|
'AphrontFormDividerControl' => 'AphrontFormControl',
|
||||||
'AphrontFormFileControl' => 'AphrontFormControl',
|
'AphrontFormFileControl' => 'AphrontFormControl',
|
||||||
|
'AphrontFormHandlesControl' => 'AphrontFormControl',
|
||||||
'AphrontFormMarkupControl' => 'AphrontFormControl',
|
'AphrontFormMarkupControl' => 'AphrontFormControl',
|
||||||
'AphrontFormPasswordControl' => 'AphrontFormControl',
|
'AphrontFormPasswordControl' => 'AphrontFormControl',
|
||||||
'AphrontFormPolicyControl' => 'AphrontFormControl',
|
'AphrontFormPolicyControl' => 'AphrontFormControl',
|
||||||
|
@ -5308,9 +5313,11 @@ phutil_register_library_map(array(
|
||||||
'ManiphestTaskHeraldField' => 'HeraldField',
|
'ManiphestTaskHeraldField' => 'HeraldField',
|
||||||
'ManiphestTaskHeraldFieldGroup' => 'HeraldFieldGroup',
|
'ManiphestTaskHeraldFieldGroup' => 'HeraldFieldGroup',
|
||||||
'ManiphestTaskListController' => 'ManiphestController',
|
'ManiphestTaskListController' => 'ManiphestController',
|
||||||
|
'ManiphestTaskListHTTPParameterType' => 'AphrontListHTTPParameterType',
|
||||||
'ManiphestTaskListView' => 'ManiphestView',
|
'ManiphestTaskListView' => 'ManiphestView',
|
||||||
'ManiphestTaskMailReceiver' => 'PhabricatorObjectMailReceiver',
|
'ManiphestTaskMailReceiver' => 'PhabricatorObjectMailReceiver',
|
||||||
'ManiphestTaskOpenStatusDatasource' => 'PhabricatorTypeaheadDatasource',
|
'ManiphestTaskOpenStatusDatasource' => 'PhabricatorTypeaheadDatasource',
|
||||||
|
'ManiphestTaskPHIDResolver' => 'PhabricatorPHIDResolver',
|
||||||
'ManiphestTaskPHIDType' => 'PhabricatorPHIDType',
|
'ManiphestTaskPHIDType' => 'PhabricatorPHIDType',
|
||||||
'ManiphestTaskPriority' => 'ManiphestConstants',
|
'ManiphestTaskPriority' => 'ManiphestConstants',
|
||||||
'ManiphestTaskPriorityDatasource' => 'PhabricatorTypeaheadDatasource',
|
'ManiphestTaskPriorityDatasource' => 'PhabricatorTypeaheadDatasource',
|
||||||
|
@ -6471,6 +6478,7 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorHandlePool' => 'Phobject',
|
'PhabricatorHandlePool' => 'Phobject',
|
||||||
'PhabricatorHandlePoolTestCase' => 'PhabricatorTestCase',
|
'PhabricatorHandlePoolTestCase' => 'PhabricatorTestCase',
|
||||||
'PhabricatorHandleQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
|
'PhabricatorHandleQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
|
||||||
|
'PhabricatorHandlesEditField' => 'PhabricatorPHIDListEditField',
|
||||||
'PhabricatorHarbormasterApplication' => 'PhabricatorApplication',
|
'PhabricatorHarbormasterApplication' => 'PhabricatorApplication',
|
||||||
'PhabricatorHarbormasterConfigOptions' => 'PhabricatorApplicationConfigOptions',
|
'PhabricatorHarbormasterConfigOptions' => 'PhabricatorApplicationConfigOptions',
|
||||||
'PhabricatorHash' => 'Phobject',
|
'PhabricatorHash' => 'Phobject',
|
||||||
|
|
|
@ -134,8 +134,6 @@ final class ManiphestTaskDetailController extends ManiphestController {
|
||||||
$task,
|
$task,
|
||||||
PhabricatorPolicyCapability::CAN_EDIT);
|
PhabricatorPolicyCapability::CAN_EDIT);
|
||||||
|
|
||||||
$can_create = $viewer->isLoggedIn();
|
|
||||||
|
|
||||||
$view = id(new PhabricatorActionListView())
|
$view = id(new PhabricatorActionListView())
|
||||||
->setUser($viewer)
|
->setUser($viewer)
|
||||||
->setObject($task)
|
->setObject($task)
|
||||||
|
@ -158,10 +156,26 @@ final class ManiphestTaskDetailController extends ManiphestController {
|
||||||
->setDisabled(!$can_edit)
|
->setDisabled(!$can_edit)
|
||||||
->setWorkflow(true));
|
->setWorkflow(true));
|
||||||
|
|
||||||
|
$edit_config = id(new ManiphestEditEngine())
|
||||||
|
->setViewer($viewer)
|
||||||
|
->loadDefaultEditConfiguration();
|
||||||
|
|
||||||
|
$can_create = (bool)$edit_config;
|
||||||
|
if ($can_create) {
|
||||||
|
$form_key = $edit_config->getIdentifier();
|
||||||
|
$edit_uri = "/editpro/form/{$form_key}/?parent={$id}&template={$id}";
|
||||||
|
$edit_uri = $this->getApplicationURI($edit_uri);
|
||||||
|
} else {
|
||||||
|
// TODO: This will usually give us a somewhat-reasonable error page, but
|
||||||
|
// could be a bit cleaner.
|
||||||
|
$edit_uri = "/editpro/{$id}/";
|
||||||
|
$edit_uri = $this->getApplicationURI($edit_uri);
|
||||||
|
}
|
||||||
|
|
||||||
$view->addAction(
|
$view->addAction(
|
||||||
id(new PhabricatorActionView())
|
id(new PhabricatorActionView())
|
||||||
->setName(pht('Create Subtask'))
|
->setName(pht('Create Subtask'))
|
||||||
->setHref($this->getApplicationURI("/task/create/?parent={$id}"))
|
->setHref($edit_uri)
|
||||||
->setIcon('fa-level-down')
|
->setIcon('fa-level-down')
|
||||||
->setDisabled(!$can_create)
|
->setDisabled(!$can_create)
|
||||||
->setWorkflow(!$can_create));
|
->setWorkflow(!$can_create));
|
||||||
|
|
|
@ -69,6 +69,13 @@ final class ManiphestEditEngine
|
||||||
}
|
}
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
|
id(new PhabricatorHandlesEditField())
|
||||||
|
->setKey('parent')
|
||||||
|
->setLabel(pht('Parent Task'))
|
||||||
|
->setDescription(pht('Task to make this a subtask of.'))
|
||||||
|
->setAliases(array('parentPHID'))
|
||||||
|
->setTransactionType(ManiphestTransaction::TYPE_PARENT)
|
||||||
|
->setSingleValue(null),
|
||||||
id(new PhabricatorTextEditField())
|
id(new PhabricatorTextEditField())
|
||||||
->setKey('title')
|
->setKey('title')
|
||||||
->setLabel(pht('Title'))
|
->setLabel(pht('Title'))
|
||||||
|
|
|
@ -26,6 +26,7 @@ final class ManiphestTransactionEditor
|
||||||
$types[] = ManiphestTransaction::TYPE_MERGED_INTO;
|
$types[] = ManiphestTransaction::TYPE_MERGED_INTO;
|
||||||
$types[] = ManiphestTransaction::TYPE_MERGED_FROM;
|
$types[] = ManiphestTransaction::TYPE_MERGED_FROM;
|
||||||
$types[] = ManiphestTransaction::TYPE_UNBLOCK;
|
$types[] = ManiphestTransaction::TYPE_UNBLOCK;
|
||||||
|
$types[] = ManiphestTransaction::TYPE_PARENT;
|
||||||
$types[] = PhabricatorTransactions::TYPE_VIEW_POLICY;
|
$types[] = PhabricatorTransactions::TYPE_VIEW_POLICY;
|
||||||
$types[] = PhabricatorTransactions::TYPE_EDIT_POLICY;
|
$types[] = PhabricatorTransactions::TYPE_EDIT_POLICY;
|
||||||
|
|
||||||
|
@ -67,6 +68,8 @@ final class ManiphestTransactionEditor
|
||||||
case ManiphestTransaction::TYPE_MERGED_INTO:
|
case ManiphestTransaction::TYPE_MERGED_INTO:
|
||||||
case ManiphestTransaction::TYPE_MERGED_FROM:
|
case ManiphestTransaction::TYPE_MERGED_FROM:
|
||||||
return null;
|
return null;
|
||||||
|
case ManiphestTransaction::TYPE_PARENT:
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,6 +91,8 @@ final class ManiphestTransactionEditor
|
||||||
case ManiphestTransaction::TYPE_MERGED_FROM:
|
case ManiphestTransaction::TYPE_MERGED_FROM:
|
||||||
case ManiphestTransaction::TYPE_UNBLOCK:
|
case ManiphestTransaction::TYPE_UNBLOCK:
|
||||||
return $xaction->getNewValue();
|
return $xaction->getNewValue();
|
||||||
|
case ManiphestTransaction::TYPE_PARENT:
|
||||||
|
return $xaction->getNewValue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -155,6 +160,8 @@ final class ManiphestTransactionEditor
|
||||||
return;
|
return;
|
||||||
case ManiphestTransaction::TYPE_MERGED_FROM:
|
case ManiphestTransaction::TYPE_MERGED_FROM:
|
||||||
return;
|
return;
|
||||||
|
case ManiphestTransaction::TYPE_PARENT:
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -163,6 +170,15 @@ final class ManiphestTransactionEditor
|
||||||
PhabricatorApplicationTransaction $xaction) {
|
PhabricatorApplicationTransaction $xaction) {
|
||||||
|
|
||||||
switch ($xaction->getTransactionType()) {
|
switch ($xaction->getTransactionType()) {
|
||||||
|
case ManiphestTransaction::TYPE_PARENT:
|
||||||
|
$parent_phid = $xaction->getNewValue();
|
||||||
|
$parent_type = ManiphestTaskDependsOnTaskEdgeType::EDGECONST;
|
||||||
|
$task_phid = $object->getPHID();
|
||||||
|
|
||||||
|
id(new PhabricatorEdgeEditor())
|
||||||
|
->addEdge($parent_phid, $parent_type, $task_phid)
|
||||||
|
->save();
|
||||||
|
break;
|
||||||
case ManiphestTransaction::TYPE_PROJECT_COLUMN:
|
case ManiphestTransaction::TYPE_PROJECT_COLUMN:
|
||||||
$board_phid = idx($xaction->getNewValue(), 'projectPHID');
|
$board_phid = idx($xaction->getNewValue(), 'projectPHID');
|
||||||
if (!$board_phid) {
|
if (!$board_phid) {
|
||||||
|
@ -740,6 +756,17 @@ final class ManiphestTransactionEditor
|
||||||
$errors[] = $error;
|
$errors[] = $error;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case ManiphestTransaction::TYPE_PARENT:
|
||||||
|
if ($xactions && !$this->getIsNewObject()) {
|
||||||
|
$error = new PhabricatorApplicationTransactionValidationError(
|
||||||
|
$type,
|
||||||
|
pht('Invalid'),
|
||||||
|
pht(
|
||||||
|
'You can only select a parent task when creating a '.
|
||||||
|
'transaction for the first time.'),
|
||||||
|
last($xactions));
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $errors;
|
return $errors;
|
||||||
|
|
|
@ -0,0 +1,47 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
final class ManiphestTaskListHTTPParameterType
|
||||||
|
extends AphrontListHTTPParameterType {
|
||||||
|
|
||||||
|
protected function getParameterValue(AphrontRequest $request, $key) {
|
||||||
|
$type = new AphrontStringListHTTPParameterType();
|
||||||
|
$list = $this->getValueWithType($type, $request, $key);
|
||||||
|
|
||||||
|
return id(new ManiphestTaskPHIDResolver())
|
||||||
|
->setViewer($this->getViewer())
|
||||||
|
->resolvePHIDs($list);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getParameterTypeName() {
|
||||||
|
return 'list<task>';
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getParameterFormatDescriptions() {
|
||||||
|
return array(
|
||||||
|
pht('Comma-separated list of task PHIDs.'),
|
||||||
|
pht('List of task PHIDs, as array.'),
|
||||||
|
pht('Comma-separated list of task IDs.'),
|
||||||
|
pht('List of task IDs, as array.'),
|
||||||
|
pht('Comma-separated list of task monograms.'),
|
||||||
|
pht('List of task monograms, as array.'),
|
||||||
|
pht('Mixture of PHIDs, IDs and monograms.'),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getParameterExamples() {
|
||||||
|
return array(
|
||||||
|
'v=PHID-TASK-1111',
|
||||||
|
'v=PHID-TASK-1111,PHID-TASK-2222',
|
||||||
|
'v[]=PHID-TASK-1111&v[]=PHID-TASK-2222',
|
||||||
|
'v=123',
|
||||||
|
'v=123,124',
|
||||||
|
'v[]=123&v[]=124',
|
||||||
|
'v=T123',
|
||||||
|
'v=T123,T124',
|
||||||
|
'v[]=T123&v[]=T124',
|
||||||
|
'v=PHID-TASK-1111,123,T124',
|
||||||
|
'v[]=PHID-TASK-1111&v[]=123&v[]=T124',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,30 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
final class ManiphestTaskPHIDResolver
|
||||||
|
extends PhabricatorPHIDResolver {
|
||||||
|
|
||||||
|
protected function getResolutionMap(array $names) {
|
||||||
|
foreach ($names as $key => $name) {
|
||||||
|
if (ctype_digit($name)) {
|
||||||
|
$names[$key] = 'T'.$name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$query = id(new PhabricatorObjectQuery())
|
||||||
|
->setViewer($this->getViewer());
|
||||||
|
|
||||||
|
$tasks = id(new ManiphestTaskPHIDType())
|
||||||
|
->loadNamedObjects($query, $names);
|
||||||
|
|
||||||
|
|
||||||
|
$results = array();
|
||||||
|
foreach ($tasks as $task) {
|
||||||
|
$task_phid = $task->getPHID();
|
||||||
|
$results[$task->getID()] = $task_phid;
|
||||||
|
$results[$task->getMonogram()] = $task_phid;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $results;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -14,6 +14,7 @@ final class ManiphestTransaction
|
||||||
const TYPE_MERGED_INTO = 'mergedinto';
|
const TYPE_MERGED_INTO = 'mergedinto';
|
||||||
const TYPE_MERGED_FROM = 'mergedfrom';
|
const TYPE_MERGED_FROM = 'mergedfrom';
|
||||||
const TYPE_UNBLOCK = 'unblock';
|
const TYPE_UNBLOCK = 'unblock';
|
||||||
|
const TYPE_PARENT = 'parent';
|
||||||
|
|
||||||
// NOTE: this type is deprecated. Keep it around for legacy installs
|
// NOTE: this type is deprecated. Keep it around for legacy installs
|
||||||
// so any transactions render correctly.
|
// so any transactions render correctly.
|
||||||
|
@ -147,6 +148,7 @@ final class ManiphestTransaction
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case self::TYPE_SUBPRIORITY:
|
case self::TYPE_SUBPRIORITY:
|
||||||
|
case self::TYPE_PARENT:
|
||||||
return true;
|
return true;
|
||||||
case self::TYPE_PROJECT_COLUMN:
|
case self::TYPE_PROJECT_COLUMN:
|
||||||
$old_cols = idx($this->getOldValue(), 'columnPHIDs');
|
$old_cols = idx($this->getOldValue(), 'columnPHIDs');
|
||||||
|
|
|
@ -252,7 +252,7 @@ abstract class PhabricatorEditEngine
|
||||||
'getCreateSortKey');
|
'getCreateSortKey');
|
||||||
}
|
}
|
||||||
|
|
||||||
private function loadDefaultEditConfiguration() {
|
public function loadDefaultEditConfiguration() {
|
||||||
$query = $this->newConfigurationQuery()
|
$query = $this->newConfigurationQuery()
|
||||||
->withIsEdit(true)
|
->withIsEdit(true)
|
||||||
->withIsDisabled(false);
|
->withIsDisabled(false);
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
final class PhabricatorHandlesEditField
|
||||||
|
extends PhabricatorPHIDListEditField {
|
||||||
|
|
||||||
|
protected function newControl() {
|
||||||
|
return id(new AphrontFormHandlesControl());
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function newHTTPParameterType() {
|
||||||
|
return new ManiphestTaskListHTTPParameterType();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -52,6 +52,14 @@ abstract class PhabricatorPHIDListEditField
|
||||||
return parent::readValueFromComment($value);
|
return parent::readValueFromComment($value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function getValueFromRequest(AphrontRequest $request, $key) {
|
||||||
|
$value = parent::getValueFromRequest($request, $key);
|
||||||
|
if ($this->getIsSingleValue()) {
|
||||||
|
$value = array_slice($value, 0, 1);
|
||||||
|
}
|
||||||
|
return $value;
|
||||||
|
}
|
||||||
|
|
||||||
public function getValueForTransaction() {
|
public function getValueForTransaction() {
|
||||||
$new = parent::getValueForTransaction();
|
$new = parent::getValueForTransaction();
|
||||||
|
|
||||||
|
|
36
src/view/form/control/AphrontFormHandlesControl.php
Normal file
36
src/view/form/control/AphrontFormHandlesControl.php
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
final class AphrontFormHandlesControl extends AphrontFormControl {
|
||||||
|
|
||||||
|
protected function getCustomControlClass() {
|
||||||
|
return 'aphront-form-control-handles';
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function shouldRender() {
|
||||||
|
return (bool)$this->getValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function renderInput() {
|
||||||
|
$value = $this->getValue();
|
||||||
|
$viewer = $this->getUser();
|
||||||
|
|
||||||
|
$list = $viewer->renderHandleList($value);
|
||||||
|
$list = id(new PHUIBoxView())
|
||||||
|
->addPadding(PHUI::PADDING_SMALL_TOP)
|
||||||
|
->appendChild($list);
|
||||||
|
|
||||||
|
$inputs = array();
|
||||||
|
foreach ($value as $phid) {
|
||||||
|
$inputs[] = phutil_tag(
|
||||||
|
'input',
|
||||||
|
array(
|
||||||
|
'type' => 'hidden',
|
||||||
|
'name' => $this->getName().'[]',
|
||||||
|
'value' => $phid,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
return array($list, $inputs);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in a new issue