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

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
This commit is contained in:
Chad Little 2015-07-28 07:47:42 -07:00
parent 62e052f3fc
commit a3a5176b7e
4 changed files with 50 additions and 8 deletions

View file

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

View file

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

View file

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

View file

@ -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 ------------------------------------------------------------ */