diff --git a/src/applications/ponder/controller/PonderCommentSaveController.php b/src/applications/ponder/controller/PonderCommentSaveController.php index 2a81e2b48e..8574e85d85 100644 --- a/src/applications/ponder/controller/PonderCommentSaveController.php +++ b/src/applications/ponder/controller/PonderCommentSaveController.php @@ -1,58 +1,67 @@ getRequest(); if (!$request->isFormPost()) { return new Aphront400Response(); } $user = $request->getUser(); $question_id = $request->getInt('question_id'); $question = PonderQuestionQuery::loadSingle($user, $question_id); if (!$question) { return new Aphront404Response(); } $target = $request->getStr('target'); $objects = id(new PhabricatorObjectHandleData(array($target))) ->loadHandles(); if (!$objects) { return new Aphront404Response(); } $content = $request->getStr('content'); + if (!strlen(trim($content))) { + $dialog = new AphrontDialogView(); + $dialog->setUser($request->getUser()); + $dialog->setTitle('Empty comment'); + $dialog->appendChild('

Your comment must not be empty.

'); + $dialog->addCancelButton('/Q'.$question_id); + + return id(new AphrontDialogResponse())->setDialog($dialog); + } + $res = new PonderComment(); $res ->setContent($content) ->setAuthorPHID($user->getPHID()) ->setTargetPHID($target) ->save(); PhabricatorSearchPonderIndexer::indexQuestion($question); return id(new AphrontRedirectResponse()) ->setURI( - id(new PhutilURI('/Q'. $question->getID())) - ->setFragment('comment-' . $res->getID())); + id(new PhutilURI('/Q'. $question->getID()))); } } diff --git a/src/applications/ponder/view/PonderAddCommentView.php b/src/applications/ponder/view/PonderAddCommentView.php index 2fdbf354df..83e491726b 100644 --- a/src/applications/ponder/view/PonderAddCommentView.php +++ b/src/applications/ponder/view/PonderAddCommentView.php @@ -1,75 +1,76 @@ target = $target; return $this; } public function setUser(PhabricatorUser $user) { $this->user = $user; return $this; } public function setQuestionID($id) { $this->questionID = $id; return $this; } public function setActionURI($uri) { $this->actionURI = $uri; return $this; } public function render() { require_celerity_resource('ponder-comment-table-css'); $is_serious = PhabricatorEnv::getEnvConfig('phabricator.serious-business'); $questionID = $this->questionID; $target = $this->target; $form = new AphrontFormView(); $form ->setUser($this->user) ->setAction($this->actionURI) + ->setWorkflow(true) ->addHiddenInput('target', $target) ->addHiddenInput('question_id', $questionID) ->appendChild( id(new AphrontFormTextAreaControl()) ->setName('content') ->setEnableDragAndDropFileUploads(false)) ->appendChild( id(new AphrontFormSubmitControl()) ->setValue($is_serious ? 'Submit' : 'Editorialize')); $view = id(new AphrontMoreView()) ->setSome(id(new AphrontNullView())->render()) ->setMore($form->render()) ->setExpandText('Add Comment'); return $view->render(); } }