mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-23 05:50:55 +01:00
Add ImageHref attribute for PHUIObjectItemListView
Summary: In some cases we may want a different URI for the image on an item than the header/title of the item (like user / title). This prioritizes ImageHref over Href. Test Plan: uiexamples Reviewers: epriestley Reviewed By: epriestley Subscribers: Korvin Differential Revision: https://secure.phabricator.com/D18016
This commit is contained in:
parent
709c304d76
commit
7cfa8a8315
2 changed files with 11 additions and 2 deletions
|
@ -330,6 +330,8 @@ final class PHUIObjectItemListExample extends PhabricatorUIExample {
|
||||||
$list->addItem(
|
$list->addItem(
|
||||||
id(new PHUIObjectItemView())
|
id(new PHUIObjectItemView())
|
||||||
->setImageURI($default_project->getViewURI())
|
->setImageURI($default_project->getViewURI())
|
||||||
|
->setImageHref('#')
|
||||||
|
->setHref('$$$')
|
||||||
->setHeader(pht('Default Project Profile Image'))
|
->setHeader(pht('Default Project Profile Image'))
|
||||||
->setGrippable(true)
|
->setGrippable(true)
|
||||||
->addAttribute(pht('This is the default project profile image.')));
|
->addAttribute(pht('This is the default project profile image.')));
|
||||||
|
|
|
@ -19,6 +19,7 @@ final class PHUIObjectItemView extends AphrontTagView {
|
||||||
private $headIcons = array();
|
private $headIcons = array();
|
||||||
private $disabled;
|
private $disabled;
|
||||||
private $imageURI;
|
private $imageURI;
|
||||||
|
private $imageHref;
|
||||||
private $imageIcon;
|
private $imageIcon;
|
||||||
private $titleText;
|
private $titleText;
|
||||||
private $badge;
|
private $badge;
|
||||||
|
@ -127,6 +128,11 @@ final class PHUIObjectItemView extends AphrontTagView {
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function setImageHref($image_href) {
|
||||||
|
$this->imageHref = $image_href;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
public function getImageURI() {
|
public function getImageURI() {
|
||||||
return $this->imageURI;
|
return $this->imageURI;
|
||||||
}
|
}
|
||||||
|
@ -575,11 +581,12 @@ final class PHUIObjectItemView extends AphrontTagView {
|
||||||
$this->getImageIcon());
|
$this->getImageIcon());
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($image && $this->href) {
|
if ($image && (strlen($this->href) || strlen($this->imageHref))) {
|
||||||
|
$image_href = ($this->imageHref) ? $this->imageHref : $this->href;
|
||||||
$image = phutil_tag(
|
$image = phutil_tag(
|
||||||
'a',
|
'a',
|
||||||
array(
|
array(
|
||||||
'href' => $this->href,
|
'href' => $image_href,
|
||||||
),
|
),
|
||||||
$image);
|
$image);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue