1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-21 04:50:55 +01:00

Use the same date rendering display logic for both tooltips and subheaders

Summary: Ref T11816. This could be a little cleaner, but we currently have two copies of the logic. Get them using the same code. Once that's actually working I can go make the code a little prettier.

Test Plan: Viewed Calendar month view tooltips, saw the same values as subheaders.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T11816

Differential Revision: https://secure.phabricator.com/D16880
This commit is contained in:
epriestley 2016-11-16 07:25:04 -08:00
parent 91ee6b78df
commit f33b5c30eb
4 changed files with 16 additions and 47 deletions

View file

@ -379,6 +379,7 @@ final class PhabricatorCalendarEventSearchEngine
->setIsAllDay($event->getIsAllDay())
->setIcon($event->getDisplayIcon($viewer))
->setViewerIsInvited($is_invited)
->setDatetimeSummary($event->renderEventDate($viewer, true))
->setIconColor($event->getDisplayIconColor($viewer));
$month_view->addEvent($event_view);
@ -447,6 +448,7 @@ final class PhabricatorCalendarEventSearchEngine
->setIconColor($status_color)
->setName($event->getName())
->setURI($event->getURI())
->setDatetimeSummary($event->renderEventDate($viewer, true))
->setIsCancelled($event->getIsCancelled());
$day_view->addEvent($event_view);

View file

@ -15,6 +15,7 @@ final class AphrontCalendarEventView extends AphrontView {
private $iconColor;
private $canEdit;
private $isCancelled;
private $datetimeSummary;
public function setIconColor($icon_color) {
$this->iconColor = $icon_color;
@ -135,6 +136,15 @@ final class AphrontCalendarEventView extends AphrontView {
return false;
}
public function setDatetimeSummary($datetime_summary) {
$this->datetimeSummary = $datetime_summary;
return $this;
}
public function getDatetimeSummary() {
return $this->datetimeSummary;
}
public function render() {
throw new Exception(pht('Events are only rendered indirectly.'));
}

View file

@ -217,6 +217,7 @@ final class PhabricatorPeopleProfileViewController
->setIcon($event->getIcon())
->setViewerIsInvited($viewer_is_invited)
->setName($event->getName())
->setDatetimeSummary($event->renderEventDate($viewer, true))
->setURI($event->getURI());
$event_views[] = $event_view;

View file

@ -54,6 +54,8 @@ final class PHUICalendarListView extends AphrontTagView {
return '';
}
Javelin::initBehavior('phabricator-tooltips');
$singletons = array();
$allday = false;
foreach ($this->events as $event) {
@ -97,7 +99,7 @@ final class PHUICalendarListView extends AphrontTagView {
$event_classes[] = 'event-cancelled';
}
$tip = $this->getEventTooltip($event);
$tip = $event->getDateTimeSummary();
if ($this->getView() == 'day') {
$tip_align = 'E';
} else if ($this->getView() == 'month') {
@ -183,52 +185,6 @@ final class PHUICalendarListView extends AphrontTagView {
$event->getName());
}
private function getEventTooltip(AphrontCalendarEventView $event) {
$viewer = $this->getViewer();
$time_key = PhabricatorTimeFormatSetting::SETTINGKEY;
$time_pref = $viewer->getUserSetting($time_key);
Javelin::initBehavior('phabricator-tooltips');
$start = id(AphrontFormDateControlValue::newFromEpoch(
$viewer,
$event->getEpochStart()));
$end = id(AphrontFormDateControlValue::newFromEpoch(
$viewer,
$event->getEpochEnd()));
$end_date = $end->getDateTime();
$end_date = $end_date->modify('-1 second');
$start_date = $start->getDateTime()->format('m d Y');
$end_date = $end_date->format('m d Y');
if ($event->getIsAllDay()) {
if ($start_date == $end_date) {
$tip = pht('All day');
} else {
$tip = pht(
'All day, %s - %s',
$start->getValueAsFormat('M j, Y'),
$end->getValueAsFormat('M j, Y'));
}
} else {
if ($start->getValueDate() == $end->getValueDate()) {
$tip = pht(
'%s - %s',
$start->getValueAsFormat($time_pref),
$end->getValueAsFormat($time_pref));
} else {
$tip = pht(
'%s - %s',
$start->getValueAsFormat('M j, Y, '.$time_pref),
$end->getValueAsFormat('M j, Y, '.$time_pref));
}
}
return $tip;
}
public function getIsViewerInvitedOnList() {
foreach ($this->events as $event) {
if ($event->getViewerIsInvited()) {