Changeset View
Changeset View
Standalone View
Standalone View
src/view/phui/PHUIWorkpanelView.php
<?php | <?php | ||||
final class PHUIWorkpanelView extends AphrontTagView { | final class PHUIWorkpanelView extends AphrontTagView { | ||||
private $cards = array(); | private $cards = array(); | ||||
private $header; | private $header; | ||||
private $editURI; | |||||
private $headerAction; | |||||
private $footerAction; | private $footerAction; | ||||
private $headerColor = PHUIActionHeaderView::HEADER_GREY; | private $headerColor = PHUIActionHeaderView::HEADER_GREY; | ||||
private $headerActions = array(); | |||||
public function setHeaderAction(PHUIIconView $header_action) { | |||||
$this->headerAction = $header_action; | |||||
return $this; | |||||
} | |||||
public function setCards(PHUIObjectItemListView $cards) { | public function setCards(PHUIObjectItemListView $cards) { | ||||
$this->cards[] = $cards; | $this->cards[] = $cards; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function setHeader($header) { | public function setHeader($header) { | ||||
$this->header = $header; | $this->header = $header; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function setEditURI($edit_uri) { | |||||
$this->editURI = $edit_uri; | |||||
return $this; | |||||
} | |||||
public function setFooterAction(PHUIListItemView $footer_action) { | public function setFooterAction(PHUIListItemView $footer_action) { | ||||
$this->footerAction = $footer_action; | $this->footerAction = $footer_action; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function setHeaderColor($header_color) { | public function setHeaderColor($header_color) { | ||||
$this->headerColor = $header_color; | $this->headerColor = $header_color; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function addHeaderAction(PHUIIconView $action) { | |||||
$this->headerActions[] = $action; | |||||
return $this; | |||||
} | |||||
public function getTagAttributes() { | public function getTagAttributes() { | ||||
return array( | return array( | ||||
'class' => 'phui-workpanel-view', | 'class' => 'phui-workpanel-view', | ||||
); | ); | ||||
} | } | ||||
public function getTagContent() { | public function getTagContent() { | ||||
require_celerity_resource('phui-workpanel-view-css'); | require_celerity_resource('phui-workpanel-view-css'); | ||||
$classes = array(); | $classes = array(); | ||||
$classes[] = 'phui-workpanel-view-inner'; | $classes[] = 'phui-workpanel-view-inner'; | ||||
$footer = ''; | $footer = ''; | ||||
if ($this->footerAction) { | if ($this->footerAction) { | ||||
$footer_tag = $this->footerAction; | $footer_tag = $this->footerAction; | ||||
$footer = phutil_tag( | $footer = phutil_tag( | ||||
'ul', | 'ul', | ||||
array( | array( | ||||
'class' => 'phui-workpanel-footer-action mst ps' | 'class' => 'phui-workpanel-footer-action mst ps' | ||||
), | ), | ||||
$footer_tag); | $footer_tag); | ||||
} | } | ||||
$header_edit = null; | |||||
if ($this->editURI) { | |||||
$header_edit = id(new PHUIIconView()) | |||||
->setIconFont('fa-pencil') | |||||
->setHref($this->editURI); | |||||
} | |||||
$header = id(new PHUIActionHeaderView()) | $header = id(new PHUIActionHeaderView()) | ||||
->setHeaderTitle($this->header) | ->setHeaderTitle($this->header) | ||||
->setHeaderColor($this->headerColor); | ->setHeaderColor($this->headerColor); | ||||
if ($header_edit) { | |||||
$header->addAction($header_edit); | foreach ($this->headerActions as $action) { | ||||
} | $header->addAction($action); | ||||
if ($this->headerAction) { | |||||
$header->addAction($this->headerAction); | |||||
} | } | ||||
$classes[] = 'phui-workpanel-'.$this->headerColor; | $classes[] = 'phui-workpanel-'.$this->headerColor; | ||||
$body = phutil_tag( | $body = phutil_tag( | ||||
'div', | 'div', | ||||
array( | array( | ||||
'class' => 'phui-workpanel-body' | 'class' => 'phui-workpanel-body' | ||||
Show All 17 Lines |