Differential D14653 Diff 35450 src/applications/transactions/view/PhabricatorApplicationTransactionCommentView.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/transactions/view/PhabricatorApplicationTransactionCommentView.php
| Show All 16 Lines | class PhabricatorApplicationTransactionCommentView extends AphrontView { | ||||
| private $draft; | private $draft; | ||||
| private $requestURI; | private $requestURI; | ||||
| private $showPreview = true; | private $showPreview = true; | ||||
| private $objectPHID; | private $objectPHID; | ||||
| private $headerText; | private $headerText; | ||||
| private $currentVersion; | private $currentVersion; | ||||
| private $versionedDraft; | private $versionedDraft; | ||||
| private $editTypes; | |||||
| public function setObjectPHID($object_phid) { | public function setObjectPHID($object_phid) { | ||||
| $this->objectPHID = $object_phid; | $this->objectPHID = $object_phid; | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| public function getObjectPHID() { | public function getObjectPHID() { | ||||
| return $this->objectPHID; | return $this->objectPHID; | ||||
| ▲ Show 20 Lines • Show All 62 Lines • ▼ Show 20 Lines | public function getAction() { | ||||
| return $this->action; | return $this->action; | ||||
| } | } | ||||
| public function setHeaderText($text) { | public function setHeaderText($text) { | ||||
| $this->headerText = $text; | $this->headerText = $text; | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| public function setEditTypes($edit_types) { | |||||
| $this->editTypes = $edit_types; | |||||
| return $this; | |||||
| } | |||||
| public function getEditTypes() { | |||||
| return $this->editTypes; | |||||
| } | |||||
| public function render() { | public function render() { | ||||
| $user = $this->getUser(); | $user = $this->getUser(); | ||||
| if (!$user->isLoggedIn()) { | if (!$user->isLoggedIn()) { | ||||
| $uri = id(new PhutilURI('/login/')) | $uri = id(new PhutilURI('/login/')) | ||||
| ->setQueryParam('next', (string)$this->getRequestURI()); | ->setQueryParam('next', (string)$this->getRequestURI()); | ||||
| return id(new PHUIObjectBoxView()) | return id(new PHUIObjectBoxView()) | ||||
| ->setFlush(true) | ->setFlush(true) | ||||
| ▲ Show 20 Lines • Show All 66 Lines • ▼ Show 20 Lines | private function renderCommentPanel() { | ||||
| if (!$this->getObjectPHID()) { | if (!$this->getObjectPHID()) { | ||||
| throw new PhutilInvalidStateException('setObjectPHID', 'render'); | throw new PhutilInvalidStateException('setObjectPHID', 'render'); | ||||
| } | } | ||||
| $version_key = PhabricatorVersionedDraft::KEY_VERSION; | $version_key = PhabricatorVersionedDraft::KEY_VERSION; | ||||
| $version_value = $this->getCurrentVersion(); | $version_value = $this->getCurrentVersion(); | ||||
| return id(new AphrontFormView()) | $form = id(new AphrontFormView()) | ||||
| ->setUser($this->getUser()) | ->setUser($this->getUser()) | ||||
| ->addSigil('transaction-append') | ->addSigil('transaction-append') | ||||
| ->setWorkflow(true) | ->setWorkflow(true) | ||||
| ->setMetadata( | ->setMetadata( | ||||
| array( | array( | ||||
| 'objectPHID' => $this->getObjectPHID(), | 'objectPHID' => $this->getObjectPHID(), | ||||
| )) | )) | ||||
| ->setAction($this->getAction()) | ->setAction($this->getAction()) | ||||
| ->setID($this->getFormID()) | ->setID($this->getFormID()) | ||||
| ->addHiddenInput('__draft__', $draft_key) | ->addHiddenInput('__draft__', $draft_key) | ||||
| ->addHiddenInput($version_key, $version_value) | ->addHiddenInput($version_key, $version_value); | ||||
| $edit_types = $this->getEditTypes(); | |||||
| if ($edit_types) { | |||||
| $action_map = array(); | |||||
| foreach ($edit_types as $edit_type) { | |||||
| $key = $edit_type->getEditType(); | |||||
| $action_map[$key] = array( | |||||
| 'key' => $key, | |||||
| 'label' => $edit_type->getLabel(), | |||||
| 'type' => $edit_type->getPHUIXControlType(), | |||||
| 'spec' => $edit_type->getPHUIXControlSpecification(), | |||||
| ); | |||||
| } | |||||
| $options = array(); | |||||
| $options['+'] = pht('Add Action...'); | |||||
| foreach ($action_map as $key => $item) { | |||||
| $options[$key] = $item['label']; | |||||
| } | |||||
| $action_id = celerity_generate_unique_node_id(); | |||||
| $input_id = celerity_generate_unique_node_id(); | |||||
| $form->appendChild( | |||||
| phutil_tag( | |||||
| 'input', | |||||
| array( | |||||
| 'type' => 'hidden', | |||||
| 'name' => 'editengine.actions', | |||||
| 'id' => $input_id, | |||||
| ))); | |||||
| $form->appendChild( | |||||
| id(new AphrontFormSelectControl()) | |||||
| ->setLabel(pht('Actions')) | |||||
| ->setID($action_id) | |||||
| ->setOptions($options)); | |||||
| Javelin::initBehavior( | |||||
| 'comment-actions', | |||||
| array( | |||||
| 'actionID' => $action_id, | |||||
| 'inputID' => $input_id, | |||||
| 'formID' => $this->getFormID(), | |||||
| 'actions' => $action_map, | |||||
| )); | |||||
| } | |||||
| $form | |||||
| ->appendChild( | ->appendChild( | ||||
| id(new PhabricatorRemarkupControl()) | id(new PhabricatorRemarkupControl()) | ||||
| ->setID($this->getCommentID()) | ->setID($this->getCommentID()) | ||||
| ->setName('comment') | ->setName('comment') | ||||
| ->setLabel(pht('Comment')) | ->setLabel(pht('Comment')) | ||||
| ->setUser($this->getUser()) | ->setUser($this->getUser()) | ||||
| ->setValue($draft_comment)) | ->setValue($draft_comment)) | ||||
| ->appendChild( | ->appendChild( | ||||
| id(new AphrontFormSubmitControl()) | id(new AphrontFormSubmitControl()) | ||||
| ->setValue($this->getSubmitButtonName())) | ->setValue($this->getSubmitButtonName())) | ||||
| ->appendChild( | ->appendChild( | ||||
| id(new AphrontFormMarkupControl()) | id(new AphrontFormMarkupControl()) | ||||
| ->setValue($status)); | ->setValue($status)); | ||||
| return $form; | |||||
| } | } | ||||
| private function renderPreviewPanel() { | private function renderPreviewPanel() { | ||||
| $preview = id(new PHUITimelineView()) | $preview = id(new PHUITimelineView()) | ||||
| ->setID($this->getPreviewTimelineID()); | ->setID($this->getPreviewTimelineID()); | ||||
| return phutil_tag( | return phutil_tag( | ||||
| ▲ Show 20 Lines • Show All 49 Lines • Show Last 20 Lines | |||||