mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-19 03:50:54 +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:
parent
91ee6b78df
commit
f33b5c30eb
4 changed files with 16 additions and 47 deletions
|
@ -379,6 +379,7 @@ final class PhabricatorCalendarEventSearchEngine
|
||||||
->setIsAllDay($event->getIsAllDay())
|
->setIsAllDay($event->getIsAllDay())
|
||||||
->setIcon($event->getDisplayIcon($viewer))
|
->setIcon($event->getDisplayIcon($viewer))
|
||||||
->setViewerIsInvited($is_invited)
|
->setViewerIsInvited($is_invited)
|
||||||
|
->setDatetimeSummary($event->renderEventDate($viewer, true))
|
||||||
->setIconColor($event->getDisplayIconColor($viewer));
|
->setIconColor($event->getDisplayIconColor($viewer));
|
||||||
|
|
||||||
$month_view->addEvent($event_view);
|
$month_view->addEvent($event_view);
|
||||||
|
@ -447,6 +448,7 @@ final class PhabricatorCalendarEventSearchEngine
|
||||||
->setIconColor($status_color)
|
->setIconColor($status_color)
|
||||||
->setName($event->getName())
|
->setName($event->getName())
|
||||||
->setURI($event->getURI())
|
->setURI($event->getURI())
|
||||||
|
->setDatetimeSummary($event->renderEventDate($viewer, true))
|
||||||
->setIsCancelled($event->getIsCancelled());
|
->setIsCancelled($event->getIsCancelled());
|
||||||
|
|
||||||
$day_view->addEvent($event_view);
|
$day_view->addEvent($event_view);
|
||||||
|
|
|
@ -15,6 +15,7 @@ final class AphrontCalendarEventView extends AphrontView {
|
||||||
private $iconColor;
|
private $iconColor;
|
||||||
private $canEdit;
|
private $canEdit;
|
||||||
private $isCancelled;
|
private $isCancelled;
|
||||||
|
private $datetimeSummary;
|
||||||
|
|
||||||
public function setIconColor($icon_color) {
|
public function setIconColor($icon_color) {
|
||||||
$this->iconColor = $icon_color;
|
$this->iconColor = $icon_color;
|
||||||
|
@ -135,6 +136,15 @@ final class AphrontCalendarEventView extends AphrontView {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function setDatetimeSummary($datetime_summary) {
|
||||||
|
$this->datetimeSummary = $datetime_summary;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getDatetimeSummary() {
|
||||||
|
return $this->datetimeSummary;
|
||||||
|
}
|
||||||
|
|
||||||
public function render() {
|
public function render() {
|
||||||
throw new Exception(pht('Events are only rendered indirectly.'));
|
throw new Exception(pht('Events are only rendered indirectly.'));
|
||||||
}
|
}
|
||||||
|
|
|
@ -217,6 +217,7 @@ final class PhabricatorPeopleProfileViewController
|
||||||
->setIcon($event->getIcon())
|
->setIcon($event->getIcon())
|
||||||
->setViewerIsInvited($viewer_is_invited)
|
->setViewerIsInvited($viewer_is_invited)
|
||||||
->setName($event->getName())
|
->setName($event->getName())
|
||||||
|
->setDatetimeSummary($event->renderEventDate($viewer, true))
|
||||||
->setURI($event->getURI());
|
->setURI($event->getURI());
|
||||||
|
|
||||||
$event_views[] = $event_view;
|
$event_views[] = $event_view;
|
||||||
|
|
|
@ -54,6 +54,8 @@ final class PHUICalendarListView extends AphrontTagView {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Javelin::initBehavior('phabricator-tooltips');
|
||||||
|
|
||||||
$singletons = array();
|
$singletons = array();
|
||||||
$allday = false;
|
$allday = false;
|
||||||
foreach ($this->events as $event) {
|
foreach ($this->events as $event) {
|
||||||
|
@ -97,7 +99,7 @@ final class PHUICalendarListView extends AphrontTagView {
|
||||||
$event_classes[] = 'event-cancelled';
|
$event_classes[] = 'event-cancelled';
|
||||||
}
|
}
|
||||||
|
|
||||||
$tip = $this->getEventTooltip($event);
|
$tip = $event->getDateTimeSummary();
|
||||||
if ($this->getView() == 'day') {
|
if ($this->getView() == 'day') {
|
||||||
$tip_align = 'E';
|
$tip_align = 'E';
|
||||||
} else if ($this->getView() == 'month') {
|
} else if ($this->getView() == 'month') {
|
||||||
|
@ -183,52 +185,6 @@ final class PHUICalendarListView extends AphrontTagView {
|
||||||
$event->getName());
|
$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() {
|
public function getIsViewerInvitedOnList() {
|
||||||
foreach ($this->events as $event) {
|
foreach ($this->events as $event) {
|
||||||
if ($event->getViewerIsInvited()) {
|
if ($event->getViewerIsInvited()) {
|
||||||
|
|
Loading…
Reference in a new issue