1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-03-25 10:40:16 +01:00
phorge-phorge/src/infrastructure/diff/view/PHUIDiffInlineCommentEditView.php
epriestley 87bc30526b Make inline content "state-oriented", not "string-oriented"
Summary:
Ref T13513. Currently, all the inline code passes around strings to describe content. I plan to add background music, animation effects, etc., soon. To prepare for this change, make content a state object.

This does not change any user-visible behavior, it just prepares for content to become more complicated than a single string.

Test Plan: Created, edited, submitted, cancelled, etc., comments.

Maniphest Tasks: T13513

Differential Revision: https://secure.phabricator.com/D21273
2020-05-20 14:24:11 -07:00

95 lines
2 KiB
PHP

<?php
final class PHUIDiffInlineCommentEditView
extends PHUIDiffInlineCommentView {
private $title;
public function setTitle($title) {
$this->title = $title;
return $this;
}
public function render() {
$viewer = $this->getViewer();
$inline = $this->getInlineComment();
$content = phabricator_form(
$viewer,
array(
'action' => $inline->getControllerURI(),
'method' => 'POST',
'sigil' => 'inline-edit-form',
),
array(
$this->renderBody(),
));
return $content;
}
private function renderBody() {
$buttons = array();
$buttons[] = id(new PHUIButtonView())
->setText(pht('Save Draft'));
$buttons[] = id(new PHUIButtonView())
->setText(pht('Cancel'))
->setColor(PHUIButtonView::GREY)
->addSigil('inline-edit-cancel');
$title = phutil_tag(
'div',
array(
'class' => 'differential-inline-comment-edit-title',
),
$this->title);
$body = phutil_tag(
'div',
array(
'class' => 'differential-inline-comment-edit-body',
),
$this->newTextarea());
$edit = phutil_tag(
'div',
array(
'class' => 'differential-inline-comment-edit-buttons grouped',
),
array(
$buttons,
));
$inline = $this->getInlineComment();
return javelin_tag(
'div',
array(
'class' => 'differential-inline-comment-edit',
'sigil' => 'differential-inline-comment',
'meta' => $this->getInlineCommentMetadata(),
),
array(
$title,
$body,
$edit,
));
}
private function newTextarea() {
$viewer = $this->getViewer();
$inline = $this->getInlineComment();
$text = $inline->getContentForEdit($viewer);
return id(new PhabricatorRemarkupControl())
->setViewer($viewer)
->setSigil('differential-inline-comment-edit-textarea')
->setName('text')
->setValue($text)
->setDisableFullScreen(true);
}
}