Files
phabricator/webroot/rsrc/js/application/maniphest/behavior-batch-selector.js
epriestley 00543f0620 Remove the ability to drag tasks up and down on (non-Workboard) priority list views
Summary:
Ref T13074. Today, in normal task list views in Maniphest (not workboards), you can (sometimes) reorder tasks if the view is priority-sorted.

I suspect no one ever does this, few users know it's supported, and that it was basically rendered obsolete the day we shipped workboards.

This also means that we need to maintain a global "subpriority" for tasks, which distinguishes between different tasks at the same priority level (e.g., "High") and maintains a consistent ordering on workboards.

As we move toward making workboards more flexible (e.g., group by author / owner / custom fields), I'd like to try moving away from "subpriority" and possibly removing it entirely, in favor of "natural order", which basically means "we kind of remember where you put the card and it works a bit like a sticky note".

Currently, the "natural order" and "subpriority" systems are sort of similar but also sort of in conflict, and the "subpriority" system can't really be extended while the "natural order / column position" system can.

The only real reason to have a global "subpriority" is to support the list-view drag-and-drop.

It's possible I'm wrong about this and a bunch of users love this feature, but we can re-evaluate if we get feedback in this vein.

(This just removes UI, the actual subpriority system is still intact and still used on workboards.)

Test Plan: Viewed task lists, was no longer able to drag stuff. Grepped for affected symbols. Dragged stuff in remaining grippable lists, like "Edit Forms" in EditEngine config.

Reviewers: amckinley

Reviewed By: amckinley

Maniphest Tasks: T13074

Differential Revision: https://secure.phabricator.com/D20263
2019-03-12 12:47:36 -07:00

161 lines
3.4 KiB
JavaScript

/**
* @provides javelin-behavior-maniphest-batch-selector
* @requires javelin-behavior
* javelin-dom
* javelin-stratcom
* javelin-util
*/
JX.behavior('maniphest-batch-selector', function(config) {
var selected = {};
// Test if a task node is selected.
var get_id = function(task) {
return JX.Stratcom.getData(task).taskID;
};
var is_selected = function(task) {
return (get_id(task) in selected);
};
// Change the selected state of a task.
var change = function(task, to) {
if (to === undefined) {
to = !is_selected(task);
}
if (to) {
selected[get_id(task)] = true;
} else {
delete selected[get_id(task)];
}
JX.DOM.alterClass(
task,
'phui-oi-selected',
is_selected(task));
update();
};
// Change all tasks to some state (used by "select all" / "clear selection"
// buttons).
var changeall = function(to) {
var inputs = JX.DOM.scry(document.body, 'li', 'maniphest-task');
for (var ii = 0; ii < inputs.length; ii++) {
change(inputs[ii], to);
}
};
// Clear any document text selection after toggling a task via shift click,
// since errant clicks tend to start selecting various ranges otherwise.
var clear_selection = function() {
if (window.getSelection) {
if (window.getSelection().empty) {
window.getSelection().empty();
} else if (window.getSelection().removeAllRanges) {
window.getSelection().removeAllRanges();
}
} else if (document.selection) {
document.selection.empty();
}
};
// Update the status text showing how many tasks are selected, and the button
// state.
var update = function() {
var count = JX.keys(selected).length;
var status;
if (count === 0) {
status = 'Shift-Click to Select Tasks';
} else if (status == 1) {
status = '1 Selected Task';
} else {
status = count + ' Selected Tasks';
}
JX.DOM.setContent(JX.$(config.status), status);
var submit = JX.$(config.submit);
var disable = (count === 0);
submit.disabled = disable;
JX.DOM.alterClass(submit, 'disabled', disable);
};
// When he user shift-clicks the task, update the rest of the application
// state.
JX.Stratcom.listen(
'click',
'maniphest-task',
function(e) {
var raw = e.getRawEvent();
if (!raw.shiftKey) {
return;
}
if (raw.ctrlKey || raw.altKey || raw.metaKey || e.isRightButton()) {
return;
}
if (JX.Stratcom.pass(e)) {
return;
}
e.kill();
change(e.getNode('maniphest-task'));
clear_selection();
});
// When the user clicks "Select All", select all tasks.
JX.DOM.listen(
JX.$(config.selectNone),
'click',
null,
function(e) {
changeall(false);
e.kill();
});
// When the user clicks "Clear Selection", clear the selection.
JX.DOM.listen(
JX.$(config.selectAll),
'click',
null,
function(e) {
changeall(true);
e.kill();
});
// When the user submits the form, dump selected state into it.
JX.DOM.listen(
JX.$(config.formID),
'submit',
null,
function() {
var ids = [];
for (var k in selected) {
ids.push(k);
}
ids = ids.join(',');
var input = JX.$N('input', {type: 'hidden', name: 'ids', value: ids});
JX.DOM.setContent(JX.$(config.idContainer), input);
});
update();
});