mirror of
https://we.phorge.it/source/phorge.git
synced 2025-01-18 02:31:10 +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());
|
||||
|
||||
$header = $this->buildHeaderView($event);
|
||||
$subheader = $this->buildSubheaderView($event);
|
||||
$curtain = $this->buildCurtain($event);
|
||||
$details = $this->buildPropertySection($event);
|
||||
$description = $this->buildDescriptionView($event);
|
||||
|
@ -47,6 +48,7 @@ final class PhabricatorCalendarEventViewController
|
|||
|
||||
$view = id(new PHUITwoColumnView())
|
||||
->setHeader($header)
|
||||
->setSubheader($subheader)
|
||||
->setMainColumn(
|
||||
array(
|
||||
$timeline,
|
||||
|
@ -201,32 +203,6 @@ final class PhabricatorCalendarEventViewController
|
|||
$properties = id(new PHUIPropertyListView())
|
||||
->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()) {
|
||||
$properties->addProperty(
|
||||
pht('Recurs'),
|
||||
|
@ -247,10 +223,6 @@ final class PhabricatorCalendarEventViewController
|
|||
}
|
||||
}
|
||||
|
||||
$properties->addProperty(
|
||||
pht('Host'),
|
||||
$viewer->renderHandle($event->getHostPHID()));
|
||||
|
||||
$invitees = $event->getInvitees();
|
||||
foreach ($invitees as $key => $invitee) {
|
||||
if ($invitee->isUninvited()) {
|
||||
|
@ -389,4 +361,29 @@ final class PhabricatorCalendarEventViewController
|
|||
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();
|
||||
|
||||
foreach ($events as $event) {
|
||||
$event_date_info = $this->getEventDateLabel($event);
|
||||
$attendees = array();
|
||||
|
||||
foreach ($event->getInvitees() as $invitee) {
|
||||
|
@ -288,7 +287,7 @@ final class PhabricatorCalendarEventSearchEngine
|
|||
->setObjectName($monogram)
|
||||
->setHeader($event->getName())
|
||||
->setHref($event->getURI())
|
||||
->addAttribute($event_date_info);
|
||||
->addAttribute($event->renderEventDate($viewer, false));
|
||||
|
||||
if ($attendees) {
|
||||
$attending = pht(
|
||||
|
@ -300,13 +299,6 @@ final class PhabricatorCalendarEventSearchEngine
|
|||
$item->addAttribute($attending);
|
||||
}
|
||||
|
||||
if ($event->getDuration()) {
|
||||
$duration = pht(
|
||||
'Duration: %s',
|
||||
$event->getDisplayDuration());
|
||||
$item->addIcon('none', $duration);
|
||||
}
|
||||
|
||||
$list->addItem($item);
|
||||
}
|
||||
|
||||
|
@ -542,40 +534,4 @@ final class PhabricatorCalendarEventSearchEngine
|
|||
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;
|
||||
}
|
||||
|
||||
public function getDisplayDuration() {
|
||||
$seconds = $this->getDuration();
|
||||
$minutes = round($seconds / 60, 1);
|
||||
$hours = round($minutes / 60, 3);
|
||||
$days = round($hours / 24, 2);
|
||||
public function renderEventDate(
|
||||
PhabricatorUser $viewer,
|
||||
$show_end) {
|
||||
|
||||
$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(
|
||||
'%s day(s)',
|
||||
round($days, 1));
|
||||
} else if ($hours >= 1) {
|
||||
'%s - %s',
|
||||
phabricator_datetime($min_epoch, $viewer),
|
||||
phabricator_datetime($max_epoch, $viewer));
|
||||
} else if ($show_end) {
|
||||
return pht(
|
||||
'%s hour(s)',
|
||||
round($hours, 1));
|
||||
} else if ($minutes >= 1) {
|
||||
'%s - %s',
|
||||
phabricator_datetime($min_epoch, $viewer),
|
||||
phabricator_time($max_epoch, $viewer));
|
||||
} else {
|
||||
return pht(
|
||||
'%s minute(s)',
|
||||
round($minutes, 0));
|
||||
'%s',
|
||||
phabricator_datetime($min_epoch, $viewer));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* -( Markup Interface )--------------------------------------------------- */
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue