2011-03-22 20:41:02 -07:00
|
|
|
<?php
|
|
|
|
|
2012-03-13 16:21:04 -07:00
|
|
|
final class AphrontTokenizerTemplateView extends AphrontView {
|
2011-03-22 20:41:02 -07:00
|
|
|
|
|
|
|
private $value;
|
|
|
|
private $name;
|
|
|
|
private $id;
|
2015-04-16 13:37:12 -07:00
|
|
|
private $browseURI;
|
|
|
|
|
|
|
|
public function setBrowseURI($browse_uri) {
|
|
|
|
$this->browseURI = $browse_uri;
|
|
|
|
return $this;
|
|
|
|
}
|
2011-03-22 20:41:02 -07:00
|
|
|
|
|
|
|
public function setID($id) {
|
|
|
|
$this->id = $id;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setValue(array $value) {
|
2015-04-16 15:30:41 -07:00
|
|
|
assert_instances_of($value, 'PhabricatorTypeaheadTokenView');
|
2011-03-22 20:41:02 -07:00
|
|
|
$this->value = $value;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getValue() {
|
|
|
|
return $this->value;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setName($name) {
|
|
|
|
$this->name = $name;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getName() {
|
|
|
|
return $this->name;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function render() {
|
|
|
|
require_celerity_resource('aphront-tokenizer-control-css');
|
|
|
|
|
|
|
|
$id = $this->id;
|
|
|
|
$name = $this->getName();
|
2015-04-16 15:30:41 -07:00
|
|
|
$tokens = nonempty($this->getValue(), array());
|
2011-03-22 20:41:02 -07:00
|
|
|
|
2013-01-25 12:57:17 -08:00
|
|
|
$input = javelin_tag(
|
2011-03-22 20:41:02 -07:00
|
|
|
'input',
|
|
|
|
array(
|
|
|
|
'mustcapture' => true,
|
|
|
|
'name' => $name,
|
|
|
|
'class' => 'jx-tokenizer-input',
|
Bring Javelin into Phabricator via git submodule, not copy-and-paste
Summary:
Javelin is currently embedded in Phabricator via copy-and-paste of prebuilt
packages. This is not so great.
Pull it in as a submodule instead and make all the Phabriator resources declare
proper dependency trees. Add Javelin linting.
Test Plan:
I tried to run through pretty much all the JS functionality on the site. This is
still a high-risk change, but I did a pretty thorough test
Differential: inline comments, revealing diffs, list tokenizers, comment
preview, editing/deleting comments, add review action.
Maniphest: list tokenizer, comment actions
Herald: rule editing, tokenizers, add/remove rows
Reviewed By: tomo
Reviewers: aran, tomo, mroch, jungejason, tuomaspelkonen
CC: aran, tomo, epriestley
Differential Revision: 223
2011-05-03 15:11:55 -07:00
|
|
|
'sigil' => 'tokenizer-input',
|
2011-03-22 20:41:02 -07:00
|
|
|
'style' => 'width: 0px;',
|
|
|
|
'disabled' => 'disabled',
|
|
|
|
'type' => 'text',
|
|
|
|
));
|
|
|
|
|
2013-01-18 00:32:58 -08:00
|
|
|
$content = $tokens;
|
|
|
|
$content[] = $input;
|
|
|
|
$content[] = phutil_tag('div', array('style' => 'clear: both;'), '');
|
|
|
|
|
2015-04-16 14:46:10 -07:00
|
|
|
$container = javelin_tag(
|
2011-03-22 20:41:02 -07:00
|
|
|
'div',
|
|
|
|
array(
|
|
|
|
'id' => $id,
|
|
|
|
'class' => 'jx-tokenizer-container',
|
2015-04-16 14:46:10 -07:00
|
|
|
'sigil' => 'tokenizer-container',
|
2011-03-22 20:41:02 -07:00
|
|
|
),
|
2013-01-18 00:32:58 -08:00
|
|
|
$content);
|
2015-04-16 13:37:12 -07:00
|
|
|
|
2015-04-16 14:46:10 -07:00
|
|
|
$icon = id(new PHUIIconView())
|
|
|
|
->setIconFont('fa-list-ul');
|
|
|
|
|
|
|
|
// TODO: This thing is ugly and the ugliness is not intentional.
|
|
|
|
// We have to give it text or PHUIButtonView collapses. It should likely
|
|
|
|
// just be an icon and look more integrated into the input.
|
|
|
|
$browse = id(new PHUIButtonView())
|
|
|
|
->setTag('a')
|
|
|
|
->setIcon($icon)
|
|
|
|
->addSigil('tokenizer-browse')
|
|
|
|
->setColor(PHUIButtonView::GREY)
|
|
|
|
->setSize(PHUIButtonView::SMALL)
|
|
|
|
->setText(pht('Browse...'));
|
|
|
|
|
|
|
|
$classes = array();
|
|
|
|
$classes[] = 'jx-tokenizer-frame';
|
|
|
|
|
2015-04-16 13:37:12 -07:00
|
|
|
if ($this->browseURI) {
|
2015-04-16 14:46:10 -07:00
|
|
|
$classes[] = 'has-browse';
|
2015-04-16 13:37:12 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
$frame = javelin_tag(
|
|
|
|
'table',
|
|
|
|
array(
|
2015-04-16 14:46:10 -07:00
|
|
|
'class' => implode(' ', $classes),
|
2015-04-16 13:37:12 -07:00
|
|
|
'sigil' => 'tokenizer-frame',
|
|
|
|
),
|
|
|
|
phutil_tag(
|
|
|
|
'tr',
|
|
|
|
array(
|
|
|
|
),
|
|
|
|
array(
|
|
|
|
phutil_tag(
|
|
|
|
'td',
|
|
|
|
array(
|
|
|
|
'class' => 'jx-tokenizer-frame-input',
|
|
|
|
),
|
|
|
|
$container),
|
|
|
|
phutil_tag(
|
|
|
|
'td',
|
|
|
|
array(
|
|
|
|
'class' => 'jx-tokenizer-frame-browse',
|
|
|
|
),
|
|
|
|
$browse),
|
|
|
|
)));
|
|
|
|
|
|
|
|
return $frame;
|
2011-03-22 20:41:02 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|