mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-18 12:52:42 +01:00
Allow projects to be filtered by icon and color
Summary: Ref T5819. Implements basic icon and color filtering for projects. Test Plan: {F189350} Reviewers: btrahan, chad Reviewed By: chad Subscribers: epriestley Maniphest Tasks: T5819 Differential Revision: https://secure.phabricator.com/D10230
This commit is contained in:
parent
9309723ac4
commit
94389fcd9f
6 changed files with 120 additions and 14 deletions
2
resources/sql/autopatches/20140812.projkey.1.sql
Normal file
2
resources/sql/autopatches/20140812.projkey.1.sql
Normal file
|
@ -0,0 +1,2 @@
|
|||
ALTER TABLE {$NAMESPACE}_project.project
|
||||
ADD KEY `key_icon` (icon);
|
2
resources/sql/autopatches/20140812.projkey.2.sql
Normal file
2
resources/sql/autopatches/20140812.projkey.2.sql
Normal file
|
@ -0,0 +1,2 @@
|
|||
ALTER TABLE {$NAMESPACE}_project.project
|
||||
ADD KEY `key_color` (color);
|
|
@ -144,11 +144,7 @@ final class PhabricatorProjectEditDetailsController
|
|||
->setError($e_name));
|
||||
$field_list->appendFieldsToForm($form);
|
||||
|
||||
$shades = PHUITagView::getShadeMap();
|
||||
$shades = array_select_keys(
|
||||
$shades,
|
||||
array(PhabricatorProject::DEFAULT_COLOR)) + $shades;
|
||||
unset($shades[PHUITagView::COLOR_DISABLED]);
|
||||
$shades = PhabricatorProjectIcon::getColorMap();
|
||||
|
||||
$icon_uri = $this->getApplicationURI('icon/'.$project->getID().'/');
|
||||
$icon_display = PhabricatorProjectIcon::renderIconForChooser($v_icon);
|
||||
|
|
|
@ -24,6 +24,16 @@ final class PhabricatorProjectIcon extends Phobject {
|
|||
);
|
||||
}
|
||||
|
||||
public static function getColorMap() {
|
||||
$shades = PHUITagView::getShadeMap();
|
||||
$shades = array_select_keys(
|
||||
$shades,
|
||||
array(PhabricatorProject::DEFAULT_COLOR)) + $shades;
|
||||
unset($shades[PHUITagView::COLOR_DISABLED]);
|
||||
|
||||
return $shades;
|
||||
}
|
||||
|
||||
public static function getLabel($key) {
|
||||
$map = self::getIconMap();
|
||||
return $map[$key];
|
||||
|
|
|
@ -10,6 +10,8 @@ final class PhabricatorProjectQuery
|
|||
private $phrictionSlugs;
|
||||
private $names;
|
||||
private $datasourceQuery;
|
||||
private $icons;
|
||||
private $colors;
|
||||
|
||||
private $status = 'status-any';
|
||||
const STATUS_ANY = 'status-any';
|
||||
|
@ -63,6 +65,16 @@ final class PhabricatorProjectQuery
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function withIcons(array $icons) {
|
||||
$this->icons = $icons;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function withColors(array $colors) {
|
||||
$this->colors = $colors;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function needMembers($need_members) {
|
||||
$this->needMembers = $need_members;
|
||||
return $this;
|
||||
|
@ -244,28 +256,28 @@ final class PhabricatorProjectQuery
|
|||
$filter);
|
||||
}
|
||||
|
||||
if ($this->ids) {
|
||||
if ($this->ids !== null) {
|
||||
$where[] = qsprintf(
|
||||
$conn_r,
|
||||
'id IN (%Ld)',
|
||||
$this->ids);
|
||||
}
|
||||
|
||||
if ($this->phids) {
|
||||
if ($this->phids !== null) {
|
||||
$where[] = qsprintf(
|
||||
$conn_r,
|
||||
'phid IN (%Ls)',
|
||||
$this->phids);
|
||||
}
|
||||
|
||||
if ($this->memberPHIDs) {
|
||||
if ($this->memberPHIDs !== null) {
|
||||
$where[] = qsprintf(
|
||||
$conn_r,
|
||||
'e.dst IN (%Ls)',
|
||||
$this->memberPHIDs);
|
||||
}
|
||||
|
||||
if ($this->slugs) {
|
||||
if ($this->slugs !== null) {
|
||||
$slugs = array();
|
||||
foreach ($this->slugs as $slug) {
|
||||
$slugs[] = rtrim(PhabricatorSlug::normalize($slug), '/');
|
||||
|
@ -277,20 +289,34 @@ final class PhabricatorProjectQuery
|
|||
$slugs);
|
||||
}
|
||||
|
||||
if ($this->phrictionSlugs) {
|
||||
if ($this->phrictionSlugs !== null) {
|
||||
$where[] = qsprintf(
|
||||
$conn_r,
|
||||
'phrictionSlug IN (%Ls)',
|
||||
$this->phrictionSlugs);
|
||||
}
|
||||
|
||||
if ($this->names) {
|
||||
if ($this->names !== null) {
|
||||
$where[] = qsprintf(
|
||||
$conn_r,
|
||||
'name IN (%Ls)',
|
||||
$this->names);
|
||||
}
|
||||
|
||||
if ($this->icons !== null) {
|
||||
$where[] = qsprintf(
|
||||
$conn_r,
|
||||
'icon IN (%Ls)',
|
||||
$this->icons);
|
||||
}
|
||||
|
||||
if ($this->colors !== null) {
|
||||
$where[] = qsprintf(
|
||||
$conn_r,
|
||||
'color IN (%Ls)',
|
||||
$this->colors);
|
||||
}
|
||||
|
||||
$where[] = $this->buildPagingClause($conn_r);
|
||||
|
||||
return $this->formatWhereClause($where);
|
||||
|
|
|
@ -25,6 +25,14 @@ final class PhabricatorProjectSearchEngine
|
|||
$saved->setParameter('status', $request->getStr('status'));
|
||||
$saved->setParameter('name', $request->getStr('name'));
|
||||
|
||||
$saved->setParameter(
|
||||
'icons',
|
||||
$this->readListFromRequest($request, 'icons'));
|
||||
|
||||
$saved->setParameter(
|
||||
'colors',
|
||||
$this->readListFromRequest($request, 'colors'));
|
||||
|
||||
$this->readCustomFieldsFromRequest($request, $saved);
|
||||
|
||||
return $saved;
|
||||
|
@ -50,6 +58,16 @@ final class PhabricatorProjectSearchEngine
|
|||
$query->withDatasourceQuery($name);
|
||||
}
|
||||
|
||||
$icons = $saved->getParameter('icons');
|
||||
if ($icons) {
|
||||
$query->withIcons($icons);
|
||||
}
|
||||
|
||||
$colors = $saved->getParameter('colors');
|
||||
if ($colors) {
|
||||
$query->withColors($colors);
|
||||
}
|
||||
|
||||
$this->applyCustomFieldsToQuery($query, $saved);
|
||||
|
||||
return $query;
|
||||
|
@ -66,14 +84,45 @@ final class PhabricatorProjectSearchEngine
|
|||
->execute();
|
||||
|
||||
$status = $saved->getParameter('status');
|
||||
$name = $saved->getParameter('name');
|
||||
$name_match = $saved->getParameter('name');
|
||||
|
||||
$icons = array_fuse($saved->getParameter('icons', array()));
|
||||
$colors = array_fuse($saved->getParameter('colors', array()));
|
||||
|
||||
$icon_control = id(new AphrontFormCheckboxControl())
|
||||
->setLabel(pht('Icons'));
|
||||
foreach (PhabricatorProjectIcon::getIconMap() as $icon => $name) {
|
||||
$image = id(new PHUIIconView())
|
||||
->setIconFont($icon);
|
||||
|
||||
$icon_control->addCheckbox(
|
||||
'icons[]',
|
||||
$icon,
|
||||
array($image, ' ', $name),
|
||||
isset($icons[$icon]));
|
||||
}
|
||||
|
||||
$color_control = id(new AphrontFormCheckboxControl())
|
||||
->setLabel(pht('Colors'));
|
||||
foreach (PhabricatorProjectIcon::getColorMap() as $color => $name) {
|
||||
$tag = id(new PHUITagView())
|
||||
->setType(PHUITagView::TYPE_SHADE)
|
||||
->setShade($color)
|
||||
->setName($name);
|
||||
|
||||
$color_control->addCheckbox(
|
||||
'colors[]',
|
||||
$color,
|
||||
$tag,
|
||||
isset($colors[$color]));
|
||||
}
|
||||
|
||||
$form
|
||||
->appendChild(
|
||||
id(new AphrontFormTextControl())
|
||||
->setName('name')
|
||||
->setLabel(pht('Name'))
|
||||
->setValue($name))
|
||||
->setValue($name_match))
|
||||
->appendChild(
|
||||
id(new AphrontFormTokenizerControl())
|
||||
->setDatasource(new PhabricatorPeopleDatasource())
|
||||
|
@ -85,7 +134,9 @@ final class PhabricatorProjectSearchEngine
|
|||
->setLabel(pht('Status'))
|
||||
->setName('status')
|
||||
->setOptions($this->getStatusOptions())
|
||||
->setValue($status));
|
||||
->setValue($status))
|
||||
->appendChild($icon_control)
|
||||
->appendChild($color_control);
|
||||
|
||||
$this->appendCustomFieldsToForm($form, $saved);
|
||||
}
|
||||
|
@ -142,6 +193,20 @@ final class PhabricatorProjectSearchEngine
|
|||
);
|
||||
}
|
||||
|
||||
private function getColorValues() {
|
||||
|
||||
}
|
||||
|
||||
private function getIconValues() {
|
||||
|
||||
}
|
||||
|
||||
protected function getRequiredHandlePHIDsForResultList(
|
||||
array $projects,
|
||||
PhabricatorSavedQuery $query) {
|
||||
return mpull($projects, 'getPHID');
|
||||
}
|
||||
|
||||
protected function renderResultList(
|
||||
array $projects,
|
||||
PhabricatorSavedQuery $query,
|
||||
|
@ -169,10 +234,15 @@ final class PhabricatorProjectSearchEngine
|
|||
),
|
||||
pht('Members'));
|
||||
|
||||
$tag_list = id(new PHUIHandleTagListView())
|
||||
->setSlim(true)
|
||||
->setHandles(array($handles[$project->getPHID()]));
|
||||
|
||||
$item = id(new PHUIObjectItemView())
|
||||
->setHeader($project->getName())
|
||||
->setHref($this->getApplicationURI("view/{$id}/"))
|
||||
->setImageURI($project->getProfileImageURI())
|
||||
->addAttribute($tag_list)
|
||||
->addAttribute($workboards_url)
|
||||
->addAttribute($members_url);
|
||||
|
||||
|
|
Loading…
Reference in a new issue