@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
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Convert PHUIObjectBoxView to AphrontTagView

Summary: Attempting to clean PHUIObjectBoxView up a little as well as finally being able to `addClass` on the sucker. I'm running into some issue with `addTabs` though, which on Files isn't firing.

Test Plan: Bounce around tons of screens.

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin

Differential Revision: https://secure.phabricator.com/D15291

+133 -141
+1 -1
src/__phutil_library_map__.php
··· 5711 5711 'PHUIListView' => 'AphrontTagView', 5712 5712 'PHUIListViewTestCase' => 'PhabricatorTestCase', 5713 5713 'PHUIMainMenuView' => 'AphrontView', 5714 - 'PHUIObjectBoxView' => 'AphrontView', 5714 + 'PHUIObjectBoxView' => 'AphrontTagView', 5715 5715 'PHUIObjectItemListExample' => 'PhabricatorUIExample', 5716 5716 'PHUIObjectItemListView' => 'AphrontTagView', 5717 5717 'PHUIObjectItemView' => 'AphrontTagView',
+2 -2
src/applications/people/controller/PhabricatorPeopleProfileViewController.php
··· 174 174 $box = id(new PHUIObjectBoxView()) 175 175 ->setHeader($header) 176 176 ->appendChild($list) 177 - ->setBackground(PHUIBoxView::GREY); 177 + ->setBackground(PHUIObjectBoxView::GREY); 178 178 179 179 return $box; 180 180 } ··· 218 218 $box = id(new PHUIObjectBoxView()) 219 219 ->setHeaderText(pht('Badges')) 220 220 ->appendChild($flex) 221 - ->setBackground(PHUIBoxView::GREY); 221 + ->setBackground(PHUIObjectBoxView::GREY); 222 222 223 223 return $box; 224 224 }
+4 -4
src/applications/project/controller/PhabricatorProjectProfileController.php
··· 59 59 ->setUser($viewer) 60 60 ->setProject($project) 61 61 ->setLimit(5) 62 - ->setBackground(PHUIBoxView::GREY) 62 + ->setBackground(PHUIObjectBoxView::GREY) 63 63 ->setUserPHIDs($project->getMemberPHIDs()); 64 64 65 65 $watcher_list = id(new PhabricatorProjectWatcherListView()) 66 66 ->setUser($viewer) 67 67 ->setProject($project) 68 68 ->setLimit(5) 69 - ->setBackground(PHUIBoxView::GREY) 69 + ->setBackground(PHUIObjectBoxView::GREY) 70 70 ->setUserPHIDs($project->getWatcherPHIDs()); 71 71 72 72 $nav = $this->getProfileMenu(); ··· 244 244 245 245 return id(new PHUIObjectBoxView()) 246 246 ->setHeader($header) 247 - ->setBackground(PHUIBoxView::GREY) 247 + ->setBackground(PHUIObjectBoxView::GREY) 248 248 ->setObjectList($milestone_list); 249 249 } 250 250 ··· 292 292 293 293 return id(new PHUIObjectBoxView()) 294 294 ->setHeader($header) 295 - ->setBackground(PHUIBoxView::GREY) 295 + ->setBackground(PHUIObjectBoxView::GREY) 296 296 ->setObjectList($subproject_list); 297 297 } 298 298
+126 -134
src/view/phui/PHUIObjectBoxView.php
··· 1 1 <?php 2 2 3 - final class PHUIObjectBoxView extends AphrontView { 3 + final class PHUIObjectBoxView extends AphrontTagView { 4 4 5 5 private $headerText; 6 6 private $color; ··· 12 12 private $validationException; 13 13 private $header; 14 14 private $flush; 15 - private $id; 16 - private $sigils = array(); 17 - private $metadata; 18 15 private $actionListID; 19 16 private $objectList; 20 17 private $table; ··· 28 25 private $showHideOpen; 29 26 30 27 private $tabs = array(); 28 + private $tabMap = null; 29 + private $tabLists = array(); 31 30 private $propertyLists = array(); 31 + private $propertyList = null; 32 32 33 33 const COLOR_RED = 'red'; 34 34 const COLOR_BLUE = 'blue'; 35 35 const COLOR_GREEN = 'green'; 36 36 const COLOR_YELLOW = 'yellow'; 37 37 38 - public function addSigil($sigil) { 39 - $this->sigils[] = $sigil; 40 - return $this; 41 - } 42 - 43 - public function setMetadata(array $metadata) { 44 - $this->metadata = $metadata; 45 - return $this; 46 - } 38 + const BLUE = 'phui-box-blue'; 39 + const GREY = 'phui-box-grey'; 47 40 48 41 public function addPropertyList( 49 42 PHUIPropertyListView $property_list, ··· 144 137 return $this; 145 138 } 146 139 147 - public function setID($id) { 148 - $this->id = $id; 149 - return $this; 150 - } 151 - 152 140 public function setHeader($header) { 153 141 $this->header = $header; 154 142 return $this; ··· 195 183 return $this; 196 184 } 197 185 198 - public function render() { 186 + public function willRender() { 187 + $tab_lists = array(); 188 + $property_lists = array(); 189 + $tab_map = array(); 190 + 191 + $default_key = 'tab.default'; 192 + 193 + // Find the selected tab, or select the first tab if none are selected. 194 + if ($this->tabs) { 195 + $selected_tab = null; 196 + foreach ($this->tabs as $key => $tab) { 197 + if ($tab->getSelected()) { 198 + $selected_tab = $key; 199 + break; 200 + } 201 + } 202 + if ($selected_tab === null) { 203 + head($this->tabs)->setSelected(true); 204 + $selected_tab = head_key($this->tabs); 205 + } 206 + } 207 + 208 + foreach ($this->propertyLists as $key => $list) { 209 + $group = new PHUIPropertyGroupView(); 210 + $i = 0; 211 + foreach ($list as $item) { 212 + $group->addPropertyList($item); 213 + if ($i > 0) { 214 + $item->addClass('phui-property-list-section-noninitial'); 215 + } 216 + $i++; 217 + } 218 + 219 + if ($this->tabs && $key != $default_key) { 220 + $tab_id = celerity_generate_unique_node_id(); 221 + $tab_map[$key] = $tab_id; 222 + 223 + if ($key === $selected_tab) { 224 + $style = null; 225 + } else { 226 + $style = 'display: none'; 227 + } 228 + 229 + $tab_lists[] = phutil_tag( 230 + 'div', 231 + array( 232 + 'style' => $style, 233 + 'id' => $tab_id, 234 + ), 235 + $group); 236 + } else { 237 + if ($this->tabs) { 238 + $group->addClass('phui-property-group-noninitial'); 239 + } 240 + $property_lists[] = $group; 241 + } 242 + $this->propertyList = $property_lists; 243 + $this->tabMap = $tab_map; 244 + $this->tabLists = $tab_lists; 245 + } 246 + } 247 + 248 + protected function getTagAttributes() { 249 + $classes = array(); 250 + $classes[] = 'phui-box'; 251 + $classes[] = 'phui-box-border'; 252 + $classes[] = 'phui-object-box'; 253 + $classes[] = 'mlt mll mlr'; 254 + 255 + if ($this->color) { 256 + $classes[] = 'phui-object-box-'.$this->color; 257 + } 258 + 259 + if ($this->collapsed) { 260 + $classes[] = 'phui-object-box-collapsed'; 261 + } 262 + 263 + if ($this->flush) { 264 + $classes[] = 'phui-object-box-flush'; 265 + } 266 + 267 + if ($this->background) { 268 + $classes[] = $this->background; 269 + } 270 + 271 + $sigil = null; 272 + $metadata = null; 273 + if ($this->tabs) { 274 + $sigil = 'phui-object-box'; 275 + $metadata = array( 276 + 'tabMap' => $this->tabMap, 277 + ); 278 + } 279 + 280 + return array( 281 + 'class' => implode(' ', $classes), 282 + 'sigil' => $sigil, 283 + 'meta' => $metadata, 284 + ); 285 + } 286 + 287 + protected function getTagContent() { 288 + require_celerity_resource('phui-box-css'); 199 289 require_celerity_resource('phui-object-box-css'); 200 290 201 291 $header = $this->header; ··· 296 386 } 297 387 } 298 388 299 - $tab_lists = array(); 300 - $property_lists = array(); 301 - $tab_map = array(); 302 - 303 - $default_key = 'tab.default'; 304 - 305 - // Find the selected tab, or select the first tab if none are selected. 306 - if ($this->tabs) { 307 - $selected_tab = null; 308 - foreach ($this->tabs as $key => $tab) { 309 - if ($tab->getSelected()) { 310 - $selected_tab = $key; 311 - break; 312 - } 313 - } 314 - if ($selected_tab === null) { 315 - head($this->tabs)->setSelected(true); 316 - $selected_tab = head_key($this->tabs); 317 - } 318 - } 319 - 320 - foreach ($this->propertyLists as $key => $list) { 321 - $group = new PHUIPropertyGroupView(); 322 - $i = 0; 323 - foreach ($list as $item) { 324 - $group->addPropertyList($item); 325 - if ($i > 0) { 326 - $item->addClass('phui-property-list-section-noninitial'); 327 - } 328 - $i++; 329 - } 330 - 331 - if ($this->tabs && $key != $default_key) { 332 - $tab_id = celerity_generate_unique_node_id(); 333 - $tab_map[$key] = $tab_id; 334 - 335 - if ($key === $selected_tab) { 336 - $style = null; 337 - } else { 338 - $style = 'display: none'; 339 - } 340 - 341 - $tab_lists[] = phutil_tag( 342 - 'div', 343 - array( 344 - 'style' => $style, 345 - 'id' => $tab_id, 346 - ), 347 - $group); 348 - } else { 349 - if ($this->tabs) { 350 - $group->addClass('phui-property-group-noninitial'); 351 - } 352 - $property_lists[] = $group; 353 - } 354 - } 355 - 356 389 $tabs = null; 357 390 if ($this->tabs) { 358 391 $tabs = id(new PHUIListView()) ··· 360 393 foreach ($this->tabs as $tab) { 361 394 $tabs->addMenuItem($tab); 362 395 } 363 - 364 396 Javelin::initBehavior('phui-object-box-tabs'); 365 397 } 366 398 367 - $content = id(new PHUIBoxView()) 368 - ->appendChild( 369 - array( 370 - ($this->showHideOpen == false ? $this->anchor : null), 371 - $header, 372 - $this->infoView, 373 - $this->formErrors, 374 - $this->formSaved, 375 - $exception_errors, 376 - $this->form, 377 - $tabs, 378 - $tab_lists, 379 - $showhide, 380 - ($this->showHideOpen == true ? $this->anchor : null), 381 - $property_lists, 382 - $this->table, 383 - $this->renderChildren(), 384 - )) 385 - ->setBorder(true) 386 - ->setID($this->id) 387 - ->addMargin(PHUI::MARGIN_LARGE_TOP) 388 - ->addMargin(PHUI::MARGIN_LARGE_LEFT) 389 - ->addMargin(PHUI::MARGIN_LARGE_RIGHT) 390 - ->addClass('phui-object-box'); 391 - 392 - if ($this->color) { 393 - $content->addClass('phui-object-box-'.$this->color); 394 - } 395 - 396 - if ($this->background) { 397 - $content->setColor($this->background); 398 - } 399 - 400 - if ($this->collapsed) { 401 - $content->addClass('phui-object-box-collapsed'); 402 - } 403 - 404 - if ($this->tabs) { 405 - $content->addSigil('phui-object-box'); 406 - $content->setMetadata( 407 - array( 408 - 'tabMap' => $tab_map, 409 - )); 410 - } 411 - 412 - if ($this->flush) { 413 - $content->addClass('phui-object-box-flush'); 414 - } 415 - 416 - foreach ($this->sigils as $sigil) { 417 - $content->addSigil($sigil); 418 - } 419 - 420 - if ($this->metadata !== null) { 421 - $content->setMetadata($this->metadata); 422 - } 399 + $content = array( 400 + ($this->showHideOpen == false ? $this->anchor : null), 401 + $header, 402 + $this->infoView, 403 + $this->formErrors, 404 + $this->formSaved, 405 + $exception_errors, 406 + $this->form, 407 + $tabs, 408 + $this->tabLists, 409 + $showhide, 410 + ($this->showHideOpen == true ? $this->anchor : null), 411 + $this->propertyList, 412 + $this->table, 413 + $this->renderChildren(), 414 + ); 423 415 424 416 if ($this->objectList) { 425 - $content->appendChild($this->objectList); 417 + $content[] = $this->objectList; 426 418 } 427 419 428 420 return $content;