Changeset View
Changeset View
Standalone View
Standalone View
src/applications/project/engine/PhabricatorProjectEditEngine.php
<?php | <?php | ||||
final class PhabricatorProjectEditEngine | final class PhabricatorProjectEditEngine | ||||
extends PhabricatorEditEngine { | extends PhabricatorEditEngine { | ||||
const ENGINECONST = 'projects.project'; | const ENGINECONST = 'projects.project'; | ||||
private $parentProject; | |||||
private $milestoneProject; | |||||
public function setParentProject(PhabricatorProject $parent_project) { | |||||
$this->parentProject = $parent_project; | |||||
return $this; | |||||
} | |||||
public function getParentProject() { | |||||
return $this->parentProject; | |||||
} | |||||
public function setMilestoneProject(PhabricatorProject $milestone_project) { | |||||
$this->milestoneProject = $milestone_project; | |||||
return $this; | |||||
} | |||||
public function getMilestoneProject() { | |||||
return $this->milestoneProject; | |||||
} | |||||
public function getEngineName() { | public function getEngineName() { | ||||
return pht('Projects'); | return pht('Projects'); | ||||
} | } | ||||
public function getSummaryHeader() { | public function getSummaryHeader() { | ||||
return pht('Configure Project Forms'); | return pht('Configure Project Forms'); | ||||
} | } | ||||
Show All 29 Lines | final class PhabricatorProjectEditEngine | ||||
protected function getObjectCreateShortText() { | protected function getObjectCreateShortText() { | ||||
return pht('Create Project'); | return pht('Create Project'); | ||||
} | } | ||||
protected function getObjectViewURI($object) { | protected function getObjectViewURI($object) { | ||||
return $object->getURI(); | return $object->getURI(); | ||||
} | } | ||||
protected function getObjectCreateCancelURI($object) { | |||||
$parent = $this->getParentProject(); | |||||
if ($parent) { | |||||
$id = $parent->getID(); | |||||
return "/project/subprojects/{$id}/"; | |||||
} | |||||
$milestone = $this->getMilestoneProject(); | |||||
if ($milestone) { | |||||
$id = $milestone->getID(); | |||||
return "/project/milestones/{$id}/"; | |||||
} | |||||
return parent::getObjectCreateCancelURI($object); | |||||
} | |||||
protected function getCreateNewObjectPolicy() { | protected function getCreateNewObjectPolicy() { | ||||
return $this->getApplication()->getPolicy( | return $this->getApplication()->getPolicy( | ||||
ProjectCreateProjectsCapability::CAPABILITY); | ProjectCreateProjectsCapability::CAPABILITY); | ||||
} | } | ||||
protected function newBuiltinEngineConfigurations() { | protected function newBuiltinEngineConfigurations() { | ||||
$configuration = head(parent::newBuiltinEngineConfigurations()); | $configuration = head(parent::newBuiltinEngineConfigurations()); | ||||
// TODO: This whole method is clumsy, and the ordering for the custom | // TODO: This whole method is clumsy, and the ordering for the custom | ||||
// field is especially clumsy. Maybe try to make this more natural to | // field is especially clumsy. Maybe try to make this more natural to | ||||
// express. | // express. | ||||
$configuration | $configuration | ||||
->setFieldOrder( | ->setFieldOrder( | ||||
array( | array( | ||||
'parent', | |||||
'milestone', | |||||
'name', | 'name', | ||||
'std:project:internal:description', | 'std:project:internal:description', | ||||
'icon', | 'icon', | ||||
'color', | 'color', | ||||
'slugs', | 'slugs', | ||||
'subscriberPHIDs', | 'subscriberPHIDs', | ||||
)); | )); | ||||
return array( | return array( | ||||
$configuration, | $configuration, | ||||
); | ); | ||||
} | } | ||||
protected function buildCustomEditFields($object) { | protected function buildCustomEditFields($object) { | ||||
$slugs = mpull($object->getSlugs(), 'getSlug'); | $slugs = mpull($object->getSlugs(), 'getSlug'); | ||||
$slugs = array_fuse($slugs); | $slugs = array_fuse($slugs); | ||||
unset($slugs[$object->getPrimarySlug()]); | unset($slugs[$object->getPrimarySlug()]); | ||||
$slugs = array_values($slugs); | $slugs = array_values($slugs); | ||||
$milestone = $this->getMilestoneProject(); | |||||
$parent = $this->getParentProject(); | |||||
if ($parent) { | |||||
$parent_phid = $parent->getPHID(); | |||||
} else { | |||||
$parent_phid = null; | |||||
} | |||||
if ($milestone) { | |||||
$milestone_phid = $milestone->getPHID(); | |||||
} else { | |||||
$milestone_phid = null; | |||||
} | |||||
return array( | return array( | ||||
id(new PhabricatorHandlesEditField()) | |||||
->setKey('parent') | |||||
->setLabel(pht('Parent')) | |||||
->setDescription(pht('Create a subproject of an existing project.')) | |||||
->setConduitDescription( | |||||
pht('Choose a parent project to create a subproject beneath.')) | |||||
->setConduitTypeDescription(pht('PHID of the parent project.')) | |||||
->setAliases(array('parentPHID')) | |||||
->setTransactionType(PhabricatorProjectTransaction::TYPE_PARENT) | |||||
->setHandleParameterType(new AphrontPHIDHTTPParameterType()) | |||||
->setSingleValue($parent_phid) | |||||
->setIsReorderable(false) | |||||
->setIsDefaultable(false) | |||||
->setIsLockable(false) | |||||
->setIsLocked(true), | |||||
id(new PhabricatorHandlesEditField()) | |||||
->setKey('milestone') | |||||
->setLabel(pht('Milestone Of')) | |||||
->setDescription(pht('Parent project to create a milestone for.')) | |||||
->setConduitDescription( | |||||
pht('Choose a parent project to create a new milestone for.')) | |||||
->setConduitTypeDescription(pht('PHID of the parent project.')) | |||||
->setAliases(array('milestonePHID')) | |||||
->setTransactionType(PhabricatorProjectTransaction::TYPE_MILESTONE) | |||||
->setHandleParameterType(new AphrontPHIDHTTPParameterType()) | |||||
->setSingleValue($milestone_phid) | |||||
->setIsReorderable(false) | |||||
->setIsDefaultable(false) | |||||
->setIsLockable(false) | |||||
->setIsLocked(true), | |||||
id(new PhabricatorTextEditField()) | id(new PhabricatorTextEditField()) | ||||
->setKey('name') | ->setKey('name') | ||||
->setLabel(pht('Name')) | ->setLabel(pht('Name')) | ||||
->setTransactionType(PhabricatorProjectTransaction::TYPE_NAME) | ->setTransactionType(PhabricatorProjectTransaction::TYPE_NAME) | ||||
->setIsRequired(true) | ->setIsRequired(true) | ||||
->setDescription(pht('Project name.')) | ->setDescription(pht('Project name.')) | ||||
->setConduitDescription(pht('Rename the project')) | ->setConduitDescription(pht('Rename the project')) | ||||
->setConduitTypeDescription(pht('New project name.')) | ->setConduitTypeDescription(pht('New project name.')) | ||||
Show All 31 Lines |