mirror of
https://we.phorge.it/source/phorge.git
synced 2025-01-29 16:08:22 +01:00
Move event host and times into event subheader
Summary: Ref T11326. Show this information with a subheader instead of in properties. Also, slightly simplify the list view. Test Plan: {F1723539} Reviewers: chad Reviewed By: chad Maniphest Tasks: T11326 Differential Revision: https://secure.phabricator.com/D16298
This commit is contained in:
parent
04a69fa313
commit
2ce37034ad
3 changed files with 73 additions and 90 deletions
|
@ -34,6 +34,7 @@ final class PhabricatorCalendarEventViewController
|
||||||
new PhabricatorCalendarEventTransactionQuery());
|
new PhabricatorCalendarEventTransactionQuery());
|
||||||
|
|
||||||
$header = $this->buildHeaderView($event);
|
$header = $this->buildHeaderView($event);
|
||||||
|
$subheader = $this->buildSubheaderView($event);
|
||||||
$curtain = $this->buildCurtain($event);
|
$curtain = $this->buildCurtain($event);
|
||||||
$details = $this->buildPropertySection($event);
|
$details = $this->buildPropertySection($event);
|
||||||
$description = $this->buildDescriptionView($event);
|
$description = $this->buildDescriptionView($event);
|
||||||
|
@ -47,6 +48,7 @@ final class PhabricatorCalendarEventViewController
|
||||||
|
|
||||||
$view = id(new PHUITwoColumnView())
|
$view = id(new PHUITwoColumnView())
|
||||||
->setHeader($header)
|
->setHeader($header)
|
||||||
|
->setSubheader($subheader)
|
||||||
->setMainColumn(
|
->setMainColumn(
|
||||||
array(
|
array(
|
||||||
$timeline,
|
$timeline,
|
||||||
|
@ -201,32 +203,6 @@ final class PhabricatorCalendarEventViewController
|
||||||
$properties = id(new PHUIPropertyListView())
|
$properties = id(new PHUIPropertyListView())
|
||||||
->setUser($viewer);
|
->setUser($viewer);
|
||||||
|
|
||||||
if ($event->getIsAllDay()) {
|
|
||||||
$date_start = phabricator_date($event->getViewerDateFrom(), $viewer);
|
|
||||||
$date_end = phabricator_date($event->getViewerDateTo(), $viewer);
|
|
||||||
|
|
||||||
if ($date_start == $date_end) {
|
|
||||||
$properties->addProperty(
|
|
||||||
pht('Time'),
|
|
||||||
phabricator_date($event->getViewerDateFrom(), $viewer));
|
|
||||||
} else {
|
|
||||||
$properties->addProperty(
|
|
||||||
pht('Starts'),
|
|
||||||
phabricator_date($event->getViewerDateFrom(), $viewer));
|
|
||||||
$properties->addProperty(
|
|
||||||
pht('Ends'),
|
|
||||||
phabricator_date($event->getViewerDateTo(), $viewer));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$properties->addProperty(
|
|
||||||
pht('Starts'),
|
|
||||||
phabricator_datetime($event->getViewerDateFrom(), $viewer));
|
|
||||||
|
|
||||||
$properties->addProperty(
|
|
||||||
pht('Ends'),
|
|
||||||
phabricator_datetime($event->getViewerDateTo(), $viewer));
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($event->getIsRecurring()) {
|
if ($event->getIsRecurring()) {
|
||||||
$properties->addProperty(
|
$properties->addProperty(
|
||||||
pht('Recurs'),
|
pht('Recurs'),
|
||||||
|
@ -247,10 +223,6 @@ final class PhabricatorCalendarEventViewController
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$properties->addProperty(
|
|
||||||
pht('Host'),
|
|
||||||
$viewer->renderHandle($event->getHostPHID()));
|
|
||||||
|
|
||||||
$invitees = $event->getInvitees();
|
$invitees = $event->getInvitees();
|
||||||
foreach ($invitees as $key => $invitee) {
|
foreach ($invitees as $key => $invitee) {
|
||||||
if ($invitee->isUninvited()) {
|
if ($invitee->isUninvited()) {
|
||||||
|
@ -389,4 +361,29 @@ final class PhabricatorCalendarEventViewController
|
||||||
return $instance;
|
return $instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function buildSubheaderView(PhabricatorCalendarEvent $event) {
|
||||||
|
$viewer = $this->getViewer();
|
||||||
|
|
||||||
|
$host_phid = $event->getHostPHID();
|
||||||
|
|
||||||
|
$handles = $viewer->loadHandles(array($host_phid));
|
||||||
|
$handle = $handles[$host_phid];
|
||||||
|
|
||||||
|
$host = $viewer->renderHandle($host_phid);
|
||||||
|
$host = phutil_tag('strong', array(), $host);
|
||||||
|
|
||||||
|
$image_uri = $handles[$host_phid]->getImageURI();
|
||||||
|
$image_href = $handles[$host_phid]->getURI();
|
||||||
|
|
||||||
|
$date = $event->renderEventDate($viewer, true);
|
||||||
|
|
||||||
|
$content = pht('Hosted by %s on %s.', $host, $date);
|
||||||
|
|
||||||
|
return id(new PHUIHeadThingView())
|
||||||
|
->setImage($image_uri)
|
||||||
|
->setImageHref($image_href)
|
||||||
|
->setContent($content);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -264,7 +264,6 @@ final class PhabricatorCalendarEventSearchEngine
|
||||||
$list = new PHUIObjectItemListView();
|
$list = new PHUIObjectItemListView();
|
||||||
|
|
||||||
foreach ($events as $event) {
|
foreach ($events as $event) {
|
||||||
$event_date_info = $this->getEventDateLabel($event);
|
|
||||||
$attendees = array();
|
$attendees = array();
|
||||||
|
|
||||||
foreach ($event->getInvitees() as $invitee) {
|
foreach ($event->getInvitees() as $invitee) {
|
||||||
|
@ -288,7 +287,7 @@ final class PhabricatorCalendarEventSearchEngine
|
||||||
->setObjectName($monogram)
|
->setObjectName($monogram)
|
||||||
->setHeader($event->getName())
|
->setHeader($event->getName())
|
||||||
->setHref($event->getURI())
|
->setHref($event->getURI())
|
||||||
->addAttribute($event_date_info);
|
->addAttribute($event->renderEventDate($viewer, false));
|
||||||
|
|
||||||
if ($attendees) {
|
if ($attendees) {
|
||||||
$attending = pht(
|
$attending = pht(
|
||||||
|
@ -300,13 +299,6 @@ final class PhabricatorCalendarEventSearchEngine
|
||||||
$item->addAttribute($attending);
|
$item->addAttribute($attending);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($event->getDuration()) {
|
|
||||||
$duration = pht(
|
|
||||||
'Duration: %s',
|
|
||||||
$event->getDisplayDuration());
|
|
||||||
$item->addIcon('none', $duration);
|
|
||||||
}
|
|
||||||
|
|
||||||
$list->addItem($item);
|
$list->addItem($item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -542,40 +534,4 @@ final class PhabricatorCalendarEventSearchEngine
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getEventDateLabel($event) {
|
|
||||||
$viewer = $this->requireViewer();
|
|
||||||
|
|
||||||
$from_datetime = PhabricatorTime::getDateTimeFromEpoch(
|
|
||||||
$event->getViewerDateFrom(),
|
|
||||||
$viewer);
|
|
||||||
$to_datetime = PhabricatorTime::getDateTimeFromEpoch(
|
|
||||||
$event->getViewerDateTo(),
|
|
||||||
$viewer);
|
|
||||||
|
|
||||||
$from_date_formatted = $from_datetime->format('Y m d');
|
|
||||||
$to_date_formatted = $to_datetime->format('Y m d');
|
|
||||||
|
|
||||||
if ($event->getIsAllDay()) {
|
|
||||||
if ($from_date_formatted == $to_date_formatted) {
|
|
||||||
return pht(
|
|
||||||
'%s, All Day',
|
|
||||||
phabricator_date($event->getViewerDateFrom(), $viewer));
|
|
||||||
} else {
|
|
||||||
return pht(
|
|
||||||
'%s - %s, All Day',
|
|
||||||
phabricator_date($event->getViewerDateFrom(), $viewer),
|
|
||||||
phabricator_date($event->getViewerDateTo(), $viewer));
|
|
||||||
}
|
|
||||||
} else if ($from_date_formatted == $to_date_formatted) {
|
|
||||||
return pht(
|
|
||||||
'%s - %s',
|
|
||||||
phabricator_datetime($event->getViewerDateFrom(), $viewer),
|
|
||||||
phabricator_time($event->getViewerDateTo(), $viewer));
|
|
||||||
} else {
|
|
||||||
return pht(
|
|
||||||
'%s - %s',
|
|
||||||
phabricator_datetime($event->getViewerDateFrom(), $viewer),
|
|
||||||
phabricator_datetime($event->getViewerDateTo(), $viewer));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -454,30 +454,60 @@ final class PhabricatorCalendarEvent extends PhabricatorCalendarDAO
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDisplayDuration() {
|
public function renderEventDate(
|
||||||
$seconds = $this->getDuration();
|
PhabricatorUser $viewer,
|
||||||
$minutes = round($seconds / 60, 1);
|
$show_end) {
|
||||||
$hours = round($minutes / 60, 3);
|
|
||||||
$days = round($hours / 24, 2);
|
|
||||||
|
|
||||||
$duration = '';
|
if ($show_end) {
|
||||||
|
$min_date = PhabricatorTime::getDateTimeFromEpoch(
|
||||||
|
$this->getViewerDateFrom(),
|
||||||
|
$viewer);
|
||||||
|
|
||||||
if ($days >= 1) {
|
$max_date = PhabricatorTime::getDateTimeFromEpoch(
|
||||||
|
$this->getViewerDateTo(),
|
||||||
|
$viewer);
|
||||||
|
|
||||||
|
$min_day = $min_date->format('Y m d');
|
||||||
|
$max_day = $max_date->format('Y m d');
|
||||||
|
|
||||||
|
$show_end_date = ($min_day != $max_day);
|
||||||
|
} else {
|
||||||
|
$show_end_date = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$min_epoch = $this->getViewerDateFrom();
|
||||||
|
$max_epoch = $this->getViewerDateTo();
|
||||||
|
|
||||||
|
if ($this->getIsAllDay()) {
|
||||||
|
if ($show_end_date) {
|
||||||
|
return pht(
|
||||||
|
'%s - %s, All Day',
|
||||||
|
phabricator_date($min_epoch, $viewer),
|
||||||
|
phabricator_date($max_epoch, $viewer));
|
||||||
|
} else {
|
||||||
|
return pht(
|
||||||
|
'%s, All Day',
|
||||||
|
phabricator_date($min_epoch, $viewer));
|
||||||
|
}
|
||||||
|
} else if ($show_end_date) {
|
||||||
return pht(
|
return pht(
|
||||||
'%s day(s)',
|
'%s - %s',
|
||||||
round($days, 1));
|
phabricator_datetime($min_epoch, $viewer),
|
||||||
} else if ($hours >= 1) {
|
phabricator_datetime($max_epoch, $viewer));
|
||||||
|
} else if ($show_end) {
|
||||||
return pht(
|
return pht(
|
||||||
'%s hour(s)',
|
'%s - %s',
|
||||||
round($hours, 1));
|
phabricator_datetime($min_epoch, $viewer),
|
||||||
} else if ($minutes >= 1) {
|
phabricator_time($max_epoch, $viewer));
|
||||||
|
} else {
|
||||||
return pht(
|
return pht(
|
||||||
'%s minute(s)',
|
'%s',
|
||||||
round($minutes, 0));
|
phabricator_datetime($min_epoch, $viewer));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* -( Markup Interface )--------------------------------------------------- */
|
/* -( Markup Interface )--------------------------------------------------- */
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue