2014-06-11 19:39:23 +02:00
|
|
|
/**
|
|
|
|
* @provides javelin-behavior-dashboard-tab-panel
|
|
|
|
* @requires javelin-behavior
|
|
|
|
* javelin-dom
|
|
|
|
* javelin-stratcom
|
|
|
|
*/
|
|
|
|
|
2014-06-23 19:27:47 +02:00
|
|
|
JX.behavior('dashboard-tab-panel', function() {
|
2014-06-11 19:39:23 +02:00
|
|
|
|
|
|
|
JX.Stratcom.listen('click', 'dashboard-tab-panel-tab', function(e) {
|
2019-04-11 16:12:13 +02:00
|
|
|
// On dashboard panels in edit mode, the user may click the dropdown caret
|
|
|
|
// within a tab to open the context menu. If they do, this click should
|
|
|
|
// just open the menu, not select the tab. For now, pass the event here
|
|
|
|
// to let the menu handler act on it.
|
|
|
|
if (JX.Stratcom.pass(e)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-06-11 19:39:23 +02:00
|
|
|
e.kill();
|
|
|
|
|
When editing a tab panel from a dashboard, redirect back to the dashboard
Summary:
Depends on D20396. Ref T13272. Currently, using the dropdowns to edit a tab panel from a dashboard redirects you to the tab panel page.
Instead, redirect back to the context page (usually, a dashboard -- but theoretically a containing tab panel, since you can put tab panels inside tab panels).
Also, fix some JS issues with non-integer panel keys. I've moved panel keys from "0, 1, 2, ..." to having arbitrary keys to make some operations less flimsy/error-prone, but this needs some JS tweaks.
Test Plan: Edited a tab panel from a dashboard, got sent sensibly back to the dashboard.
Reviewers: amckinley
Reviewed By: amckinley
Maniphest Tasks: T13272
Differential Revision: https://secure.phabricator.com/D20397
2019-04-11 18:13:43 +02:00
|
|
|
var selected_key = e.getNodeData('dashboard-tab-panel-tab').panelKey;
|
2014-06-11 19:39:23 +02:00
|
|
|
|
|
|
|
var root = e.getNode('dashboard-tab-panel-container');
|
|
|
|
var data = JX.Stratcom.getData(root);
|
|
|
|
|
When editing a tab panel from a dashboard, redirect back to the dashboard
Summary:
Depends on D20396. Ref T13272. Currently, using the dropdowns to edit a tab panel from a dashboard redirects you to the tab panel page.
Instead, redirect back to the context page (usually, a dashboard -- but theoretically a containing tab panel, since you can put tab panels inside tab panels).
Also, fix some JS issues with non-integer panel keys. I've moved panel keys from "0, 1, 2, ..." to having arbitrary keys to make some operations less flimsy/error-prone, but this needs some JS tweaks.
Test Plan: Edited a tab panel from a dashboard, got sent sensibly back to the dashboard.
Reviewers: amckinley
Reviewed By: amckinley
Maniphest Tasks: T13272
Differential Revision: https://secure.phabricator.com/D20397
2019-04-11 18:13:43 +02:00
|
|
|
|
|
|
|
var ii;
|
2014-06-11 19:39:23 +02:00
|
|
|
// Give the tab the user clicked a selected style, and remove it from
|
|
|
|
// the other tabs.
|
|
|
|
var tabs = JX.DOM.scry(root, 'li', 'dashboard-tab-panel-tab');
|
|
|
|
for (ii = 0; ii < tabs.length; ii++) {
|
When editing a tab panel from a dashboard, redirect back to the dashboard
Summary:
Depends on D20396. Ref T13272. Currently, using the dropdowns to edit a tab panel from a dashboard redirects you to the tab panel page.
Instead, redirect back to the context page (usually, a dashboard -- but theoretically a containing tab panel, since you can put tab panels inside tab panels).
Also, fix some JS issues with non-integer panel keys. I've moved panel keys from "0, 1, 2, ..." to having arbitrary keys to make some operations less flimsy/error-prone, but this needs some JS tweaks.
Test Plan: Edited a tab panel from a dashboard, got sent sensibly back to the dashboard.
Reviewers: amckinley
Reviewed By: amckinley
Maniphest Tasks: T13272
Differential Revision: https://secure.phabricator.com/D20397
2019-04-11 18:13:43 +02:00
|
|
|
var tab = tabs[ii];
|
|
|
|
var tab_data = JX.Stratcom.getData(tab);
|
|
|
|
var is_selected = (tab_data.panelKey === selected_key);
|
|
|
|
JX.DOM.alterClass(tabs[ii], 'phui-list-item-selected', is_selected);
|
2014-06-11 19:39:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Switch the visible content to correspond to whatever the user clicked.
|
|
|
|
for (ii = 0; ii < data.panels.length; ii++) {
|
When editing a tab panel from a dashboard, redirect back to the dashboard
Summary:
Depends on D20396. Ref T13272. Currently, using the dropdowns to edit a tab panel from a dashboard redirects you to the tab panel page.
Instead, redirect back to the context page (usually, a dashboard -- but theoretically a containing tab panel, since you can put tab panels inside tab panels).
Also, fix some JS issues with non-integer panel keys. I've moved panel keys from "0, 1, 2, ..." to having arbitrary keys to make some operations less flimsy/error-prone, but this needs some JS tweaks.
Test Plan: Edited a tab panel from a dashboard, got sent sensibly back to the dashboard.
Reviewers: amckinley
Reviewed By: amckinley
Maniphest Tasks: T13272
Differential Revision: https://secure.phabricator.com/D20397
2019-04-11 18:13:43 +02:00
|
|
|
var panel = data.panels[ii];
|
|
|
|
var node = JX.$(panel.panelContentID);
|
|
|
|
|
|
|
|
if (panel.panelKey == selected_key) {
|
|
|
|
JX.DOM.show(node);
|
2014-06-11 19:39:23 +02:00
|
|
|
} else {
|
When editing a tab panel from a dashboard, redirect back to the dashboard
Summary:
Depends on D20396. Ref T13272. Currently, using the dropdowns to edit a tab panel from a dashboard redirects you to the tab panel page.
Instead, redirect back to the context page (usually, a dashboard -- but theoretically a containing tab panel, since you can put tab panels inside tab panels).
Also, fix some JS issues with non-integer panel keys. I've moved panel keys from "0, 1, 2, ..." to having arbitrary keys to make some operations less flimsy/error-prone, but this needs some JS tweaks.
Test Plan: Edited a tab panel from a dashboard, got sent sensibly back to the dashboard.
Reviewers: amckinley
Reviewed By: amckinley
Maniphest Tasks: T13272
Differential Revision: https://secure.phabricator.com/D20397
2019-04-11 18:13:43 +02:00
|
|
|
JX.DOM.hide(node);
|
2014-06-11 19:39:23 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|