mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-24 14:30:56 +01:00
Give tokenizer tokens CSS color classes on the container instead of the icon
Summary: Ref T4100. See D12465. - Instead of putting CSS color classes on the tokenizer icons, put them on the container tags. - Note that this removes the "bluegrey" default classes. - This doesn't actually add CSS for the classes so, e.g., "green" doesn't make things green yet. This just supports D12465. Test Plan: Viewed markup, saw classes. Reviewers: chad Reviewed By: chad Subscribers: epriestley Maniphest Tasks: T4100 Differential Revision: https://secure.phabricator.com/D12467
This commit is contained in:
parent
2106a553e4
commit
8f61eb45ab
6 changed files with 46 additions and 10 deletions
|
@ -63,7 +63,8 @@ final class PhabricatorProjectDatasource
|
||||||
->setDisplayType('Project')
|
->setDisplayType('Project')
|
||||||
->setURI('/tag/'.$proj->getPrimarySlug().'/')
|
->setURI('/tag/'.$proj->getPrimarySlug().'/')
|
||||||
->setPHID($proj->getPHID())
|
->setPHID($proj->getPHID())
|
||||||
->setIcon($proj->getIcon().' '.$proj->getColor())
|
->setIcon($proj->getIcon())
|
||||||
|
->setColor($proj->getColor())
|
||||||
->setPriorityType('proj')
|
->setPriorityType('proj')
|
||||||
->setClosed($closed);
|
->setClosed($closed);
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,7 @@ final class PhabricatorTypeaheadResult {
|
||||||
private $priorityType;
|
private $priorityType;
|
||||||
private $imageSprite;
|
private $imageSprite;
|
||||||
private $icon;
|
private $icon;
|
||||||
|
private $color;
|
||||||
private $closed;
|
private $closed;
|
||||||
private $tokenType;
|
private $tokenType;
|
||||||
private $unique;
|
private $unique;
|
||||||
|
@ -104,6 +105,15 @@ final class PhabricatorTypeaheadResult {
|
||||||
return $this->tokenType;
|
return $this->tokenType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function setColor($color) {
|
||||||
|
$this->color = $color;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getColor() {
|
||||||
|
return $this->color;
|
||||||
|
}
|
||||||
|
|
||||||
public function getSortKey() {
|
public function getSortKey() {
|
||||||
// Put unique results (special parameter functions) ahead of other
|
// Put unique results (special parameter functions) ahead of other
|
||||||
// results.
|
// results.
|
||||||
|
@ -129,6 +139,7 @@ final class PhabricatorTypeaheadResult {
|
||||||
$this->getIcon(),
|
$this->getIcon(),
|
||||||
$this->closed,
|
$this->closed,
|
||||||
$this->imageSprite ? (string)$this->imageSprite : null,
|
$this->imageSprite ? (string)$this->imageSprite : null,
|
||||||
|
$this->color,
|
||||||
$this->tokenType,
|
$this->tokenType,
|
||||||
$this->unique ? 1 : null,
|
$this->unique ? 1 : null,
|
||||||
);
|
);
|
||||||
|
@ -151,7 +162,7 @@ final class PhabricatorTypeaheadResult {
|
||||||
foreach ($types as $type) {
|
foreach ($types as $type) {
|
||||||
$icon = $type->getTypeIcon();
|
$icon = $type->getTypeIcon();
|
||||||
if ($icon !== null) {
|
if ($icon !== null) {
|
||||||
$map[$type->getTypeConstant()] = "{$icon} bluegrey";
|
$map[$type->getTypeConstant()] = $icon;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@ final class PhabricatorTypeaheadTokenView
|
||||||
|
|
||||||
private $key;
|
private $key;
|
||||||
private $icon;
|
private $icon;
|
||||||
|
private $color;
|
||||||
private $inputName;
|
private $inputName;
|
||||||
private $value;
|
private $value;
|
||||||
private $tokenType = self::TYPE_OBJECT;
|
private $tokenType = self::TYPE_OBJECT;
|
||||||
|
@ -20,6 +21,7 @@ final class PhabricatorTypeaheadTokenView
|
||||||
return id(new PhabricatorTypeaheadTokenView())
|
return id(new PhabricatorTypeaheadTokenView())
|
||||||
->setKey($result->getPHID())
|
->setKey($result->getPHID())
|
||||||
->setIcon($result->getIcon())
|
->setIcon($result->getIcon())
|
||||||
|
->setColor($result->getColor())
|
||||||
->setValue($result->getDisplayName())
|
->setValue($result->getDisplayName())
|
||||||
->setTokenType($result->getTokenType());
|
->setTokenType($result->getTokenType());
|
||||||
}
|
}
|
||||||
|
@ -30,11 +32,13 @@ final class PhabricatorTypeaheadTokenView
|
||||||
$token = id(new PhabricatorTypeaheadTokenView())
|
$token = id(new PhabricatorTypeaheadTokenView())
|
||||||
->setKey($handle->getPHID())
|
->setKey($handle->getPHID())
|
||||||
->setValue($handle->getFullName())
|
->setValue($handle->getFullName())
|
||||||
->setIcon(rtrim($handle->getIcon().' '.$handle->getIconColor()));
|
->setIcon($handle->getIcon());
|
||||||
|
|
||||||
if ($handle->isDisabled() ||
|
if ($handle->isDisabled() ||
|
||||||
$handle->getStatus() == PhabricatorObjectHandleStatus::STATUS_CLOSED) {
|
$handle->getStatus() == PhabricatorObjectHandleStatus::STATUS_CLOSED) {
|
||||||
$token->setTokenType(self::TYPE_DISABLED);
|
$token->setTokenType(self::TYPE_DISABLED);
|
||||||
|
} else {
|
||||||
|
$token->setColor($handle->getTagColor());
|
||||||
}
|
}
|
||||||
|
|
||||||
return $token;
|
return $token;
|
||||||
|
@ -76,6 +80,15 @@ final class PhabricatorTypeaheadTokenView
|
||||||
return $this->icon;
|
return $this->icon;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function setColor($color) {
|
||||||
|
$this->color = $color;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getColor() {
|
||||||
|
return $this->color;
|
||||||
|
}
|
||||||
|
|
||||||
public function setValue($value) {
|
public function setValue($value) {
|
||||||
$this->value = $value;
|
$this->value = $value;
|
||||||
return $this;
|
return $this;
|
||||||
|
@ -107,6 +120,8 @@ final class PhabricatorTypeaheadTokenView
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$classes[] = $this->getColor();
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
'class' => $classes,
|
'class' => $classes,
|
||||||
);
|
);
|
||||||
|
@ -126,7 +141,7 @@ final class PhabricatorTypeaheadTokenView
|
||||||
phutil_tag(
|
phutil_tag(
|
||||||
'span',
|
'span',
|
||||||
array(
|
array(
|
||||||
'class' => 'phui-icon-view phui-font-fa bluetext '.$icon,
|
'class' => 'phui-icon-view phui-font-fa '.$icon,
|
||||||
)),
|
)),
|
||||||
$value,
|
$value,
|
||||||
);
|
);
|
||||||
|
|
|
@ -24,8 +24,9 @@ final class PHUITypeaheadExample extends PhabricatorUIExample {
|
||||||
->setIcon('fa-user');
|
->setIcon('fa-user');
|
||||||
|
|
||||||
$token_list[] = id(new PhabricatorTypeaheadTokenView())
|
$token_list[] = id(new PhabricatorTypeaheadTokenView())
|
||||||
->setValue(pht('Custom Object'))
|
->setValue(pht('Object with Color'))
|
||||||
->setIcon('fa-tag green');
|
->setIcon('fa-tag')
|
||||||
|
->setColor('green');
|
||||||
|
|
||||||
$token_list[] = id(new PhabricatorTypeaheadTokenView())
|
$token_list[] = id(new PhabricatorTypeaheadTokenView())
|
||||||
->setValue(pht('Function Token'))
|
->setValue(pht('Function Token'))
|
||||||
|
|
|
@ -125,6 +125,7 @@ final class AphrontFormTokenizerControl extends AphrontFormControl {
|
||||||
'value' => mpull($tokens, 'getValue', 'getKey'),
|
'value' => mpull($tokens, 'getValue', 'getKey'),
|
||||||
'icons' => mpull($tokens, 'getIcon', 'getKey'),
|
'icons' => mpull($tokens, 'getIcon', 'getKey'),
|
||||||
'types' => mpull($tokens, 'getTokenType', 'getKey'),
|
'types' => mpull($tokens, 'getTokenType', 'getKey'),
|
||||||
|
'colors' => mpull($tokens, 'getColor', 'getKey'),
|
||||||
'limit' => $this->limit,
|
'limit' => $this->limit,
|
||||||
'username' => $username,
|
'username' => $username,
|
||||||
'placeholder' => $placeholder,
|
'placeholder' => $placeholder,
|
||||||
|
|
|
@ -177,21 +177,27 @@ JX.install('Prefab', {
|
||||||
|
|
||||||
var icon;
|
var icon;
|
||||||
var type;
|
var type;
|
||||||
|
var color;
|
||||||
if (result) {
|
if (result) {
|
||||||
icon = result.icon;
|
icon = result.icon;
|
||||||
value = result.displayName;
|
value = result.displayName;
|
||||||
type = result.tokenType;
|
type = result.tokenType;
|
||||||
|
color = result.color;
|
||||||
} else {
|
} else {
|
||||||
icon = config.icons[key];
|
icon = config.icons[key];
|
||||||
type = config.types[key];
|
type = config.types[key];
|
||||||
|
color = config.colors[key];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (icon) {
|
if (icon) {
|
||||||
icon = JX.Prefab._renderIcon(icon);
|
icon = JX.Prefab._renderIcon(icon);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type) {
|
type = type || 'object';
|
||||||
JX.DOM.alterClass(container, 'jx-tokenizer-token-' + type, true);
|
JX.DOM.alterClass(container, 'jx-tokenizer-token-' + type, true);
|
||||||
|
|
||||||
|
if (color) {
|
||||||
|
JX.DOM.alterClass(container, color, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
return [icon, value];
|
return [icon, value];
|
||||||
|
@ -292,8 +298,9 @@ JX.install('Prefab', {
|
||||||
closed: closed,
|
closed: closed,
|
||||||
type: fields[5],
|
type: fields[5],
|
||||||
sprite: fields[10],
|
sprite: fields[10],
|
||||||
tokenType: fields[11],
|
color: fields[11],
|
||||||
unique: fields[12] || false
|
tokenType: fields[12],
|
||||||
|
unique: fields[13] || false
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue