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

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
This commit is contained in:
lkassianik 2015-05-06 19:19:14 -07:00
parent 7fd401d0e0
commit 78438951c8
7 changed files with 41 additions and 166 deletions

View file

@ -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',

View file

@ -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());

View file

@ -1,58 +0,0 @@
<?php
final class AphrontCalendarDayEventView extends AphrontView {
private $eventID;
private $epochStart;
private $epochEnd;
private $name;
private $uri;
public function setEventID($event_id) {
$this->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;
}
}

View file

@ -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;

View file

@ -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,

View file

@ -123,7 +123,7 @@ final class PHUICalendarListView extends AphrontTagView {
'size' => 200,
),
),
$description);
$event->getName());
return $anchor;
}

View file

@ -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};