2012-12-07 22:32:14 +01:00
|
|
|
<?php
|
|
|
|
|
2013-06-05 17:41:43 +02:00
|
|
|
final class PHUIListItemView extends AphrontTagView {
|
2012-12-07 22:32:14 +01:00
|
|
|
|
|
|
|
const TYPE_LINK = 'type-link';
|
|
|
|
const TYPE_SPACER = 'type-spacer';
|
|
|
|
const TYPE_LABEL = 'type-label';
|
2013-01-29 19:20:17 +01:00
|
|
|
const TYPE_BUTTON = 'type-button';
|
2013-02-03 19:02:35 +01:00
|
|
|
const TYPE_CUSTOM = 'type-custom';
|
2013-06-05 17:41:43 +02:00
|
|
|
const TYPE_DIVIDER = 'type-divider';
|
|
|
|
const TYPE_ICON = 'type-icon';
|
2012-12-07 22:32:14 +01:00
|
|
|
|
|
|
|
private $name;
|
|
|
|
private $href;
|
|
|
|
private $type = self::TYPE_LINK;
|
|
|
|
private $isExternal;
|
|
|
|
private $key;
|
2012-12-07 22:33:03 +01:00
|
|
|
private $icon;
|
|
|
|
private $selected;
|
2013-06-17 15:12:45 +02:00
|
|
|
private $disabled;
|
2013-07-12 20:28:18 +02:00
|
|
|
private $renderNameAsTooltip;
|
|
|
|
|
|
|
|
public function setRenderNameAsTooltip($render_name_as_tooltip) {
|
|
|
|
$this->renderNameAsTooltip = $render_name_as_tooltip;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getRenderNameAsTooltip() {
|
|
|
|
return $this->renderNameAsTooltip;
|
|
|
|
}
|
2013-01-16 18:00:11 +01:00
|
|
|
|
2012-12-07 22:33:03 +01:00
|
|
|
public function setSelected($selected) {
|
|
|
|
$this->selected = $selected;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getSelected() {
|
|
|
|
return $this->selected;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setIcon($icon) {
|
|
|
|
$this->icon = $icon;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getIcon() {
|
|
|
|
return $this->icon;
|
|
|
|
}
|
2012-12-07 22:32:14 +01:00
|
|
|
|
|
|
|
public function setKey($key) {
|
2012-12-07 22:35:17 +01:00
|
|
|
$this->key = (string)$key;
|
2012-12-07 22:32:14 +01:00
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getKey() {
|
|
|
|
return $this->key;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setType($type) {
|
|
|
|
$this->type = $type;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getType() {
|
|
|
|
return $this->type;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setHref($href) {
|
|
|
|
$this->href = $href;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getHref() {
|
|
|
|
return $this->href;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setName($name) {
|
|
|
|
$this->name = $name;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getName() {
|
|
|
|
return $this->name;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setIsExternal($is_external) {
|
|
|
|
$this->isExternal = $is_external;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getIsExternal() {
|
|
|
|
return $this->isExternal;
|
|
|
|
}
|
|
|
|
|
2013-01-16 19:50:41 +01:00
|
|
|
protected function getTagName() {
|
2013-06-06 01:21:55 +02:00
|
|
|
return 'li';
|
2013-01-16 19:50:41 +01:00
|
|
|
}
|
2012-12-07 22:32:14 +01:00
|
|
|
|
2013-06-06 01:21:55 +02:00
|
|
|
protected function getTagAttributes() {
|
|
|
|
$classes = array();
|
|
|
|
$classes[] = 'phui-list-item-view';
|
|
|
|
$classes[] = 'phui-list-item-'.$this->type;
|
2013-06-05 17:41:43 +02:00
|
|
|
|
2013-06-06 01:21:55 +02:00
|
|
|
if ($this->icon) {
|
|
|
|
$classes[] = 'phui-list-item-has-icon';
|
|
|
|
}
|
2013-06-05 17:41:43 +02:00
|
|
|
|
2013-06-06 01:21:55 +02:00
|
|
|
if ($this->selected) {
|
|
|
|
$classes[] = 'phui-list-item-selected';
|
|
|
|
}
|
2013-06-05 17:41:43 +02:00
|
|
|
|
2013-01-16 19:50:41 +01:00
|
|
|
return array(
|
2013-06-06 01:21:55 +02:00
|
|
|
'class' => $classes,
|
|
|
|
);
|
2013-01-16 19:50:41 +01:00
|
|
|
}
|
2012-12-07 22:32:14 +01:00
|
|
|
|
2013-06-17 15:12:45 +02:00
|
|
|
public function setDisabled($disabled) {
|
|
|
|
$this->disabled = $disabled;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getDisabled() {
|
|
|
|
return $this->disabled;
|
|
|
|
}
|
|
|
|
|
2013-01-16 19:50:41 +01:00
|
|
|
protected function getTagContent() {
|
2012-12-07 22:33:03 +01:00
|
|
|
$name = null;
|
2013-03-30 22:46:02 +01:00
|
|
|
$icon = null;
|
2013-07-12 20:28:18 +02:00
|
|
|
$meta = null;
|
|
|
|
$sigil = null;
|
2013-03-30 22:46:02 +01:00
|
|
|
|
2012-12-07 22:33:03 +01:00
|
|
|
if ($this->name) {
|
2013-07-12 20:28:18 +02:00
|
|
|
if ($this->getRenderNameAsTooltip()) {
|
|
|
|
$sigil = 'has-tooltip';
|
|
|
|
$meta = array(
|
|
|
|
'tip' => $this->name,
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
$external = null;
|
|
|
|
if ($this->isExternal) {
|
|
|
|
$external = " \xE2\x86\x97";
|
|
|
|
}
|
|
|
|
|
|
|
|
$name = phutil_tag(
|
|
|
|
'span',
|
|
|
|
array(
|
|
|
|
'class' => 'phui-list-item-name',
|
|
|
|
),
|
|
|
|
array(
|
|
|
|
$this->name,
|
|
|
|
$external,
|
|
|
|
));
|
2012-12-07 22:33:03 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Add action icons to object list views
Summary:
We have a few interfaces where add "Edit", "Delete" or some other action to a list. Currently, this happens via icons, but these are cumbersome and weird, are inconsistent, can't be workflow'd, are hard to hit on desktops and virtually impossible to hit on mobile, and generally just feel iffy to me. Prominent examples are Projects and Flags. I'd like to try adding an "edit" action to Maniphest (to provide quick edit from list views, basically). It looks like some of Releeph would benefit here, as well.
Instead, provide first-class actions:
{F42978}
They produce targets which my meaty ham-fists can plausibly hit on mobile, too:
{F42979}
(We could do some kind of swipe-to-expose thing eventually, but I think putting them by default is OK?)
Test Plan: Added UIExamples. Checked desktop/mobile.
Reviewers: chad, btrahan, edward
Reviewed By: btrahan
CC: aran
Differential Revision: https://secure.phabricator.com/D5890
2013-05-10 21:57:01 +02:00
|
|
|
if ($this->icon) {
|
2013-06-17 15:12:45 +02:00
|
|
|
$icon_name = $this->icon;
|
|
|
|
if ($this->getDisabled()) {
|
|
|
|
$icon_name .= '-grey';
|
|
|
|
}
|
|
|
|
|
Add action icons to object list views
Summary:
We have a few interfaces where add "Edit", "Delete" or some other action to a list. Currently, this happens via icons, but these are cumbersome and weird, are inconsistent, can't be workflow'd, are hard to hit on desktops and virtually impossible to hit on mobile, and generally just feel iffy to me. Prominent examples are Projects and Flags. I'd like to try adding an "edit" action to Maniphest (to provide quick edit from list views, basically). It looks like some of Releeph would benefit here, as well.
Instead, provide first-class actions:
{F42978}
They produce targets which my meaty ham-fists can plausibly hit on mobile, too:
{F42979}
(We could do some kind of swipe-to-expose thing eventually, but I think putting them by default is OK?)
Test Plan: Added UIExamples. Checked desktop/mobile.
Reviewers: chad, btrahan, edward
Reviewed By: btrahan
CC: aran
Differential Revision: https://secure.phabricator.com/D5890
2013-05-10 21:57:01 +02:00
|
|
|
$icon = id(new PHUIIconView())
|
2013-06-05 17:41:43 +02:00
|
|
|
->addClass('phui-list-item-icon')
|
Add action icons to object list views
Summary:
We have a few interfaces where add "Edit", "Delete" or some other action to a list. Currently, this happens via icons, but these are cumbersome and weird, are inconsistent, can't be workflow'd, are hard to hit on desktops and virtually impossible to hit on mobile, and generally just feel iffy to me. Prominent examples are Projects and Flags. I'd like to try adding an "edit" action to Maniphest (to provide quick edit from list views, basically). It looks like some of Releeph would benefit here, as well.
Instead, provide first-class actions:
{F42978}
They produce targets which my meaty ham-fists can plausibly hit on mobile, too:
{F42979}
(We could do some kind of swipe-to-expose thing eventually, but I think putting them by default is OK?)
Test Plan: Added UIExamples. Checked desktop/mobile.
Reviewers: chad, btrahan, edward
Reviewed By: btrahan
CC: aran
Differential Revision: https://secure.phabricator.com/D5890
2013-05-10 21:57:01 +02:00
|
|
|
->setSpriteSheet(PHUIIconView::SPRITE_ICONS)
|
2013-06-17 15:12:45 +02:00
|
|
|
->setSpriteIcon($icon_name);
|
Add action icons to object list views
Summary:
We have a few interfaces where add "Edit", "Delete" or some other action to a list. Currently, this happens via icons, but these are cumbersome and weird, are inconsistent, can't be workflow'd, are hard to hit on desktops and virtually impossible to hit on mobile, and generally just feel iffy to me. Prominent examples are Projects and Flags. I'd like to try adding an "edit" action to Maniphest (to provide quick edit from list views, basically). It looks like some of Releeph would benefit here, as well.
Instead, provide first-class actions:
{F42978}
They produce targets which my meaty ham-fists can plausibly hit on mobile, too:
{F42979}
(We could do some kind of swipe-to-expose thing eventually, but I think putting them by default is OK?)
Test Plan: Added UIExamples. Checked desktop/mobile.
Reviewers: chad, btrahan, edward
Reviewed By: btrahan
CC: aran
Differential Revision: https://secure.phabricator.com/D5890
2013-05-10 21:57:01 +02:00
|
|
|
}
|
|
|
|
|
2013-07-12 20:28:18 +02:00
|
|
|
return javelin_tag(
|
2013-06-06 01:21:55 +02:00
|
|
|
$this->href ? 'a' : 'div',
|
|
|
|
array(
|
|
|
|
'href' => $this->href,
|
|
|
|
'class' => $this->href ? 'phui-list-item-href' : null,
|
2013-07-12 20:28:18 +02:00
|
|
|
'meta' => $meta,
|
|
|
|
'sigil' => $sigil,
|
2013-06-06 01:21:55 +02:00
|
|
|
),
|
|
|
|
array(
|
|
|
|
$icon,
|
|
|
|
$this->renderChildren(),
|
|
|
|
$name,
|
|
|
|
));
|
2012-12-07 22:32:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|