From a3a5176b7e17da4daaf7e8e24b09f65db8f2a331 Mon Sep 17 00:00:00 2001 From: Chad Little Date: Tue, 28 Jul 2015 07:47:42 -0700 Subject: [PATCH] Add basic countdown timer to object list Summary: Allows a rough setting of a number and noun for object item list view. Test Plan: Use in countdown, set various times. {F670267} Reviewers: epriestley Reviewed By: epriestley Subscribers: epriestley, Korvin Differential Revision: https://secure.phabricator.com/D13742 --- resources/celerity/map.php | 6 ++--- .../PhabricatorCountdownSearchEngine.php | 13 ++++++---- src/view/phui/PHUIObjectItemView.php | 26 +++++++++++++++++++ .../css/phui/phui-object-item-list-view.css | 13 ++++++++++ 4 files changed, 50 insertions(+), 8 deletions(-) diff --git a/resources/celerity/map.php b/resources/celerity/map.php index 14a77746e2..bb24a63231 100644 --- a/resources/celerity/map.php +++ b/resources/celerity/map.php @@ -7,7 +7,7 @@ */ return array( 'names' => array( - 'core.pkg.css' => 'b7d43de8', + 'core.pkg.css' => 'af140e11', 'core.pkg.js' => 'a590b451', 'darkconsole.pkg.js' => 'e7393ebb', 'differential.pkg.css' => '9451634c', @@ -142,7 +142,7 @@ return array( 'rsrc/css/phui/phui-info-view.css' => '5b16bac6', 'rsrc/css/phui/phui-list.css' => '125599df', 'rsrc/css/phui/phui-object-box.css' => '407eaf5a', - 'rsrc/css/phui/phui-object-item-list-view.css' => 'a1b990b7', + 'rsrc/css/phui/phui-object-item-list-view.css' => '36ce366c', 'rsrc/css/phui/phui-pager.css' => 'bea33d23', 'rsrc/css/phui/phui-pinboard-view.css' => '2495140e', 'rsrc/css/phui/phui-property-list-view.css' => 'aeb09581', @@ -797,7 +797,7 @@ return array( 'phui-inline-comment-view-css' => '9fadd6b8', 'phui-list-view-css' => '125599df', 'phui-object-box-css' => '407eaf5a', - 'phui-object-item-list-view-css' => 'a1b990b7', + 'phui-object-item-list-view-css' => '36ce366c', 'phui-pager-css' => 'bea33d23', 'phui-pinboard-view-css' => '2495140e', 'phui-property-list-view-css' => 'aeb09581', diff --git a/src/applications/countdown/query/PhabricatorCountdownSearchEngine.php b/src/applications/countdown/query/PhabricatorCountdownSearchEngine.php index 74ee2b9518..b9f438ece8 100644 --- a/src/applications/countdown/query/PhabricatorCountdownSearchEngine.php +++ b/src/applications/countdown/query/PhabricatorCountdownSearchEngine.php @@ -102,13 +102,9 @@ final class PhabricatorCountdownSearchEngine foreach ($countdowns as $countdown) { $id = $countdown->getID(); $ended = false; - $icon = 'fa-clock-o'; - $color = 'green'; $epoch = $countdown->getEpoch(); if ($epoch <= PhabricatorTime::getNow()) { $ended = true; - $icon = 'fa-check-square-o'; - $color = 'grey'; } $item = id(new PHUIObjectItemView()) @@ -116,7 +112,6 @@ final class PhabricatorCountdownSearchEngine ->setObject($countdown) ->setObjectName("C{$id}") ->setHeader($countdown->getTitle()) - ->setStatusIcon($icon.' '.$color) ->setHref($this->getApplicationURI("{$id}/")) ->addByline( pht( @@ -128,6 +123,14 @@ final class PhabricatorCountdownSearchEngine pht('Launched on %s', phabricator_datetime($epoch, $viewer))); $item->setDisabled(true); } else { + $time_left = ($epoch - PhabricatorTime::getNow()); + $num = round($time_left / (60 * 60 * 24)); + $noun = pht('Days'); + if ($num < 1) { + $num = round($time_left / (60 * 60), 1); + $noun = pht('Hours'); + } + $item->setCountdown($num, $noun); $item->addAttribute( phabricator_datetime($epoch, $viewer)); } diff --git a/src/view/phui/PHUIObjectItemView.php b/src/view/phui/PHUIObjectItemView.php index 626dcd2781..973592a94c 100644 --- a/src/view/phui/PHUIObjectItemView.php +++ b/src/view/phui/PHUIObjectItemView.php @@ -24,6 +24,8 @@ final class PHUIObjectItemView extends AphrontTagView { private $imageIcon; private $titleText; private $badge; + private $countdownNum; + private $countdownNoun; const AGE_FRESH = 'fresh'; const AGE_STALE = 'stale'; @@ -105,6 +107,12 @@ final class PHUIObjectItemView extends AphrontTagView { return $this; } + public function setCountdown($num, $noun) { + $this->countdownNum = $num; + $this->countdownNoun = $noun; + return $this; + } + public function setTitleText($title_text) { $this->titleText = $title_text; return $this; @@ -603,6 +611,24 @@ final class PHUIObjectItemView extends AphrontTagView { $this->badge); } + if ($this->countdownNum) { + $countdown = phutil_tag( + 'div', + array( + 'class' => 'phui-object-item-countdown-number', + ), + array( + phutil_tag_div('', $this->countdownNum), + phutil_tag_div('', $this->countdownNoun), + )); + $column0 = phutil_tag( + 'div', + array( + 'class' => 'phui-object-item-col0 phui-object-item-countdown', + ), + $countdown); + } + $column1 = phutil_tag( 'div', array( diff --git a/webroot/rsrc/css/phui/phui-object-item-list-view.css b/webroot/rsrc/css/phui/phui-object-item-list-view.css index 2be3de770d..fe965b1b00 100644 --- a/webroot/rsrc/css/phui/phui-object-item-list-view.css +++ b/webroot/rsrc/css/phui/phui-object-item-list-view.css @@ -627,6 +627,19 @@ ul.phui-object-item-list-view .phui-object-item-selected left: 0; } +/* - Countdowns ------------------------------------------------------------ */ + +.phui-object-item-col0.phui-object-item-countdown { + width: 52px; + padding: 0; +} + +.phui-object-item-countdown .phui-object-item-countdown-number { + border-right: 1px solid {$thinblueborder}; + text-align: center; + color: {$bluetext}; +} + /* - Dashboards ------------------------------------------------------------ */