Page MenuHomePhabricator

D17867.diff
No OneTemporary

D17867.diff

diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -1404,7 +1404,6 @@
'LegalpadDefaultViewCapability' => 'applications/legalpad/capability/LegalpadDefaultViewCapability.php',
'LegalpadDocument' => 'applications/legalpad/storage/LegalpadDocument.php',
'LegalpadDocumentBody' => 'applications/legalpad/storage/LegalpadDocumentBody.php',
- 'LegalpadDocumentCommentController' => 'applications/legalpad/controller/LegalpadDocumentCommentController.php',
'LegalpadDocumentDatasource' => 'applications/legalpad/typeahead/LegalpadDocumentDatasource.php',
'LegalpadDocumentDoneController' => 'applications/legalpad/controller/LegalpadDocumentDoneController.php',
'LegalpadDocumentEditController' => 'applications/legalpad/controller/LegalpadDocumentEditController.php',
@@ -6436,7 +6435,6 @@
'LegalpadDAO',
'PhabricatorMarkupInterface',
),
- 'LegalpadDocumentCommentController' => 'LegalpadController',
'LegalpadDocumentDatasource' => 'PhabricatorTypeaheadDatasource',
'LegalpadDocumentDoneController' => 'LegalpadController',
'LegalpadDocumentEditController' => 'LegalpadController',
diff --git a/src/applications/legalpad/application/PhabricatorLegalpadApplication.php b/src/applications/legalpad/application/PhabricatorLegalpadApplication.php
--- a/src/applications/legalpad/application/PhabricatorLegalpadApplication.php
+++ b/src/applications/legalpad/application/PhabricatorLegalpadApplication.php
@@ -57,7 +57,6 @@
=> 'LegalpadDocumentListController',
$this->getEditRoutePattern('edit/')
=> 'LegalpadDocumentEditController',
- 'comment/(?P<id>\d+)/' => 'LegalpadDocumentCommentController',
'view/(?P<id>\d+)/' => 'LegalpadDocumentManageController',
'done/' => 'LegalpadDocumentDoneController',
'verify/(?P<code>[^/]+)/'
diff --git a/src/applications/legalpad/controller/LegalpadDocumentCommentController.php b/src/applications/legalpad/controller/LegalpadDocumentCommentController.php
deleted file mode 100644
--- a/src/applications/legalpad/controller/LegalpadDocumentCommentController.php
+++ /dev/null
@@ -1,72 +0,0 @@
-<?php
-
-final class LegalpadDocumentCommentController extends LegalpadController {
-
- public function handleRequest(AphrontRequest $request) {
- $viewer = $request->getViewer();
- $id = $request->getURIData('id');
-
- if (!$request->isFormPost()) {
- return new Aphront400Response();
- }
-
- $document = id(new LegalpadDocumentQuery())
- ->setViewer($viewer)
- ->withIDs(array($id))
- ->needDocumentBodies(true)
- ->executeOne();
-
- if (!$document) {
- return new Aphront404Response();
- }
-
- $is_preview = $request->isPreviewRequest();
-
- $draft = PhabricatorDraft::buildFromRequest($request);
-
- $document_uri = $this->getApplicationURI('view/'.$document->getID());
-
- $comment = $request->getStr('comment');
-
- $xactions = array();
-
- if (strlen($comment)) {
- $xactions[] = id(new LegalpadTransaction())
- ->setTransactionType(PhabricatorTransactions::TYPE_COMMENT)
- ->attachComment(
- id(new LegalpadTransactionComment())
- ->setDocumentID($document->getID())
- ->setLineNumber(0)
- ->setLineLength(0)
- ->setContent($comment));
- }
-
- $editor = id(new LegalpadDocumentEditor())
- ->setActor($viewer)
- ->setContentSourceFromRequest($request)
- ->setContinueOnNoEffect($request->isContinueRequest())
- ->setIsPreview($is_preview);
-
- try {
- $xactions = $editor->applyTransactions($document, $xactions);
- } catch (PhabricatorApplicationTransactionNoEffectException $ex) {
- return id(new PhabricatorApplicationTransactionNoEffectResponse())
- ->setCancelURI($document_uri)
- ->setException($ex);
- }
-
- if ($draft) {
- $draft->replaceOrDelete();
- }
-
- if ($request->isAjax() && $is_preview) {
- return id(new PhabricatorApplicationTransactionResponse())
- ->setViewer($viewer)
- ->setTransactions($xactions)
- ->setIsPreview($is_preview);
- } else {
- return id(new AphrontRedirectResponse())->setURI($document_uri);
- }
- }
-
-}
diff --git a/src/applications/legalpad/controller/LegalpadDocumentManageController.php b/src/applications/legalpad/controller/LegalpadDocumentManageController.php
--- a/src/applications/legalpad/controller/LegalpadDocumentManageController.php
+++ b/src/applications/legalpad/controller/LegalpadDocumentManageController.php
@@ -37,6 +37,7 @@
$document,
new LegalpadTransactionQuery(),
$engine);
+ $timeline->setQuoteRef($document->getMonogram());
$title = $document_body->getTitle();
@@ -50,9 +51,7 @@
$properties = $this->buildPropertyView($document, $engine);
$document_view = $this->buildDocumentView($document, $engine);
- $comment_form_id = celerity_generate_unique_node_id();
-
- $add_comment = $this->buildAddCommentView($document, $comment_form_id);
+ $comment_form = $this->buildCommentView($document, $timeline);
$crumbs = $this->buildApplicationCrumbs();
$crumbs->addTextCrumb(
@@ -69,7 +68,7 @@
$properties,
$document_view,
$timeline,
- $add_comment,
+ $comment_form,
));
return $this->newPage()
@@ -181,31 +180,14 @@
->setBackground(PHUIObjectBoxView::BLUE_PROPERTY);
}
- private function buildAddCommentView(
- LegalpadDocument $document,
- $comment_form_id) {
+ private function buildCommentView(LegalpadDocument $document, $timeline) {
$viewer = $this->getViewer();
+ $box = id(new LegalpadDocumentEditEngine())
+ ->setViewer($viewer)
+ ->buildEditEngineCommentView($document)
+ ->setTransactionTimeline($timeline);
- $draft = PhabricatorDraft::newFromUserAndKey($viewer, $document->getPHID());
-
- $is_serious = PhabricatorEnv::getEnvConfig('phabricator.serious-business');
-
- $title = $is_serious
- ? pht('Add Comment')
- : pht('Debate Legislation');
-
- $form = id(new PhabricatorApplicationTransactionCommentView())
- ->setUser($viewer)
- ->setObjectPHID($document->getPHID())
- ->setFormID($comment_form_id)
- ->setHeaderText($title)
- ->setDraft($draft)
- ->setSubmitButtonName(pht('Add Comment'))
- ->setAction($this->getApplicationURI('/comment/'.$document->getID().'/'))
- ->setRequestURI($this->getRequest()->getRequestURI());
-
- return $form;
-
+ return $box;
}
}

File Metadata

Mime Type
text/plain
Expires
Fri, Feb 28, 5:37 PM (6 h, 34 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7214344
Default Alt Text
D17867.diff (6 KB)

Event Timeline