2013-04-02 18:15:33 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The default one-for-all hovercard. We may derive from this one to create
|
|
|
|
* more specialized ones
|
|
|
|
*/
|
|
|
|
final class PhabricatorHovercardView extends AphrontView {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var PhabricatorObjectHandle
|
|
|
|
*/
|
|
|
|
private $handle;
|
|
|
|
|
|
|
|
private $title = array();
|
|
|
|
private $detail;
|
|
|
|
private $tags = array();
|
|
|
|
private $fields = array();
|
|
|
|
private $actions = array();
|
|
|
|
|
Hovercard tweaks
Summary: Tightens up spacing, remove some of the borders, add alpha channel, make them all blue (sorry, red green and yellow are for 'status'). If we want to do more colors just for hovercards, I have a brown and a black in the mock, but would like to try just blue for now.
Test Plan: UIExamples, Tasks, People, Diffs, and Pastes.
Reviewers: epriestley, AnhNhan, btrahan
CC: aran, Korvin
Differential Revision: https://secure.phabricator.com/D5609
2013-04-07 06:13:11 +02:00
|
|
|
private $color = 'blue';
|
2013-04-02 18:15:33 +02:00
|
|
|
|
|
|
|
public function setObjectHandle(PhabricatorObjectHandle $handle) {
|
|
|
|
$this->handle = $handle;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setTitle($title) {
|
|
|
|
$this->title = $title;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setDetail($detail) {
|
|
|
|
$this->detail = $detail;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function addField($label, $value) {
|
|
|
|
$this->fields[] = array(
|
|
|
|
'label' => $label,
|
|
|
|
'value' => $value,
|
|
|
|
);
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function addAction($label, $uri, $workflow = false) {
|
|
|
|
$this->actions[] = array(
|
|
|
|
'label' => $label,
|
|
|
|
'uri' => $uri,
|
|
|
|
'workflow' => $workflow,
|
|
|
|
);
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function addTag(PhabricatorTagView $tag) {
|
|
|
|
$this->tags[] = $tag;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setColor($color) {
|
|
|
|
$this->color = $color;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function render() {
|
2013-04-03 01:51:03 +02:00
|
|
|
if (!$this->handle) {
|
|
|
|
throw new Exception("Call setObjectHandle() before calling render()!");
|
|
|
|
}
|
|
|
|
|
2013-04-02 18:15:33 +02:00
|
|
|
$handle = $this->handle;
|
|
|
|
|
|
|
|
require_celerity_resource("phabricator-hovercard-view-css");
|
|
|
|
|
2013-04-05 17:21:01 +02:00
|
|
|
$title = pht("%s: %s",
|
2013-04-03 01:51:03 +02:00
|
|
|
$handle->getTypeName(),
|
2013-04-05 17:11:16 +02:00
|
|
|
$this->title ? $this->title : $handle->getName());
|
2013-04-02 18:15:33 +02:00
|
|
|
|
2013-04-05 17:21:01 +02:00
|
|
|
$header = new PhabricatorActionHeaderView();
|
|
|
|
$header->setHeaderColor($this->color);
|
|
|
|
$header->setHeaderTitle($title);
|
|
|
|
if ($this->tags) {
|
|
|
|
foreach ($this->tags as $tag) {
|
|
|
|
$header->setTag($tag);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-04-02 18:15:33 +02:00
|
|
|
$body = array();
|
Hovercard tweaks
Summary: Tightens up spacing, remove some of the borders, add alpha channel, make them all blue (sorry, red green and yellow are for 'status'). If we want to do more colors just for hovercards, I have a brown and a black in the mock, but would like to try just blue for now.
Test Plan: UIExamples, Tasks, People, Diffs, and Pastes.
Reviewers: epriestley, AnhNhan, btrahan
CC: aran, Korvin
Differential Revision: https://secure.phabricator.com/D5609
2013-04-07 06:13:11 +02:00
|
|
|
|
2013-04-02 18:15:33 +02:00
|
|
|
if ($this->detail) {
|
Hovercard tweaks
Summary: Tightens up spacing, remove some of the borders, add alpha channel, make them all blue (sorry, red green and yellow are for 'status'). If we want to do more colors just for hovercards, I have a brown and a black in the mock, but would like to try just blue for now.
Test Plan: UIExamples, Tasks, People, Diffs, and Pastes.
Reviewers: epriestley, AnhNhan, btrahan
CC: aran, Korvin
Differential Revision: https://secure.phabricator.com/D5609
2013-04-07 06:13:11 +02:00
|
|
|
$body_title = $this->detail;
|
2013-04-02 18:15:33 +02:00
|
|
|
} else {
|
|
|
|
// Fallback for object handles
|
Hovercard tweaks
Summary: Tightens up spacing, remove some of the borders, add alpha channel, make them all blue (sorry, red green and yellow are for 'status'). If we want to do more colors just for hovercards, I have a brown and a black in the mock, but would like to try just blue for now.
Test Plan: UIExamples, Tasks, People, Diffs, and Pastes.
Reviewers: epriestley, AnhNhan, btrahan
CC: aran, Korvin
Differential Revision: https://secure.phabricator.com/D5609
2013-04-07 06:13:11 +02:00
|
|
|
$body_title = $handle->getFullName();
|
2013-04-02 18:15:33 +02:00
|
|
|
}
|
|
|
|
|
2013-11-09 19:48:19 +01:00
|
|
|
$body[] = phutil_tag_div('phabricator-hovercard-body-header', $body_title);
|
Hovercard tweaks
Summary: Tightens up spacing, remove some of the borders, add alpha channel, make them all blue (sorry, red green and yellow are for 'status'). If we want to do more colors just for hovercards, I have a brown and a black in the mock, but would like to try just blue for now.
Test Plan: UIExamples, Tasks, People, Diffs, and Pastes.
Reviewers: epriestley, AnhNhan, btrahan
CC: aran, Korvin
Differential Revision: https://secure.phabricator.com/D5609
2013-04-07 06:13:11 +02:00
|
|
|
|
2013-04-02 18:15:33 +02:00
|
|
|
foreach ($this->fields as $field) {
|
2013-11-09 19:48:19 +01:00
|
|
|
$item = array(
|
|
|
|
phutil_tag('strong', array(), $field['label']),
|
|
|
|
' ',
|
|
|
|
phutil_tag('span', array(), $field['value']),
|
|
|
|
);
|
|
|
|
$body[] = phutil_tag_div('phabricator-hovercard-body-item', $item);
|
2013-04-02 18:15:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if ($handle->getImageURI()) {
|
|
|
|
// Probably a user, we don't need to assume something else
|
|
|
|
// "Prepend" the image by appending $body
|
|
|
|
$body = phutil_tag(
|
|
|
|
'div',
|
|
|
|
array(
|
|
|
|
'class' => 'profile-header-picture-frame',
|
|
|
|
'style' => 'background-image: url('.$handle->getImageURI().');',
|
|
|
|
),
|
|
|
|
'')
|
|
|
|
->appendHTML($body);
|
|
|
|
}
|
|
|
|
|
|
|
|
$buttons = array();
|
|
|
|
|
|
|
|
foreach ($this->actions as $action) {
|
|
|
|
$options = array(
|
|
|
|
'class' => 'button grey',
|
|
|
|
'href' => $action['uri'],
|
|
|
|
);
|
|
|
|
|
|
|
|
if ($action['workflow']) {
|
|
|
|
$options['sigil'] = 'workflow';
|
|
|
|
$buttons[] = javelin_tag(
|
|
|
|
'a',
|
|
|
|
$options,
|
|
|
|
$action['label']);
|
|
|
|
} else {
|
|
|
|
$buttons[] = phutil_tag(
|
|
|
|
'a',
|
|
|
|
$options,
|
|
|
|
$action['label']);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$tail = null;
|
|
|
|
if ($buttons) {
|
2013-11-09 19:48:19 +01:00
|
|
|
$tail = phutil_tag_div('phabricator-hovercard-tail', $buttons);
|
2013-04-02 18:15:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Assemble container
|
|
|
|
// TODO: Add color support
|
2013-11-09 19:48:19 +01:00
|
|
|
$hovercard = phutil_tag_div(
|
|
|
|
'phabricator-hovercard-container',
|
2013-04-02 18:15:33 +02:00
|
|
|
array(
|
2013-11-09 19:48:19 +01:00
|
|
|
phutil_tag_div('phabricator-hovercard-head', $header),
|
|
|
|
phutil_tag_div('phabricator-hovercard-body', $body),
|
|
|
|
$tail,
|
|
|
|
));
|
2013-04-02 18:15:33 +02:00
|
|
|
|
|
|
|
// Wrap for thick border
|
|
|
|
// and later the tip at the bottom
|
2013-11-09 19:48:19 +01:00
|
|
|
return phutil_tag_div('phabricator-hovercard-wrapper', $hovercard);
|
2013-04-02 18:15:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|