diff options
| author | Khoi Nguyen <khoi@nguyen.me.uk> | 2017-07-06 10:43:00 +0200 |
|---|---|---|
| committer | Khoi Nguyen <khoi@nguyen.me.uk> | 2017-07-06 11:50:35 +0200 |
| commit | 5854bb7d12ebae359dc1bef20c966c9f0e8d983e (patch) | |
| tree | dc5f3fcbda3d9635bb8f1a1d422855f773437bf0 | |
| parent | 70e1efd41e6433ab2e010fdd923ff0d3683504c0 (diff) | |
[IMP] web: Add disableDrop option to dragAndDrop
In some situations, it would be desirable to be able to attempt a drag
and drop, without actually triggering the dropping action. As an
example, we would like to see whether dragging a new field in studio
ensures that a class 'o_web_studio_nearest_hook' be assigned. This can
only be tested *before* the new field is dropped.
This commit adds an optional argument 'disableDrop' to the
dragAndDrop method, and sets it by default to false. The dropping action
will then only be triggered if the aforementioned parameter is set to
false.
| -rw-r--r-- | addons/web/static/tests/helpers/test_utils.js | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/addons/web/static/tests/helpers/test_utils.js b/addons/web/static/tests/helpers/test_utils.js index bc2cf05f360..fafe2dee1c6 100644 --- a/addons/web/static/tests/helpers/test_utils.js +++ b/addons/web/static/tests/helpers/test_utils.js @@ -369,6 +369,7 @@ function createModel(params) { * @param {jqueryElement} $to * @param {Object} [options] * @param {string} [options.position=center] target position + * @param {string} [options.disableDrop=false] whether to trigger the drop action */ function dragAndDrop($el, $to, options) { var position = (options && options.position) || 'center'; @@ -396,11 +397,13 @@ function dragAndDrop($el, $to, options) { pageY: toOffset.top })); - $el.trigger($.Event("mouseup", { - which: 1, - pageX: toOffset.left, - pageY: toOffset.top - })); + if (!(options && options.disableDrop)) { + $el.trigger($.Event("mouseup", { + which: 1, + pageX: toOffset.left, + pageY: toOffset.top + })); + } } /** |
