Skip to content

Commit 2c43d05

Browse files
author
epriestley
committedJul 1, 2016
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
1 parent 65980ac commit 2c43d05

File tree

5 files changed

+37
-147
lines changed

5 files changed

+37
-147
lines changed
 

‎resources/celerity/map.php

+7-7
Original file line numberDiff line numberDiff line change
@@ -518,9 +518,9 @@
518518
'rsrc/js/core/phtize.js' => 'd254d646',
519519
'rsrc/js/phui/behavior-phui-dropdown-menu.js' => '1aa4c968',
520520
'rsrc/js/phui/behavior-phui-file-upload.js' => 'b003d4fb',
521-
'rsrc/js/phui/behavior-phui-object-box-tabs.js' => '2bfa2836',
522521
'rsrc/js/phui/behavior-phui-profile-menu.js' => '12884df9',
523522
'rsrc/js/phui/behavior-phui-submenu.js' => 'a6f7a73b',
523+
'rsrc/js/phui/behavior-phui-tab-group.js' => '0a0b10e9',
524524
'rsrc/js/phuix/PHUIXActionListView.js' => 'b5c256b8',
525525
'rsrc/js/phuix/PHUIXActionView.js' => '8cf6d262',
526526
'rsrc/js/phuix/PHUIXAutocomplete.js' => '9196fb06',
@@ -673,9 +673,9 @@
673673
'javelin-behavior-phui-dropdown-menu' => '1aa4c968',
674674
'javelin-behavior-phui-file-upload' => 'b003d4fb',
675675
'javelin-behavior-phui-hovercards' => 'bcaccd64',
676-
'javelin-behavior-phui-object-box-tabs' => '2bfa2836',
677676
'javelin-behavior-phui-profile-menu' => '12884df9',
678677
'javelin-behavior-phui-submenu' => 'a6f7a73b',
678+
'javelin-behavior-phui-tab-group' => '0a0b10e9',
679679
'javelin-behavior-policy-control' => 'd0c516d5',
680680
'javelin-behavior-policy-rule-editor' => '5e9f347c',
681681
'javelin-behavior-project-boards' => '14a1faae',
@@ -977,6 +977,11 @@
977977
'javelin-stratcom',
978978
'javelin-vector',
979979
),
980+
'0a0b10e9' => array(
981+
'javelin-behavior',
982+
'javelin-stratcom',
983+
'javelin-dom',
984+
),
980985
'0a3f3021' => array(
981986
'javelin-behavior',
982987
'javelin-stratcom',
@@ -1107,11 +1112,6 @@
11071112
'javelin-install',
11081113
'javelin-util',
11091114
),
1110-
'2bfa2836' => array(
1111-
'javelin-behavior',
1112-
'javelin-stratcom',
1113-
'javelin-dom',
1114-
),
11151115
'2c426492' => array(
11161116
'javelin-behavior',
11171117
'javelin-dom',

‎src/view/phui/PHUIObjectBoxView.php

+17-129
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,7 @@ final class PHUIObjectBoxView extends AphrontTagView {
2525
private $showHideContent;
2626
private $showHideOpen;
2727

28-
private $tabs = array();
29-
private $tabMap = null;
30-
private $tabLists = array();
3128
private $propertyLists = array();
32-
private $propertyList = null;
3329

3430
const COLOR_RED = 'red';
3531
const COLOR_BLUE = 'blue';
@@ -40,48 +36,8 @@ final class PHUIObjectBoxView extends AphrontTagView {
4036
const BLUE_PROPERTY = 'phui-box-blue-property';
4137
const GREY = 'phui-box-grey';
4238

43-
public function addPropertyList(
44-
PHUIPropertyListView $property_list,
45-
$tab = null) {
46-
47-
if (!($tab instanceof PHUIListItemView) &&
48-
($tab !== null)) {
49-
assert_stringlike($tab);
50-
$tab = id(new PHUIListItemView())->setName($tab);
51-
}
52-
53-
if ($tab) {
54-
if ($tab->getKey()) {
55-
$key = $tab->getKey();
56-
} else {
57-
$key = 'tab.default.'.spl_object_hash($tab);
58-
$tab->setKey($key);
59-
}
60-
} else {
61-
$key = 'tab.default';
62-
}
63-
64-
if ($tab) {
65-
if (empty($this->tabs[$key])) {
66-
$tab->addSigil('phui-object-box-tab');
67-
$tab->setMetadata(
68-
array(
69-
'tabKey' => $key,
70-
));
71-
72-
if (!$tab->getHref()) {
73-
$tab->setHref('#');
74-
}
75-
76-
if (!$tab->getType()) {
77-
$tab->setType(PHUIListItemView::TYPE_LINK);
78-
}
79-
80-
$this->tabs[$key] = $tab;
81-
}
82-
}
83-
84-
$this->propertyLists[$key][] = $property_list;
39+
public function addPropertyList(PHUIPropertyListView $property_list) {
40+
$this->propertyLists[] = $property_list;
8541

8642
$action_list = $property_list->getActionList();
8743
if ($action_list) {
@@ -190,68 +146,6 @@ public function setValidationException(
190146
return $this;
191147
}
192148

193-
public function willRender() {
194-
$tab_lists = array();
195-
$property_lists = array();
196-
$tab_map = array();
197-
198-
$default_key = 'tab.default';
199-
200-
// Find the selected tab, or select the first tab if none are selected.
201-
if ($this->tabs) {
202-
$selected_tab = null;
203-
foreach ($this->tabs as $key => $tab) {
204-
if ($tab->getSelected()) {
205-
$selected_tab = $key;
206-
break;
207-
}
208-
}
209-
if ($selected_tab === null) {
210-
head($this->tabs)->setSelected(true);
211-
$selected_tab = head_key($this->tabs);
212-
}
213-
}
214-
215-
foreach ($this->propertyLists as $key => $list) {
216-
$group = new PHUIPropertyGroupView();
217-
$i = 0;
218-
foreach ($list as $item) {
219-
$group->addPropertyList($item);
220-
if ($i > 0 || $this->tabGroups) {
221-
$item->addClass('phui-property-list-section-noninitial');
222-
}
223-
$i++;
224-
}
225-
226-
if ($this->tabs && $key != $default_key) {
227-
$tab_id = celerity_generate_unique_node_id();
228-
$tab_map[$key] = $tab_id;
229-
230-
if ($key === $selected_tab) {
231-
$style = null;
232-
} else {
233-
$style = 'display: none';
234-
}
235-
236-
$tab_lists[] = phutil_tag(
237-
'div',
238-
array(
239-
'style' => $style,
240-
'id' => $tab_id,
241-
),
242-
$group);
243-
} else {
244-
if ($this->tabs) {
245-
$group->addClass('phui-property-group-noninitial');
246-
}
247-
$property_lists[] = $group;
248-
}
249-
$this->propertyList = $property_lists;
250-
$this->tabMap = $tab_map;
251-
$this->tabLists = $tab_lists;
252-
}
253-
}
254-
255149
protected function getTagAttributes() {
256150
$classes = array();
257151
$classes[] = 'phui-box';
@@ -275,19 +169,8 @@ protected function getTagAttributes() {
275169
$classes[] = $this->background;
276170
}
277171

278-
$sigil = null;
279-
$metadata = null;
280-
if ($this->tabs) {
281-
$sigil = 'phui-object-box';
282-
$metadata = array(
283-
'tabMap' => $this->tabMap,
284-
);
285-
}
286-
287172
return array(
288173
'class' => implode(' ', $classes),
289-
'sigil' => $sigil,
290-
'meta' => $metadata,
291174
);
292175
}
293176

@@ -393,16 +276,23 @@ protected function getTagContent() {
393276
}
394277
}
395278

396-
$tabs = null;
397-
if ($this->tabs) {
398-
$tabs = id(new PHUIListView())
399-
->setType(PHUIListView::NAVBAR_LIST);
400-
foreach ($this->tabs as $tab) {
401-
$tabs->addMenuItem($tab);
279+
if ($this->propertyLists) {
280+
$lists = new PHUIPropertyGroupView();
281+
282+
$ii = 0;
283+
foreach ($this->propertyLists as $list) {
284+
if ($ii > 0 || $this->tabGroups) {
285+
$list->addClass('phui-property-list-section-noninitial');
286+
}
287+
288+
$lists->addPropertyList($list);
289+
$ii++;
402290
}
403-
Javelin::initBehavior('phui-object-box-tabs');
291+
} else {
292+
$lists = null;
404293
}
405294

295+
406296
$content = array(
407297
($this->showHideOpen == false ? $this->anchor : null),
408298
$header,
@@ -412,11 +302,9 @@ protected function getTagContent() {
412302
$exception_errors,
413303
$this->form,
414304
$this->tabGroups,
415-
$tabs,
416-
$this->tabLists,
417305
$showhide,
418306
($this->showHideOpen == true ? $this->anchor : null),
419-
$this->propertyList,
307+
$lists,
420308
$this->table,
421309
$this->renderChildren(),
422310
);

‎src/view/phui/PHUITabGroupView.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -66,15 +66,15 @@ protected function getTagAttributes() {
6666
$tab_map = mpull($this->tabs, 'getContentID', 'getKey');
6767

6868
return array(
69-
'sigil' => 'phui-object-box',
69+
'sigil' => 'phui-tab-group-view',
7070
'meta' => array(
7171
'tabMap' => $tab_map,
7272
),
7373
);
7474
}
7575

7676
protected function getTagContent() {
77-
Javelin::initBehavior('phui-object-box-tabs');
77+
Javelin::initBehavior('phui-tab-group');
7878

7979
$tabs = id(new PHUIListView())
8080
->setType(PHUIListView::NAVBAR_LIST);

‎src/view/phui/PHUITabView.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public function newMenuItem() {
6464
->setKey($this->getKey())
6565
->setType(PHUIListItemView::TYPE_LINK)
6666
->setHref('#')
67-
->addSigil('phui-object-box-tab')
67+
->addSigil('phui-tab-view')
6868
->setMetadata(
6969
array(
7070
'tabKey' => $this->getKey(),

‎webroot/rsrc/js/phui/behavior-phui-object-box-tabs.js ‎webroot/rsrc/js/phui/behavior-phui-tab-group.js

+10-8
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,25 @@
11
/**
2-
* @provides javelin-behavior-phui-object-box-tabs
2+
* @provides javelin-behavior-phui-tab-group
33
* @requires javelin-behavior
44
* javelin-stratcom
55
* javelin-dom
66
*/
77

8-
JX.behavior('phui-object-box-tabs', function() {
8+
JX.behavior('phui-tab-group', function() {
99

1010
JX.Stratcom.listen(
1111
'click',
12-
'phui-object-box-tab',
12+
'phui-tab-view',
1313
function (e) {
1414
e.kill();
15-
var key = e.getNodeData('phui-object-box-tab').tabKey;
16-
var map = e.getNodeData('phui-object-box').tabMap;
17-
var tab = e.getNode('phui-object-box-tab');
1815

19-
var box = e.getNode('phui-object-box');
20-
var tabs = JX.DOM.scry(box, 'li', 'phui-object-box-tab');
16+
var map = e.getNodeData('phui-tab-group-view').tabMap;
17+
var key = e.getNodeData('phui-tab-view').tabKey;
18+
19+
var group = e.getNode('phui-tab-group-view');
20+
var tab = e.getNode('phui-tab-view');
21+
var tabs = JX.DOM.scry(group, 'li', 'phui-tab-view');
22+
2123
for (var ii = 0; ii < tabs.length; ii++) {
2224
JX.DOM.alterClass(
2325
tabs[ii],

0 commit comments

Comments
 (0)
Failed to load comments.