From 78438951c804e3ec184a839d8f96741146a21dd4 Mon Sep 17 00:00:00 2001 From: lkassianik Date: Wed, 6 May 2015 19:19:14 -0700 Subject: [PATCH] Refactoring to use `PHUICalendarListView` instead of boxes Summary: Ref T4393, Refactoring to use `PHUICalendarListView` instead of boxes Test Plan: See new sidebar Reviewers: chad, #blessed_reviewers, epriestley Reviewed By: #blessed_reviewers, epriestley Subscribers: Korvin, epriestley Maniphest Tasks: T4393 Differential Revision: https://secure.phabricator.com/D12743 --- resources/celerity/map.php | 4 +- .../PhabricatorCalendarEventSearchEngine.php | 2 +- .../view/AphrontCalendarDayEventView.php | 58 ---------- .../view/AphrontCalendarEventView.php | 10 ++ .../phui/calendar/PHUICalendarDayView.php | 108 +++++------------- .../phui/calendar/PHUICalendarListView.php | 2 +- .../css/phui/calendar/phui-calendar-day.css | 23 ---- 7 files changed, 41 insertions(+), 166 deletions(-) delete mode 100644 src/applications/calendar/view/AphrontCalendarDayEventView.php diff --git a/resources/celerity/map.php b/resources/celerity/map.php index daa73b4445..53b5069337 100644 --- a/resources/celerity/map.php +++ b/resources/celerity/map.php @@ -119,7 +119,7 @@ return array( 'rsrc/css/layout/phabricator-hovercard-view.css' => '44394670', 'rsrc/css/layout/phabricator-side-menu-view.css' => 'c1db9e9c', 'rsrc/css/layout/phabricator-source-code-view.css' => '2ceee894', - 'rsrc/css/phui/calendar/phui-calendar-day.css' => 'c2eb34ce', + 'rsrc/css/phui/calendar/phui-calendar-day.css' => '75b8cc4a', 'rsrc/css/phui/calendar/phui-calendar-list.css' => 'c1d0ca59', 'rsrc/css/phui/calendar/phui-calendar-month.css' => 'a92e47d2', 'rsrc/css/phui/calendar/phui-calendar.css' => '8675968e', @@ -773,7 +773,7 @@ return array( 'phui-box-css' => '7b3a2eed', 'phui-button-css' => 'de610129', 'phui-calendar-css' => '8675968e', - 'phui-calendar-day-css' => 'c2eb34ce', + 'phui-calendar-day-css' => '75b8cc4a', 'phui-calendar-list-css' => 'c1d0ca59', 'phui-calendar-month-css' => 'a92e47d2', 'phui-crumbs-view-css' => '594d719e', diff --git a/src/applications/calendar/query/PhabricatorCalendarEventSearchEngine.php b/src/applications/calendar/query/PhabricatorCalendarEventSearchEngine.php index 5eada843d3..b525420ca3 100644 --- a/src/applications/calendar/query/PhabricatorCalendarEventSearchEngine.php +++ b/src/applications/calendar/query/PhabricatorCalendarEventSearchEngine.php @@ -389,7 +389,7 @@ final class PhabricatorCalendarEventSearchEngine $phids = mpull($statuses, 'getUserPHID'); foreach ($statuses as $status) { - $event = new AphrontCalendarDayEventView(); + $event = new AphrontCalendarEventView(); $event->setEventID($status->getID()); $event->setEpochRange($status->getDateFrom(), $status->getDateTo()); diff --git a/src/applications/calendar/view/AphrontCalendarDayEventView.php b/src/applications/calendar/view/AphrontCalendarDayEventView.php deleted file mode 100644 index 0989b8fefa..0000000000 --- a/src/applications/calendar/view/AphrontCalendarDayEventView.php +++ /dev/null @@ -1,58 +0,0 @@ -eventID = $event_id; - return $this; - } - - public function getEventID() { - return $this->eventID; - } - - public function setName($name) { - $this->name = $name; - return $this; - } - - public function getName() { - return $this->name; - } - - public function setURI($uri) { - $this->uri = $uri; - return $this; - } - - public function getURI() { - return $this->uri; - } - - public function setEpochRange($start, $end) { - $this->epochStart = $start; - $this->epochEnd = $end; - return $this; - } - - public function getEpochStart() { - return $this->epochStart; - } - - public function getEpochEnd() { - return $this->epochEnd; - } - - public function render() { - $box = new PHUIObjectBoxView(); - $box->setHeaderText($this->name); - return $box; - - } -} diff --git a/src/applications/calendar/view/AphrontCalendarEventView.php b/src/applications/calendar/view/AphrontCalendarEventView.php index c34d3c6d5d..aebfaa9a50 100644 --- a/src/applications/calendar/view/AphrontCalendarEventView.php +++ b/src/applications/calendar/view/AphrontCalendarEventView.php @@ -9,6 +9,16 @@ final class AphrontCalendarEventView extends AphrontView { private $description; private $eventID; private $color; + private $uri; + + public function setURI($uri) { + $this->uri = $uri; + return $this; + } + + public function getURI() { + return $this->uri; + } public function setEventID($event_id) { $this->eventID = $event_id; diff --git a/src/view/phui/calendar/PHUICalendarDayView.php b/src/view/phui/calendar/PHUICalendarDayView.php index ed17f88ab6..6d42fdcec3 100644 --- a/src/view/phui/calendar/PHUICalendarDayView.php +++ b/src/view/phui/calendar/PHUICalendarDayView.php @@ -8,7 +8,7 @@ final class PHUICalendarDayView extends AphrontView { private $browseURI; private $events = array(); - public function addEvent(AphrontCalendarDayEventView $event) { + public function addEvent(AphrontCalendarEventView $event) { $this->events[] = $event; return $this; } @@ -121,41 +121,21 @@ final class PHUICalendarDayView extends AphrontView { $table_box = id(new PHUIObjectBoxView()) ->setHeader($header) - ->appendChild($table); - - $column1 = phutil_tag( - 'div', - array( - 'class' => 'pm', - ), - $sidebar); - - $column2 = phutil_tag( - 'div', - array( - 'class' => 'pm', - ), - $table_box); + ->appendChild($table) + ->setFlush(true); $layout = id(new AphrontMultiColumnView()) - ->addColumn($column1, 'third') - ->addColumn($column2, 'thirds') + ->addColumn($sidebar, 'third') + ->addColumn($table_box, 'thirds') ->setFluidLayout(true) ->setGutter(AphrontMultiColumnView::GUTTER_MEDIUM); - $wrap = phutil_tag( + return phutil_tag( 'div', array( 'class' => 'ml', ), $layout); - - return phutil_tag( - 'div', - array(), - array( - $wrap, - )); } private function renderSidebar() { @@ -163,11 +143,10 @@ final class PHUICalendarDayView extends AphrontView { $week_of_boxes = $this->getWeekOfBoxes(); $filled_boxes = array(); - foreach ($week_of_boxes as $box) { - $start = $box['start']; + foreach ($week_of_boxes as $weekly_box) { + $start = $weekly_box['start']; $end = id(clone $start)->modify('+1 day'); - $box = $box['box']; $box_events = array(); foreach ($this->events as $event) { @@ -176,65 +155,32 @@ final class PHUICalendarDayView extends AphrontView { $box_events[] = $event; } } - $filled_boxes[] = $this->renderSidebarBox($box_events, $box); + $filled_boxes[] = $this->renderSidebarBox( + $box_events, + $weekly_box['title']); } return $filled_boxes; } - private function renderSidebarBox($events, $box) { - $user = $this->user; - $rows = array(); + private function renderSidebarBox($events, $title) { + $widget = new PHUICalendarWidgetView(); - foreach ($events as $key => $event) { - $uri = $event->getURI(); - $name = $event->getName(); - $time = id(AphrontFormDateControlValue::newFromEpoch( - $user, - $event->getEpochStart())) - ->getValueTime(); + $list = id(new PHUICalendarListView()) + ->setUser($this->user); - $name = phutil_tag( - 'a', - array( - 'href' => $uri, - ), - $name); - - $name = phutil_tag( - 'td', - array( - 'class' => 'calendar-day-sidebar-column-name', - ), - $name); - - $time = phutil_tag( - 'td', - array( - 'class' => 'calendar-day-sidebar-column-time', - ), - $time); - - $rows[] = phutil_tag( - 'tr', - array( - 'class' => 'calendar-day-sidebar-row', - ), - array( - $name, - $time, - )); + if (count($events) == 0) { + $list->showBlankState(true); + } else { + foreach ($events as $event) { + $list->addEvent($event); + } } - $table = phutil_tag( - 'table', - array( - 'class' => 'calendar-day-sidebar-today-table', - ), - $rows); - - $box->appendChild($table); - return $box; + $widget + ->setCalendarList($list) + ->setHeader($title); + return $widget; } private function getWeekOfBoxes() { @@ -259,7 +205,7 @@ final class PHUICalendarDayView extends AphrontView { } $sidebar_day_boxes[] = array( - 'box' => id(new PHUIObjectBoxView())->setHeaderText($title), + 'title' => $title, 'start' => clone $box_start_time, ); @@ -339,7 +285,7 @@ final class PHUICalendarDayView extends AphrontView { } private function drawEvent( - AphrontCalendarDayEventView $event, + AphrontCalendarEventView $event, $offset, $width, $top, diff --git a/src/view/phui/calendar/PHUICalendarListView.php b/src/view/phui/calendar/PHUICalendarListView.php index fe2bdfb3d0..fd6a7a0e73 100644 --- a/src/view/phui/calendar/PHUICalendarListView.php +++ b/src/view/phui/calendar/PHUICalendarListView.php @@ -123,7 +123,7 @@ final class PHUICalendarListView extends AphrontTagView { 'size' => 200, ), ), - $description); + $event->getName()); return $anchor; } diff --git a/webroot/rsrc/css/phui/calendar/phui-calendar-day.css b/webroot/rsrc/css/phui/calendar/phui-calendar-day.css index 6ac1c8436a..bb07f8b8f8 100644 --- a/webroot/rsrc/css/phui/calendar/phui-calendar-day.css +++ b/webroot/rsrc/css/phui/calendar/phui-calendar-day.css @@ -7,29 +7,6 @@ width: 100%; } -.calendar-day-sidebar-today-table { - width: 100%; - margin: 8px 0; -} - -.calendar-day-sidebar-column-name { - text-align: left; - color: {$bluetext}; - width: 60%; - padding: 4px 16px; -} - -.calendar-day-sidebar-column-name a { - color: {$bluetext}; -} - -.calendar-day-sidebar-column-time { - color: {$bluetext}; - text-align: right; - width: 40%; - padding: 4px 16px; -} - .phui-calendar-day-hour { width: 60px; color: {$lightgreytext};