1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-10 08:52:39 +01:00

Modernize Calendar View

Summary: Updates Calendar View to more modern components.

Test Plan: Browse Calendar Forward and Back, Create a Status, Get Excited, Get PUMPED.

Reviewers: epriestley, btrahan

Reviewed By: epriestley

CC: Korvin, epriestley, aran

Maniphest Tasks: T4392

Differential Revision: https://secure.phabricator.com/D8247
This commit is contained in:
Chad Little 2014-02-16 09:25:29 -08:00
parent 569a5be561
commit 32cff58cd2
7 changed files with 191 additions and 171 deletions

View file

@ -19,7 +19,6 @@ return array(
'maniphest.pkg.js' => '1e8f11af', 'maniphest.pkg.js' => '1e8f11af',
'rsrc/css/aphront/aphront-bars.css' => '231ac33c', 'rsrc/css/aphront/aphront-bars.css' => '231ac33c',
'rsrc/css/aphront/aphront-notes.css' => '6acadd3f', 'rsrc/css/aphront/aphront-notes.css' => '6acadd3f',
'rsrc/css/aphront/calendar-view.css' => '166af03d',
'rsrc/css/aphront/context-bar.css' => '1c3b0529', 'rsrc/css/aphront/context-bar.css' => '1c3b0529',
'rsrc/css/aphront/dark-console.css' => '6378ef3d', 'rsrc/css/aphront/dark-console.css' => '6378ef3d',
'rsrc/css/aphront/dialog-view.css' => 'dd9db96c', 'rsrc/css/aphront/dialog-view.css' => 'dd9db96c',
@ -126,6 +125,7 @@ return array(
'rsrc/css/layout/phabricator-source-code-view.css' => '62a99814', 'rsrc/css/layout/phabricator-source-code-view.css' => '62a99814',
'rsrc/css/phui/phui-box.css' => '6c21bd6a', 'rsrc/css/phui/phui-box.css' => '6c21bd6a',
'rsrc/css/phui/phui-button.css' => '8784a966', 'rsrc/css/phui/phui-button.css' => '8784a966',
'rsrc/css/phui/phui-calendar-month.css' => '3474d15a',
'rsrc/css/phui/phui-document.css' => '143b2ac8', 'rsrc/css/phui/phui-document.css' => '143b2ac8',
'rsrc/css/phui/phui-feed-story.css' => '3a59c2cf', 'rsrc/css/phui/phui-feed-story.css' => '3a59c2cf',
'rsrc/css/phui/phui-form-view.css' => '0efd3326', 'rsrc/css/phui/phui-form-view.css' => '0efd3326',
@ -478,7 +478,6 @@ return array(
'symbols' => 'symbols' =>
array( array(
'aphront-bars' => '231ac33c', 'aphront-bars' => '231ac33c',
'aphront-calendar-view-css' => '166af03d',
'aphront-contextbar-view-css' => '1c3b0529', 'aphront-contextbar-view-css' => '1c3b0529',
'aphront-dark-console-css' => '6378ef3d', 'aphront-dark-console-css' => '6378ef3d',
'aphront-dialog-view-css' => 'dd9db96c', 'aphront-dialog-view-css' => 'dd9db96c',
@ -738,6 +737,7 @@ return array(
'phriction-document-css' => 'b0309d8e', 'phriction-document-css' => 'b0309d8e',
'phui-box-css' => '6c21bd6a', 'phui-box-css' => '6c21bd6a',
'phui-button-css' => '8784a966', 'phui-button-css' => '8784a966',
'phui-calendar-month-css' => '3474d15a',
'phui-document-view-css' => '143b2ac8', 'phui-document-view-css' => '143b2ac8',
'phui-feed-story-css' => '3a59c2cf', 'phui-feed-story-css' => '3a59c2cf',
'phui-form-css' => 'b78ec020', 'phui-form-css' => 'b78ec020',

View file

@ -20,7 +20,6 @@ phutil_register_library_map(array(
'AphrontBarView' => 'view/widget/bars/AphrontBarView.php', 'AphrontBarView' => 'view/widget/bars/AphrontBarView.php',
'AphrontCSRFException' => 'aphront/exception/AphrontCSRFException.php', 'AphrontCSRFException' => 'aphront/exception/AphrontCSRFException.php',
'AphrontCalendarEventView' => 'applications/calendar/view/AphrontCalendarEventView.php', 'AphrontCalendarEventView' => 'applications/calendar/view/AphrontCalendarEventView.php',
'AphrontCalendarMonthView' => 'applications/calendar/view/AphrontCalendarMonthView.php',
'AphrontContextBarView' => 'view/layout/AphrontContextBarView.php', 'AphrontContextBarView' => 'view/layout/AphrontContextBarView.php',
'AphrontController' => 'aphront/AphrontController.php', 'AphrontController' => 'aphront/AphrontController.php',
'AphrontCursorPagerView' => 'view/control/AphrontCursorPagerView.php', 'AphrontCursorPagerView' => 'view/control/AphrontCursorPagerView.php',
@ -983,6 +982,7 @@ phutil_register_library_map(array(
'PHUIButtonBarView' => 'view/phui/PHUIButtonBarView.php', 'PHUIButtonBarView' => 'view/phui/PHUIButtonBarView.php',
'PHUIButtonExample' => 'applications/uiexample/examples/PHUIButtonExample.php', 'PHUIButtonExample' => 'applications/uiexample/examples/PHUIButtonExample.php',
'PHUIButtonView' => 'view/phui/PHUIButtonView.php', 'PHUIButtonView' => 'view/phui/PHUIButtonView.php',
'PHUICalendarMonthView' => 'applications/calendar/view/PHUICalendarMonthView.php',
'PHUIColorPalletteExample' => 'applications/uiexample/examples/PHUIColorPalletteExample.php', 'PHUIColorPalletteExample' => 'applications/uiexample/examples/PHUIColorPalletteExample.php',
'PHUIDocumentExample' => 'applications/uiexample/examples/PHUIDocumentExample.php', 'PHUIDocumentExample' => 'applications/uiexample/examples/PHUIDocumentExample.php',
'PHUIDocumentView' => 'view/phui/PHUIDocumentView.php', 'PHUIDocumentView' => 'view/phui/PHUIDocumentView.php',
@ -2549,7 +2549,6 @@ phutil_register_library_map(array(
'AphrontBarView' => 'AphrontView', 'AphrontBarView' => 'AphrontView',
'AphrontCSRFException' => 'AphrontException', 'AphrontCSRFException' => 'AphrontException',
'AphrontCalendarEventView' => 'AphrontView', 'AphrontCalendarEventView' => 'AphrontView',
'AphrontCalendarMonthView' => 'AphrontView',
'AphrontContextBarView' => 'AphrontView', 'AphrontContextBarView' => 'AphrontView',
'AphrontController' => 'Phobject', 'AphrontController' => 'Phobject',
'AphrontCursorPagerView' => 'AphrontView', 'AphrontCursorPagerView' => 'AphrontView',
@ -3613,6 +3612,7 @@ phutil_register_library_map(array(
'PHUIButtonBarView' => 'AphrontTagView', 'PHUIButtonBarView' => 'AphrontTagView',
'PHUIButtonExample' => 'PhabricatorUIExample', 'PHUIButtonExample' => 'PhabricatorUIExample',
'PHUIButtonView' => 'AphrontTagView', 'PHUIButtonView' => 'AphrontTagView',
'PHUICalendarMonthView' => 'AphrontView',
'PHUIColorPalletteExample' => 'PhabricatorUIExample', 'PHUIColorPalletteExample' => 'PhabricatorUIExample',
'PHUIDocumentExample' => 'PhabricatorUIExample', 'PHUIDocumentExample' => 'PhabricatorUIExample',
'PHUIDocumentView' => 'AphrontTagView', 'PHUIDocumentView' => 'AphrontTagView',

View file

@ -27,9 +27,9 @@ final class PhabricatorCalendarBrowseController
->execute(); ->execute();
if ($month == $month_d && $year == $year_d) { if ($month == $month_d && $year == $year_d) {
$month_view = new AphrontCalendarMonthView($month, $year, $day); $month_view = new PHUICalendarMonthView($month, $year, $day);
} else { } else {
$month_view = new AphrontCalendarMonthView($month, $year); $month_view = new PHUICalendarMonthView($month, $year);
} }
$month_view->setBrowseURI($request->getRequestURI()); $month_view->setBrowseURI($request->getRequestURI());
@ -62,7 +62,7 @@ final class PhabricatorCalendarBrowseController
$nav->appendChild( $nav->appendChild(
array( array(
$this->getNoticeView(), $this->getNoticeView(),
phutil_tag('div', array('style' => 'padding: 20px;'), $month_view), $month_view,
)); ));
return $this->buildApplicationPage( return $this->buildApplicationPage(

View file

@ -1,6 +1,6 @@
<?php <?php
final class AphrontCalendarMonthView extends AphrontView { final class PHUICalendarMonthView extends AphrontView {
private $day; private $day;
private $month; private $month;
@ -43,7 +43,7 @@ final class AphrontCalendarMonthView extends AphrontView {
$days = $this->getDatesInMonth(); $days = $this->getDatesInMonth();
require_celerity_resource('aphront-calendar-view-css'); require_celerity_resource('phui-calendar-month-css');
$first = reset($days); $first = reset($days);
$empty = $first->format('w'); $empty = $first->format('w');
@ -52,7 +52,7 @@ final class AphrontCalendarMonthView extends AphrontView {
$empty_box = phutil_tag( $empty_box = phutil_tag(
'div', 'div',
array('class' => 'aphront-calendar-day aphront-calendar-empty'), array('class' => 'phui-calendar-day phui-calendar-empty'),
''); '');
for ($ii = 0; $ii < $empty; $ii++) { for ($ii = 0; $ii < $empty; $ii++) {
@ -65,15 +65,15 @@ final class AphrontCalendarMonthView extends AphrontView {
$day_number = $day->format('j'); $day_number = $day->format('j');
$holiday = idx($this->holidays, $day->format('Y-m-d')); $holiday = idx($this->holidays, $day->format('Y-m-d'));
$class = 'aphront-calendar-day'; $class = 'phui-calendar-day';
$weekday = $day->format('w'); $weekday = $day->format('w');
if ($day_number == $this->day) { if ($day_number == $this->day) {
$class .= ' aphront-calendar-today'; $class .= ' phui-calendar-today';
} }
if ($holiday || $weekday == 0 || $weekday == 6) { if ($holiday || $weekday == 0 || $weekday == 6) {
$class .= ' aphront-calendar-not-work-day'; $class .= ' phui-calendar-not-work-day';
} }
$day->setTime(0, 0, 0); $day->setTime(0, 0, 0);
@ -88,7 +88,7 @@ final class AphrontCalendarMonthView extends AphrontView {
$show_events = array_fill_keys( $show_events = array_fill_keys(
array_keys($show_events), array_keys($show_events),
phutil_tag_div( phutil_tag_div(
'aphront-calendar-event aphront-calendar-event-empty', 'phui-calendar-event phui-calendar-event-empty',
"\xC2\xA0")); // &nbsp; "\xC2\xA0")); // &nbsp;
} }
@ -112,7 +112,7 @@ final class AphrontCalendarMonthView extends AphrontView {
$holiday_markup = phutil_tag( $holiday_markup = phutil_tag(
'div', 'div',
array( array(
'class' => 'aphront-calendar-holiday', 'class' => 'phui-calendar-holiday',
'title' => $name, 'title' => $name,
), ),
$name); $name);
@ -121,7 +121,7 @@ final class AphrontCalendarMonthView extends AphrontView {
$markup[] = phutil_tag_div( $markup[] = phutil_tag_div(
$class, $class,
array( array(
phutil_tag_div('aphront-calendar-date-number', $day_number), phutil_tag_div('phui-calendar-date-number', $day_number),
$holiday_markup, $holiday_markup,
phutil_implode_html("\n", $show_events), phutil_implode_html("\n", $show_events),
)); ));
@ -134,15 +134,25 @@ final class AphrontCalendarMonthView extends AphrontView {
while (count($row) < 7) { while (count($row) < 7) {
$row[] = $empty_box; $row[] = $empty_box;
} }
$j = 0;
foreach ($row as $cell) { foreach ($row as $cell) {
if ($j == 0) {
$cells[] = phutil_tag(
'td',
array(
'class' => 'phui-calendar-month-weekstart'),
$cell);
} else {
$cells[] = phutil_tag('td', array(), $cell); $cells[] = phutil_tag('td', array(), $cell);
} }
$j++;
}
$table[] = phutil_tag('tr', array(), $cells); $table[] = phutil_tag('tr', array(), $cells);
} }
$header = phutil_tag( $header = phutil_tag(
'tr', 'tr',
array('class' => 'aphront-calendar-day-of-week-header'), array('class' => 'phui-calendar-day-of-week-header'),
array( array(
phutil_tag('th', array(), pht('Sun')), phutil_tag('th', array(), pht('Sun')),
phutil_tag('th', array(), pht('Mon')), phutil_tag('th', array(), pht('Mon')),
@ -155,52 +165,69 @@ final class AphrontCalendarMonthView extends AphrontView {
$table = phutil_tag( $table = phutil_tag(
'table', 'table',
array('class' => 'aphront-calendar-view'), array('class' => 'phui-calendar-view'),
array( array(
$this->renderCalendarHeader($first),
$header, $header,
phutil_implode_html("\n", $table), phutil_implode_html("\n", $table),
)); ));
return $table; $box = id(new PHUIObjectBoxView())
->setHeader($this->renderCalendarHeader($first))
->appendChild($table);
return $box;
} }
private function renderCalendarHeader(DateTime $date) { private function renderCalendarHeader(DateTime $date) {
$colspan = 7; $button_bar = null;
$left_th = '';
$right_th = '';
// check for a browseURI, which means we need "fancy" prev / next UI // check for a browseURI, which means we need "fancy" prev / next UI
$uri = $this->getBrowseURI(); $uri = $this->getBrowseURI();
if ($uri) { if ($uri) {
$colspan = 5;
$uri = new PhutilURI($uri); $uri = new PhutilURI($uri);
list($prev_year, $prev_month) = $this->getPrevYearAndMonth(); list($prev_year, $prev_month) = $this->getPrevYearAndMonth();
$query = array('year' => $prev_year, 'month' => $prev_month); $query = array('year' => $prev_year, 'month' => $prev_month);
$prev_link = phutil_tag( $prev_uri = (string) $uri->setQueryParams($query);
'a',
array('href' => (string) $uri->setQueryParams($query)),
"\xE2\x86\x90");
list($next_year, $next_month) = $this->getNextYearAndMonth(); list($next_year, $next_month) = $this->getNextYearAndMonth();
$query = array('year' => $next_year, 'month' => $next_month); $query = array('year' => $next_year, 'month' => $next_month);
$next_link = phutil_tag( $next_uri = (string) $uri->setQueryParams($query);
'a',
array('href' => (string) $uri->setQueryParams($query)), $button_bar = new PHUIButtonBarView();
"\xE2\x86\x92");
$left_icon = id(new PHUIIconView())
->setSpriteSheet(PHUIIconView::SPRITE_BUTTONBAR)
->setSpriteIcon('chevron-left');
$left = id(new PHUIButtonView())
->setTag('a')
->setColor(PHUIButtonView::GREY)
->setHref($prev_uri)
->setTitle(pht('Previous Month'))
->setIcon($left_icon);
$right_icon = id(new PHUIIconView())
->setSpriteSheet(PHUIIconView::SPRITE_BUTTONBAR)
->setSpriteIcon('chevron-right');
$right = id(new PHUIButtonView())
->setTag('a')
->setColor(PHUIButtonView::GREY)
->setHref($next_uri)
->setTitle(pht('Next Month'))
->setIcon($right_icon);
$button_bar->addButton($left);
$button_bar->addButton($right);
$left_th = phutil_tag('th', array(), $prev_link);
$right_th = phutil_tag('th', array(), $next_link);
} }
return phutil_tag( $header = id(new PHUIHeaderView())
'tr', ->setHeader($date->format('F Y'));
array('class' => 'aphront-calendar-month-year-header'),
array( if ($button_bar) {
$left_th, $header->setButtonBar($button_bar);
phutil_tag('th', array('colspan' => $colspan), $date->format('F Y')), }
$right_th,
)); return $header;
} }
private function getNextYearAndMonth() { private function getNextYearAndMonth() {
@ -279,16 +306,16 @@ final class AphrontCalendarMonthView extends AphrontView {
$classes = array(); $classes = array();
$when = array(); $when = array();
$classes[] = 'aphront-calendar-event'; $classes[] = 'phui-calendar-event';
if ($event_start < $epoch_start) { if ($event_start < $epoch_start) {
$classes[] = 'aphront-calendar-event-continues-before'; $classes[] = 'phui-calendar-event-continues-before';
$when[] = 'Started '.phabricator_datetime($event_start, $user); $when[] = 'Started '.phabricator_datetime($event_start, $user);
} else { } else {
$when[] = 'Starts at '.phabricator_time($event_start, $user); $when[] = 'Starts at '.phabricator_time($event_start, $user);
} }
if ($event_end > $epoch_end) { if ($event_end > $epoch_end) {
$classes[] = 'aphront-calendar-event-continues-after'; $classes[] = 'phui-calendar-event-continues-after';
$when[] = 'Ends '.phabricator_datetime($event_end, $user); $when[] = 'Ends '.phabricator_datetime($event_end, $user);
} else { } else {
$when[] = 'Ends at '.phabricator_time($event_end, $user); $when[] = 'Ends at '.phabricator_time($event_end, $user);
@ -309,7 +336,7 @@ final class AphrontCalendarMonthView extends AphrontView {
'tip' => $info."\n\n".implode("\n", $when), 'tip' => $info."\n\n".implode("\n", $when),
'size' => 240, 'size' => 240,
), ),
'class' => 'aphront-calendar-event-text', 'class' => 'phui-calendar-event-text',
'href' => '/calendar/event/view/'.$event->getEventID().'/', 'href' => '/calendar/event/view/'.$event->getEventID().'/',
), ),
phutil_utf8_shorten($event->getName(), 32)); phutil_utf8_shorten($event->getName(), 32));

View file

@ -14,6 +14,7 @@ final class PHUIHeaderView extends AphrontView {
private $bleedHeader; private $bleedHeader;
private $properties = array(); private $properties = array();
private $actionLinks = array(); private $actionLinks = array();
private $buttonBar = null;
private $policyObject; private $policyObject;
public function setHeader($header) { public function setHeader($header) {
@ -71,6 +72,11 @@ final class PHUIHeaderView extends AphrontView {
return $this; return $this;
} }
public function setButtonBar(PHUIButtonBarView $bb) {
$this->buttonBar = $bb;
return $this;
}
public function setStatus($icon, $color, $name) { public function setStatus($icon, $color, $name) {
$header_class = 'phui-header-status'; $header_class = 'phui-header-status';
@ -206,6 +212,15 @@ final class PHUIHeaderView extends AphrontView {
$actions); $actions);
} }
if ($this->buttonBar) {
$header[] = phutil_tag(
'div',
array(
'class' => 'phui-header-action-links',
),
$this->buttonBar);
}
return phutil_tag( return phutil_tag(
'div', 'div',
array( array(

View file

@ -1,124 +0,0 @@
/**
* @provides aphront-calendar-view-css
*/
.aphront-calendar-view {
width: 100%;
border-collapse: collapse;
background: #fff;
border: 2px solid #4f3612;
box-shadow: 0px 2px 6px #ccc;
}
tr.aphront-calendar-month-year-header th {
text-align: center;
font-weight: bold;
font-size: 20px;
padding: 10px;
color: white;
background: #4f3612;
height: 26px;
}
tr.aphront-calendar-month-year-header th a {
color: white;
font-weight: bold;
text-decoration: none;
display: block;
}
tr.aphront-calendar-month-year-header th a:hover {
color: #feffd0;
}
tr.aphront-calendar-day-of-week-header th {
text-align: center;
font-size: 11px;
padding: 3px;
color: white;
background: #896c45;
}
table.aphront-calendar-view td {
border: 1px solid #dfdfdf;
width: 14.2857%; /* This is one seventh, approximately. */
}
table.aphront-calendar-view td div.aphront-calendar-day {
min-height: 125px;
}
.aphront-calendar-holiday {
color: {$greytext};
padding: .5em;
max-height: 1em;
overflow: hidden;
}
.aphront-calendar-date-number {
font-weight: normal;
color: {$lightgreytext};
padding: 4px;
border-color: #dfdfdf;
border-style: solid;
border-width: 0 0 1px 1px;
float: right;
background: #ffffff;
width: 1.25em;
height: 1.25em;
text-align: center;
margin-bottom: 3px;
}
.aphront-calendar-not-work-day {
background-color: #fdfae7;
}
.aphront-calendar-today {
background-color: #A6FAAD;
}
.aphront-calendar-empty {
background-color: #ededed;
}
.aphront-calendar-event {
clear: both;
background: #006799;
font-size: 11px;
margin: 2px 0;
border-radius: 10px;
padding: 3px 5%;
width: 90%;
overflow: hidden;
}
.aphront-calendar-event a:link {
color: #fff;
}
.aphront-calendar-event-empty {
border-color: transparent;
background: transparent;
}
.aphront-calendar-event-text {
color: #fff;
overflow: hidden;
white-space: nowrap;
}
.aphront-calendar-event-continues-before {
border-top-left-radius: 0px;
border-bottom-left-radius: 0px;
border-left-width: 0px;
}
.aphront-calendar-event-continues-after {
border-top-right-radius: 0px;
border-bottom-right-radius: 0px;
border-right-width: 0px;
}

View file

@ -0,0 +1,102 @@
/**
* @provides phui-calendar-month-css
*/
.phui-calendar-view {
width: 100%;
border-collapse: collapse;
background: #fff;
}
tr.phui-calendar-day-of-week-header th {
text-align: center;
font-size: 11px;
padding: 3px;
color: {$lightbluetext};
background: {$lightgreybackground};
}
table.phui-calendar-view td {
border: 1px solid #dfdfdf;
width: 14.2857%; /* This is one seventh, approximately. */
}
table.phui-calendar-view td div.phui-calendar-day {
min-height: 125px;
}
.phui-calendar-holiday {
color: {$greytext};
padding: .5em;
max-height: 1em;
overflow: hidden;
}
table.phui-calendar-view td.phui-calendar-month-weekstart {
border-left: none;
}
.phui-calendar-date-number {
font-weight: normal;
color: {$lightgreytext};
padding: 4px;
border-color: {$thinblueborder};
border-style: solid;
border-width: 0 0 1px 1px;
float: right;
background: #ffffff;
width: 16px;
height: 16px;
text-align: center;
margin-bottom: 3px;
}
.phui-calendar-not-work-day {
background-color: {$lightgreybackground};
}
.phui-calendar-today {
background-color: {$lightgreen};
}
.phui-calendar-empty {
background-color: {$greybackground};
}
.phui-calendar-event {
clear: both;
background: {$sky};
font-size: 11px;
margin: 2px 0;
border-radius: 3px;
padding: 3px 5%;
width: 90%;
overflow: hidden;
}
.phui-calendar-event a:link {
color: #fff;
}
.phui-calendar-event-empty {
border-color: transparent;
background: transparent;
}
.phui-calendar-event-text {
color: #fff;
overflow: hidden;
white-space: nowrap;
}
.phui-calendar-event-continues-before {
border-top-left-radius: 0px;
border-bottom-left-radius: 0px;
border-left-width: 0px;
}
.phui-calendar-event-continues-after {
border-top-right-radius: 0px;
border-bottom-right-radius: 0px;
border-right-width: 0px;
}