mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-30 02:32:42 +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:
parent
39e252caf5
commit
64c8777026
4 changed files with 46 additions and 13 deletions
|
@ -53,7 +53,7 @@ final class PhabricatorCalendarApplication extends PhabricatorApplication {
|
||||||
=> 'PhabricatorCalendarEventEditController',
|
=> 'PhabricatorCalendarEventEditController',
|
||||||
'cancel/(?P<id>[1-9]\d*)/'
|
'cancel/(?P<id>[1-9]\d*)/'
|
||||||
=> 'PhabricatorCalendarEventCancelController',
|
=> 'PhabricatorCalendarEventCancelController',
|
||||||
'join/(?P<id>[1-9]\d*)/'
|
'(?P<action>join|decline|accept)/(?P<id>[1-9]\d*)/'
|
||||||
=> 'PhabricatorCalendarEventJoinController',
|
=> 'PhabricatorCalendarEventJoinController',
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
|
@ -65,6 +65,7 @@ final class PhabricatorCalendarEventEditController
|
||||||
|
|
||||||
$subscribers = PhabricatorSubscribersQuery::loadSubscribersForPHID(
|
$subscribers = PhabricatorSubscribersQuery::loadSubscribersForPHID(
|
||||||
$event->getPHID());
|
$event->getPHID());
|
||||||
|
|
||||||
$invitees = array();
|
$invitees = array();
|
||||||
foreach ($event->getInvitees() as $invitee) {
|
foreach ($event->getInvitees() as $invitee) {
|
||||||
if ($invitee->isUninvited()) {
|
if ($invitee->isUninvited()) {
|
||||||
|
@ -84,12 +85,12 @@ final class PhabricatorCalendarEventEditController
|
||||||
$end_value = $end_time->readValueFromRequest($request);
|
$end_value = $end_time->readValueFromRequest($request);
|
||||||
$description = $request->getStr('description');
|
$description = $request->getStr('description');
|
||||||
$subscribers = $request->getArr('subscribers');
|
$subscribers = $request->getArr('subscribers');
|
||||||
|
|
||||||
$invitees = $request->getArr('invitees');
|
$invitees = $request->getArr('invitees');
|
||||||
$new_invitees = $this->getNewInviteeList($invitees, $event);
|
$new_invitees = $this->getNewInviteeList($invitees, $event);
|
||||||
|
$status_attending = PhabricatorCalendarEventInvitee::STATUS_ATTENDING;
|
||||||
if ($this->isCreate()) {
|
if ($this->isCreate()) {
|
||||||
$status = idx($new_invitees, $user->getPHID());
|
$status = idx($new_invitees, $user->getPHID());
|
||||||
$status_attending = PhabricatorCalendarEventInvitee::STATUS_ATTENDING;
|
|
||||||
if ($status) {
|
if ($status) {
|
||||||
$new_invitees[$user->getPHID()] = $status_attending;
|
$new_invitees[$user->getPHID()] = $status_attending;
|
||||||
}
|
}
|
||||||
|
@ -256,13 +257,10 @@ final class PhabricatorCalendarEventEditController
|
||||||
|
|
||||||
$new = array();
|
$new = array();
|
||||||
foreach ($phids as $phid) {
|
foreach ($phids as $phid) {
|
||||||
$old_invitee = idx($invitees, $phid);
|
$old_status = $event->getUserInviteStatus($phid);
|
||||||
if ($old_invitee) {
|
|
||||||
$old_status = $old_invitee->getStatus();
|
|
||||||
if ($old_status != $uninvited_status) {
|
if ($old_status != $uninvited_status) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
$new[$phid] = $invited_status;
|
$new[$phid] = $invited_status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,8 +5,14 @@ final class PhabricatorCalendarEventJoinController
|
||||||
|
|
||||||
private $id;
|
private $id;
|
||||||
|
|
||||||
|
const ACTION_ACCEPT = 'accept';
|
||||||
|
const ACTION_DECLINE = 'decline';
|
||||||
|
const ACTION_JOIN = 'join';
|
||||||
|
|
||||||
public function handleRequest(AphrontRequest $request) {
|
public function handleRequest(AphrontRequest $request) {
|
||||||
$this->id = $request->getURIData('id');
|
$this->id = $request->getURIData('id');
|
||||||
|
$action = $request->getURIData('action');
|
||||||
|
|
||||||
$request = $this->getRequest();
|
$request = $this->getRequest();
|
||||||
$viewer = $request->getViewer();
|
$viewer = $request->getViewer();
|
||||||
$declined_status = PhabricatorCalendarEventInvitee::STATUS_DECLINED;
|
$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');
|
$title = pht('Join Event');
|
||||||
$paragraph = pht('Would you like to join this event?');
|
$paragraph = pht('Would you like to join this event?');
|
||||||
$submit = pht('Join');
|
$submit = pht('Join');
|
||||||
|
|
|
@ -56,16 +56,44 @@ final class PhabricatorCalendarEventViewController
|
||||||
|
|
||||||
private function buildHeaderView(PhabricatorCalendarEvent $event) {
|
private function buildHeaderView(PhabricatorCalendarEvent $event) {
|
||||||
$viewer = $this->getRequest()->getUser();
|
$viewer = $this->getRequest()->getUser();
|
||||||
|
$id = $event->getID();
|
||||||
|
|
||||||
$is_cancelled = $event->getIsCancelled();
|
$is_cancelled = $event->getIsCancelled();
|
||||||
$icon = $is_cancelled ? ('fa-times') : ('fa-calendar');
|
$icon = $is_cancelled ? ('fa-times') : ('fa-calendar');
|
||||||
$color = $is_cancelled ? ('grey') : ('green');
|
$color = $is_cancelled ? ('grey') : ('green');
|
||||||
$status = $is_cancelled ? ('Cancelled') : ('Active');
|
$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)
|
->setUser($viewer)
|
||||||
->setHeader($event->getName())
|
->setHeader($event->getName())
|
||||||
->setStatus($icon, $color, $status)
|
->setStatus($icon, $color, $status)
|
||||||
->setPolicyObject($event);
|
->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) {
|
private function buildActionView(PhabricatorCalendarEvent $event) {
|
||||||
|
@ -153,8 +181,8 @@ final class PhabricatorCalendarEventViewController
|
||||||
$item = new PHUIStatusItemView();
|
$item = new PHUIStatusItemView();
|
||||||
$invitee_phid = $invitee->getInviteePHID();
|
$invitee_phid = $invitee->getInviteePHID();
|
||||||
$target = $viewer->renderHandle($invitee_phid);
|
$target = $viewer->renderHandle($invitee_phid);
|
||||||
$item->setNote($invitee->getStatus());
|
$item->setNote($invitee->getStatus())
|
||||||
$item->setTarget($target);
|
->setTarget($target);
|
||||||
$invitee_list->addItem($item);
|
$invitee_list->addItem($item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue