Changeset View
Changeset View
Standalone View
Standalone View
src/applications/transactions/editengine/PhabricatorEditEngine.php
| Show First 20 Lines • Show All 157 Lines • ▼ Show 20 Lines | /* -( Display Text )------------------------------------------------------- */ | ||||
| /** | /** | ||||
| * @task text | * @task text | ||||
| */ | */ | ||||
| protected function getObjectEditButtonText($object) { | protected function getObjectEditButtonText($object) { | ||||
| return pht('Save Changes'); | return pht('Save Changes'); | ||||
| } | } | ||||
| /** | |||||
| * @task text | |||||
| */ | |||||
| protected function getCommentViewHeaderText($object) { | |||||
| return pht('Add Comment'); | |||||
| } | |||||
| /** | |||||
| * @task text | |||||
| */ | |||||
| protected function getCommentViewButtonText($object) { | |||||
| return pht('Add Comment'); | |||||
| } | |||||
| /* -( Edit Engine Configuration )------------------------------------------ */ | /* -( Edit Engine Configuration )------------------------------------------ */ | ||||
| protected function supportsEditEngineConfiguration() { | protected function supportsEditEngineConfiguration() { | ||||
| return true; | return true; | ||||
| } | } | ||||
| final protected function getEditEngineConfiguration() { | final protected function getEditEngineConfiguration() { | ||||
| ▲ Show 20 Lines • Show All 395 Lines • ▼ Show 20 Lines | final public function buildResponse() { | ||||
| $this->validateObject($object); | $this->validateObject($object); | ||||
| $action = $request->getURIData('editAction'); | $action = $request->getURIData('editAction'); | ||||
| switch ($action) { | switch ($action) { | ||||
| case 'parameters': | case 'parameters': | ||||
| return $this->buildParametersResponse($object); | return $this->buildParametersResponse($object); | ||||
| case 'nodefault': | case 'nodefault': | ||||
| return $this->buildNoDefaultResponse($object); | return $this->buildNoDefaultResponse($object); | ||||
| case 'comment': | |||||
| return $this->buildCommentResponse($object); | |||||
| default: | default: | ||||
| return $this->buildEditResponse($object); | return $this->buildEditResponse($object); | ||||
| } | } | ||||
| } | } | ||||
| private function buildCrumbs($object, $final = false) { | private function buildCrumbs($object, $final = false) { | ||||
| $controller = $this->getcontroller(); | $controller = $this->getcontroller(); | ||||
| ▲ Show 20 Lines • Show All 264 Lines • ▼ Show 20 Lines | final public function addActionToCrumbs(PHUICrumbsView $crumbs) { | ||||
| if ($dropdown) { | if ($dropdown) { | ||||
| $action->setDropdownMenu($dropdown); | $action->setDropdownMenu($dropdown); | ||||
| } | } | ||||
| $crumbs->addAction($action); | $crumbs->addAction($action); | ||||
| } | } | ||||
| final public function buildEditEngineCommentView($object) { | |||||
| $viewer = $this->getViewer(); | |||||
| $object_phid = $object->getPHID(); | |||||
| $header_text = $this->getCommentViewHeaderText($object); | |||||
| $button_text = $this->getCommentViewButtonText($object); | |||||
| // TODO: Drafts. | |||||
| // $draft = PhabricatorDraft::newFromUserAndKey( | |||||
| // $viewer, | |||||
| // $object_phid); | |||||
| $comment_uri = $this->getEditURI($object, 'comment/'); | |||||
| return id(new PhabricatorApplicationTransactionCommentView()) | |||||
| ->setUser($viewer) | |||||
| ->setObjectPHID($object_phid) | |||||
| ->setHeaderText($header_text) | |||||
| ->setAction($comment_uri) | |||||
| ->setSubmitButtonName($button_text); | |||||
| } | |||||
| /* -( Responding to HTTP Parameter Requests )------------------------------ */ | /* -( Responding to HTTP Parameter Requests )------------------------------ */ | ||||
| /** | /** | ||||
| * Respond to a request for documentation on HTTP parameters. | * Respond to a request for documentation on HTTP parameters. | ||||
| * | * | ||||
| * @param object Editable object. | * @param object Editable object. | ||||
| ▲ Show 20 Lines • Show All 41 Lines • ▼ Show 20 Lines | return $this->getController() | ||||
| ->setTitle(pht('No Default Create Forms')) | ->setTitle(pht('No Default Create Forms')) | ||||
| ->appendParagraph( | ->appendParagraph( | ||||
| pht( | pht( | ||||
| 'This application is not configured with any visible, enabled '. | 'This application is not configured with any visible, enabled '. | ||||
| 'forms for creating objects.')) | 'forms for creating objects.')) | ||||
| ->addCancelButton($cancel_uri); | ->addCancelButton($cancel_uri); | ||||
| } | } | ||||
| private function buildCommentResponse($object) { | |||||
| $viewer = $this->getViewer(); | |||||
| if ($this->getIsCreate()) { | |||||
| return new Aphront404Response(); | |||||
| } | |||||
| $controller = $this->getController(); | |||||
| $request = $controller->getRequest(); | |||||
| if (!$request->isFormPost()) { | |||||
| return new Aphront400Response(); | |||||
| } | |||||
| $is_preview = $request->isPreviewRequest(); | |||||
| $view_uri = $this->getObjectViewURI($object); | |||||
| $template = $object->getApplicationTransactionTemplate(); | |||||
| $comment_template = $template->getApplicationTransactionCommentObject(); | |||||
| $xactions = array(); | |||||
| $xactions[] = id(clone $template) | |||||
| ->setTransactionType(PhabricatorTransactions::TYPE_COMMENT) | |||||
| ->attachComment( | |||||
| id(clone $comment_template) | |||||
| ->setContent($request->getStr('comment'))); | |||||
| $editor = $object->getApplicationTransactionEditor() | |||||
| ->setActor($viewer) | |||||
| ->setContinueOnNoEffect($request->isContinueRequest()) | |||||
| ->setContentSourceFromRequest($request) | |||||
| ->setIsPreview($is_preview); | |||||
| try { | |||||
| $xactions = $editor->applyTransactions($object, $xactions); | |||||
| } catch (PhabricatorApplicationTransactionNoEffectException $ex) { | |||||
| return id(new PhabricatorApplicationTransactionNoEffectResponse()) | |||||
| ->setCancelURI($view_uri) | |||||
| ->setException($ex); | |||||
| } | |||||
| if ($request->isAjax() && $is_preview) { | |||||
| return id(new PhabricatorApplicationTransactionResponse()) | |||||
| ->setViewer($viewer) | |||||
| ->setTransactions($xactions) | |||||
| ->setIsPreview($is_preview); | |||||
| } else { | |||||
| return id(new AphrontRedirectResponse()) | |||||
| ->setURI($view_uri); | |||||
| } | |||||
| } | |||||
| /* -( Conduit )------------------------------------------------------------ */ | /* -( Conduit )------------------------------------------------------------ */ | ||||
| /** | /** | ||||
| * Respond to a Conduit edit request. | * Respond to a Conduit edit request. | ||||
| * | * | ||||
| * This method accepts a list of transactions to apply to an object, and | * This method accepts a list of transactions to apply to an object, and | ||||
| * either edits an existing object or creates a new one. | * either edits an existing object or creates a new one. | ||||
| ▲ Show 20 Lines • Show All 205 Lines • Show Last 20 Lines | |||||