mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-27 01:02:42 +01:00
Allow draggable elements to be dragged to the first list position
Summary: Currently, draggable lists (in Config and ApplicationSearch, for example) don't let you drag an item into the first position. This is because the behavior is correct in Maniphest: the first position is above an initial header, like "High Prioirty", and shouldn't be targetable. Permit the behavior in general; forbid it in Maniphest. Test Plan: - Dragged elements into the first position in ApplicationSearch. - Failed to drag elements into the first position in Maniphest. Reviewers: garoevans, btrahan Reviewed By: garoevans CC: aran Differential Revision: https://secure.phabricator.com/D7128
This commit is contained in:
parent
3361eba139
commit
21bd596d71
3 changed files with 32 additions and 17 deletions
|
@ -1859,7 +1859,7 @@ celerity_register_resource_map(array(
|
|||
),
|
||||
'javelin-behavior-maniphest-subpriority-editor' =>
|
||||
array(
|
||||
'uri' => '/res/99d84c61/rsrc/js/application/maniphest/behavior-subpriorityeditor.js',
|
||||
'uri' => '/res/1fa4961f/rsrc/js/application/maniphest/behavior-subpriorityeditor.js',
|
||||
'type' => 'js',
|
||||
'requires' =>
|
||||
array(
|
||||
|
@ -3095,7 +3095,7 @@ celerity_register_resource_map(array(
|
|||
),
|
||||
'phabricator-draggable-list' =>
|
||||
array(
|
||||
'uri' => '/res/7292a1c4/rsrc/js/core/DraggableList.js',
|
||||
'uri' => '/res/75c556db/rsrc/js/core/DraggableList.js',
|
||||
'type' => 'js',
|
||||
'requires' =>
|
||||
array(
|
||||
|
@ -4382,7 +4382,7 @@ celerity_register_resource_map(array(
|
|||
'uri' => '/res/pkg/49898640/maniphest.pkg.css',
|
||||
'type' => 'css',
|
||||
),
|
||||
'83a3853e' =>
|
||||
'0a694954' =>
|
||||
array(
|
||||
'name' => 'maniphest.pkg.js',
|
||||
'symbols' =>
|
||||
|
@ -4393,7 +4393,7 @@ celerity_register_resource_map(array(
|
|||
3 => 'javelin-behavior-maniphest-transaction-expand',
|
||||
4 => 'javelin-behavior-maniphest-subpriority-editor',
|
||||
),
|
||||
'uri' => '/res/pkg/83a3853e/maniphest.pkg.js',
|
||||
'uri' => '/res/pkg/0a694954/maniphest.pkg.js',
|
||||
'type' => 'js',
|
||||
),
|
||||
),
|
||||
|
@ -4453,11 +4453,11 @@ celerity_register_resource_map(array(
|
|||
'javelin-behavior-konami' => '8977e356',
|
||||
'javelin-behavior-lightbox-attachments' => '8977e356',
|
||||
'javelin-behavior-load-blame' => '5e9e5c4e',
|
||||
'javelin-behavior-maniphest-batch-selector' => '83a3853e',
|
||||
'javelin-behavior-maniphest-subpriority-editor' => '83a3853e',
|
||||
'javelin-behavior-maniphest-transaction-controls' => '83a3853e',
|
||||
'javelin-behavior-maniphest-transaction-expand' => '83a3853e',
|
||||
'javelin-behavior-maniphest-transaction-preview' => '83a3853e',
|
||||
'javelin-behavior-maniphest-batch-selector' => '0a694954',
|
||||
'javelin-behavior-maniphest-subpriority-editor' => '0a694954',
|
||||
'javelin-behavior-maniphest-transaction-controls' => '0a694954',
|
||||
'javelin-behavior-maniphest-transaction-expand' => '0a694954',
|
||||
'javelin-behavior-maniphest-transaction-preview' => '0a694954',
|
||||
'javelin-behavior-phabricator-active-nav' => '8977e356',
|
||||
'javelin-behavior-phabricator-autofocus' => '8977e356',
|
||||
'javelin-behavior-phabricator-gesture' => '8977e356',
|
||||
|
|
|
@ -16,6 +16,12 @@ JX.behavior('maniphest-subpriority-editor', function(config) {
|
|||
return tasks.concat(heads);
|
||||
})
|
||||
.setGhostHandler(function(ghost, target) {
|
||||
if (!target) {
|
||||
// The user is trying to drag a task above the first group header;
|
||||
// don't permit that since it doesn't make sense.
|
||||
return false;
|
||||
}
|
||||
|
||||
if (target.nextSibling) {
|
||||
if (JX.DOM.isType(target, 'h1')) {
|
||||
target.nextSibling.insertBefore(ghost, target.nextSibling.firstChild);
|
||||
|
|
|
@ -126,7 +126,7 @@ JX.install('DraggableList', {
|
|||
}
|
||||
targets.sort(function(u, v) { return v.y - u.y; });
|
||||
this._targets = targets;
|
||||
this._target = null;
|
||||
this._target = false;
|
||||
|
||||
if (!this.invoke('didBeginDrag', this._dragging).getPrevented()) {
|
||||
var ghost = this.getGhostNode();
|
||||
|
@ -159,6 +159,11 @@ JX.install('DraggableList', {
|
|||
// we're dragging or its predecessor, don't select a target, because the
|
||||
// operation would be a no-op.
|
||||
|
||||
// NOTE: When we're dragging into the first position in the list, we
|
||||
// use the target `null`. When we don't have a valid target, we use
|
||||
// the target `false`. Spooky! Magic! Anyway, `null` and `false` mean
|
||||
// completely different things.
|
||||
|
||||
var cur_target = null;
|
||||
var trigger;
|
||||
for (var ii = 0; ii < targets.length; ii++) {
|
||||
|
@ -183,10 +188,10 @@ JX.install('DraggableList', {
|
|||
|
||||
cur_target = targets[ii].item;
|
||||
if (cur_target == dragging) {
|
||||
cur_target = null;
|
||||
cur_target = false;
|
||||
}
|
||||
if (targets[ii - 1] && targets[ii - 1].item == dragging) {
|
||||
cur_target = null;
|
||||
cur_target = false;
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -201,13 +206,17 @@ JX.install('DraggableList', {
|
|||
JX.DOM.remove(ghost);
|
||||
}
|
||||
|
||||
if (cur_target) {
|
||||
this.getGhostHandler()(ghost, cur_target);
|
||||
if (cur_target !== false) {
|
||||
var ok = this.getGhostHandler()(ghost, cur_target);
|
||||
// If the handler returns explicit `false`, prevent the drag.
|
||||
if (ok === false) {
|
||||
cur_target = false;
|
||||
}
|
||||
}
|
||||
|
||||
target = cur_target;
|
||||
|
||||
if (target) {
|
||||
if (target !== false) {
|
||||
|
||||
// If we've changed where the ghost node is, update the adjustments
|
||||
// so we accurately reflect document state when we tweak things below.
|
||||
|
@ -223,7 +232,7 @@ JX.install('DraggableList', {
|
|||
// adjust the cursor position for the change in node document position.
|
||||
// Do this before choosing a new target to avoid a flash of nonsense.
|
||||
|
||||
if (target) {
|
||||
if (target !== false) {
|
||||
if (adjust_y <= origin.y) {
|
||||
p.y -= adjust_h;
|
||||
}
|
||||
|
@ -250,7 +259,7 @@ JX.install('DraggableList', {
|
|||
|
||||
JX.$V(0, 0).setPos(dragging);
|
||||
|
||||
if (target) {
|
||||
if (target !== false) {
|
||||
JX.DOM.remove(dragging);
|
||||
JX.DOM.replace(ghost, dragging);
|
||||
this.invoke('didDrop', dragging, target);
|
||||
|
|
Loading…
Reference in a new issue