@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator

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

+120 -14
+2
resources/sql/autopatches/20140812.projkey.1.sql
··· 1 + ALTER TABLE {$NAMESPACE}_project.project 2 + ADD KEY `key_icon` (icon);
+2
resources/sql/autopatches/20140812.projkey.2.sql
··· 1 + ALTER TABLE {$NAMESPACE}_project.project 2 + ADD KEY `key_color` (color);
+1 -5
src/applications/project/controller/PhabricatorProjectEditDetailsController.php
··· 144 144 ->setError($e_name)); 145 145 $field_list->appendFieldsToForm($form); 146 146 147 - $shades = PHUITagView::getShadeMap(); 148 - $shades = array_select_keys( 149 - $shades, 150 - array(PhabricatorProject::DEFAULT_COLOR)) + $shades; 151 - unset($shades[PHUITagView::COLOR_DISABLED]); 147 + $shades = PhabricatorProjectIcon::getColorMap(); 152 148 153 149 $icon_uri = $this->getApplicationURI('icon/'.$project->getID().'/'); 154 150 $icon_display = PhabricatorProjectIcon::renderIconForChooser($v_icon);
+10
src/applications/project/icon/PhabricatorProjectIcon.php
··· 24 24 ); 25 25 } 26 26 27 + public static function getColorMap() { 28 + $shades = PHUITagView::getShadeMap(); 29 + $shades = array_select_keys( 30 + $shades, 31 + array(PhabricatorProject::DEFAULT_COLOR)) + $shades; 32 + unset($shades[PHUITagView::COLOR_DISABLED]); 33 + 34 + return $shades; 35 + } 36 + 27 37 public static function getLabel($key) { 28 38 $map = self::getIconMap(); 29 39 return $map[$key];
+32 -6
src/applications/project/query/PhabricatorProjectQuery.php
··· 10 10 private $phrictionSlugs; 11 11 private $names; 12 12 private $datasourceQuery; 13 + private $icons; 14 + private $colors; 13 15 14 16 private $status = 'status-any'; 15 17 const STATUS_ANY = 'status-any'; ··· 60 62 61 63 public function withDatasourceQuery($string) { 62 64 $this->datasourceQuery = $string; 65 + return $this; 66 + } 67 + 68 + public function withIcons(array $icons) { 69 + $this->icons = $icons; 70 + return $this; 71 + } 72 + 73 + public function withColors(array $colors) { 74 + $this->colors = $colors; 63 75 return $this; 64 76 } 65 77 ··· 244 256 $filter); 245 257 } 246 258 247 - if ($this->ids) { 259 + if ($this->ids !== null) { 248 260 $where[] = qsprintf( 249 261 $conn_r, 250 262 'id IN (%Ld)', 251 263 $this->ids); 252 264 } 253 265 254 - if ($this->phids) { 266 + if ($this->phids !== null) { 255 267 $where[] = qsprintf( 256 268 $conn_r, 257 269 'phid IN (%Ls)', 258 270 $this->phids); 259 271 } 260 272 261 - if ($this->memberPHIDs) { 273 + if ($this->memberPHIDs !== null) { 262 274 $where[] = qsprintf( 263 275 $conn_r, 264 276 'e.dst IN (%Ls)', 265 277 $this->memberPHIDs); 266 278 } 267 279 268 - if ($this->slugs) { 280 + if ($this->slugs !== null) { 269 281 $slugs = array(); 270 282 foreach ($this->slugs as $slug) { 271 283 $slugs[] = rtrim(PhabricatorSlug::normalize($slug), '/'); ··· 277 289 $slugs); 278 290 } 279 291 280 - if ($this->phrictionSlugs) { 292 + if ($this->phrictionSlugs !== null) { 281 293 $where[] = qsprintf( 282 294 $conn_r, 283 295 'phrictionSlug IN (%Ls)', 284 296 $this->phrictionSlugs); 285 297 } 286 298 287 - if ($this->names) { 299 + if ($this->names !== null) { 288 300 $where[] = qsprintf( 289 301 $conn_r, 290 302 'name IN (%Ls)', 291 303 $this->names); 304 + } 305 + 306 + if ($this->icons !== null) { 307 + $where[] = qsprintf( 308 + $conn_r, 309 + 'icon IN (%Ls)', 310 + $this->icons); 311 + } 312 + 313 + if ($this->colors !== null) { 314 + $where[] = qsprintf( 315 + $conn_r, 316 + 'color IN (%Ls)', 317 + $this->colors); 292 318 } 293 319 294 320 $where[] = $this->buildPagingClause($conn_r);
+73 -3
src/applications/project/query/PhabricatorProjectSearchEngine.php
··· 25 25 $saved->setParameter('status', $request->getStr('status')); 26 26 $saved->setParameter('name', $request->getStr('name')); 27 27 28 + $saved->setParameter( 29 + 'icons', 30 + $this->readListFromRequest($request, 'icons')); 31 + 32 + $saved->setParameter( 33 + 'colors', 34 + $this->readListFromRequest($request, 'colors')); 35 + 28 36 $this->readCustomFieldsFromRequest($request, $saved); 29 37 30 38 return $saved; ··· 50 58 $query->withDatasourceQuery($name); 51 59 } 52 60 61 + $icons = $saved->getParameter('icons'); 62 + if ($icons) { 63 + $query->withIcons($icons); 64 + } 65 + 66 + $colors = $saved->getParameter('colors'); 67 + if ($colors) { 68 + $query->withColors($colors); 69 + } 70 + 53 71 $this->applyCustomFieldsToQuery($query, $saved); 54 72 55 73 return $query; ··· 66 84 ->execute(); 67 85 68 86 $status = $saved->getParameter('status'); 69 - $name = $saved->getParameter('name'); 87 + $name_match = $saved->getParameter('name'); 88 + 89 + $icons = array_fuse($saved->getParameter('icons', array())); 90 + $colors = array_fuse($saved->getParameter('colors', array())); 91 + 92 + $icon_control = id(new AphrontFormCheckboxControl()) 93 + ->setLabel(pht('Icons')); 94 + foreach (PhabricatorProjectIcon::getIconMap() as $icon => $name) { 95 + $image = id(new PHUIIconView()) 96 + ->setIconFont($icon); 97 + 98 + $icon_control->addCheckbox( 99 + 'icons[]', 100 + $icon, 101 + array($image, ' ', $name), 102 + isset($icons[$icon])); 103 + } 104 + 105 + $color_control = id(new AphrontFormCheckboxControl()) 106 + ->setLabel(pht('Colors')); 107 + foreach (PhabricatorProjectIcon::getColorMap() as $color => $name) { 108 + $tag = id(new PHUITagView()) 109 + ->setType(PHUITagView::TYPE_SHADE) 110 + ->setShade($color) 111 + ->setName($name); 112 + 113 + $color_control->addCheckbox( 114 + 'colors[]', 115 + $color, 116 + $tag, 117 + isset($colors[$color])); 118 + } 70 119 71 120 $form 72 121 ->appendChild( 73 122 id(new AphrontFormTextControl()) 74 123 ->setName('name') 75 124 ->setLabel(pht('Name')) 76 - ->setValue($name)) 125 + ->setValue($name_match)) 77 126 ->appendChild( 78 127 id(new AphrontFormTokenizerControl()) 79 128 ->setDatasource(new PhabricatorPeopleDatasource()) ··· 85 134 ->setLabel(pht('Status')) 86 135 ->setName('status') 87 136 ->setOptions($this->getStatusOptions()) 88 - ->setValue($status)); 137 + ->setValue($status)) 138 + ->appendChild($icon_control) 139 + ->appendChild($color_control); 89 140 90 141 $this->appendCustomFieldsToForm($form, $saved); 91 142 } ··· 142 193 ); 143 194 } 144 195 196 + private function getColorValues() { 197 + 198 + } 199 + 200 + private function getIconValues() { 201 + 202 + } 203 + 204 + protected function getRequiredHandlePHIDsForResultList( 205 + array $projects, 206 + PhabricatorSavedQuery $query) { 207 + return mpull($projects, 'getPHID'); 208 + } 209 + 145 210 protected function renderResultList( 146 211 array $projects, 147 212 PhabricatorSavedQuery $query, ··· 169 234 ), 170 235 pht('Members')); 171 236 237 + $tag_list = id(new PHUIHandleTagListView()) 238 + ->setSlim(true) 239 + ->setHandles(array($handles[$project->getPHID()])); 240 + 172 241 $item = id(new PHUIObjectItemView()) 173 242 ->setHeader($project->getName()) 174 243 ->setHref($this->getApplicationURI("view/{$id}/")) 175 244 ->setImageURI($project->getProfileImageURI()) 245 + ->addAttribute($tag_list) 176 246 ->addAttribute($workboards_url) 177 247 ->addAttribute($members_url); 178 248