Changeset View
Changeset View
Standalone View
Standalone View
src/infrastructure/diff/view/PHUIDiffInlineCommentEditView.php
| Show All 40 Lines | private function renderBody() { | ||||
| $title = phutil_tag( | $title = phutil_tag( | ||||
| 'div', | 'div', | ||||
| array( | array( | ||||
| 'class' => 'differential-inline-comment-edit-title', | 'class' => 'differential-inline-comment-edit-title', | ||||
| ), | ), | ||||
| $this->title); | $this->title); | ||||
| $corpus_view = $this->newCorpusView(); | |||||
| $body = phutil_tag( | $body = phutil_tag( | ||||
| 'div', | 'div', | ||||
| array( | array( | ||||
| 'class' => 'differential-inline-comment-edit-body', | 'class' => 'differential-inline-comment-edit-body', | ||||
| ), | ), | ||||
| $this->newTextarea()); | array( | ||||
| $corpus_view, | |||||
| $this->newTextarea(), | |||||
| )); | |||||
| $edit = phutil_tag( | $edit = javelin_tag( | ||||
| 'div', | 'div', | ||||
| array( | array( | ||||
| 'class' => 'differential-inline-comment-edit-buttons grouped', | 'class' => 'differential-inline-comment-edit-buttons grouped', | ||||
| 'sigil' => 'inline-edit-buttons', | |||||
| ), | ), | ||||
| array( | array( | ||||
| $buttons, | $buttons, | ||||
| )); | )); | ||||
| $inline = $this->getInlineComment(); | $inline = $this->getInlineComment(); | ||||
| return javelin_tag( | return javelin_tag( | ||||
| Show All 18 Lines | private function newTextarea() { | ||||
| return id(new PhabricatorRemarkupControl()) | return id(new PhabricatorRemarkupControl()) | ||||
| ->setViewer($viewer) | ->setViewer($viewer) | ||||
| ->setSigil('inline-content-text') | ->setSigil('inline-content-text') | ||||
| ->setValue($state->getContentText()) | ->setValue($state->getContentText()) | ||||
| ->setDisableFullScreen(true); | ->setDisableFullScreen(true); | ||||
| } | } | ||||
| private function newCorpusView() { | |||||
| $viewer = $this->getViewer(); | |||||
| $inline = $this->getInlineComment(); | |||||
| $context = $inline->getInlineContext(); | |||||
| if ($context === null) { | |||||
| return null; | |||||
| } | |||||
| $head = $context->getHeadLines(); | |||||
| $head = $this->newContextView($head); | |||||
| $state = $inline->getContentStateForEdit($viewer); | |||||
| $main = $state->getContentSuggestionText(); | |||||
| $main_count = count(phutil_split_lines($main)); | |||||
| $default = $context->getBodyLines(); | |||||
| $default = implode('', $default); | |||||
| // Browsers ignore one leading newline in text areas. Add one so that | |||||
| // any actual leading newlines in the content are preserved. | |||||
| $main = "\n".$main; | |||||
| $textarea = javelin_tag( | |||||
| 'textarea', | |||||
| array( | |||||
| 'class' => 'inline-suggestion-input PhabricatorMonospaced', | |||||
| 'rows' => max(3, $main_count + 1), | |||||
| 'sigil' => 'inline-content-suggestion', | |||||
| 'meta' => array( | |||||
| 'defaultText' => $default, | |||||
| ), | |||||
| ), | |||||
| $main); | |||||
| $main = phutil_tag( | |||||
| 'tr', | |||||
| array( | |||||
| 'class' => 'inline-suggestion-input-row', | |||||
| ), | |||||
| array( | |||||
| phutil_tag( | |||||
| 'td', | |||||
| array( | |||||
| 'class' => 'inline-suggestion-line-cell', | |||||
| ), | |||||
| null), | |||||
| phutil_tag( | |||||
| 'td', | |||||
| array( | |||||
| 'class' => 'inline-suggestion-input-cell', | |||||
| ), | |||||
| $textarea), | |||||
| )); | |||||
| $tail = $context->getTailLines(); | |||||
| $tail = $this->newContextView($tail); | |||||
| $body = phutil_tag( | |||||
| 'tbody', | |||||
| array(), | |||||
| array( | |||||
| $head, | |||||
| $main, | |||||
| $tail, | |||||
| )); | |||||
| $table = phutil_tag( | |||||
| 'table', | |||||
| array( | |||||
| 'class' => 'inline-suggestion-table', | |||||
| ), | |||||
| $body); | |||||
| $container = phutil_tag( | |||||
| 'div', | |||||
| array( | |||||
| 'class' => 'inline-suggestion', | |||||
| ), | |||||
| $table); | |||||
| return $container; | |||||
| } | |||||
| private function newContextView(array $lines) { | |||||
| if (!$lines) { | |||||
| return array(); | |||||
| } | |||||
| $rows = array(); | |||||
| foreach ($lines as $index => $line) { | |||||
| $line_cell = phutil_tag( | |||||
| 'td', | |||||
| array( | |||||
| 'class' => 'inline-suggestion-line-cell PhabricatorMonospaced', | |||||
| ), | |||||
| $index + 1); | |||||
| $text_cell = phutil_tag( | |||||
| 'td', | |||||
| array( | |||||
| 'class' => 'inline-suggestion-text-cell PhabricatorMonospaced', | |||||
| ), | |||||
| $line); | |||||
| $cells = array( | |||||
| $line_cell, | |||||
| $text_cell, | |||||
| ); | |||||
| $rows[] = phutil_tag('tr', array(), $cells); | |||||
| } | |||||
| return $rows; | |||||
| } | |||||
| } | } | ||||