Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15414392
D8149.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
6 KB
Referenced Files
None
Subscribers
None
D8149.diff
View Options
Index: src/__phutil_library_map__.php
===================================================================
--- src/__phutil_library_map__.php
+++ src/__phutil_library_map__.php
@@ -1268,6 +1268,7 @@
'PhabricatorCalendarEventOverlapException' => 'applications/calendar/exception/PhabricatorCalendarEventOverlapException.php',
'PhabricatorCalendarEventQuery' => 'applications/calendar/query/PhabricatorCalendarEventQuery.php',
'PhabricatorCalendarEventSearchEngine' => 'applications/calendar/query/PhabricatorCalendarEventSearchEngine.php',
+ 'PhabricatorCalendarEventViewController' => 'applications/calendar/controller/PhabricatorCalendarEventViewController.php',
'PhabricatorCalendarHoliday' => 'applications/calendar/storage/PhabricatorCalendarHoliday.php',
'PhabricatorCalendarHolidayTestCase' => 'applications/calendar/storage/__tests__/PhabricatorCalendarHolidayTestCase.php',
'PhabricatorCampfireProtocolAdapter' => 'infrastructure/daemon/bot/adapter/PhabricatorCampfireProtocolAdapter.php',
@@ -3916,6 +3917,7 @@
'PhabricatorCalendarEventOverlapException' => 'Exception',
'PhabricatorCalendarEventQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
'PhabricatorCalendarEventSearchEngine' => 'PhabricatorApplicationSearchEngine',
+ 'PhabricatorCalendarEventViewController' => 'PhabricatorDashboardController',
'PhabricatorCalendarHoliday' => 'PhabricatorCalendarDAO',
'PhabricatorCalendarHolidayTestCase' => 'PhabricatorTestCase',
'PhabricatorCampfireProtocolAdapter' => 'PhabricatorBotBaseStreamingProtocolAdapter',
Index: src/applications/calendar/application/PhabricatorApplicationCalendar.php
===================================================================
--- src/applications/calendar/application/PhabricatorApplicationCalendar.php
+++ src/applications/calendar/application/PhabricatorApplicationCalendar.php
@@ -45,6 +45,8 @@
'PhabricatorCalendarEventEditController',
'delete/(?P<id>[1-9]\d*)/' =>
'PhabricatorCalendarEventDeleteController',
+ 'view/(?P<id>[1-9]\d*)/' =>
+ 'PhabricatorCalendarEventViewController',
),
),
);
Index: src/applications/calendar/controller/PhabricatorCalendarEventEditController.php
===================================================================
--- src/applications/calendar/controller/PhabricatorCalendarEventEditController.php
+++ src/applications/calendar/controller/PhabricatorCalendarEventEditController.php
@@ -156,8 +156,7 @@
$submit->addCancelButton($this->getApplicationURI());
} else {
$submit->addCancelButton(
- $this->getApplicationURI('event/delete/'.$status->getID().'/'),
- pht('Delete Event'));
+ $this->getApplicationURI('event/view/'.$status->getID().'/'));
}
if ($request->isAjax()) {
Index: src/applications/calendar/controller/PhabricatorCalendarEventViewController.php
===================================================================
--- /dev/null
+++ src/applications/calendar/controller/PhabricatorCalendarEventViewController.php
@@ -0,0 +1,107 @@
+<?php
+
+final class PhabricatorCalendarEventViewController
+ extends PhabricatorDashboardController {
+
+ private $id;
+
+ public function willProcessRequest(array $data) {
+ $this->id = $data['id'];
+ }
+
+ public function processRequest() {
+ $request = $this->getRequest();
+ $viewer = $request->getUser();
+
+ $event = id(new PhabricatorCalendarEventQuery())
+ ->setViewer($viewer)
+ ->withIDs(array($this->id))
+ ->executeOne();
+ if (!$event) {
+ return new Aphront404Response();
+ }
+
+ $title = pht('Event %d', $event->getID());
+ $crumbs = $this->buildApplicationCrumbs();
+ $crumbs->addTextCrumb($title);
+
+ $header = $this->buildHeaderView($event);
+ $actions = $this->buildActionView($event);
+ $properties = $this->buildPropertyView($event);
+
+ $properties->setActionList($actions);
+ $box = id(new PHUIObjectBoxView())
+ ->setHeader($header)
+ ->addPropertyList($properties);
+
+ return $this->buildApplicationPage(
+ array(
+ $crumbs,
+ $box,
+ ),
+ array(
+ 'title' => $title,
+ 'device' => true,
+ ));
+ }
+
+ private function buildHeaderView(PhabricatorCalendarEvent $event) {
+ $viewer = $this->getRequest()->getUser();
+
+ return id(new PHUIHeaderView())
+ ->setUser($viewer)
+ ->setHeader($event->getTerseSummary($viewer))
+ ->setPolicyObject($event);
+ }
+
+ private function buildActionView(PhabricatorCalendarEvent $event) {
+ $viewer = $this->getRequest()->getUser();
+ $id = $event->getID();
+
+ $actions = id(new PhabricatorActionListView())
+ ->setObjectURI($this->getApplicationURI('event/'.$id.'/'))
+ ->setUser($viewer);
+
+ $can_edit = PhabricatorPolicyFilter::hasCapability(
+ $viewer,
+ $event,
+ PhabricatorPolicyCapability::CAN_EDIT);
+
+ $actions->addAction(
+ id(new PhabricatorActionView())
+ ->setName(pht('Edit Event'))
+ ->setIcon('edit')
+ ->setHref($this->getApplicationURI("event/edit/{$id}/"))
+ ->setDisabled(!$can_edit)
+ ->setWorkflow(!$can_edit));
+
+ $actions->addAction(
+ id(new PhabricatorActionView())
+ ->setName(pht('Cancel Event'))
+ ->setIcon('delete')
+ ->setHref($this->getApplicationURI("event/delete/{$id}/"))
+ ->setDisabled(!$can_edit)
+ ->setWorkflow(true));
+
+ return $actions;
+ }
+
+ private function buildPropertyView(PhabricatorCalendarEvent $event) {
+ $viewer = $this->getRequest()->getUser();
+
+ $properties = id(new PHUIPropertyListView())
+ ->setUser($viewer)
+ ->setObject($event);
+
+ $properties->addProperty(
+ pht('Starts'),
+ phabricator_datetime($event->getDateFrom(), $viewer));
+
+ $properties->addProperty(
+ pht('Ends'),
+ phabricator_datetime($event->getDateTo(), $viewer));
+
+ return $properties;
+ }
+
+}
Index: src/applications/calendar/view/AphrontCalendarMonthView.php
===================================================================
--- src/applications/calendar/view/AphrontCalendarMonthView.php
+++ src/applications/calendar/view/AphrontCalendarMonthView.php
@@ -301,16 +301,8 @@
$info .= "\n\n".$event->getDescription();
}
- if ($user->getPHID() == $event->getUserPHID()) {
- $tag = 'a';
- $href = '/calendar/event/edit/'.$event->getEventID().'/';
- } else {
- $tag = 'div';
- $href = null;
- }
-
$text_div = javelin_tag(
- $tag,
+ 'a',
array(
'sigil' => 'has-tooltip',
'meta' => array(
@@ -318,7 +310,7 @@
'size' => 240,
),
'class' => 'aphront-calendar-event-text',
- 'href' => $href,
+ 'href' => '/calendar/event/view/'.$event->getEventID().'/',
),
phutil_utf8_shorten($event->getName(), 32));
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Mar 21, 12:25 AM (3 w, 1 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7517152
Default Alt Text
D8149.diff (6 KB)
Attached To
Mode
D8149: Give Calendar events a more modern view/detail page
Attached
Detach File
Event Timeline
Log In to Comment