Differential D20810 Diff 49617 src/applications/transactions/engineextension/PhabricatorSubtypeEditEngineExtension.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/transactions/engineextension/PhabricatorSubtypeEditEngineExtension.php
Show All 23 Lines | public function supportsObject( | ||||
return $engine->supportsSubtypes(); | return $engine->supportsSubtypes(); | ||||
} | } | ||||
public function buildCustomEditFields( | public function buildCustomEditFields( | ||||
PhabricatorEditEngine $engine, | PhabricatorEditEngine $engine, | ||||
PhabricatorApplicationTransactionInterface $object) { | PhabricatorApplicationTransactionInterface $object) { | ||||
$subtype_type = PhabricatorTransactions::TYPE_SUBTYPE; | $subtype_type = PhabricatorTransactions::TYPE_SUBTYPE; | ||||
$subtype_value = $object->getEditEngineSubtype(); | |||||
$map = $object->newEditEngineSubtypeMap(); | $map = $object->newEditEngineSubtypeMap(); | ||||
if ($object->getID()) { | |||||
$options = $map->getMutationMap($subtype_value); | |||||
} else { | |||||
// NOTE: This is a crude proxy for "are we in the bulk edit workflow". | |||||
// We want to allow any mutation. | |||||
$options = $map->getDisplayMap(); | $options = $map->getDisplayMap(); | ||||
} | |||||
$subtype_field = id(new PhabricatorSelectEditField()) | $subtype_field = id(new PhabricatorSelectEditField()) | ||||
->setKey(self::EDITKEY) | ->setKey(self::EDITKEY) | ||||
->setLabel(pht('Subtype')) | ->setLabel(pht('Subtype')) | ||||
->setIsFormField(false) | ->setIsFormField(false) | ||||
->setTransactionType($subtype_type) | ->setTransactionType($subtype_type) | ||||
->setConduitDescription(pht('Change the object subtype.')) | ->setConduitDescription(pht('Change the object subtype.')) | ||||
->setConduitTypeDescription(pht('New object subtype key.')) | ->setConduitTypeDescription(pht('New object subtype key.')) | ||||
->setValue($object->getEditEngineSubtype()) | ->setValue($subtype_value) | ||||
->setOptions($options); | ->setOptions($options); | ||||
// If subtypes are configured, enable changing them from the bulk editor | // If subtypes are configured, enable changing them from the bulk editor. | ||||
// and comment action stack. | // Bulk editor | ||||
if ($map->getCount() > 1) { | if ($options) { | ||||
$subtype_field | $subtype_field | ||||
->setBulkEditLabel(pht('Change subtype to')) | ->setBulkEditLabel(pht('Change subtype to')) | ||||
->setCommentActionLabel(pht('Change Subtype')) | ->setCommentActionLabel(pht('Change Subtype')) | ||||
->setCommentActionOrder(3000); | ->setCommentActionOrder(3000); | ||||
} | } | ||||
return array( | return array( | ||||
$subtype_field, | $subtype_field, | ||||
); | ); | ||||
} | } | ||||
} | } |