mirror of
https://we.phorge.it/source/phorge.git
synced 2025-01-20 03:31:10 +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();
|
||||
|
||||
$engine = new PhabricatorMarkupEngine();
|
||||
|
||||
foreach ($inline_comments as $inline_comment) {
|
||||
$inline_view = id(new PholioInlineCommentView())
|
||||
->setUser($user)
|
||||
->setHandle($authors[$inline_comment->getAuthorPHID()])
|
||||
->setInlineComment($inline_comment);
|
||||
|
||||
if ($inline_comment->getEditPolicy(PhabricatorPolicyCapability::CAN_EDIT)
|
||||
== $user->getPHID() && $inline_comment->getTransactionPHID() === null) {
|
||||
$inline_view->setEditable(true);
|
||||
}
|
||||
->setInlineComment($inline_comment)
|
||||
->setEngine($engine);
|
||||
|
||||
$inlines[] = $inline_comment->toDictionary() + array(
|
||||
'contentHTML' => $inline_view->render(),
|
||||
|
|
|
@ -59,13 +59,13 @@ final class PholioInlineSaveController extends PholioController {
|
|||
|
||||
$draft->save();
|
||||
|
||||
$handle = head($this->loadViewerHandles(array($user->getPHID())));
|
||||
|
||||
$inline_view = id(new PholioInlineCommentView())
|
||||
->setInlineComment($draft)
|
||||
->setEditable(true)
|
||||
->setHandle(
|
||||
PhabricatorObjectHandleData::loadOneHandle(
|
||||
$user->getPHID(),
|
||||
$user));
|
||||
->setEngine(new PhabricatorMarkupEngine())
|
||||
->setUser($user)
|
||||
->setHandle($handle);
|
||||
|
||||
return id(new AphrontAjaxResponse())
|
||||
->setContent(
|
||||
|
|
|
@ -16,18 +16,14 @@ final class PholioInlineViewController extends PholioController {
|
|||
$user = $request->getUser();
|
||||
|
||||
$inline_comment = id(new PholioTransactionComment())->load($this->id);
|
||||
$handle = PhabricatorObjectHandleData::loadOneHandle(
|
||||
$inline_comment->getAuthorPHID(),
|
||||
$user);
|
||||
$handle = head($this->loadViewerHandles(
|
||||
array($inline_comment->getAuthorPHID())));
|
||||
|
||||
$inline_view = id(new PholioInlineCommentView())
|
||||
->setUser($user)
|
||||
->setHandle($handle)
|
||||
->setInlineComment($inline_comment);
|
||||
|
||||
if ($inline_comment->getEditPolicy(PhabricatorPolicyCapability::CAN_EDIT)
|
||||
== $user->getPHID() && $inline_comment->getTransactionPHID() === null) {
|
||||
$inline_view->setEditable(true);
|
||||
}
|
||||
->setInlineComment($inline_comment)
|
||||
->setEngine(new PhabricatorMarkupEngine());
|
||||
|
||||
return id(new AphrontAjaxResponse())->setContent(
|
||||
$inline_comment->toDictionary() + array(
|
||||
|
|
|
@ -123,7 +123,13 @@ final class PholioMock extends PholioDAO
|
|||
}
|
||||
|
||||
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) {
|
||||
|
|
|
@ -11,6 +11,7 @@ final class PholioTransactionComment
|
|||
protected $y;
|
||||
protected $width;
|
||||
protected $height;
|
||||
protected $content;
|
||||
|
||||
public function getApplicationTransactionObject() {
|
||||
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 {
|
||||
|
||||
private $engine;
|
||||
private $handle;
|
||||
private $inlineComment;
|
||||
|
||||
private $handle;
|
||||
private $editable;
|
||||
public function setEngine(PhabricatorMarkupEngine $engine) {
|
||||
$this->engine = $engine;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setHandle(PhabricatorObjectHandle $handle) {
|
||||
$this->handle = $handle;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setInlineComment(PholioTransactionComment $inline_comment) {
|
||||
if ($inline_comment->getImageID() === null) {
|
||||
|
@ -16,24 +25,26 @@ final class PholioInlineCommentView extends AphrontView {
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function setHandle(PhabricatorObjectHandle $handle) {
|
||||
$this->handle = $handle;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setEditable($editable) {
|
||||
$this->editable = $editable;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function render() {
|
||||
if (!$this->inlineComment) {
|
||||
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;
|
||||
|
||||
if ($this->editable) {
|
||||
if ($this->inlineComment->getTransactionPHID() === null &&
|
||||
$this->inlineComment->getEditPolicy(
|
||||
PhabricatorPolicyCapability::CAN_EDIT) == $this->user->getPHID()) {
|
||||
|
||||
$edit_action = javelin_tag(
|
||||
'a',
|
||||
array(
|
||||
|
@ -74,12 +85,16 @@ final class PholioInlineCommentView extends AphrontView {
|
|||
),
|
||||
array($this->handle->getName(), $actions));
|
||||
|
||||
|
||||
$comment = $this->engine->renderOneObject(
|
||||
$this->inlineComment,
|
||||
PholioTransactionComment::MARKUP_FIELD_COMMENT,
|
||||
$this->user);
|
||||
|
||||
$comment_body = phutil_tag(
|
||||
'div',
|
||||
array(
|
||||
|
||||
),
|
||||
$this->inlineComment->getContent());
|
||||
array(),
|
||||
$comment);
|
||||
|
||||
$comment_block = javelin_tag(
|
||||
'div',
|
||||
|
|
|
@ -74,7 +74,7 @@ final class PholioMockImagesView extends AphrontView {
|
|||
),
|
||||
array($mock_wrapper, $inline_comments_holder));
|
||||
|
||||
if (count($mock->getImages()) > 1) {
|
||||
if (count($mock->getImages()) > 0) {
|
||||
$thumbnails = array();
|
||||
foreach ($mock->getImages() as $image) {
|
||||
$thumbfile = $image->getFile();
|
||||
|
|
Loading…
Reference in a new issue