mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-27 01:02:42 +01:00
130a15b51b
Summary: Ref T603. Make this a little easier to use by highlighting the current value. Test Plan: See screenshot. Reviewers: chad, btrahan Reviewed By: chad CC: chad, aran Maniphest Tasks: T603 Differential Revision: https://secure.phabricator.com/D7289
56 lines
1.4 KiB
JavaScript
56 lines
1.4 KiB
JavaScript
/**
|
|
* @provides javelin-behavior-policy-control
|
|
* @requires javelin-behavior
|
|
* javelin-dom
|
|
* javelin-util
|
|
* phabricator-dropdown-menu
|
|
* phabricator-menu-item
|
|
* @javelin
|
|
*/
|
|
JX.behavior('policy-control', function(config) {
|
|
var control = JX.$(config.controlID);
|
|
var input = JX.$(config.inputID);
|
|
var value = config.value;
|
|
|
|
var menu = new JX.PhabricatorDropdownMenu(control)
|
|
.setWidth(260);
|
|
|
|
menu.toggleAlignDropdownRight(false);
|
|
|
|
menu.listen('open', function() {
|
|
menu.clear();
|
|
|
|
for (var ii = 0; ii < config.groups.length; ii++) {
|
|
var group = config.groups[ii];
|
|
|
|
var header = new JX.PhabricatorMenuItem(config.labels[group]);
|
|
header.setDisabled(true);
|
|
menu.addItem(header);
|
|
|
|
for (var jj = 0; jj < config.order[group].length; jj++) {
|
|
var phid = config.order[group][jj];
|
|
var option = config.options[phid];
|
|
|
|
var render = [JX.$H(config.icons[option.icon]), option.name];
|
|
|
|
var item = new JX.PhabricatorMenuItem(
|
|
render,
|
|
JX.bind(null, function(phid, render) {
|
|
JX.DOM.setContent(
|
|
JX.DOM.find(control, 'span', 'policy-label'),
|
|
render);
|
|
input.value = phid;
|
|
value = phid;
|
|
}, phid, render));
|
|
|
|
if (phid == value) {
|
|
item.setSelected(true);
|
|
}
|
|
|
|
menu.addItem(item);
|
|
}
|
|
}
|
|
|
|
});
|
|
|
|
});
|