mirror of
https://we.phorge.it/source/phorge.git
synced 2025-01-25 22:18:19 +01:00
Calendar events should support comments
Summary: Closes T7956, Calendar events should support comments. Test Plan: Open event, add comment, save, comment should appear in timeline. Reviewers: epriestley, #blessed_reviewers Reviewed By: epriestley, #blessed_reviewers Subscribers: Korvin, epriestley Maniphest Tasks: T7956 Differential Revision: https://secure.phabricator.com/D12640
This commit is contained in:
parent
4699c29017
commit
bbba6241c2
5 changed files with 91 additions and 0 deletions
|
@ -1483,6 +1483,7 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorCalendarDAO' => 'applications/calendar/storage/PhabricatorCalendarDAO.php',
|
'PhabricatorCalendarDAO' => 'applications/calendar/storage/PhabricatorCalendarDAO.php',
|
||||||
'PhabricatorCalendarEvent' => 'applications/calendar/storage/PhabricatorCalendarEvent.php',
|
'PhabricatorCalendarEvent' => 'applications/calendar/storage/PhabricatorCalendarEvent.php',
|
||||||
'PhabricatorCalendarEventCancelController' => 'applications/calendar/controller/PhabricatorCalendarEventCancelController.php',
|
'PhabricatorCalendarEventCancelController' => 'applications/calendar/controller/PhabricatorCalendarEventCancelController.php',
|
||||||
|
'PhabricatorCalendarEventCommentController' => 'applications/calendar/controller/PhabricatorCalendarEventCommentController.php',
|
||||||
'PhabricatorCalendarEventEditController' => 'applications/calendar/controller/PhabricatorCalendarEventEditController.php',
|
'PhabricatorCalendarEventEditController' => 'applications/calendar/controller/PhabricatorCalendarEventEditController.php',
|
||||||
'PhabricatorCalendarEventEditor' => 'applications/calendar/editor/PhabricatorCalendarEventEditor.php',
|
'PhabricatorCalendarEventEditor' => 'applications/calendar/editor/PhabricatorCalendarEventEditor.php',
|
||||||
'PhabricatorCalendarEventInvalidEpochException' => 'applications/calendar/exception/PhabricatorCalendarEventInvalidEpochException.php',
|
'PhabricatorCalendarEventInvalidEpochException' => 'applications/calendar/exception/PhabricatorCalendarEventInvalidEpochException.php',
|
||||||
|
@ -4818,6 +4819,7 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorFlaggableInterface',
|
'PhabricatorFlaggableInterface',
|
||||||
),
|
),
|
||||||
'PhabricatorCalendarEventCancelController' => 'PhabricatorCalendarController',
|
'PhabricatorCalendarEventCancelController' => 'PhabricatorCalendarController',
|
||||||
|
'PhabricatorCalendarEventCommentController' => 'PhabricatorCalendarController',
|
||||||
'PhabricatorCalendarEventEditController' => 'PhabricatorCalendarController',
|
'PhabricatorCalendarEventEditController' => 'PhabricatorCalendarController',
|
||||||
'PhabricatorCalendarEventEditor' => 'PhabricatorApplicationTransactionEditor',
|
'PhabricatorCalendarEventEditor' => 'PhabricatorApplicationTransactionEditor',
|
||||||
'PhabricatorCalendarEventInvalidEpochException' => 'Exception',
|
'PhabricatorCalendarEventInvalidEpochException' => 'Exception',
|
||||||
|
|
|
@ -55,6 +55,8 @@ final class PhabricatorCalendarApplication extends PhabricatorApplication {
|
||||||
=> 'PhabricatorCalendarEventCancelController',
|
=> 'PhabricatorCalendarEventCancelController',
|
||||||
'(?P<action>join|decline|accept)/(?P<id>[1-9]\d*)/'
|
'(?P<action>join|decline|accept)/(?P<id>[1-9]\d*)/'
|
||||||
=> 'PhabricatorCalendarEventJoinController',
|
=> 'PhabricatorCalendarEventJoinController',
|
||||||
|
'comment/(?P<id>[1-9]\d*)/'
|
||||||
|
=> 'PhabricatorCalendarEventCommentController',
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
|
@ -0,0 +1,69 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
final class PhabricatorCalendarEventCommentController
|
||||||
|
extends PhabricatorCalendarController {
|
||||||
|
|
||||||
|
private $id;
|
||||||
|
|
||||||
|
|
||||||
|
public function willProcessRequest(array $data) {
|
||||||
|
$this->id = idx($data, 'id');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function handleRequest(AphrontRequest $request) {
|
||||||
|
$user = $request->getUser();
|
||||||
|
|
||||||
|
if (!$request->isFormPost()) {
|
||||||
|
return new Aphront400Response();
|
||||||
|
}
|
||||||
|
|
||||||
|
$event = id(new PhabricatorCalendarEventQuery())
|
||||||
|
->setViewer($user)
|
||||||
|
->withIDs(array($this->id))
|
||||||
|
->executeOne();
|
||||||
|
if (!$event) {
|
||||||
|
return new Aphront404Response();
|
||||||
|
}
|
||||||
|
|
||||||
|
$is_preview = $request->isPreviewRequest();
|
||||||
|
$draft = PhabricatorDraft::buildFromRequest($request);
|
||||||
|
|
||||||
|
$view_uri = '/'.$event->getMonogram();
|
||||||
|
|
||||||
|
$xactions = array();
|
||||||
|
$xactions[] = id(new PhabricatorCalendarEventTransaction())
|
||||||
|
->setTransactionType(PhabricatorTransactions::TYPE_COMMENT)
|
||||||
|
->attachComment(
|
||||||
|
id(new PhabricatorCalendarEventTransactionComment())
|
||||||
|
->setContent($request->getStr('comment')));
|
||||||
|
|
||||||
|
$editor = id(new PhabricatorCalendarEventEditor())
|
||||||
|
->setActor($user)
|
||||||
|
->setContinueOnNoEffect($request->isContinueRequest())
|
||||||
|
->setContentSourceFromRequest($request)
|
||||||
|
->setIsPreview($is_preview);
|
||||||
|
|
||||||
|
try {
|
||||||
|
$xactions = $editor->applyTransactions($event, $xactions);
|
||||||
|
} catch (PhabricatorApplicationTransactionNoEffectException $ex) {
|
||||||
|
return id(new PhabricatorApplicationTransactionNoEffectResponse())
|
||||||
|
->setCancelURI($view_uri)
|
||||||
|
->setException($ex);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($draft) {
|
||||||
|
$draft->replaceOrDelete();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($request->isAjax() && $is_preview) {
|
||||||
|
return id(new PhabricatorApplicationTransactionResponse())
|
||||||
|
->setViewer($user)
|
||||||
|
->setTransactions($xactions)
|
||||||
|
->setIsPreview($is_preview);
|
||||||
|
} else {
|
||||||
|
return id(new AphrontRedirectResponse())
|
||||||
|
->setURI($view_uri);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -43,11 +43,26 @@ final class PhabricatorCalendarEventViewController
|
||||||
->setHeader($header)
|
->setHeader($header)
|
||||||
->addPropertyList($properties);
|
->addPropertyList($properties);
|
||||||
|
|
||||||
|
$is_serious = PhabricatorEnv::getEnvConfig('phabricator.serious-business');
|
||||||
|
$add_comment_header = $is_serious
|
||||||
|
? pht('Add Comment')
|
||||||
|
: pht('Add To Plate');
|
||||||
|
$draft = PhabricatorDraft::newFromUserAndKey($viewer, $event->getPHID());
|
||||||
|
$add_comment_form = id(new PhabricatorApplicationTransactionCommentView())
|
||||||
|
->setUser($viewer)
|
||||||
|
->setObjectPHID($event->getPHID())
|
||||||
|
->setDraft($draft)
|
||||||
|
->setHeaderText($add_comment_header)
|
||||||
|
->setAction(
|
||||||
|
$this->getApplicationURI('/event/comment/'.$event->getID().'/'))
|
||||||
|
->setSubmitButtonName(pht('Add Comment'));
|
||||||
|
|
||||||
return $this->buildApplicationPage(
|
return $this->buildApplicationPage(
|
||||||
array(
|
array(
|
||||||
$crumbs,
|
$crumbs,
|
||||||
$box,
|
$box,
|
||||||
$timeline,
|
$timeline,
|
||||||
|
$add_comment_form,
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'title' => $page_title,
|
'title' => $page_title,
|
||||||
|
|
|
@ -22,6 +22,7 @@ final class PhabricatorCalendarEventEditor
|
||||||
$types[] = PhabricatorCalendarEventTransaction::TYPE_CANCEL;
|
$types[] = PhabricatorCalendarEventTransaction::TYPE_CANCEL;
|
||||||
$types[] = PhabricatorCalendarEventTransaction::TYPE_INVITE;
|
$types[] = PhabricatorCalendarEventTransaction::TYPE_INVITE;
|
||||||
|
|
||||||
|
$types[] = PhabricatorTransactions::TYPE_COMMENT;
|
||||||
$types[] = PhabricatorTransactions::TYPE_VIEW_POLICY;
|
$types[] = PhabricatorTransactions::TYPE_VIEW_POLICY;
|
||||||
$types[] = PhabricatorTransactions::TYPE_EDIT_POLICY;
|
$types[] = PhabricatorTransactions::TYPE_EDIT_POLICY;
|
||||||
|
|
||||||
|
@ -119,6 +120,7 @@ final class PhabricatorCalendarEventEditor
|
||||||
$object->setIsCancelled((int)$xaction->getNewValue());
|
$object->setIsCancelled((int)$xaction->getNewValue());
|
||||||
return;
|
return;
|
||||||
case PhabricatorCalendarEventTransaction::TYPE_INVITE:
|
case PhabricatorCalendarEventTransaction::TYPE_INVITE:
|
||||||
|
case PhabricatorTransactions::TYPE_COMMENT:
|
||||||
case PhabricatorTransactions::TYPE_VIEW_POLICY:
|
case PhabricatorTransactions::TYPE_VIEW_POLICY:
|
||||||
case PhabricatorTransactions::TYPE_EDIT_POLICY:
|
case PhabricatorTransactions::TYPE_EDIT_POLICY:
|
||||||
case PhabricatorTransactions::TYPE_EDGE:
|
case PhabricatorTransactions::TYPE_EDGE:
|
||||||
|
@ -167,6 +169,7 @@ final class PhabricatorCalendarEventEditor
|
||||||
->save();
|
->save();
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
case PhabricatorTransactions::TYPE_COMMENT:
|
||||||
case PhabricatorTransactions::TYPE_VIEW_POLICY:
|
case PhabricatorTransactions::TYPE_VIEW_POLICY:
|
||||||
case PhabricatorTransactions::TYPE_EDIT_POLICY:
|
case PhabricatorTransactions::TYPE_EDIT_POLICY:
|
||||||
case PhabricatorTransactions::TYPE_EDGE:
|
case PhabricatorTransactions::TYPE_EDGE:
|
||||||
|
|
Loading…
Add table
Reference in a new issue