1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-26 15:30:58 +01:00

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
This commit is contained in:
epriestley 2016-06-30 16:55:28 -07:00
parent 65980ac683
commit 2c43d055b1
5 changed files with 37 additions and 147 deletions

View file

@ -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',

View file

@ -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(),
);

View file

@ -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);

View file

@ -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(),

View file

@ -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],