1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-18 19:40:55 +01:00

Format Calendar list objects

Summary: Closes T8050, Format Calendar list objects

Test Plan: Open Calendar list, check that new formatting is true to mocks.

Reviewers: chad, #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: epriestley, Korvin

Maniphest Tasks: T8050

Differential Revision: https://secure.phabricator.com/D13318
This commit is contained in:
lkassianik 2015-06-18 11:02:12 -07:00
parent 9109cf62e4
commit e291b90641
2 changed files with 45 additions and 8 deletions

View file

@ -313,17 +313,31 @@ final class PhabricatorCalendarEventSearchEngine
$list = new PHUIObjectItemListView(); $list = new PHUIObjectItemListView();
foreach ($events as $event) { foreach ($events as $event) {
$from = phabricator_datetime($event->getDateFrom(), $viewer); $from = phabricator_datetime($event->getDateFrom(), $viewer);
$to = phabricator_datetime($event->getDateTo(), $viewer); $duration = '';
$creator_handle = $handles[$event->getUserPHID()]; $creator_handle = $handles[$event->getUserPHID()];
$attendees = array();
foreach ($event->getInvitees() as $invitee) {
$attendees[] = $invitee->getInviteePHID();
}
$attendees = pht(
'Attending: %s',
$viewer->renderHandleList($attendees)
->setAsInline(1)
->render());
if (strlen($event->getDuration()) > 0) {
$duration = pht(
'Duration: %s',
$event->getDuration());
}
$item = id(new PHUIObjectItemView()) $item = id(new PHUIObjectItemView())
->setHeader($event->getName()) ->setHeader($viewer->renderHandle($event->getPHID())->render())
->setHref($event->getURI()) ->addAttribute($attendees)
->addByline(pht('Creator: %s', $creator_handle->renderLink())) ->addIcon('none', $from)
->addAttribute(pht('From %s to %s', $from, $to)) ->addIcon('none', $duration);
->addAttribute(id(new PhutilUTF8StringTruncator())
->setMaximumGlyphs(64)
->truncateString($event->getDescription()));
$list->addItem($item); $list->addItem($item);
} }

View file

@ -373,6 +373,29 @@ final class PhabricatorCalendarEvent extends PhabricatorCalendarDAO
return false; return false;
} }
public function getDuration() {
$seconds = $this->dateTo - $this->dateFrom;
$minutes = round($seconds / 60, 1);
$hours = round($minutes / 60, 3);
$days = round($hours / 24, 2);
$duration = '';
if ($days >= 1) {
return pht(
'%s day(s)',
round($days, 1));
} else if ($hours >= 1) {
return pht(
'%s hour(s)',
round($hours, 1));
} else if ($minutes >= 1) {
return pht(
'%s minute(s)',
round($minutes, 0));
}
}
/* -( Markup Interface )--------------------------------------------------- */ /* -( Markup Interface )--------------------------------------------------- */