Changeset View
Changeset View
Standalone View
Standalone View
src/infrastructure/diff/view/PHUIDiffInlineCommentEditView.php
| <?php | <?php | ||||
| final class PHUIDiffInlineCommentEditView | final class PHUIDiffInlineCommentEditView | ||||
| extends PHUIDiffInlineCommentView { | extends PHUIDiffInlineCommentView { | ||||
| private $inputs = array(); | |||||
| private $uri; | |||||
| private $title; | private $title; | ||||
| private $number; | |||||
| private $length; | |||||
| private $renderer; | |||||
| private $isNewFile; | |||||
| private $replyToCommentPHID; | |||||
| private $changesetID; | |||||
| public function setIsNewFile($is_new_file) { | |||||
| $this->isNewFile = $is_new_file; | |||||
| return $this; | |||||
| } | |||||
| public function getIsNewFile() { | |||||
| return $this->isNewFile; | |||||
| } | |||||
| public function setRenderer($renderer) { | |||||
| $this->renderer = $renderer; | |||||
| return $this; | |||||
| } | |||||
| public function getRenderer() { | |||||
| return $this->renderer; | |||||
| } | |||||
| public function addHiddenInput($key, $value) { | |||||
| $this->inputs[] = array($key, $value); | |||||
| return $this; | |||||
| } | |||||
| public function setSubmitURI($uri) { | |||||
| $this->uri = $uri; | |||||
| return $this; | |||||
| } | |||||
| public function setTitle($title) { | public function setTitle($title) { | ||||
| $this->title = $title; | $this->title = $title; | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| public function setReplyToCommentPHID($reply_to_phid) { | |||||
| $this->replyToCommentPHID = $reply_to_phid; | |||||
| return $this; | |||||
| } | |||||
| public function getReplyToCommentPHID() { | |||||
| return $this->replyToCommentPHID; | |||||
| } | |||||
| public function setChangesetID($changeset_id) { | |||||
| $this->changesetID = $changeset_id; | |||||
| return $this; | |||||
| } | |||||
| public function getChangesetID() { | |||||
| return $this->changesetID; | |||||
| } | |||||
| public function setNumber($number) { | |||||
| $this->number = $number; | |||||
| return $this; | |||||
| } | |||||
| public function setLength($length) { | |||||
| $this->length = $length; | |||||
| return $this; | |||||
| } | |||||
| public function render() { | public function render() { | ||||
| if (!$this->uri) { | |||||
| throw new PhutilInvalidStateException('setSubmitURI'); | |||||
| } | |||||
| $viewer = $this->getViewer(); | $viewer = $this->getViewer(); | ||||
| $inline = $this->getInlineComment(); | |||||
| $content = phabricator_form( | $content = phabricator_form( | ||||
| $viewer, | $viewer, | ||||
| array( | array( | ||||
| 'action' => $this->uri, | 'action' => $inline->getControllerURI(), | ||||
| 'method' => 'POST', | 'method' => 'POST', | ||||
| 'sigil' => 'inline-edit-form', | 'sigil' => 'inline-edit-form', | ||||
| ), | ), | ||||
| array( | array( | ||||
| $this->renderInputs(), | $this->renderInputs(), | ||||
| $this->renderBody(), | $this->renderBody(), | ||||
| )); | )); | ||||
| return $content; | return $content; | ||||
| } | } | ||||
| private function renderInputs() { | private function renderInputs() { | ||||
| $inputs = $this->inputs; | $inputs = array(); | ||||
| $out = array(); | $inline = $this->getInlineComment(); | ||||
| $inputs[] = array('on_right', (bool)$this->getIsOnRight()); | $inputs[] = array('op', 'edit'); | ||||
| $inputs[] = array('replyToCommentPHID', $this->getReplyToCommentPHID()); | $inputs[] = array('id', $inline->getID()); | ||||
| $inputs[] = array('on_right', $this->getIsOnRight()); | |||||
| $inputs[] = array('renderer', $this->getRenderer()); | $inputs[] = array('renderer', $this->getRenderer()); | ||||
| $inputs[] = array('changesetID', $this->getChangesetID()); | |||||
| $out = array(); | |||||
| foreach ($inputs as $input) { | foreach ($inputs as $input) { | ||||
| list($name, $value) = $input; | list($name, $value) = $input; | ||||
| $out[] = phutil_tag( | $out[] = phutil_tag( | ||||
| 'input', | 'input', | ||||
| array( | array( | ||||
| 'type' => 'hidden', | 'type' => 'hidden', | ||||
| 'name' => $name, | 'name' => $name, | ||||
| 'value' => $value, | 'value' => $value, | ||||
| )); | )); | ||||
| } | } | ||||
| return $out; | return $out; | ||||
| } | } | ||||
| private function renderBody() { | private function renderBody() { | ||||
| $buttons = array(); | $buttons = array(); | ||||
| $buttons[] = id(new PHUIButtonView()) | $buttons[] = id(new PHUIButtonView()) | ||||
| ->setText(pht('Save Draft')); | ->setText(pht('Save Draft')); | ||||
| Show All 10 Lines | $title = phutil_tag( | ||||
| ), | ), | ||||
| $this->title); | $this->title); | ||||
| $body = phutil_tag( | $body = phutil_tag( | ||||
| 'div', | 'div', | ||||
| array( | array( | ||||
| 'class' => 'differential-inline-comment-edit-body', | 'class' => 'differential-inline-comment-edit-body', | ||||
| ), | ), | ||||
| $this->renderChildren()); | $this->newTextarea()); | ||||
| $edit = phutil_tag( | $edit = phutil_tag( | ||||
| 'div', | 'div', | ||||
| array( | array( | ||||
| 'class' => 'differential-inline-comment-edit-buttons grouped', | 'class' => 'differential-inline-comment-edit-buttons grouped', | ||||
| ), | ), | ||||
| array( | array( | ||||
| $buttons, | $buttons, | ||||
| )); | )); | ||||
| $inline = $this->getInlineComment(); | |||||
| return javelin_tag( | return javelin_tag( | ||||
| 'div', | 'div', | ||||
| array( | array( | ||||
| 'class' => 'differential-inline-comment-edit', | 'class' => 'differential-inline-comment-edit', | ||||
| 'sigil' => 'differential-inline-comment', | 'sigil' => 'differential-inline-comment', | ||||
| 'meta' => array( | 'meta' => $this->getInlineCommentMetadata(), | ||||
| 'changesetID' => $this->getChangesetID(), | |||||
| 'on_right' => $this->getIsOnRight(), | |||||
| 'isNewFile' => (bool)$this->getIsNewFile(), | |||||
| 'number' => $this->number, | |||||
| 'length' => $this->length, | |||||
| 'replyToCommentPHID' => $this->getReplyToCommentPHID(), | |||||
| ), | |||||
| ), | ), | ||||
| array( | array( | ||||
| $title, | $title, | ||||
| $body, | $body, | ||||
| $edit, | $edit, | ||||
| )); | )); | ||||
| } | } | ||||
| private function newTextarea() { | |||||
| $viewer = $this->getViewer(); | |||||
| $inline = $this->getInlineComment(); | |||||
| $text = $inline->getContent(); | |||||
| return id(new PhabricatorRemarkupControl()) | |||||
| ->setViewer($viewer) | |||||
| ->setSigil('differential-inline-comment-edit-textarea') | |||||
| ->setName('text') | |||||
| ->setValue($text) | |||||
| ->setDisableFullScreen(true); | |||||
| } | |||||
| } | } | ||||