mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-10 17:02:41 +01:00
5af031ec9b
Summary: Ref T603. After thinking about this for a bit I can't really come up with anything better than what Facebook does, so I'm going to implement something similar for choosing custom policies. To start with, swap this over to a JS-driven dropdown. Test Plan: See screenshot. Reviewers: chad, btrahan Reviewed By: btrahan CC: chad, aran Maniphest Tasks: T603 Differential Revision: https://secure.phabricator.com/D7285
50 lines
1.3 KiB
JavaScript
50 lines
1.3 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 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;
|
|
}, phid, render));
|
|
|
|
menu.addItem(item);
|
|
}
|
|
}
|
|
|
|
});
|
|
|
|
});
|