From 2c43d055b1919bdc915a0efe6de7b48ac6c38555 Mon Sep 17 00:00:00 2001 From: epriestley Date: Thu, 30 Jun 2016 16:55:28 -0700 Subject: [PATCH] Remove old ObjectBox tab cruft Summary: Ref T10628. Cleans up remaining weird, unused tab behaviors in ObjectBoxView to simplify ObjectBox. Test Plan: Toggled tabs in Files. Reviewers: chad Reviewed By: chad Maniphest Tasks: T10628 Differential Revision: https://secure.phabricator.com/D16208 --- resources/celerity/map.php | 14 +- src/view/phui/PHUIObjectBoxView.php | 146 ++---------------- src/view/phui/PHUITabGroupView.php | 4 +- src/view/phui/PHUITabView.php | 2 +- ...box-tabs.js => behavior-phui-tab-group.js} | 18 ++- 5 files changed, 37 insertions(+), 147 deletions(-) rename webroot/rsrc/js/phui/{behavior-phui-object-box-tabs.js => behavior-phui-tab-group.js} (55%) diff --git a/resources/celerity/map.php b/resources/celerity/map.php index b6385b9aeb..b53242b6fd 100644 --- a/resources/celerity/map.php +++ b/resources/celerity/map.php @@ -518,9 +518,9 @@ return array( 'rsrc/js/core/phtize.js' => 'd254d646', 'rsrc/js/phui/behavior-phui-dropdown-menu.js' => '1aa4c968', 'rsrc/js/phui/behavior-phui-file-upload.js' => 'b003d4fb', - 'rsrc/js/phui/behavior-phui-object-box-tabs.js' => '2bfa2836', 'rsrc/js/phui/behavior-phui-profile-menu.js' => '12884df9', 'rsrc/js/phui/behavior-phui-submenu.js' => 'a6f7a73b', + 'rsrc/js/phui/behavior-phui-tab-group.js' => '0a0b10e9', 'rsrc/js/phuix/PHUIXActionListView.js' => 'b5c256b8', 'rsrc/js/phuix/PHUIXActionView.js' => '8cf6d262', 'rsrc/js/phuix/PHUIXAutocomplete.js' => '9196fb06', @@ -673,9 +673,9 @@ return array( 'javelin-behavior-phui-dropdown-menu' => '1aa4c968', 'javelin-behavior-phui-file-upload' => 'b003d4fb', 'javelin-behavior-phui-hovercards' => 'bcaccd64', - 'javelin-behavior-phui-object-box-tabs' => '2bfa2836', 'javelin-behavior-phui-profile-menu' => '12884df9', 'javelin-behavior-phui-submenu' => 'a6f7a73b', + 'javelin-behavior-phui-tab-group' => '0a0b10e9', 'javelin-behavior-policy-control' => 'd0c516d5', 'javelin-behavior-policy-rule-editor' => '5e9f347c', 'javelin-behavior-project-boards' => '14a1faae', @@ -977,6 +977,11 @@ return array( 'javelin-stratcom', 'javelin-vector', ), + '0a0b10e9' => array( + 'javelin-behavior', + 'javelin-stratcom', + 'javelin-dom', + ), '0a3f3021' => array( 'javelin-behavior', 'javelin-stratcom', @@ -1107,11 +1112,6 @@ return array( 'javelin-install', 'javelin-util', ), - '2bfa2836' => array( - 'javelin-behavior', - 'javelin-stratcom', - 'javelin-dom', - ), '2c426492' => array( 'javelin-behavior', 'javelin-dom', diff --git a/src/view/phui/PHUIObjectBoxView.php b/src/view/phui/PHUIObjectBoxView.php index 41e176173f..5c6cef49a3 100644 --- a/src/view/phui/PHUIObjectBoxView.php +++ b/src/view/phui/PHUIObjectBoxView.php @@ -25,11 +25,7 @@ final class PHUIObjectBoxView extends AphrontTagView { private $showHideContent; private $showHideOpen; - private $tabs = array(); - private $tabMap = null; - private $tabLists = array(); private $propertyLists = array(); - private $propertyList = null; const COLOR_RED = 'red'; const COLOR_BLUE = 'blue'; @@ -40,48 +36,8 @@ final class PHUIObjectBoxView extends AphrontTagView { const BLUE_PROPERTY = 'phui-box-blue-property'; const GREY = 'phui-box-grey'; - public function addPropertyList( - PHUIPropertyListView $property_list, - $tab = null) { - - if (!($tab instanceof PHUIListItemView) && - ($tab !== null)) { - assert_stringlike($tab); - $tab = id(new PHUIListItemView())->setName($tab); - } - - if ($tab) { - if ($tab->getKey()) { - $key = $tab->getKey(); - } else { - $key = 'tab.default.'.spl_object_hash($tab); - $tab->setKey($key); - } - } else { - $key = 'tab.default'; - } - - if ($tab) { - if (empty($this->tabs[$key])) { - $tab->addSigil('phui-object-box-tab'); - $tab->setMetadata( - array( - 'tabKey' => $key, - )); - - if (!$tab->getHref()) { - $tab->setHref('#'); - } - - if (!$tab->getType()) { - $tab->setType(PHUIListItemView::TYPE_LINK); - } - - $this->tabs[$key] = $tab; - } - } - - $this->propertyLists[$key][] = $property_list; + public function addPropertyList(PHUIPropertyListView $property_list) { + $this->propertyLists[] = $property_list; $action_list = $property_list->getActionList(); if ($action_list) { @@ -190,68 +146,6 @@ final class PHUIObjectBoxView extends AphrontTagView { return $this; } - public function willRender() { - $tab_lists = array(); - $property_lists = array(); - $tab_map = array(); - - $default_key = 'tab.default'; - - // Find the selected tab, or select the first tab if none are selected. - if ($this->tabs) { - $selected_tab = null; - foreach ($this->tabs as $key => $tab) { - if ($tab->getSelected()) { - $selected_tab = $key; - break; - } - } - if ($selected_tab === null) { - head($this->tabs)->setSelected(true); - $selected_tab = head_key($this->tabs); - } - } - - foreach ($this->propertyLists as $key => $list) { - $group = new PHUIPropertyGroupView(); - $i = 0; - foreach ($list as $item) { - $group->addPropertyList($item); - if ($i > 0 || $this->tabGroups) { - $item->addClass('phui-property-list-section-noninitial'); - } - $i++; - } - - if ($this->tabs && $key != $default_key) { - $tab_id = celerity_generate_unique_node_id(); - $tab_map[$key] = $tab_id; - - if ($key === $selected_tab) { - $style = null; - } else { - $style = 'display: none'; - } - - $tab_lists[] = phutil_tag( - 'div', - array( - 'style' => $style, - 'id' => $tab_id, - ), - $group); - } else { - if ($this->tabs) { - $group->addClass('phui-property-group-noninitial'); - } - $property_lists[] = $group; - } - $this->propertyList = $property_lists; - $this->tabMap = $tab_map; - $this->tabLists = $tab_lists; - } - } - protected function getTagAttributes() { $classes = array(); $classes[] = 'phui-box'; @@ -275,19 +169,8 @@ final class PHUIObjectBoxView extends AphrontTagView { $classes[] = $this->background; } - $sigil = null; - $metadata = null; - if ($this->tabs) { - $sigil = 'phui-object-box'; - $metadata = array( - 'tabMap' => $this->tabMap, - ); - } - return array( 'class' => implode(' ', $classes), - 'sigil' => $sigil, - 'meta' => $metadata, ); } @@ -393,16 +276,23 @@ final class PHUIObjectBoxView extends AphrontTagView { } } - $tabs = null; - if ($this->tabs) { - $tabs = id(new PHUIListView()) - ->setType(PHUIListView::NAVBAR_LIST); - foreach ($this->tabs as $tab) { - $tabs->addMenuItem($tab); + if ($this->propertyLists) { + $lists = new PHUIPropertyGroupView(); + + $ii = 0; + foreach ($this->propertyLists as $list) { + if ($ii > 0 || $this->tabGroups) { + $list->addClass('phui-property-list-section-noninitial'); + } + + $lists->addPropertyList($list); + $ii++; } - Javelin::initBehavior('phui-object-box-tabs'); + } else { + $lists = null; } + $content = array( ($this->showHideOpen == false ? $this->anchor : null), $header, @@ -412,11 +302,9 @@ final class PHUIObjectBoxView extends AphrontTagView { $exception_errors, $this->form, $this->tabGroups, - $tabs, - $this->tabLists, $showhide, ($this->showHideOpen == true ? $this->anchor : null), - $this->propertyList, + $lists, $this->table, $this->renderChildren(), ); diff --git a/src/view/phui/PHUITabGroupView.php b/src/view/phui/PHUITabGroupView.php index 6037343852..4a1963e050 100644 --- a/src/view/phui/PHUITabGroupView.php +++ b/src/view/phui/PHUITabGroupView.php @@ -66,7 +66,7 @@ final class PHUITabGroupView extends AphrontTagView { $tab_map = mpull($this->tabs, 'getContentID', 'getKey'); return array( - 'sigil' => 'phui-object-box', + 'sigil' => 'phui-tab-group-view', 'meta' => array( 'tabMap' => $tab_map, ), @@ -74,7 +74,7 @@ final class PHUITabGroupView extends AphrontTagView { } protected function getTagContent() { - Javelin::initBehavior('phui-object-box-tabs'); + Javelin::initBehavior('phui-tab-group'); $tabs = id(new PHUIListView()) ->setType(PHUIListView::NAVBAR_LIST); diff --git a/src/view/phui/PHUITabView.php b/src/view/phui/PHUITabView.php index d037eb0a7b..670fc0759a 100644 --- a/src/view/phui/PHUITabView.php +++ b/src/view/phui/PHUITabView.php @@ -64,7 +64,7 @@ final class PHUITabView extends AphrontTagView { ->setKey($this->getKey()) ->setType(PHUIListItemView::TYPE_LINK) ->setHref('#') - ->addSigil('phui-object-box-tab') + ->addSigil('phui-tab-view') ->setMetadata( array( 'tabKey' => $this->getKey(), diff --git a/webroot/rsrc/js/phui/behavior-phui-object-box-tabs.js b/webroot/rsrc/js/phui/behavior-phui-tab-group.js similarity index 55% rename from webroot/rsrc/js/phui/behavior-phui-object-box-tabs.js rename to webroot/rsrc/js/phui/behavior-phui-tab-group.js index 85cdf9345d..23c1ca5b68 100644 --- a/webroot/rsrc/js/phui/behavior-phui-object-box-tabs.js +++ b/webroot/rsrc/js/phui/behavior-phui-tab-group.js @@ -1,23 +1,25 @@ /** - * @provides javelin-behavior-phui-object-box-tabs + * @provides javelin-behavior-phui-tab-group * @requires javelin-behavior * javelin-stratcom * javelin-dom */ -JX.behavior('phui-object-box-tabs', function() { +JX.behavior('phui-tab-group', function() { JX.Stratcom.listen( 'click', - 'phui-object-box-tab', + 'phui-tab-view', function (e) { e.kill(); - var key = e.getNodeData('phui-object-box-tab').tabKey; - var map = e.getNodeData('phui-object-box').tabMap; - var tab = e.getNode('phui-object-box-tab'); - var box = e.getNode('phui-object-box'); - var tabs = JX.DOM.scry(box, 'li', 'phui-object-box-tab'); + var map = e.getNodeData('phui-tab-group-view').tabMap; + var key = e.getNodeData('phui-tab-view').tabKey; + + var group = e.getNode('phui-tab-group-view'); + var tab = e.getNode('phui-tab-view'); + var tabs = JX.DOM.scry(group, 'li', 'phui-tab-view'); + for (var ii = 0; ii < tabs.length; ii++) { JX.DOM.alterClass( tabs[ii],