Changeset View
Changeset View
Standalone View
Standalone View
src/view/control/AphrontTokenizerTemplateView.php
Show All 12 Lines | final class AphrontTokenizerTemplateView extends AphrontView { | ||||
} | } | ||||
public function setID($id) { | public function setID($id) { | ||||
$this->id = $id; | $this->id = $id; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function setValue(array $value) { | public function setValue(array $value) { | ||||
assert_instances_of($value, 'PhabricatorObjectHandle'); | assert_instances_of($value, 'PhabricatorTypeaheadTokenView'); | ||||
$this->value = $value; | $this->value = $value; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function getValue() { | public function getValue() { | ||||
return $this->value; | return $this->value; | ||||
} | } | ||||
public function setName($name) { | public function setName($name) { | ||||
$this->name = $name; | $this->name = $name; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function getName() { | public function getName() { | ||||
return $this->name; | return $this->name; | ||||
} | } | ||||
public function render() { | public function render() { | ||||
require_celerity_resource('aphront-tokenizer-control-css'); | require_celerity_resource('aphront-tokenizer-control-css'); | ||||
$id = $this->id; | $id = $this->id; | ||||
$name = $this->getName(); | $name = $this->getName(); | ||||
$values = nonempty($this->getValue(), array()); | $tokens = nonempty($this->getValue(), array()); | ||||
$tokens = array(); | |||||
foreach ($values as $key => $value) { | |||||
$tokens[] = $this->renderToken( | |||||
$value->getPHID(), | |||||
$value->getFullName(), | |||||
$value->getType()); | |||||
} | |||||
$input = javelin_tag( | $input = javelin_tag( | ||||
'input', | 'input', | ||||
array( | array( | ||||
'mustcapture' => true, | 'mustcapture' => true, | ||||
'name' => $name, | 'name' => $name, | ||||
'class' => 'jx-tokenizer-input', | 'class' => 'jx-tokenizer-input', | ||||
'sigil' => 'tokenizer-input', | 'sigil' => 'tokenizer-input', | ||||
▲ Show 20 Lines • Show All 59 Lines • ▼ Show 20 Lines | $frame = javelin_tag( | ||||
'class' => 'jx-tokenizer-frame-browse', | 'class' => 'jx-tokenizer-frame-browse', | ||||
), | ), | ||||
$browse), | $browse), | ||||
))); | ))); | ||||
return $frame; | return $frame; | ||||
} | } | ||||
private function renderToken($key, $value, $icon) { | |||||
return id(new PhabricatorTypeaheadTokenView()) | |||||
->setKey($key) | |||||
->setValue($value) | |||||
->setIcon($icon) | |||||
->setInputName($this->getName()); | |||||
} | |||||
} | } |