1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-26 16:52:41 +01:00

Ability to RSVP to event

Summary: Closes T7986, Ability to RSVP to event.

Test Plan: Create event, invite users, invited users should see buttons on event detail header to accept/decline. Accepting/declining reflects in the invitee status in the property list.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin, epriestley

Maniphest Tasks: T7986

Differential Revision: https://secure.phabricator.com/D12619
This commit is contained in:
lkassianik 2015-04-29 19:48:46 -07:00
parent 39e252caf5
commit 64c8777026
4 changed files with 46 additions and 13 deletions

View file

@ -53,7 +53,7 @@ final class PhabricatorCalendarApplication extends PhabricatorApplication {
=> 'PhabricatorCalendarEventEditController',
'cancel/(?P<id>[1-9]\d*)/'
=> 'PhabricatorCalendarEventCancelController',
'join/(?P<id>[1-9]\d*)/'
'(?P<action>join|decline|accept)/(?P<id>[1-9]\d*)/'
=> 'PhabricatorCalendarEventJoinController',
),
),

View file

@ -65,6 +65,7 @@ final class PhabricatorCalendarEventEditController
$subscribers = PhabricatorSubscribersQuery::loadSubscribersForPHID(
$event->getPHID());
$invitees = array();
foreach ($event->getInvitees() as $invitee) {
if ($invitee->isUninvited()) {
@ -84,12 +85,12 @@ final class PhabricatorCalendarEventEditController
$end_value = $end_time->readValueFromRequest($request);
$description = $request->getStr('description');
$subscribers = $request->getArr('subscribers');
$invitees = $request->getArr('invitees');
$new_invitees = $this->getNewInviteeList($invitees, $event);
$status_attending = PhabricatorCalendarEventInvitee::STATUS_ATTENDING;
if ($this->isCreate()) {
$status = idx($new_invitees, $user->getPHID());
$status_attending = PhabricatorCalendarEventInvitee::STATUS_ATTENDING;
if ($status) {
$new_invitees[$user->getPHID()] = $status_attending;
}
@ -256,13 +257,10 @@ final class PhabricatorCalendarEventEditController
$new = array();
foreach ($phids as $phid) {
$old_invitee = idx($invitees, $phid);
if ($old_invitee) {
$old_status = $old_invitee->getStatus();
$old_status = $event->getUserInviteStatus($phid);
if ($old_status != $uninvited_status) {
continue;
}
}
$new[$phid] = $invited_status;
}

View file

@ -5,8 +5,14 @@ final class PhabricatorCalendarEventJoinController
private $id;
const ACTION_ACCEPT = 'accept';
const ACTION_DECLINE = 'decline';
const ACTION_JOIN = 'join';
public function handleRequest(AphrontRequest $request) {
$this->id = $request->getURIData('id');
$action = $request->getURIData('action');
$request = $this->getRequest();
$viewer = $request->getViewer();
$declined_status = PhabricatorCalendarEventInvitee::STATUS_DECLINED;
@ -54,7 +60,8 @@ final class PhabricatorCalendarEventJoinController
}
}
if (!$is_attending) {
if (($action == self::ACTION_JOIN && !$is_attending)
|| $action == self::ACTION_ACCEPT) {
$title = pht('Join Event');
$paragraph = pht('Would you like to join this event?');
$submit = pht('Join');

View file

@ -56,16 +56,44 @@ final class PhabricatorCalendarEventViewController
private function buildHeaderView(PhabricatorCalendarEvent $event) {
$viewer = $this->getRequest()->getUser();
$id = $event->getID();
$is_cancelled = $event->getIsCancelled();
$icon = $is_cancelled ? ('fa-times') : ('fa-calendar');
$color = $is_cancelled ? ('grey') : ('green');
$status = $is_cancelled ? ('Cancelled') : ('Active');
return id(new PHUIHeaderView())
$invite_status = $event->getUserInviteStatus($viewer->getPHID());
$status_invited = PhabricatorCalendarEventInvitee::STATUS_INVITED;
$is_invite_pending = ($invite_status == $status_invited);
$header = id(new PHUIHeaderView())
->setUser($viewer)
->setHeader($event->getName())
->setStatus($icon, $color, $status)
->setPolicyObject($event);
if ($is_invite_pending) {
$decline_button = id(new PHUIButtonView())
->setTag('a')
->setIcon(id(new PHUIIconView())
->setIconFont('fa-times grey'))
->setHref($this->getApplicationURI("/event/decline/{$id}/"))
->setWorkflow(true)
->setText(pht('Decline'));
$accept_button = id(new PHUIButtonView())
->setTag('a')
->setIcon(id(new PHUIIconView())
->setIconFont('fa-check green'))
->setHref($this->getApplicationURI("/event/accept/{$id}/"))
->setWorkflow(true)
->setText(pht('Accept'));
$header->addActionLink($decline_button)
->addActionLink($accept_button);
}
return $header;
}
private function buildActionView(PhabricatorCalendarEvent $event) {
@ -153,8 +181,8 @@ final class PhabricatorCalendarEventViewController
$item = new PHUIStatusItemView();
$invitee_phid = $invitee->getInviteePHID();
$target = $viewer->renderHandle($invitee_phid);
$item->setNote($invitee->getStatus());
$item->setTarget($target);
$item->setNote($invitee->getStatus())
->setTarget($target);
$invitee_list->addItem($item);
}