Page MenuHomePhabricator

D14659.id35459.diff
No OneTemporary

D14659.id35459.diff

diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -1260,6 +1260,8 @@
'ManiphestDefaultEditCapability' => 'applications/maniphest/capability/ManiphestDefaultEditCapability.php',
'ManiphestDefaultViewCapability' => 'applications/maniphest/capability/ManiphestDefaultViewCapability.php',
'ManiphestEditAssignCapability' => 'applications/maniphest/capability/ManiphestEditAssignCapability.php',
+ 'ManiphestEditConduitAPIMethod' => 'applications/maniphest/conduit/ManiphestEditConduitAPIMethod.php',
+ 'ManiphestEditEngine' => 'applications/maniphest/editor/ManiphestEditEngine.php',
'ManiphestEditPoliciesCapability' => 'applications/maniphest/capability/ManiphestEditPoliciesCapability.php',
'ManiphestEditPriorityCapability' => 'applications/maniphest/capability/ManiphestEditPriorityCapability.php',
'ManiphestEditProjectsCapability' => 'applications/maniphest/capability/ManiphestEditProjectsCapability.php',
@@ -1299,6 +1301,7 @@
'ManiphestTaskDetailController' => 'applications/maniphest/controller/ManiphestTaskDetailController.php',
'ManiphestTaskEditBulkJobType' => 'applications/maniphest/bulk/ManiphestTaskEditBulkJobType.php',
'ManiphestTaskEditController' => 'applications/maniphest/controller/ManiphestTaskEditController.php',
+ 'ManiphestTaskEditProController' => 'applications/maniphest/controller/ManiphestTaskEditProController.php',
'ManiphestTaskHasCommitEdgeType' => 'applications/maniphest/edge/ManiphestTaskHasCommitEdgeType.php',
'ManiphestTaskHasMockEdgeType' => 'applications/maniphest/edge/ManiphestTaskHasMockEdgeType.php',
'ManiphestTaskHasRevisionEdgeType' => 'applications/maniphest/edge/ManiphestTaskHasRevisionEdgeType.php',
@@ -5233,6 +5236,8 @@
'ManiphestDefaultEditCapability' => 'PhabricatorPolicyCapability',
'ManiphestDefaultViewCapability' => 'PhabricatorPolicyCapability',
'ManiphestEditAssignCapability' => 'PhabricatorPolicyCapability',
+ 'ManiphestEditConduitAPIMethod' => 'PhabricatorEditEngineAPIMethod',
+ 'ManiphestEditEngine' => 'PhabricatorEditEngine',
'ManiphestEditPoliciesCapability' => 'PhabricatorPolicyCapability',
'ManiphestEditPriorityCapability' => 'PhabricatorPolicyCapability',
'ManiphestEditProjectsCapability' => 'PhabricatorPolicyCapability',
@@ -5286,6 +5291,7 @@
'ManiphestTaskDetailController' => 'ManiphestController',
'ManiphestTaskEditBulkJobType' => 'PhabricatorWorkerBulkJobType',
'ManiphestTaskEditController' => 'ManiphestController',
+ 'ManiphestTaskEditProController' => 'ManiphestController',
'ManiphestTaskHasCommitEdgeType' => 'PhabricatorEdgeType',
'ManiphestTaskHasMockEdgeType' => 'PhabricatorEdgeType',
'ManiphestTaskHasRevisionEdgeType' => 'PhabricatorEdgeType',
diff --git a/src/applications/maniphest/application/PhabricatorManiphestApplication.php b/src/applications/maniphest/application/PhabricatorManiphestApplication.php
--- a/src/applications/maniphest/application/PhabricatorManiphestApplication.php
+++ b/src/applications/maniphest/application/PhabricatorManiphestApplication.php
@@ -69,6 +69,8 @@
),
'export/(?P<key>[^/]+)/' => 'ManiphestExportController',
'subpriority/' => 'ManiphestSubpriorityController',
+ $this->getEditRoutePattern('editpro/')
+ => 'ManiphestTaskEditProController',
),
);
}
diff --git a/src/applications/maniphest/conduit/ManiphestEditConduitAPIMethod.php b/src/applications/maniphest/conduit/ManiphestEditConduitAPIMethod.php
new file mode 100644
--- /dev/null
+++ b/src/applications/maniphest/conduit/ManiphestEditConduitAPIMethod.php
@@ -0,0 +1,19 @@
+<?php
+
+final class ManiphestEditConduitAPIMethod
+ extends PhabricatorEditEngineAPIMethod {
+
+ public function getAPIMethodName() {
+ return 'maniphest.edit';
+ }
+
+ public function newEditEngine() {
+ return new ManiphestEditEngine();
+ }
+
+ public function getMethodSummary() {
+ return pht(
+ 'Apply transactions to create a new task or edit an existing one.');
+ }
+
+}
diff --git a/src/applications/maniphest/controller/ManiphestTaskEditProController.php b/src/applications/maniphest/controller/ManiphestTaskEditProController.php
new file mode 100644
--- /dev/null
+++ b/src/applications/maniphest/controller/ManiphestTaskEditProController.php
@@ -0,0 +1,11 @@
+<?php
+
+final class ManiphestTaskEditProController extends ManiphestController {
+
+ public function handleRequest(AphrontRequest $request) {
+ return id(new ManiphestEditEngine())
+ ->setController($this)
+ ->buildResponse();
+ }
+
+}
diff --git a/src/applications/maniphest/editor/ManiphestEditEngine.php b/src/applications/maniphest/editor/ManiphestEditEngine.php
new file mode 100644
--- /dev/null
+++ b/src/applications/maniphest/editor/ManiphestEditEngine.php
@@ -0,0 +1,113 @@
+<?php
+
+final class ManiphestEditEngine
+ extends PhabricatorEditEngine {
+
+ const ENGINECONST = 'maniphest.task';
+
+ public function getEngineName() {
+ return pht('Maniphest Tasks');
+ }
+
+ public function getEngineApplicationClass() {
+ return 'PhabricatorManiphestApplication';
+ }
+
+ protected function newEditableObject() {
+ return ManiphestTask::initializeNewTask($this->getViewer());
+ }
+
+ protected function newObjectQuery() {
+ return id(new ManiphestTaskQuery());
+ }
+
+ protected function getObjectCreateTitleText($object) {
+ return pht('Create New Task');
+ }
+
+ protected function getObjectEditTitleText($object) {
+ return pht('Edit %s %s', $object->getMonogram(), $object->getTitle());
+ }
+
+ protected function getObjectEditShortText($object) {
+ return $object->getMonogram();
+ }
+
+ protected function getObjectCreateShortText() {
+ return pht('Create Task');
+ }
+
+ protected function getCommentViewHeaderText($object) {
+ $is_serious = PhabricatorEnv::getEnvConfig('phabricator.serious-business');
+ if (!$is_serious) {
+ return pht('Weigh In');
+ }
+
+ return parent::getCommentViewHeaderText($object);
+ }
+
+ protected function getObjectViewURI($object) {
+ return '/'.$object->getMonogram();
+ }
+
+ protected function buildCustomEditFields($object) {
+ // See T4819.
+ $status_map = ManiphestTaskStatus::getTaskStatusMap();
+ $dup_status = ManiphestTaskStatus::getDuplicateStatus();
+ if ($object->getStatus() != $dup_status) {
+ unset($status_map[$dup_status]);
+ }
+
+ $owner_phid = $object->getOwnerPHID();
+ if ($owner_phid) {
+ $owner_value = array($owner_phid);
+ } else {
+ $owner_value = array();
+ }
+
+ $priority_map = ManiphestTaskPriority::getTaskPriorityMap();
+
+ return array(
+ id(new PhabricatorTextEditField())
+ ->setKey('title')
+ ->setLabel(pht('Title'))
+ ->setDescription(pht('Name of the paste.'))
+ ->setTransactionType(ManiphestTransaction::TYPE_TITLE)
+ ->setIsRequired(true)
+ ->setValue($object->getTitle()),
+ id(new PhabricatorSelectEditField())
+ ->setKey('status')
+ ->setLabel(pht('Status'))
+ ->setDescription(pht('Status of the task.'))
+ ->setTransactionType(ManiphestTransaction::TYPE_STATUS)
+ ->setValue($object->getStatus())
+ ->setOptions($status_map),
+ id(new PhabricatorUsersEditField())
+ ->setKey('assigned')
+ ->setAliases(array('assign', 'assignee'))
+ ->setLabel(pht('Assigned To'))
+ ->setDescription(pht('User who is responsible for the task.'))
+ ->setTransactionType(ManiphestTransaction::TYPE_OWNER)
+ ->setValue($owner_value),
+ id(new PhabricatorSelectEditField())
+ ->setKey('priority')
+ ->setLabel(pht('Priority'))
+ ->setDescription(pht('Priority of the task.'))
+ ->setTransactionType(ManiphestTransaction::TYPE_PRIORITY)
+ ->setValue($object->getPriority())
+ ->setOptions($priority_map),
+ id(new PhabricatorRemarkupEditField())
+ ->setKey('description')
+ ->setLabel(pht('Description'))
+ ->setDescription(pht('Task description.'))
+ ->setTransactionType(ManiphestTransaction::TYPE_DESCRIPTION)
+ ->setValue($object->getDescription()),
+ );
+ }
+
+ protected function getEditorURI() {
+ // TODO: Remove when cutting over.
+ return $this->getApplication()->getApplicationURI('editpro/');
+ }
+
+}
diff --git a/src/applications/maniphest/editor/ManiphestTransactionEditor.php b/src/applications/maniphest/editor/ManiphestTransactionEditor.php
--- a/src/applications/maniphest/editor/ManiphestTransactionEditor.php
+++ b/src/applications/maniphest/editor/ManiphestTransactionEditor.php
@@ -716,5 +716,34 @@
return array($dst->getPriority(), $sub);
}
+ protected function validateTransaction(
+ PhabricatorLiskDAO $object,
+ $type,
+ array $xactions) {
+
+ $errors = parent::validateTransaction($object, $type, $xactions);
+
+ switch ($type) {
+ case ManiphestTransaction::TYPE_TITLE:
+ $missing = $this->validateIsEmptyTextField(
+ $object->getTitle(),
+ $xactions);
+
+ if ($missing) {
+ $error = new PhabricatorApplicationTransactionValidationError(
+ $type,
+ pht('Required'),
+ pht('Task title is required.'),
+ nonempty(last($xactions), null));
+
+ $error->setIsMissingFieldError(true);
+ $errors[] = $error;
+ }
+ break;
+ }
+
+ return $errors;
+ }
+
}

File Metadata

Mime Type
text/plain
Expires
Wed, Apr 2, 6:55 AM (2 d, 15 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7704253
Default Alt Text
D14659.id35459.diff (9 KB)

Event Timeline