2012-08-15 19:45:06 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class PhabricatorObjectItemListView extends AphrontView {
|
|
|
|
|
|
|
|
private $header;
|
|
|
|
private $items;
|
|
|
|
private $pager;
|
2013-01-25 06:00:47 +01:00
|
|
|
private $stackable;
|
2013-03-10 02:55:01 +01:00
|
|
|
private $cards;
|
2012-09-11 18:55:27 +02:00
|
|
|
private $noDataString;
|
2012-08-15 19:45:06 +02:00
|
|
|
|
|
|
|
public function setHeader($header) {
|
|
|
|
$this->header = $header;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setPager($pager) {
|
|
|
|
$this->pager = $pager;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2012-09-11 18:55:27 +02:00
|
|
|
public function setNoDataString($no_data_string) {
|
|
|
|
$this->noDataString = $no_data_string;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2012-08-15 19:45:06 +02:00
|
|
|
public function addItem(PhabricatorObjectItemView $item) {
|
|
|
|
$this->items[] = $item;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2013-03-10 02:55:01 +01:00
|
|
|
public function setStackable($stackable) {
|
|
|
|
$this->stackable = $stackable;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setCards($cards) {
|
|
|
|
$this->cards = $cards;
|
2013-01-25 06:00:47 +01:00
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2012-08-15 19:45:06 +02:00
|
|
|
public function render() {
|
|
|
|
require_celerity_resource('phabricator-object-item-list-view-css');
|
|
|
|
|
2013-01-25 06:00:47 +01:00
|
|
|
$classes = array();
|
2012-12-13 19:59:29 +01:00
|
|
|
$header = null;
|
|
|
|
if (strlen($this->header)) {
|
2013-01-18 03:43:35 +01:00
|
|
|
$header = phutil_tag(
|
2012-12-13 19:59:29 +01:00
|
|
|
'h1',
|
|
|
|
array(
|
|
|
|
'class' => 'phabricator-object-item-list-header',
|
|
|
|
),
|
2013-01-18 03:43:35 +01:00
|
|
|
$this->header);
|
2012-12-13 19:59:29 +01:00
|
|
|
}
|
2012-09-11 18:55:27 +02:00
|
|
|
|
|
|
|
if ($this->items) {
|
2013-03-09 22:52:41 +01:00
|
|
|
$items = $this->items;
|
2012-09-11 18:55:27 +02:00
|
|
|
} else {
|
|
|
|
$string = nonempty($this->noDataString, pht('No data.'));
|
|
|
|
$items = id(new AphrontErrorView())
|
|
|
|
->setSeverity(AphrontErrorView::SEVERITY_NODATA)
|
2013-02-07 01:53:49 +01:00
|
|
|
->appendChild($string);
|
2012-09-11 18:55:27 +02:00
|
|
|
}
|
2012-08-15 19:45:06 +02:00
|
|
|
|
|
|
|
$pager = null;
|
|
|
|
if ($this->pager) {
|
2013-03-09 22:52:41 +01:00
|
|
|
$pager = $this->pager;
|
2012-08-15 19:45:06 +02:00
|
|
|
}
|
|
|
|
|
2013-01-25 06:00:47 +01:00
|
|
|
$classes[] = 'phabricator-object-item-list-view';
|
|
|
|
if ($this->stackable) {
|
|
|
|
$classes[] = 'phabricator-object-list-stackable';
|
|
|
|
}
|
2013-03-10 02:55:01 +01:00
|
|
|
if ($this->cards) {
|
|
|
|
$classes[] = 'phabricator-object-list-cards';
|
|
|
|
}
|
2013-01-25 06:00:47 +01:00
|
|
|
|
2013-01-29 03:09:00 +01:00
|
|
|
return phutil_tag(
|
2013-01-25 06:00:47 +01:00
|
|
|
'ul',
|
2012-08-15 19:45:06 +02:00
|
|
|
array(
|
2013-01-25 06:00:47 +01:00
|
|
|
'class' => implode(' ', $classes),
|
2012-08-15 19:45:06 +02:00
|
|
|
),
|
2013-03-09 22:52:41 +01:00
|
|
|
array(
|
|
|
|
$header,
|
|
|
|
$items,
|
|
|
|
$pager,
|
|
|
|
));
|
2012-08-15 19:45:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|