diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index a3e56a36af..7a7ca114d1 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -1404,7 +1404,6 @@ phutil_register_library_map(array( '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 @@ phutil_register_library_map(array( '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 index ecdb3f337b..a3eaff5792 100644 --- a/src/applications/legalpad/application/PhabricatorLegalpadApplication.php +++ b/src/applications/legalpad/application/PhabricatorLegalpadApplication.php @@ -57,7 +57,6 @@ final class PhabricatorLegalpadApplication extends PhabricatorApplication { => 'LegalpadDocumentListController', $this->getEditRoutePattern('edit/') => 'LegalpadDocumentEditController', - 'comment/(?P\d+)/' => 'LegalpadDocumentCommentController', 'view/(?P\d+)/' => 'LegalpadDocumentManageController', 'done/' => 'LegalpadDocumentDoneController', 'verify/(?P[^/]+)/' diff --git a/src/applications/legalpad/controller/LegalpadDocumentCommentController.php b/src/applications/legalpad/controller/LegalpadDocumentCommentController.php deleted file mode 100644 index 530696437b..0000000000 --- a/src/applications/legalpad/controller/LegalpadDocumentCommentController.php +++ /dev/null @@ -1,72 +0,0 @@ -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 index 6d9360a731..b39bc89270 100644 --- a/src/applications/legalpad/controller/LegalpadDocumentManageController.php +++ b/src/applications/legalpad/controller/LegalpadDocumentManageController.php @@ -37,6 +37,7 @@ final class LegalpadDocumentManageController extends LegalpadController { $document, new LegalpadTransactionQuery(), $engine); + $timeline->setQuoteRef($document->getMonogram()); $title = $document_body->getTitle(); @@ -50,9 +51,7 @@ final class LegalpadDocumentManageController extends LegalpadController { $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 @@ final class LegalpadDocumentManageController extends LegalpadController { $properties, $document_view, $timeline, - $add_comment, + $comment_form, )); return $this->newPage() @@ -181,31 +180,14 @@ final class LegalpadDocumentManageController extends LegalpadController { ->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; } }