mirror of
https://we.phorge.it/source/phorge.git
synced 2025-02-01 01:18:22 +01:00
Fixed rendering markup
Summary: Description for mock renders now. Inline comments (on side) render now. Test Plan: {F34021} Reviewers: epriestley Reviewed By: epriestley CC: aran, Korvin, chad Maniphest Tasks: T2597 Differential Revision: https://secure.phabricator.com/D5138
This commit is contained in:
parent
85975084e9
commit
4f1ca64159
7 changed files with 60 additions and 39 deletions
|
@ -26,15 +26,14 @@ final class PholioInlineController extends PholioController {
|
||||||
|
|
||||||
$inlines = array();
|
$inlines = array();
|
||||||
|
|
||||||
|
$engine = new PhabricatorMarkupEngine();
|
||||||
|
|
||||||
foreach ($inline_comments as $inline_comment) {
|
foreach ($inline_comments as $inline_comment) {
|
||||||
$inline_view = id(new PholioInlineCommentView())
|
$inline_view = id(new PholioInlineCommentView())
|
||||||
|
->setUser($user)
|
||||||
->setHandle($authors[$inline_comment->getAuthorPHID()])
|
->setHandle($authors[$inline_comment->getAuthorPHID()])
|
||||||
->setInlineComment($inline_comment);
|
->setInlineComment($inline_comment)
|
||||||
|
->setEngine($engine);
|
||||||
if ($inline_comment->getEditPolicy(PhabricatorPolicyCapability::CAN_EDIT)
|
|
||||||
== $user->getPHID() && $inline_comment->getTransactionPHID() === null) {
|
|
||||||
$inline_view->setEditable(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
$inlines[] = $inline_comment->toDictionary() + array(
|
$inlines[] = $inline_comment->toDictionary() + array(
|
||||||
'contentHTML' => $inline_view->render(),
|
'contentHTML' => $inline_view->render(),
|
||||||
|
|
|
@ -59,13 +59,13 @@ final class PholioInlineSaveController extends PholioController {
|
||||||
|
|
||||||
$draft->save();
|
$draft->save();
|
||||||
|
|
||||||
|
$handle = head($this->loadViewerHandles(array($user->getPHID())));
|
||||||
|
|
||||||
$inline_view = id(new PholioInlineCommentView())
|
$inline_view = id(new PholioInlineCommentView())
|
||||||
->setInlineComment($draft)
|
->setInlineComment($draft)
|
||||||
->setEditable(true)
|
->setEngine(new PhabricatorMarkupEngine())
|
||||||
->setHandle(
|
->setUser($user)
|
||||||
PhabricatorObjectHandleData::loadOneHandle(
|
->setHandle($handle);
|
||||||
$user->getPHID(),
|
|
||||||
$user));
|
|
||||||
|
|
||||||
return id(new AphrontAjaxResponse())
|
return id(new AphrontAjaxResponse())
|
||||||
->setContent(
|
->setContent(
|
||||||
|
|
|
@ -16,18 +16,14 @@ final class PholioInlineViewController extends PholioController {
|
||||||
$user = $request->getUser();
|
$user = $request->getUser();
|
||||||
|
|
||||||
$inline_comment = id(new PholioTransactionComment())->load($this->id);
|
$inline_comment = id(new PholioTransactionComment())->load($this->id);
|
||||||
$handle = PhabricatorObjectHandleData::loadOneHandle(
|
$handle = head($this->loadViewerHandles(
|
||||||
$inline_comment->getAuthorPHID(),
|
array($inline_comment->getAuthorPHID())));
|
||||||
$user);
|
|
||||||
|
|
||||||
$inline_view = id(new PholioInlineCommentView())
|
$inline_view = id(new PholioInlineCommentView())
|
||||||
|
->setUser($user)
|
||||||
->setHandle($handle)
|
->setHandle($handle)
|
||||||
->setInlineComment($inline_comment);
|
->setInlineComment($inline_comment)
|
||||||
|
->setEngine(new PhabricatorMarkupEngine());
|
||||||
if ($inline_comment->getEditPolicy(PhabricatorPolicyCapability::CAN_EDIT)
|
|
||||||
== $user->getPHID() && $inline_comment->getTransactionPHID() === null) {
|
|
||||||
$inline_view->setEditable(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
return id(new AphrontAjaxResponse())->setContent(
|
return id(new AphrontAjaxResponse())->setContent(
|
||||||
$inline_comment->toDictionary() + array(
|
$inline_comment->toDictionary() + array(
|
||||||
|
|
|
@ -123,7 +123,13 @@ final class PholioMock extends PholioDAO
|
||||||
}
|
}
|
||||||
|
|
||||||
public function didMarkupText($field, $output, PhutilMarkupEngine $engine) {
|
public function didMarkupText($field, $output, PhutilMarkupEngine $engine) {
|
||||||
return $output;
|
require_celerity_resource('phabricator-remarkup-css');
|
||||||
|
return phutil_tag(
|
||||||
|
'div',
|
||||||
|
array(
|
||||||
|
'class' => 'phabricator-remarkup',
|
||||||
|
),
|
||||||
|
$output);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function shouldUseMarkupCache($field) {
|
public function shouldUseMarkupCache($field) {
|
||||||
|
|
|
@ -11,6 +11,7 @@ final class PholioTransactionComment
|
||||||
protected $y;
|
protected $y;
|
||||||
protected $width;
|
protected $width;
|
||||||
protected $height;
|
protected $height;
|
||||||
|
protected $content;
|
||||||
|
|
||||||
public function getApplicationTransactionObject() {
|
public function getApplicationTransactionObject() {
|
||||||
return new PholioTransaction();
|
return new PholioTransaction();
|
||||||
|
@ -28,4 +29,8 @@ final class PholioTransactionComment
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function shouldUseMarkupCache($field) {
|
||||||
|
// Only cache submitted comments.
|
||||||
|
return ($this->getTransactionPHID() != null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,10 +2,19 @@
|
||||||
|
|
||||||
final class PholioInlineCommentView extends AphrontView {
|
final class PholioInlineCommentView extends AphrontView {
|
||||||
|
|
||||||
|
private $engine;
|
||||||
|
private $handle;
|
||||||
private $inlineComment;
|
private $inlineComment;
|
||||||
|
|
||||||
private $handle;
|
public function setEngine(PhabricatorMarkupEngine $engine) {
|
||||||
private $editable;
|
$this->engine = $engine;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setHandle(PhabricatorObjectHandle $handle) {
|
||||||
|
$this->handle = $handle;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
public function setInlineComment(PholioTransactionComment $inline_comment) {
|
public function setInlineComment(PholioTransactionComment $inline_comment) {
|
||||||
if ($inline_comment->getImageID() === null) {
|
if ($inline_comment->getImageID() === null) {
|
||||||
|
@ -16,24 +25,26 @@ final class PholioInlineCommentView extends AphrontView {
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setHandle(PhabricatorObjectHandle $handle) {
|
|
||||||
$this->handle = $handle;
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setEditable($editable) {
|
|
||||||
$this->editable = $editable;
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function render() {
|
public function render() {
|
||||||
if (!$this->inlineComment) {
|
if (!$this->inlineComment) {
|
||||||
throw new Exception("Call setInlineComment() before render()!");
|
throw new Exception("Call setInlineComment() before render()!");
|
||||||
}
|
}
|
||||||
|
if ($this->user === null) {
|
||||||
|
throw new Exception("Call setUser() before render()!");
|
||||||
|
}
|
||||||
|
if ($this->engine === null) {
|
||||||
|
throw new Exception("Call setEngine() before render()!");
|
||||||
|
}
|
||||||
|
if ($this->handle === null) {
|
||||||
|
throw new Exception("Call setHandle() before render()!");
|
||||||
|
}
|
||||||
|
|
||||||
$actions = null;
|
$actions = null;
|
||||||
|
|
||||||
if ($this->editable) {
|
if ($this->inlineComment->getTransactionPHID() === null &&
|
||||||
|
$this->inlineComment->getEditPolicy(
|
||||||
|
PhabricatorPolicyCapability::CAN_EDIT) == $this->user->getPHID()) {
|
||||||
|
|
||||||
$edit_action = javelin_tag(
|
$edit_action = javelin_tag(
|
||||||
'a',
|
'a',
|
||||||
array(
|
array(
|
||||||
|
@ -74,12 +85,16 @@ final class PholioInlineCommentView extends AphrontView {
|
||||||
),
|
),
|
||||||
array($this->handle->getName(), $actions));
|
array($this->handle->getName(), $actions));
|
||||||
|
|
||||||
|
|
||||||
|
$comment = $this->engine->renderOneObject(
|
||||||
|
$this->inlineComment,
|
||||||
|
PholioTransactionComment::MARKUP_FIELD_COMMENT,
|
||||||
|
$this->user);
|
||||||
|
|
||||||
$comment_body = phutil_tag(
|
$comment_body = phutil_tag(
|
||||||
'div',
|
'div',
|
||||||
array(
|
array(),
|
||||||
|
$comment);
|
||||||
),
|
|
||||||
$this->inlineComment->getContent());
|
|
||||||
|
|
||||||
$comment_block = javelin_tag(
|
$comment_block = javelin_tag(
|
||||||
'div',
|
'div',
|
||||||
|
|
|
@ -74,7 +74,7 @@ final class PholioMockImagesView extends AphrontView {
|
||||||
),
|
),
|
||||||
array($mock_wrapper, $inline_comments_holder));
|
array($mock_wrapper, $inline_comments_holder));
|
||||||
|
|
||||||
if (count($mock->getImages()) > 1) {
|
if (count($mock->getImages()) > 0) {
|
||||||
$thumbnails = array();
|
$thumbnails = array();
|
||||||
foreach ($mock->getImages() as $image) {
|
foreach ($mock->getImages() as $image) {
|
||||||
$thumbfile = $image->getFile();
|
$thumbfile = $image->getFile();
|
||||||
|
|
Loading…
Add table
Reference in a new issue