1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-03 04:02:43 +01:00
phorge-phorge/src/applications/flag/view/PhabricatorFlagSelectControl.php
epriestley c8061d5da8 Implement ApplicationSearch in Flags
Summary:
Ref T1809. Provide ApplicationSearch to Flags and allow the user to select flags by color.

@chad might have some design feedback on my control.

Test Plan: {F54131}

Reviewers: btrahan, chad

Reviewed By: chad

CC: aran

Maniphest Tasks: T1809

Differential Revision: https://secure.phabricator.com/D6747
2013-08-13 16:27:26 -07:00

65 lines
1.7 KiB
PHP

<?php
final class PhabricatorFlagSelectControl extends AphrontFormControl {
public function getCustomControlClass() {
return 'phabricator-flag-select-control';
}
public function renderInput() {
require_celerity_resource('phabricator-flag-css');
$colors = PhabricatorFlagColor::getColorNameMap();
$value_map = array_fuse($this->getValue());
$file_map = array(
PhabricatorFlagColor::COLOR_RED => 'red',
PhabricatorFlagColor::COLOR_ORANGE => 'orange',
PhabricatorFlagColor::COLOR_YELLOW => 'yellow',
PhabricatorFlagColor::COLOR_GREEN => 'green',
PhabricatorFlagColor::COLOR_BLUE => 'blue',
PhabricatorFlagColor::COLOR_PINK => 'pink',
PhabricatorFlagColor::COLOR_PURPLE => 'purple',
PhabricatorFlagColor::COLOR_CHECKERED => 'finish',
);
$out = array();
foreach ($colors as $const => $name) {
// TODO: This should probably be a sprite sheet.
$partial = $file_map[$const];
$uri = '/rsrc/image/icon/fatcow/flag_'.$partial.'.png';
$uri = celerity_get_resource_uri($uri);
$icon = id(new PHUIIconView())
->setImage($uri);
$input = phutil_tag(
'input',
array(
'type' => 'checkbox',
'name' => $this->getName().'[]',
'value' => $const,
'checked' => isset($value_map[$const])
? 'checked'
: null,
'class' => 'phabricator-flag-select-checkbox',
));
$label = phutil_tag(
'label',
array(
'class' => 'phabricator-flag-select-label',
),
array(
$icon,
$input,
));
$out[] = $label;
}
return $out;
}
}