phorge/webroot/rsrc/js/phui/behavior-phui-selectable-list.js
epriestley ad659627b3 Make bulk editor working set editable and more homogenous
Summary:
Ref T13025. See PHI50. Fixes T11286. Ref T10005. Begin modernizing the bulk editor.

For T10005 ("move the bulk editor to modern infrastructure"), rewrite the rendering of the editable set so that it is application-agnostic and can work with any kind of object.

For T11286 ("let users de-select items in the working set"), make the working set editable.

Test Plan:
{F5302158}

  - Deselected some objects, applied an edit, saw the edit apply to only selected objects.

Reviewers: amckinley

Reviewed By: amckinley

Maniphest Tasks: T13025, T11286, T10005

Differential Revision: https://secure.phabricator.com/D18805
2018-01-19 12:39:27 -08:00

45 lines
1 KiB
JavaScript

/**
* @provides javelin-behavior-phui-selectable-list
* @requires javelin-behavior
* javelin-stratcom
* javelin-dom
*/
JX.behavior('phui-selectable-list', function() {
JX.Stratcom.listen('click', 'phui-oi-selectable', function(e) {
if (!e.isNormalClick()) {
return;
}
// If the user clicked a link, ignore it.
if (e.getNode('tag:a')) {
return;
}
var root = e.getNode('phui-oi-selectable');
// If the user did not click the checkbox, pretend they did. This makes
// the entire element a click target to make changing the selection set a
// bit easier.
if (!e.getNode('tag:input')) {
var checkbox = getCheckbox(root);
checkbox.checked = !checkbox.checked;
e.kill();
}
setTimeout(JX.bind(null, redraw, root), 0);
});
function getCheckbox(root) {
return JX.DOM.find(root, 'input');
}
function redraw(root) {
var checkbox = getCheckbox(root);
JX.DOM.alterClass(root, 'phui-oi-selected', !!checkbox.checked);
}
});