Differential D14672 Diff 35495 src/applications/transactions/view/PhabricatorApplicationTransactionCommentView.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/transactions/view/PhabricatorApplicationTransactionCommentView.php
| <?php | <?php | ||||
| /** | /** | ||||
| * @concrete-extensible | * @concrete-extensible | ||||
| */ | */ | ||||
| class PhabricatorApplicationTransactionCommentView extends AphrontView { | class PhabricatorApplicationTransactionCommentView extends AphrontView { | ||||
| private $submitButtonName; | private $submitButtonName; | ||||
| private $action; | private $action; | ||||
| private $previewPanelID; | private $previewPanelID; | ||||
| private $previewTimelineID; | private $previewTimelineID; | ||||
| private $previewToggleID; | private $previewToggleID; | ||||
| private $formID; | private $formID; | ||||
| private $statusID; | |||||
| private $commentID; | private $commentID; | ||||
| 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; | ||||
| ▲ Show 20 Lines • Show All 119 Lines • ▼ Show 20 Lines | public function render() { | ||||
| $comment = $this->renderCommentPanel(); | $comment = $this->renderCommentPanel(); | ||||
| if ($this->getShowPreview()) { | if ($this->getShowPreview()) { | ||||
| $preview = $this->renderPreviewPanel(); | $preview = $this->renderPreviewPanel(); | ||||
| } else { | } else { | ||||
| $preview = null; | $preview = null; | ||||
| } | } | ||||
| if (!$this->getEditTypes()) { | |||||
| Javelin::initBehavior( | Javelin::initBehavior( | ||||
| 'phabricator-transaction-comment-form', | 'phabricator-transaction-comment-form', | ||||
| array( | array( | ||||
| 'formID' => $this->getFormID(), | 'formID' => $this->getFormID(), | ||||
| 'timelineID' => $this->getPreviewTimelineID(), | 'timelineID' => $this->getPreviewTimelineID(), | ||||
| 'panelID' => $this->getPreviewPanelID(), | 'panelID' => $this->getPreviewPanelID(), | ||||
| 'statusID' => $this->getStatusID(), | |||||
| 'commentID' => $this->getCommentID(), | |||||
| 'loadingString' => pht('Loading Preview...'), | |||||
| 'savingString' => pht('Saving Draft...'), | |||||
| 'draftString' => pht('Saved Draft'), | |||||
| 'showPreview' => $this->getShowPreview(), | 'showPreview' => $this->getShowPreview(), | ||||
| 'actionURI' => $this->getAction(), | 'actionURI' => $this->getAction(), | ||||
| )); | )); | ||||
| } | |||||
| $comment_box = id(new PHUIObjectBoxView()) | $comment_box = id(new PHUIObjectBoxView()) | ||||
| ->setFlush(true) | ->setFlush(true) | ||||
| ->setHeaderText($this->headerText) | ->setHeaderText($this->headerText) | ||||
| ->appendChild($comment); | ->appendChild($comment); | ||||
| return array($comment_box, $preview); | return array($comment_box, $preview); | ||||
| } | } | ||||
| private function renderCommentPanel() { | private function renderCommentPanel() { | ||||
| $status = phutil_tag( | |||||
| 'div', | |||||
| array( | |||||
| 'id' => $this->getStatusID(), | |||||
| ), | |||||
| ''); | |||||
| $draft_comment = ''; | $draft_comment = ''; | ||||
| $draft_key = null; | $draft_key = null; | ||||
| if ($this->getDraft()) { | if ($this->getDraft()) { | ||||
| $draft_comment = $this->getDraft()->getDraft(); | $draft_comment = $this->getDraft()->getDraft(); | ||||
| $draft_key = $this->getDraft()->getDraftKey(); | $draft_key = $this->getDraft()->getDraftKey(); | ||||
| } | } | ||||
| $versioned_draft = $this->getVersionedDraft(); | $versioned_draft = $this->getVersionedDraft(); | ||||
| ▲ Show 20 Lines • Show All 71 Lines • ▼ Show 20 Lines | if ($edit_types) { | ||||
| Javelin::initBehavior( | Javelin::initBehavior( | ||||
| 'comment-actions', | 'comment-actions', | ||||
| array( | array( | ||||
| 'actionID' => $action_id, | 'actionID' => $action_id, | ||||
| 'inputID' => $input_id, | 'inputID' => $input_id, | ||||
| 'formID' => $this->getFormID(), | 'formID' => $this->getFormID(), | ||||
| 'placeID' => $place_id, | 'placeID' => $place_id, | ||||
| 'panelID' => $this->getPreviewPanelID(), | |||||
| 'timelineID' => $this->getPreviewTimelineID(), | |||||
| 'actions' => $action_map, | 'actions' => $action_map, | ||||
| 'showPreview' => $this->getShowPreview(), | |||||
| 'actionURI' => $this->getAction(), | |||||
| )); | )); | ||||
| } | } | ||||
| $form | $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( | |||||
| id(new AphrontFormMarkupControl()) | |||||
| ->setValue($status)); | |||||
| return $form; | return $form; | ||||
| } | } | ||||
| private function renderPreviewPanel() { | private function renderPreviewPanel() { | ||||
| $preview = id(new PHUITimelineView()) | $preview = id(new PHUITimelineView()) | ||||
| ->setID($this->getPreviewTimelineID()); | ->setID($this->getPreviewTimelineID()); | ||||
| ▲ Show 20 Lines • Show All 51 Lines • Show Last 20 Lines | |||||